diff options
author | Valery Piashchynski <[email protected]> | 2020-12-15 11:46:23 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-15 11:46:23 +0300 |
commit | 0652f9f507f3b7a09d0b7f259588c794bd20bc02 (patch) | |
tree | 1fb8db5006e0dece7b9e23a2d28615d533c0fb4e | |
parent | 9b1c2648bdbf80bdf43fbe2c64d06cfbad1340fc (diff) |
Tests fixed
-rw-r--r-- | .github/workflows/build.yml | 2 | ||||
-rw-r--r-- | plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml | 2 | ||||
-rw-r--r-- | plugins/http/tests/uploads_test.go | 4 | ||||
-rwxr-xr-x | worker_watcher.go | 6 |
4 files changed, 9 insertions, 5 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 685aed7a..7e4ebb1e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: golang: name: Build (Go ${{ matrix.go }}, PHP ${{ matrix.php }}, OS ${{matrix.os}}) runs-on: ${{ matrix.os }} - timeout-minutes: 20 + timeout-minutes: 15 strategy: fail-fast: false matrix: diff --git a/plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml b/plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml index df02c043..3dc5f9df 100644 --- a/plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml +++ b/plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml @@ -1,5 +1,5 @@ server: - command: "php psr-worker.php" + command: "php ../../../tests/psr-worker.php" user: "" group: "" env: diff --git a/plugins/http/tests/uploads_test.go b/plugins/http/tests/uploads_test.go index ee244c06..d36d4793 100644 --- a/plugins/http/tests/uploads_test.go +++ b/plugins/http/tests/uploads_test.go @@ -269,7 +269,7 @@ func TestHandler_Upload_File_NoTmpDir(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 200, r.StatusCode) - fs := fileString(testFile, 5, "application/octet-stream") + fs := fileString(testFile, 6, "application/octet-stream") assert.Equal(t, `{"upload":`+fs+`}`, string(b)) } @@ -352,7 +352,7 @@ func TestHandler_Upload_File_Forbids(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 200, r.StatusCode) - fs := fileString(testFile, 7, "application/octet-stream") + fs := fileString(testFile, 8, "application/octet-stream") assert.Equal(t, `{"upload":`+fs+`}`, string(b)) } diff --git a/worker_watcher.go b/worker_watcher.go index fa160d57..f9b3d372 100755 --- a/worker_watcher.go +++ b/worker_watcher.go @@ -32,6 +32,8 @@ func (stack *Stack) Reset() { stack.workers = nil } +// Push worker back to the stack +// If stack in destroy state, Push will provide 100ms window to unlock the mutex func (stack *Stack) Push(w WorkerBase) { stack.mutex.Lock() defer stack.mutex.Unlock() @@ -42,13 +44,13 @@ func (stack *Stack) Push(w WorkerBase) { func (stack *Stack) IsEmpty() bool { stack.mutex.Lock() defer stack.mutex.Unlock() - return len(stack.workers) == 0 } func (stack *Stack) Pop() (WorkerBase, bool) { stack.mutex.Lock() defer stack.mutex.Unlock() + // do not release new stack if stack.destroy { return nil, true @@ -58,6 +60,7 @@ func (stack *Stack) Pop() (WorkerBase, bool) { return nil, false } + // move worker w := stack.workers[len(stack.workers)-1] stack.workers = stack.workers[:len(stack.workers)-1] stack.actualNumOfWorkers-- @@ -80,6 +83,7 @@ func (stack *Stack) FindAndRemoveByPid(pid int64) bool { return false } +// Workers return copy of the workers in the stack func (stack *Stack) Workers() []WorkerBase { stack.mutex.Lock() defer stack.mutex.Unlock() |