summaryrefslogtreecommitdiff
path: root/tests/plugins/informer/informer_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins/informer/informer_test.go')
-rw-r--r--tests/plugins/informer/informer_test.go67
1 files changed, 39 insertions, 28 deletions
diff --git a/tests/plugins/informer/informer_test.go b/tests/plugins/informer/informer_test.go
index 15063d7e..d9fc2143 100644
--- a/tests/plugins/informer/informer_test.go
+++ b/tests/plugins/informer/informer_test.go
@@ -5,17 +5,18 @@ import (
"net/rpc"
"os"
"os/signal"
+ "sync"
"syscall"
"testing"
"time"
"github.com/spiral/endure"
goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc"
- "github.com/spiral/roadrunner-plugins/config"
- "github.com/spiral/roadrunner-plugins/logger"
- rpcPlugin "github.com/spiral/roadrunner-plugins/rpc"
- "github.com/spiral/roadrunner/v2/pkg/plugins/informer"
- "github.com/spiral/roadrunner/v2/pkg/plugins/server"
+ "github.com/spiral/roadrunner/v2/plugins/config"
+ "github.com/spiral/roadrunner/v2/plugins/informer"
+ "github.com/spiral/roadrunner/v2/plugins/logger"
+ rpcPlugin "github.com/spiral/roadrunner/v2/plugins/rpc"
+ "github.com/spiral/roadrunner/v2/plugins/server"
"github.com/spiral/roadrunner/v2/tools"
"github.com/stretchr/testify/assert"
)
@@ -52,33 +53,43 @@ func TestInformerInit(t *testing.T) {
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
- tt := time.NewTimer(time.Second * 15)
+ stopCh := make(chan struct{}, 1)
- t.Run("InformerRpcTest", informerRPCTest)
+ wg := &sync.WaitGroup{}
+ wg.Add(1)
- for {
- select {
- case e := <-ch:
- assert.Fail(t, "error", e.Error.Error())
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- case <-sig:
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
+ go func() {
+ defer wg.Done()
+ for {
+ select {
+ case e := <-ch:
+ assert.Fail(t, "error", e.Error.Error())
+ err = cont.Stop()
+ if err != nil {
+ assert.FailNow(t, "error", err.Error())
+ }
+ 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
}
- return
- case <-tt.C:
- // timeout
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- return
}
- }
+ }()
+
+ time.Sleep(time.Second)
+ t.Run("InformerRpcTest", informerRPCTest)
+
+ stopCh <- struct{}{}
+ wg.Wait()
}
func informerRPCTest(t *testing.T) {