From f5aa29b628ee50ab4c194f3f58a595a8102b7535 Mon Sep 17 00:00:00 2001 From: mlumish Date: Wed, 10 Dec 2014 11:29:16 -0800 Subject: [PATCH] Added utility to make different tests bind to different ports Change on 2014/12/10 by mlumish ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=81800876 --- src/php/tests/unit_tests/EndToEndTest.php | 6 ++++-- src/php/tests/unit_tests/SecureEndToEndTest.php | 5 +++-- src/php/tests/util/port_picker.php | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100755 src/php/tests/util/port_picker.php diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php index a6e4a89ac02..be801bf016b 100755 --- a/src/php/tests/unit_tests/EndToEndTest.php +++ b/src/php/tests/unit_tests/EndToEndTest.php @@ -1,11 +1,13 @@ 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 d645c03e4c9..d14574b4f7d 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 00000000000..d869d8b0a49 --- /dev/null +++ b/src/php/tests/util/port_picker.php @@ -0,0 +1,6 @@ +