diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/exec_ttl.php | 15 | ||||
-rw-r--r-- | tests/idle.php | 15 | ||||
-rw-r--r-- | tests/memleak.php | 2 | ||||
-rw-r--r-- | tests/plugins/http/configs/.rr-http-supervised-pool.yaml | 2 | ||||
-rw-r--r-- | tests/plugins/http/http_plugin_test.go | 28 | ||||
-rw-r--r-- | tests/sleep.php | 2 |
6 files changed, 53 insertions, 11 deletions
diff --git a/tests/exec_ttl.php b/tests/exec_ttl.php new file mode 100644 index 00000000..fb5c9df2 --- /dev/null +++ b/tests/exec_ttl.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +use Spiral\Goridge\StreamRelay; +use Spiral\RoadRunner\Worker as RoadRunner; + +require __DIR__ . "/vendor/autoload.php"; + +$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); + +while($rr->waitPayload()){ + sleep(3); + $rr->respond(new \Spiral\RoadRunner\Payload("")); +} diff --git a/tests/idle.php b/tests/idle.php new file mode 100644 index 00000000..fb5c9df2 --- /dev/null +++ b/tests/idle.php @@ -0,0 +1,15 @@ +<?php + +declare(strict_types=1); + +use Spiral\Goridge\StreamRelay; +use Spiral\RoadRunner\Worker as RoadRunner; + +require __DIR__ . "/vendor/autoload.php"; + +$rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); + +while($rr->waitPayload()){ + sleep(3); + $rr->respond(new \Spiral\RoadRunner\Payload("")); +} diff --git a/tests/memleak.php b/tests/memleak.php index f2879e18..96ed5006 100644 --- a/tests/memleak.php +++ b/tests/memleak.php @@ -10,6 +10,6 @@ require __DIR__ . "/vendor/autoload.php"; $rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); $mem = ''; while($rr->waitPayload()){ - $mem .= str_repeat("a", 1024*1024); + $mem .= str_repeat("a", 1024*1024*10); $rr->respond(new \Spiral\RoadRunner\Payload("")); } diff --git a/tests/plugins/http/configs/.rr-http-supervised-pool.yaml b/tests/plugins/http/configs/.rr-http-supervised-pool.yaml index 3e392577..e92ce051 100644 --- a/tests/plugins/http/configs/.rr-http-supervised-pool.yaml +++ b/tests/plugins/http/configs/.rr-http-supervised-pool.yaml @@ -25,7 +25,7 @@ http: supervisor: watch_tick: 1s ttl: 0 - idle_ttl: 5s + idle_ttl: 1s exec_ttl: 10s max_worker_memory: 100 logs: diff --git a/tests/plugins/http/http_plugin_test.go b/tests/plugins/http/http_plugin_test.go index cfc5bc01..d55491ea 100644 --- a/tests/plugins/http/http_plugin_test.go +++ b/tests/plugins/http/http_plugin_test.go @@ -1287,9 +1287,13 @@ func TestHTTPSupervisedPool(t *testing.T) { }() time.Sleep(time.Second * 1) - t.Run("HTTPEchoTest", echoHTTP2) + t.Run("HTTPEchoRunActivateWorker", echoHTTP2) + // bigger timeout to handle idle_ttl on slow systems + time.Sleep(time.Second * 10) + t.Run("HTTPInformerCompareWorkersTestBefore", informerTestBefore) + t.Run("HTTPEchoShouldBeNewWorker", echoHTTP2) // worker should be destructed (idle_ttl) - t.Run("HTTPInformerCompareWorkersTest", informerTest2) + t.Run("HTTPInformerCompareWorkersTestAfter", informerTestAfter) stopCh <- struct{}{} wg.Wait() @@ -1314,11 +1318,12 @@ func echoHTTP2(t *testing.T) { // sleep // supervisor destroy worker // compare pid's -func informerTest2(t *testing.T) { +var workerPid int = 0 + +func informerTestBefore(t *testing.T) { conn, err := net.Dial("tcp", "127.0.0.1:15432") assert.NoError(t, err) client := rpc.NewClientWithCodec(goridgeRpc.NewClientCodec(conn)) - pid := 0 // WorkerList contains list of workers. list := struct { // Workers is list of workers. @@ -1329,18 +1334,25 @@ func informerTest2(t *testing.T) { assert.NoError(t, err) assert.Len(t, list.Workers, 1) // save the pid - pid = list.Workers[0].Pid - time.Sleep(time.Second * 10) + workerPid = list.Workers[0].Pid +} - list = struct { +func informerTestAfter(t *testing.T) { + conn, err := net.Dial("tcp", "127.0.0.1:15432") + assert.NoError(t, err) + client := rpc.NewClientWithCodec(goridgeRpc.NewClientCodec(conn)) + // WorkerList contains list of workers. + list := struct { // Workers is list of workers. Workers []tools.ProcessState `json:"workers"` }{} + assert.NotZero(t, workerPid) + err = client.Call("informer.Workers", "http", &list) assert.NoError(t, err) assert.Len(t, list.Workers, 1) - assert.NotEqual(t, list.Workers[0].Pid, pid) + assert.NotEqual(t, workerPid, list.Workers[0].Pid) } func get(url string) (string, *http.Response, error) { diff --git a/tests/sleep.php b/tests/sleep.php index fb5c9df2..d36ae3e3 100644 --- a/tests/sleep.php +++ b/tests/sleep.php @@ -10,6 +10,6 @@ require __DIR__ . "/vendor/autoload.php"; $rr = new RoadRunner(new StreamRelay(\STDIN, \STDOUT)); while($rr->waitPayload()){ - sleep(3); + sleep(300); $rr->respond(new \Spiral\RoadRunner\Payload("")); } |