Skip to content

Commit

Permalink
Added utility to make different tests bind to different ports
Browse files Browse the repository at this point in the history
	Change on 2014/12/10 by mlumish <mlumish@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81800876
  • Loading branch information
murgatroid99 committed Dec 10, 2014
1 parent 8919f60 commit f5aa29b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/php/tests/unit_tests/EndToEndTest.php
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
5 changes: 3 additions & 2 deletions src/php/tests/unit_tests/SecureEndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public function setUp() {
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
Expand Down
6 changes: 6 additions & 0 deletions src/php/tests/util/port_picker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
function getNewPort() {
static $port = 10000;
$port += 1;
return $port;
}

0 comments on commit f5aa29b

Please sign in to comment.