summaryrefslogtreecommitdiff
path: root/static_pool_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-01 16:59:06 +0300
committerValery Piashchynski <[email protected]>2020-12-01 16:59:06 +0300
commit84c8234ec01ad1d5ea5f0a8c7dbca9a3012bcb2b (patch)
treed70f1d5fb0f36821825d0805d71f22940ec6a1af /static_pool_test.go
parent2ac6d3192fbd43f0911d7c87f394fd0839b0fcfa (diff)
parent70910821a0ffb10316f9970a2fec4c3379d10675 (diff)
Merge branch 'release_2.0' into plugin/headers
# Conflicts: # static_pool_test.go
Diffstat (limited to 'static_pool_test.go')
-rwxr-xr-xstatic_pool_test.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/static_pool_test.go b/static_pool_test.go
index 77e554e5..747f26c4 100755
--- a/static_pool_test.go
+++ b/static_pool_test.go
@@ -6,6 +6,7 @@ import (
"os/exec"
"runtime"
"strconv"
+ "strings"
"sync"
"testing"
"time"
@@ -16,8 +17,8 @@ import (
var cfg = PoolConfig{
NumWorkers: int64(runtime.NumCPU()),
- AllocateTimeout: time.Second,
- DestroyTimeout: time.Second,
+ AllocateTimeout: time.Second * 5,
+ DestroyTimeout: time.Second * 5,
}
func Test_NewPool(t *testing.T) {
@@ -171,15 +172,16 @@ func Test_StaticPool_Broken_Replace(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, p)
- wg := &sync.WaitGroup{}
- wg.Add(1)
+ block := make(chan struct{})
p.AddListener(func(event interface{}) {
if wev, ok := event.(WorkerEvent); ok {
if wev.Event == EventWorkerLog {
- assert.Contains(t, string(wev.Payload.([]byte)), "undefined_function()")
- wg.Done()
- return
+ e := string(wev.Payload.([]byte))
+ if strings.ContainsAny(e, "undefined_function()") {
+ block <- struct{}{}
+ return
+ }
}
}
})
@@ -189,7 +191,7 @@ func Test_StaticPool_Broken_Replace(t *testing.T) {
assert.Nil(t, res.Context)
assert.Nil(t, res.Body)
- wg.Wait()
+ <-block
p.Destroy(ctx)
}