Skip to content
Snippets Groups Projects
Commit f5aa29b6 authored by mlumish's avatar mlumish Committed by Michael Lumish
Browse files

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
parent 8919f608
No related branches found
No related tags found
No related merge requests found
<?php <?php
require __DIR__ . '/../util/port_picker.php';
class EndToEndTest extends PHPUnit_Framework_TestCase{ class EndToEndTest extends PHPUnit_Framework_TestCase{
public function setUp() { public function setUp() {
$this->client_queue = new Grpc\CompletionQueue(); $this->client_queue = new Grpc\CompletionQueue();
$this->server_queue = new Grpc\CompletionQueue(); $this->server_queue = new Grpc\CompletionQueue();
$this->server = new Grpc\Server($this->server_queue, []); $this->server = new Grpc\Server($this->server_queue, []);
$this->server->add_http2_port('localhost:9000'); $address = '127.0.0.1:' . getNewPort();
$this->channel = new Grpc\Channel('localhost:9000', []); $this->server->add_http2_port($address);
$this->channel = new Grpc\Channel($address, []);
} }
public function tearDown() { public function tearDown() {
......
...@@ -11,9 +11,10 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{ ...@@ -11,9 +11,10 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
file_get_contents(dirname(__FILE__) . '/../data/server1.pem')); file_get_contents(dirname(__FILE__) . '/../data/server1.pem'));
$this->server = new Grpc\Server($this->server_queue, $this->server = new Grpc\Server($this->server_queue,
['credentials' => $server_credentials]); ['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( $this->channel = new Grpc\Channel(
'localhost:9000', $address,
[ [
'grpc.ssl_target_name_override' => 'foo.test.google.com', 'grpc.ssl_target_name_override' => 'foo.test.google.com',
'credentials' => $credentials 'credentials' => $credentials
......
<?php
function getNewPort() {
static $port = 10000;
$port += 1;
return $port;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment