diff options
author | Wolfy-J <[email protected]> | 2018-09-23 15:31:52 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-09-23 15:31:52 +0300 |
commit | 5bdff4aea88a6c74c67abe447cbb47ddd58b7bc7 (patch) | |
tree | 031647c71a33303771a0c7701fa17775528955c8 | |
parent | dac0e9cb81cf49cb5967c04eb494709ee3f164d9 (diff) |
more coverage
-rw-r--r-- | static_pool_test.go | 17 | ||||
-rw-r--r-- | tests/slow-destroy.php | 37 |
2 files changed, 54 insertions, 0 deletions
diff --git a/static_pool_test.go b/static_pool_test.go index 102717dd..0259bc33 100644 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -370,6 +370,23 @@ func Test_Static_Pool_Handle_Dead(t *testing.T) { assert.Error(t, err) } +// identical to replace but controlled on worker side +func Test_Static_Pool_Slow_Destory(t *testing.T) { + p, err := NewPool( + func() *exec.Cmd { return exec.Command("php", "tests/slow-destroy.php", "echo", "pipes") }, + NewPipeFactory(), + Config{ + NumWorkers: 5, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + ) + p.Destroy() + + assert.NotNil(t, p) + assert.NoError(t, err) +} + func Benchmark_Pool_Allocate(b *testing.B) { p, _ := NewPool( func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, diff --git a/tests/slow-destroy.php b/tests/slow-destroy.php new file mode 100644 index 00000000..0f0abc1c --- /dev/null +++ b/tests/slow-destroy.php @@ -0,0 +1,37 @@ +<?php + +use Spiral\Goridge; + +ini_set('display_errors', 'stderr'); +require dirname(__DIR__) . "/vendor/autoload.php"; + +if (count($argv) < 3) { + die("need 2 arguments"); +} + +list($test, $goridge) = [$argv[1], $argv[2]]; + +switch ($goridge) { + case "pipes": + $relay = new Goridge\StreamRelay(STDIN, STDOUT); + break; + + case "tcp": + $relay = new Goridge\SocketRelay("localhost", 9007); + break; + + case "unix": + $relay = new Goridge\SocketRelay( + "sock.unix", + null, + Goridge\SocketRelay::SOCK_UNIX + ); + break; + + default: + die("invalid protocol selection"); +} + +require_once sprintf("%s/%s.php", __DIR__, $test); + +sleep(10);
\ No newline at end of file |