diff options
author | Valery Piashchynski <[email protected]> | 2020-12-26 00:40:31 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-26 00:40:31 +0300 |
commit | 7a0dee1a416705c621edbf50e1f43fb39845348f (patch) | |
tree | 0007a6b8c8ac9e7d31b8a5f3f7f27669c860d261 /tests/plugins/server | |
parent | 8526c03822e724bc2ebb64b6197085fea335b782 (diff) |
Huge tests refactoring. Reduce running time 2-3x times
Diffstat (limited to 'tests/plugins/server')
-rw-r--r-- | tests/plugins/server/plugin_pipes.go | 4 | ||||
-rw-r--r-- | tests/plugins/server/plugin_sockets.go | 4 | ||||
-rw-r--r-- | tests/plugins/server/plugin_tcp.go | 4 | ||||
-rw-r--r-- | tests/plugins/server/server_plugin_test.go (renamed from tests/plugins/server/server_test.go) | 49 |
4 files changed, 33 insertions, 28 deletions
diff --git a/tests/plugins/server/plugin_pipes.go b/tests/plugins/server/plugin_pipes.go index 6f31395a..5eb2fed1 100644 --- a/tests/plugins/server/plugin_pipes.go +++ b/tests/plugins/server/plugin_pipes.go @@ -5,12 +5,12 @@ import ( "time" "github.com/spiral/errors" - "github.com/spiral/roadrunner-plugins/config" "github.com/spiral/roadrunner/v2/interfaces/pool" "github.com/spiral/roadrunner/v2/pkg/payload" - "github.com/spiral/roadrunner/v2/pkg/plugins/server" poolImpl "github.com/spiral/roadrunner/v2/pkg/pool" "github.com/spiral/roadrunner/v2/pkg/worker" + "github.com/spiral/roadrunner/v2/plugins/config" + "github.com/spiral/roadrunner/v2/plugins/server" ) const ConfigSection = "server" diff --git a/tests/plugins/server/plugin_sockets.go b/tests/plugins/server/plugin_sockets.go index 1820b4c1..ede67ded 100644 --- a/tests/plugins/server/plugin_sockets.go +++ b/tests/plugins/server/plugin_sockets.go @@ -4,11 +4,11 @@ import ( "context" "github.com/spiral/errors" - "github.com/spiral/roadrunner-plugins/config" "github.com/spiral/roadrunner/v2/interfaces/pool" "github.com/spiral/roadrunner/v2/pkg/payload" - "github.com/spiral/roadrunner/v2/pkg/plugins/server" "github.com/spiral/roadrunner/v2/pkg/worker" + "github.com/spiral/roadrunner/v2/plugins/config" + "github.com/spiral/roadrunner/v2/plugins/server" ) type Foo2 struct { diff --git a/tests/plugins/server/plugin_tcp.go b/tests/plugins/server/plugin_tcp.go index 01fa0cf5..98c13b2b 100644 --- a/tests/plugins/server/plugin_tcp.go +++ b/tests/plugins/server/plugin_tcp.go @@ -4,11 +4,11 @@ import ( "context" "github.com/spiral/errors" - "github.com/spiral/roadrunner-plugins/config" "github.com/spiral/roadrunner/v2/interfaces/pool" "github.com/spiral/roadrunner/v2/pkg/payload" - "github.com/spiral/roadrunner/v2/pkg/plugins/server" "github.com/spiral/roadrunner/v2/pkg/worker" + "github.com/spiral/roadrunner/v2/plugins/config" + "github.com/spiral/roadrunner/v2/plugins/server" ) type Foo3 struct { diff --git a/tests/plugins/server/server_test.go b/tests/plugins/server/server_plugin_test.go index 75111ef7..d63b0ccd 100644 --- a/tests/plugins/server/server_test.go +++ b/tests/plugins/server/server_plugin_test.go @@ -3,13 +3,14 @@ package server import ( "os" "os/signal" + "sync" "testing" "time" "github.com/spiral/endure" - "github.com/spiral/roadrunner-plugins/config" - "github.com/spiral/roadrunner-plugins/logger" - "github.com/spiral/roadrunner/v2/pkg/plugins/server" + "github.com/spiral/roadrunner/v2/plugins/config" + "github.com/spiral/roadrunner/v2/plugins/logger" + "github.com/spiral/roadrunner/v2/plugins/server" "github.com/stretchr/testify/assert" ) @@ -56,27 +57,31 @@ func TestAppPipes(t *testing.T) { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) - // stop after 10 seconds - tt := time.NewTicker(time.Second * 10) - - for { - select { - case e := <-errCh: - assert.NoError(t, e.Error) - assert.NoError(t, container.Stop()) - return - case <-c: - er := container.Stop() - if er != nil { - panic(er) + tt := time.NewTimer(time.Second * 10) + wg := &sync.WaitGroup{} + wg.Add(1) + + go func() { + defer wg.Done() + defer tt.Stop() + for { + select { + case e := <-errCh: + assert.NoError(t, e.Error) + assert.NoError(t, container.Stop()) + return + case <-c: + er := container.Stop() + assert.NoError(t, er) + return + case <-tt.C: + assert.NoError(t, container.Stop()) + return } - return - case <-tt.C: - tt.Stop() - assert.NoError(t, container.Stop()) - return } - } + }() + + wg.Wait() } func TestAppSockets(t *testing.T) { |