PHP: fix flaky tests

pull/15594/head
ZhouyihaiDing 7 years ago
parent 2357b2de2c
commit 4677c70684
  1. 1
      src/php/tests/unit_tests/CallCredentials2Test.php
  2. 1
      src/php/tests/unit_tests/CallCredentialsTest.php
  3. 6
      src/php/tests/unit_tests/CallTest.php
  4. 5
      src/php/tests/unit_tests/EndToEndTest.php
  5. 30
      src/php/tests/unit_tests/InterceptorTest.php
  6. 2
      src/php/tests/unit_tests/SecureEndToEndTest.php
  7. 5
      src/php/tests/unit_tests/ServerTest.php

@ -35,6 +35,7 @@ class CallCredentials2Test extends PHPUnit_Framework_TestCase
$this->channel = new Grpc\Channel(
'localhost:'.$this->port,
[
'force_new' => true,
'grpc.ssl_target_name_override' => $this->host_override,
'grpc.default_authority' => $this->host_override,
'credentials' => $credentials,

@ -41,6 +41,7 @@ class CallCredentialsTest extends PHPUnit_Framework_TestCase
$this->channel = new Grpc\Channel(
'localhost:'.$this->port,
[
'force_new' => true,
'grpc.ssl_target_name_override' => $this->host_override,
'grpc.default_authority' => $this->host_override,
'credentials' => $this->credentials,

@ -24,12 +24,14 @@ class CallTest extends PHPUnit_Framework_TestCase
public static function setUpBeforeClass()
{
self::$server = new Grpc\Server([]);
self::$port = self::$server->addHttp2Port('0.0.0.0:0');
self::$port = self::$server->addHttp2Port('0.0.0.0:53000');
}
public function setUp()
{
$this->channel = new Grpc\Channel('localhost:'.self::$port, []);
$this->channel = new Grpc\Channel('localhost:'.self::$port, [
'force_new' => true,
]);
$this->call = new Grpc\Call($this->channel,
'/foo',
Grpc\Timeval::infFuture());

@ -22,13 +22,16 @@ class EndToEndTest extends PHPUnit_Framework_TestCase
{
$this->server = new Grpc\Server([]);
$this->port = $this->server->addHttp2Port('0.0.0.0:0');
$this->channel = new Grpc\Channel('localhost:'.$this->port, []);
$this->channel = new Grpc\Channel('localhost:'.$this->port, [
"force_new" => true,
]);
$this->server->start();
}
public function tearDown()
{
$this->channel->close();
unset($this->server);
}
public function testSimpleRequestBody()

@ -206,13 +206,16 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
{
$this->server = new Grpc\Server([]);
$this->port = $this->server->addHttp2Port('0.0.0.0:0');
$this->channel = new Grpc\Channel('localhost:'.$this->port, ['credentials' => Grpc\ChannelCredentials::createInsecure()]);
$this->channel = new Grpc\Channel('localhost:'.$this->port, [
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure()]);
$this->server->start();
}
public function tearDown()
{
$this->channel->close();
unset($this->server);
}
@ -222,6 +225,7 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
$channel_matadata_interceptor = new ChangeMetadataInterceptor();
$intercept_channel = Grpc\Interceptor::intercept($this->channel, $channel_matadata_interceptor);
$client = new InterceptorClient('localhost:'.$this->port, [
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure(),
], $intercept_channel);
$req = new SimpleRequest($req_text);
@ -250,6 +254,7 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
$intercept_channel1 = Grpc\Interceptor::intercept($this->channel, $channel_matadata_interceptor);
$intercept_channel2 = Grpc\Interceptor::intercept($intercept_channel1, $channel_matadata_intercepto2);
$client = new InterceptorClient('localhost:'.$this->port, [
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure(),
], $intercept_channel2);
@ -275,6 +280,7 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
$intercept_channel3 = Grpc\Interceptor::intercept($this->channel,
[$channel_matadata_intercepto2, $channel_matadata_interceptor]);
$client = new InterceptorClient('localhost:'.$this->port, [
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure(),
], $intercept_channel3);
@ -304,6 +310,7 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
$intercept_channel = Grpc\Interceptor::intercept($this->channel,
$change_request_interceptor);
$client = new InterceptorClient('localhost:'.$this->port, [
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure(),
], $intercept_channel);
@ -354,6 +361,7 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
$intercept_channel = Grpc\Interceptor::intercept($this->channel,
$channel_request_interceptor);
$client = new InterceptorClient('localhost:'.$this->port, [
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure(),
], $intercept_channel);
@ -374,7 +382,10 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
{
$channel = new Grpc\Channel(
'localhost:0',
['credentials' => Grpc\ChannelCredentials::createInsecure()]
[
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure()
]
);
$interceptor_channel = Grpc\Interceptor::intercept($channel, new Grpc\Interceptor());
$state = $interceptor_channel->getConnectivityState();
@ -386,7 +397,10 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
{
$channel = new Grpc\Channel(
'localhost:0',
['credentials' => Grpc\ChannelCredentials::createInsecure()]
[
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure()
]
);
$interceptor_channel = Grpc\Interceptor::intercept($channel, new Grpc\Interceptor());
$now = Grpc\Timeval::now();
@ -402,7 +416,10 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
{
$channel = new Grpc\Channel(
'localhost:0',
['credentials' => Grpc\ChannelCredentials::createInsecure()]
[
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure()
]
);
$interceptor_channel = Grpc\Interceptor::intercept($channel, new Grpc\Interceptor());
$this->assertNotNull($interceptor_channel);
@ -413,7 +430,10 @@ class InterceptorTest extends PHPUnit_Framework_TestCase
{
$channel = new Grpc\Channel(
'localhost:8888',
['credentials' => Grpc\ChannelCredentials::createInsecure()]
[
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure()
]
);
$interceptor_channel = Grpc\Interceptor::intercept($channel, new Grpc\Interceptor());
$target = $interceptor_channel->getTarget();

@ -34,6 +34,7 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase
$this->channel = new Grpc\Channel(
'localhost:'.$this->port,
[
'force_new' => true,
'grpc.ssl_target_name_override' => $this->host_override,
'grpc.default_authority' => $this->host_override,
'credentials' => $credentials,
@ -44,6 +45,7 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase
public function tearDown()
{
$this->channel->close();
unset($this->server);
}
public function testSimpleRequestBody()

@ -55,7 +55,10 @@ class ServerTest extends PHPUnit_Framework_TestCase
$port = $this->server->addHttp2Port('0.0.0.0:0');
$this->server->start();
$channel = new Grpc\Channel('localhost:'.$port,
['credentials' => Grpc\ChannelCredentials::createInsecure()]);
[
'force_new' => true,
'credentials' => Grpc\ChannelCredentials::createInsecure()
]);
$deadline = Grpc\Timeval::infFuture();
$call = new Grpc\Call($channel, 'dummy_method', $deadline);

Loading…
Cancel
Save