Switched to binding servers to port 0 in tests

pull/376/head
murgatroid99 10 years ago
parent 8c0596edca
commit d96db79b92
  1. 4
      src/php/ext/grpc/server.c
  2. 5
      src/php/tests/unit_tests/CallTest.php
  3. 6
      src/php/tests/unit_tests/EndToEndTest.php
  4. 5
      src/php/tests/unit_tests/SecureEndToEndTest.php
  5. 6
      src/php/tests/util/port_picker.php

@ -146,7 +146,7 @@ PHP_METHOD(Server, add_http2_port) {
"add_http2_port expects a string", 1 TSRMLS_CC);
return;
}
RETURN_BOOL(grpc_server_add_http2_port(server->wrapped, addr));
RETURN_LONG(grpc_server_add_http2_port(server->wrapped, addr));
}
PHP_METHOD(Server, add_secure_http2_port) {
@ -161,7 +161,7 @@ PHP_METHOD(Server, add_secure_http2_port) {
"add_http2_port expects a string", 1 TSRMLS_CC);
return;
}
RETURN_BOOL(grpc_server_add_secure_http2_port(server->wrapped, addr));
RETURN_LONG(grpc_server_add_secure_http2_port(server->wrapped, addr));
}
/**

@ -1,16 +1,17 @@
<?php
class CallTest extends PHPUnit_Framework_TestCase{
static $server;
static $port;
public static function setUpBeforeClass() {
$cq = new Grpc\CompletionQueue();
self::$server = new Grpc\Server($cq, []);
self::$server->add_http2_port('localhost:9001');
self::$port = self::$server->add_http2_port('0.0.0.0:0');
}
public function setUp() {
$this->cq = new Grpc\CompletionQueue();
$this->channel = new Grpc\Channel('localhost:9001', []);
$this->channel = new Grpc\Channel('localhost:' . self::$port, []);
$this->call = new Grpc\Call($this->channel,
'/foo',
Grpc\Timeval::inf_future());

@ -1,13 +1,11 @@
<?php
require __DIR__ . '/../util/port_picker.php';
class EndToEndTest extends PHPUnit_Framework_TestCase{
public function setUp() {
$this->client_queue = new Grpc\CompletionQueue();
$this->server_queue = new Grpc\CompletionQueue();
$this->server = new Grpc\Server($this->server_queue, []);
$address = '127.0.0.1:' . getNewPort();
$this->server->add_http2_port($address);
$this->channel = new Grpc\Channel($address, []);
$port = $this->server->add_http2_port('0.0.0.0:0');
$this->channel = new Grpc\Channel('localhost:' . $port, []);
}
public function tearDown() {

@ -11,10 +11,9 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
file_get_contents(dirname(__FILE__) . '/../data/server1.pem'));
$this->server = new Grpc\Server($this->server_queue,
['credentials' => $server_credentials]);
$address = '127.0.0.1:' . getNewPort();
$this->server->add_secure_http2_port($address);
$port = $this->server->add_secure_http2_port('0.0.0.0:0');
$this->channel = new Grpc\Channel(
$address,
'localhost:' . $port,
[
'grpc.ssl_target_name_override' => 'foo.test.google.com',
'credentials' => $credentials

@ -1,6 +0,0 @@
<?php
function getNewPort() {
static $port = 10000;
$port += 1;
return $port;
}
Loading…
Cancel
Save