summaryrefslogtreecommitdiff
path: root/service/limit
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-12-23 14:43:47 +0300
committerWolfy-J <[email protected]>2019-12-23 14:43:47 +0300
commitc7b0a4a81827284f7565c56aa476eea34fb6382f (patch)
treeee30e93169c37fb058fbe55af6b3f954eabd9646 /service/limit
parent7f694966730f6dac09d0d0ea3bf51276b8e4dfe4 (diff)
- test fixes
Diffstat (limited to 'service/limit')
-rw-r--r--service/limit/config_test.go5
-rw-r--r--service/limit/controller.go7
-rw-r--r--service/limit/service_test.go66
3 files changed, 66 insertions, 12 deletions
diff --git a/service/limit/config_test.go b/service/limit/config_test.go
index b8a6c0aa..b388791f 100644
--- a/service/limit/config_test.go
+++ b/service/limit/config_test.go
@@ -31,7 +31,10 @@ func Test_Controller_Default(t *testing.T) {
}
`}
c := &Config{}
- c.InitDefaults()
+ err := c.InitDefaults()
+ if err != nil {
+ t.Errorf("failed to InitDefaults: error %v", err)
+ }
assert.NoError(t, c.Hydrate(cfg))
assert.Equal(t, time.Second, c.Interval)
diff --git a/service/limit/controller.go b/service/limit/controller.go
index c11f4b91..24a158f7 100644
--- a/service/limit/controller.go
+++ b/service/limit/controller.go
@@ -66,7 +66,12 @@ func (c *controller) control(p roadrunner.Pool) {
// make sure worker still on initial request
if p.Remove(w, err) && w.State().NumExecs() == eID {
- go w.Kill()
+ go func() {
+ err := w.Kill()
+ if err != nil {
+ fmt.Printf("error killing worker with PID number: %d, created: %s", w.Pid, w.Created)
+ }
+ }()
c.report(EventExecTTL, w, err)
}
}
diff --git a/service/limit/service_test.go b/service/limit/service_test.go
index ade4abcc..8cb3d7dc 100644
--- a/service/limit/service_test.go
+++ b/service/limit/service_test.go
@@ -75,7 +75,12 @@ func Test_Service_PidEcho(t *testing.T) {
s, _ := c.Get(rrhttp.ID)
assert.NotNil(t, s)
- go func() { c.Serve() }()
+ go func() {
+ err := c.Serve()
+ if err != nil {
+ t.Errorf("error during the Serve: error %v", err)
+ }
+ }()
time.Sleep(time.Millisecond * 100)
defer c.Stop()
@@ -84,7 +89,12 @@ func Test_Service_PidEcho(t *testing.T) {
r, err := http.DefaultClient.Do(req)
assert.NoError(t, err)
- defer r.Body.Close()
+ defer func() {
+ err := r.Body.Close()
+ if err != nil {
+ t.Errorf("error during the body closing: error %v", err)
+ }
+ }()
b, err := ioutil.ReadAll(r.Body)
assert.NoError(t, err)
@@ -129,7 +139,12 @@ func Test_Service_ListenerPlusTTL(t *testing.T) {
}
})
- go func() { c.Serve() }()
+ go func() {
+ err := c.Serve()
+ if err != nil {
+ t.Errorf("error during the Serve: error %v", err)
+ }
+ }()
time.Sleep(time.Millisecond * 100)
defer c.Stop()
@@ -140,7 +155,12 @@ func Test_Service_ListenerPlusTTL(t *testing.T) {
r, err := http.DefaultClient.Do(req)
assert.NoError(t, err)
- defer r.Body.Close()
+ defer func() {
+ err := r.Body.Close()
+ if err != nil {
+ t.Errorf("error during the body closing: error %v", err)
+ }
+ }()
b, err := ioutil.ReadAll(r.Body)
assert.NoError(t, err)
@@ -194,7 +214,12 @@ func Test_Service_ListenerPlusIdleTTL(t *testing.T) {
}
})
- go func() { c.Serve() }()
+ go func() {
+ err := c.Serve()
+ if err != nil {
+ t.Errorf("error during the Serve: error %v", err)
+ }
+ }()
time.Sleep(time.Millisecond * 100)
defer c.Stop()
@@ -205,7 +230,12 @@ func Test_Service_ListenerPlusIdleTTL(t *testing.T) {
r, err := http.DefaultClient.Do(req)
assert.NoError(t, err)
- defer r.Body.Close()
+ defer func() {
+ err := r.Body.Close()
+ if err != nil {
+ t.Errorf("error during the body closing: error %v", err)
+ }
+ }()
b, err := ioutil.ReadAll(r.Body)
assert.NoError(t, err)
@@ -261,7 +291,12 @@ func Test_Service_Listener_MaxExecTTL(t *testing.T) {
}
})
- go func() { c.Serve() }()
+ go func() {
+ err := c.Serve()
+ if err != nil {
+ t.Errorf("error during the Serve: error %v", err)
+ }
+ }()
time.Sleep(time.Millisecond * 100)
defer c.Stop()
@@ -313,7 +348,12 @@ func Test_Service_Listener_MaxMemoryUsage(t *testing.T) {
}
})
- go func() { c.Serve() }()
+ go func() {
+ err := c.Serve()
+ if err != nil {
+ t.Errorf("error during the Serve: error %v", err)
+ }
+ }()
time.Sleep(time.Millisecond * 100)
defer c.Stop()
@@ -325,11 +365,17 @@ func Test_Service_Listener_MaxMemoryUsage(t *testing.T) {
for {
select {
case <-captured:
- http.DefaultClient.Do(req)
+ _, err := http.DefaultClient.Do(req)
+ if err != nil {
+ t.Errorf("error during sending the http request: error %v", err)
+ }
assert.NotEqual(t, lastPID, getPID(s))
return
default:
- http.DefaultClient.Do(req)
+ _, err := http.DefaultClient.Do(req)
+ if err != nil {
+ t.Errorf("error during sending the http request: error %v", err)
+ }
}
}
}