diff options
author | Valery Piashchynski <[email protected]> | 2021-04-20 15:52:27 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-20 15:52:27 +0300 |
commit | 02cb030cec51a81c6b2f6d8351e66112eb2c9b7f (patch) | |
tree | b3feb3cf19a34652d5ad23be3e049123bbc04233 /tests/plugins/http/http_plugin_test.go | |
parent | a3ced86a77b406bd8d127135636d33e12517d7f8 (diff) | |
parent | 5c63b9b8b774917712bab165b37f360aab509828 (diff) |
#638 fix(http): Make a Serve function in the `http` plugin asynchronousv2.1.0-beta.3
#638 fix(http): Make a Serve function in the `http` plugin asynchronous
Diffstat (limited to 'tests/plugins/http/http_plugin_test.go')
-rw-r--r-- | tests/plugins/http/http_plugin_test.go | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/tests/plugins/http/http_plugin_test.go b/tests/plugins/http/http_plugin_test.go index 73d6d102..0e43dac4 100644 --- a/tests/plugins/http/http_plugin_test.go +++ b/tests/plugins/http/http_plugin_test.go @@ -1227,10 +1227,43 @@ func TestHttpBrokenPipes(t *testing.T) { err = cont.Init() assert.NoError(t, err) - _, err = cont.Serve() - assert.Error(t, err) + ch, err := cont.Serve() + assert.NoError(t, err) + + sig := make(chan os.Signal, 1) + signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) + + wg := &sync.WaitGroup{} + wg.Add(1) + + stopCh := make(chan struct{}, 1) + + go func() { + defer wg.Done() + for { + select { + // should be error from the plugin + case e := <-ch: + assert.Error(t, e.Error) + return + case <-sig: + err = cont.Stop() + if err != nil { + assert.FailNow(t, "error", err.Error()) + } + return + case <-stopCh: + // timeout + err = cont.Stop() + if err != nil { + assert.FailNow(t, "error", err.Error()) + } + return + } + } + }() - assert.NoError(t, cont.Stop()) + wg.Wait() } func TestHTTPSupervisedPool(t *testing.T) { @@ -1512,6 +1545,8 @@ func TestHTTPBigRequestSize(t *testing.T) { } }() + time.Sleep(time.Second * 2) + t.Run("HTTPBigEcho10Mb", bigEchoHTTP) stopCh <- struct{}{} |