aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mlumish <mlumish@google.com>2014-12-10 11:29:16 -0800
committerGravatar Michael Lumish <mlumish@google.com>2014-12-10 13:25:41 -0800
commitf5aa29b628ee50ab4c194f3f58a595a8102b7535 (patch)
treee9cec1f621e4861d54768919b644d86417458327
parent8919f6087f97de2a625b1faa386f0dab271bbba1 (diff)
Added utility to make different tests bind to different ports
Change on 2014/12/10 by mlumish <mlumish@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=81800876
-rwxr-xr-xsrc/php/tests/unit_tests/EndToEndTest.php6
-rwxr-xr-xsrc/php/tests/unit_tests/SecureEndToEndTest.php5
-rwxr-xr-xsrc/php/tests/util/port_picker.php6
3 files changed, 13 insertions, 4 deletions
diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php
index a6e4a89ac0..be801bf016 100755
--- a/src/php/tests/unit_tests/EndToEndTest.php
+++ b/src/php/tests/unit_tests/EndToEndTest.php
@@ -1,11 +1,13 @@
<?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, []);
- $this->server->add_http2_port('localhost:9000');
- $this->channel = new Grpc\Channel('localhost:9000', []);
+ $address = '127.0.0.1:' . getNewPort();
+ $this->server->add_http2_port($address);
+ $this->channel = new Grpc\Channel($address, []);
}
public function tearDown() {
diff --git a/src/php/tests/unit_tests/SecureEndToEndTest.php b/src/php/tests/unit_tests/SecureEndToEndTest.php
index d645c03e4c..d14574b4f7 100755
--- a/src/php/tests/unit_tests/SecureEndToEndTest.php
+++ b/src/php/tests/unit_tests/SecureEndToEndTest.php
@@ -11,9 +11,10 @@ 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]);
- $this->server->add_secure_http2_port('localhost:9000');
+ $address = '127.0.0.1:' . getNewPort();
+ $this->server->add_secure_http2_port($address);
$this->channel = new Grpc\Channel(
- 'localhost:9000',
+ $address,
[
'grpc.ssl_target_name_override' => 'foo.test.google.com',
'credentials' => $credentials
diff --git a/src/php/tests/util/port_picker.php b/src/php/tests/util/port_picker.php
new file mode 100755
index 0000000000..d869d8b0a4
--- /dev/null
+++ b/src/php/tests/util/port_picker.php
@@ -0,0 +1,6 @@
+<?php
+function getNewPort() {
+ static $port = 10000;
+ $port += 1;
+ return $port;
+} \ No newline at end of file