diff options
author | Valery Piashchynski <[email protected]> | 2020-10-27 15:58:46 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-10-27 15:58:46 +0300 |
commit | c9af916ae4d78334d348ed1ef7238206f3ecb7a1 (patch) | |
tree | 43c04f7c538ecbd0b29fc280d41df5d00f203436 /static_pool_test.go | |
parent | fd60aff1cddf32b0c45d934fcf14b070df80adcf (diff) | |
parent | 105bde0e0c1a7c133d1daa10603ca5ce9a9ade4d (diff) |
Merge remote-tracking branch 'origin/release_2.0' into feature/pool_supervisor
# Conflicts:
# static_pool.go
# sync_worker.go
Diffstat (limited to 'static_pool_test.go')
-rwxr-xr-x | static_pool_test.go | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/static_pool_test.go b/static_pool_test.go index 8633f9c5..f1e3e4e4 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() |