summaryrefslogtreecommitdiff
path: root/static_pool_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-10-27 15:50:57 +0300
committerGitHub <[email protected]>2020-10-27 15:50:57 +0300
commit105bde0e0c1a7c133d1daa10603ca5ce9a9ade4d (patch)
tree0d4664ef76ff6515fa965690a79dc69604eb3849 /static_pool_test.go
parent91cf918b30938129609323ded53e190385e019a6 (diff)
parent2176584129e493e08aed158bc050070d520ee183 (diff)
Merge pull request #376 from spiral/feature/lazy-load
Feature/lazy load
Diffstat (limited to 'static_pool_test.go')
-rwxr-xr-xstatic_pool_test.go41
1 files changed, 40 insertions, 1 deletions
diff --git a/static_pool_test.go b/static_pool_test.go
index ec80e92a..b75bd0bf 100755
--- a/static_pool_test.go
+++ b/static_pool_test.go
@@ -152,7 +152,7 @@ func Test_StaticPool_JobError(t *testing.T) {
assert.Nil(t, res.Body)
assert.Nil(t, res.Context)
- assert.IsType(t, JobError{}, err)
+ assert.IsType(t, ExecError{}, err)
assert.Equal(t, "hello", err.Error())
}
@@ -301,6 +301,45 @@ func Test_StaticPool_Replace_Worker(t *testing.T) {
}
}
+func Test_StaticPool_Debug_Worker(t *testing.T) {
+ ctx := context.Background()
+ p, err := NewPool(
+ ctx,
+ func() *exec.Cmd { return exec.Command("php", "tests/client.php", "pid", "pipes") },
+ NewPipeFactory(),
+ Config{
+ Debug: true,
+ AllocateTimeout: time.Second,
+ DestroyTimeout: time.Second,
+ },
+ )
+ assert.NoError(t, err)
+ defer p.Destroy(ctx)
+
+ assert.NotNil(t, p)
+
+ assert.Len(t, p.Workers(), 0)
+
+ var lastPID string
+ res, _ := p.Exec(Payload{Body: []byte("hello")})
+ assert.NotEqual(t, lastPID, string(res.Body))
+
+ assert.Len(t, p.Workers(), 0)
+
+ for i := 0; i < 10; i++ {
+ assert.Len(t, p.Workers(), 0)
+ res, err := p.Exec(Payload{Body: []byte("hello")})
+
+ assert.NoError(t, err)
+ assert.NotNil(t, res)
+ assert.NotNil(t, res.Body)
+ assert.Nil(t, res.Context)
+
+ assert.NotEqual(t, lastPID, string(res.Body))
+ lastPID = string(res.Body)
+ }
+}
+
// identical to replace but controlled on worker side
func Test_StaticPool_Stop_Worker(t *testing.T) {
ctx := context.Background()