summaryrefslogtreecommitdiff
path: root/pkg/pool/supervisor_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-23 17:54:58 +0300
committerValery Piashchynski <[email protected]>2021-01-23 17:54:58 +0300
commit01a6fab935fc2e40d7b6c17ab75a20a74ca23d1d (patch)
tree59967433eb8220e60020011873623a7454941314 /pkg/pool/supervisor_test.go
parent29d6020a9e8a3713b22269ed946547c96c24d3da (diff)
Stabilization PR
Diffstat (limited to 'pkg/pool/supervisor_test.go')
-rw-r--r--pkg/pool/supervisor_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/pkg/pool/supervisor_test.go b/pkg/pool/supervisor_test.go
index b3358965..a9424cd5 100644
--- a/pkg/pool/supervisor_test.go
+++ b/pkg/pool/supervisor_test.go
@@ -194,3 +194,48 @@ func TestSupervisedPool_ExecTTL_OK(t *testing.T) {
// should be the same pid
assert.Equal(t, pid, p.Workers()[0].Pid())
}
+
+func TestSupervisedPool_MaxMemoryReached(t *testing.T) {
+ var cfgExecTTL = Config{
+ NumWorkers: int64(1),
+ AllocateTimeout: time.Second,
+ DestroyTimeout: time.Second,
+ Supervisor: &SupervisorConfig{
+ WatchTick: 1,
+ TTL: 100,
+ IdleTTL: 100,
+ ExecTTL: 4,
+ MaxWorkerMemory: 1,
+ },
+ }
+
+ // constructed
+ // max memory
+ // constructed
+ ctx := context.Background()
+ p, err := Initialize(
+ ctx,
+ func() *exec.Cmd { return exec.Command("php", "../../tests/memleak.php", "pipes") },
+ pipe.NewPipeFactory(),
+ cfgExecTTL,
+ )
+
+ assert.NoError(t, err)
+ assert.NotNil(t, p)
+ defer p.Destroy(context.Background())
+
+ pid := p.Workers()[0].Pid()
+
+ time.Sleep(time.Millisecond * 100)
+ resp, err := p.Exec(payload.Payload{
+ Context: []byte(""),
+ Body: []byte("foo"),
+ })
+
+ assert.NoError(t, err)
+ assert.Empty(t, resp.Body)
+ assert.Empty(t, resp.Context)
+
+ time.Sleep(time.Second * 2)
+ assert.NotEqual(t, pid, p.Workers()[0].Pid())
+}