summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-14 13:54:44 +0300
committerValery Piashchynski <[email protected]>2020-12-14 13:54:44 +0300
commitf6063d06d3a381036abd672dfbb799d777455fb0 (patch)
tree2370c6e2263fd286d8fe412de951304df69f9806
parent00b42663891713f142a6cc67bcccdc31353daeb2 (diff)
fix tests issues
-rwxr-xr-xMakefile28
-rwxr-xr-xpipe_factory_test.go2
-rwxr-xr-xsocket_factory_test.go4
-rwxr-xr-xstatic_pool.go2
-rwxr-xr-xstatic_pool_test.go14
-rw-r--r--supervisor_test.go3
-rwxr-xr-xsync_worker.go1
-rwxr-xr-xsync_worker_test.go4
8 files changed, 30 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index bb1e1975..e3f00c63 100755
--- a/Makefile
+++ b/Makefile
@@ -24,19 +24,21 @@ uninstall: ## Uninstall locally installed RR
rm -f /usr/local/bin/rr
test: ## Run application tests
- go test -v -race -cover
- go test -v -race -cover ./util
- go test -v -race -cover ./service
- go test -v -race -cover ./service/env
- go test -v -race -cover ./service/rpc
- go test -v -race -cover ./service/http
- go test -v -race -cover ./service/static
- go test -v -race -cover ./service/limit
- go test -v -race -cover ./service/headers
- go test -v -race -cover ./service/metrics
- go test -v -race -cover ./service/health
- go test -v -race -cover ./service/gzip
- go test -v -race -cover ./service/reload
+ go test -v -race -cover -tags=debug -covermode=atomic .
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/rpc
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/rpc/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/config/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/logger/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/server/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/metrics/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/informer/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/resetter/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/http/attributes
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/http/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/gzip/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/static/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/headers/tests
+ go test -v -race -cover -tags=debug -covermode=atomic ./plugins/checker/tests
lint: ## Run application linters
go fmt ./...
diff --git a/pipe_factory_test.go b/pipe_factory_test.go
index bdb861de..c742f522 100755
--- a/pipe_factory_test.go
+++ b/pipe_factory_test.go
@@ -105,7 +105,7 @@ func Test_Pipe_Echo(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.Equal(t, "hello", res.String())
}
diff --git a/socket_factory_test.go b/socket_factory_test.go
index ab6927bd..bbe8cc31 100755
--- a/socket_factory_test.go
+++ b/socket_factory_test.go
@@ -254,7 +254,7 @@ func Test_Tcp_Echo(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.Equal(t, "hello", res.String())
}
@@ -442,7 +442,7 @@ func Test_Unix_Echo(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.Equal(t, "hello", res.String())
}
diff --git a/static_pool.go b/static_pool.go
index 3b5ed00c..fbb2e5e8 100755
--- a/static_pool.go
+++ b/static_pool.go
@@ -163,7 +163,7 @@ func (sp *StaticPool) Exec(p Payload) (Payload, error) {
// worker want's to be terminated
// TODO careful with string(rsp.Context)
- if rsp.Body == nil && rsp.Context != nil && string(rsp.Context) == StopRequest {
+ if len(rsp.Body) == 0 && string(rsp.Context) == StopRequest {
sw.State().Set(StateInvalid)
err = sw.Stop(bCtx)
if err != nil {
diff --git a/static_pool_test.go b/static_pool_test.go
index 747f26c4..33799c40 100755
--- a/static_pool_test.go
+++ b/static_pool_test.go
@@ -82,7 +82,7 @@ func Test_StaticPool_Echo(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.Equal(t, "hello", res.String())
}
@@ -106,7 +106,7 @@ func Test_StaticPool_Echo_NilContext(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.Equal(t, "hello", res.String())
}
@@ -129,7 +129,7 @@ func Test_StaticPool_Echo_Context(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
- assert.Nil(t, res.Body)
+ assert.Empty(t, res.Body)
assert.NotNil(t, res.Context)
assert.Equal(t, "world", string(res.Context))
@@ -214,7 +214,7 @@ func Test_StaticPool_Broken_FromOutside(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.Equal(t, "hello", res.String())
assert.Equal(t, runtime.NumCPU(), len(p.Workers()))
@@ -293,7 +293,7 @@ func Test_StaticPool_Replace_Worker(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.NotEqual(t, lastPID, string(res.Body))
lastPID = string(res.Body)
@@ -332,7 +332,7 @@ func Test_StaticPool_Debug_Worker(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.NotEqual(t, lastPID, string(res.Body))
lastPID = string(res.Body)
@@ -372,7 +372,7 @@ func Test_StaticPool_Stop_Worker(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.NotEqual(t, lastPID, string(res.Body))
lastPID = string(res.Body)
diff --git a/supervisor_test.go b/supervisor_test.go
index 08ea356d..d5d7d04c 100644
--- a/supervisor_test.go
+++ b/supervisor_test.go
@@ -142,7 +142,8 @@ func TestSupervisedPool_ExecTTL_OK(t *testing.T) {
})
assert.NoError(t, err)
- assert.Empty(t, resp)
+ assert.Empty(t, resp.Body)
+ assert.Empty(t, resp.Context)
time.Sleep(time.Second * 1)
// should be the same pid
diff --git a/sync_worker.go b/sync_worker.go
index 99620c01..94a804a7 100755
--- a/sync_worker.go
+++ b/sync_worker.go
@@ -185,7 +185,6 @@ func (tw *syncWorker) execPayload(p Payload) (Payload, error) {
}
payload := Payload{}
-
payload.Context = frameR.Payload()[:options[0]]
payload.Body = frameR.Payload()[options[0]:]
diff --git a/sync_worker_test.go b/sync_worker_test.go
index 30b5bae8..0ef1e0cd 100755
--- a/sync_worker_test.go
+++ b/sync_worker_test.go
@@ -40,7 +40,7 @@ func Test_Echo(t *testing.T) {
assert.Nil(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.Equal(t, "hello", res.String())
}
@@ -148,7 +148,7 @@ func Test_Echo_Slow(t *testing.T) {
assert.Nil(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Body)
- assert.Nil(t, res.Context)
+ assert.Empty(t, res.Context)
assert.Equal(t, "hello", res.String())
}