diff options
author | Valery Piashchynski <[email protected]> | 2021-01-23 17:54:58 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-23 17:54:58 +0300 |
commit | 01a6fab935fc2e40d7b6c17ab75a20a74ca23d1d (patch) | |
tree | 59967433eb8220e60020011873623a7454941314 | |
parent | 29d6020a9e8a3713b22269ed946547c96c24d3da (diff) |
Stabilization PR
40 files changed, 225 insertions, 80 deletions
@@ -13,7 +13,7 @@ server: logs: mode: development - level: debug + level: error http: # host and port separated by semicolon @@ -70,13 +70,13 @@ http: # MaxWorkerMemory limits memory per worker (MB) max_worker_memory: 100 - # ssl: - # host and port separated by semicolon (default :443) - # address: :8892 - # redirect: false - # cert: fixtures/server.crt - # key: fixtures/server.key - # rootCa: root.crt + ssl: + # host and port separated by semicolon (default :443) + address: :8892 + redirect: false + cert: fixtures/server.crt + key: fixtures/server.key + rootCa: root.crt fcgi: address: tcp://0.0.0.0:7921 http2: diff --git a/cmd/cli/root.go b/cmd/cli/root.go index 5e201daa..6f73aecf 100644 --- a/cmd/cli/root.go +++ b/cmd/cli/root.go @@ -16,7 +16,7 @@ import ( "net/http" "github.com/spf13/cobra" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" ) var ( diff --git a/cmd/main.go b/cmd/main.go index 68d0cadb..1dd19107 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -3,7 +3,7 @@ package main import ( "log" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/roadrunner/v2/cmd/cli" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" "github.com/spiral/roadrunner/v2/plugins/informer" @@ -22,7 +22,7 @@ import ( func main() { var err error - cli.Container, err = endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel), endure.RetryOnFail(false)) + cli.Container, err = endure.NewContainer(nil, endure.SetLogLevel(endure.ErrorLevel), endure.RetryOnFail(false)) if err != nil { log.Fatal(err) } @@ -36,3 +36,5 @@ require ( golang.org/x/sync v0.0.0-20201207232520-09787c993a3a golang.org/x/sys v0.0.0-20201221093633-bc327ba9c2f0 ) + +replace github.com/spiral/endure => ../endure @@ -239,6 +239,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -304,9 +306,13 @@ github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spiral/endure v1.0.0-beta20 h1:QD3EJ6CRLgeo/6trfnlUcQhH3vrK8Hvf9ceDpde+yss= github.com/spiral/endure v1.0.0-beta20/go.mod h1:qCU2/4gAItVESzUK0yPExmUTlTcpRLqJUgcV+nqxn+o= +github.com/spiral/endure v1.0.0-beta9 h1:PNiVit9DCucmhZLd4RgoiVL7Y5DBmweUwadFyulAct8= +github.com/spiral/endure v1.0.0-beta9/go.mod h1:EhC6CKaSQum/gz1zRqkyu4LqFOlngVTGbXK69pebmxQ= github.com/spiral/errors v1.0.4/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o= github.com/spiral/errors v1.0.5 h1:TwlR9cZtTgnZrSngcEUpyiMO9yJ45gdQ+XcrCRoCCAM= github.com/spiral/errors v1.0.5/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o= +github.com/spiral/errors v1.0.6/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o= +github.com/spiral/errors v1.0.7/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o= github.com/spiral/errors v1.0.9 h1:RcVZ7a1RYkaT3HWFGDuQiDB02pG6yqh7715Uwd7urwM= github.com/spiral/errors v1.0.9/go.mod h1:SwMSZVdZkkJVgXNNafccqOaxWg0XPzVU/dEdUEInE0o= github.com/spiral/goridge/v3 v3.0.0 h1:FIz6wHaob5KynpOfzVpzj4bmqbEelGPFyuEf4i2+CG8= diff --git a/pkg/pool/static_pool.go b/pkg/pool/static_pool.go index 438f936f..d1b726c1 100755 --- a/pkg/pool/static_pool.go +++ b/pkg/pool/static_pool.go @@ -132,8 +132,9 @@ func (sp *StaticPool) RemoveWorker(wb worker.BaseProcess) error { return sp.ww.RemoveWorker(wb) } +// Be careful, sync Exec with ExecWithContext func (sp *StaticPool) Exec(p payload.Payload) (payload.Payload, error) { - const op = errors.Op("exec") + const op = errors.Op("static_pool_exec") if sp.cfg.Debug { return sp.execDebug(p) } @@ -152,28 +153,21 @@ func (sp *StaticPool) Exec(p payload.Payload) (payload.Payload, error) { // worker want's to be terminated // TODO careful with string(rsp.Context) if len(rsp.Body) == 0 && string(rsp.Context) == StopRequest { - w.State().Set(internal.StateInvalid) - err = w.Stop() - if err != nil { - sp.events.Push(events.WorkerEvent{Event: events.EventWorkerError, Worker: w, Payload: errors.E(op, err)}) - } + sp.stopWorker(&w) return sp.Exec(p) } - if sp.cfg.MaxJobs != 0 && w.State().NumExecs() >= sp.cfg.MaxJobs { - err = sp.ww.AllocateNew() - if err != nil { - return payload.Payload{}, errors.E(op, err) - } - } else { - sp.ww.PushWorker(w) + err = sp.checkMaxJobs(&w) + if err != nil { + return payload.Payload{}, errors.E(op, err) } return rsp, nil } -func (sp *StaticPool) ExecWithContext(ctx context.Context, rqs payload.Payload) (payload.Payload, error) { +// Be careful, sync with pool.Exec method +func (sp *StaticPool) ExecWithContext(ctx context.Context, p payload.Payload) (payload.Payload, error) { const op = errors.Op("static_pool_exec_with_context") ctxGetFree, cancel := context.WithTimeout(ctx, sp.cfg.AllocateTimeout) defer cancel() @@ -182,32 +176,46 @@ func (sp *StaticPool) ExecWithContext(ctx context.Context, rqs payload.Payload) return payload.Payload{}, errors.E(op, err) } - rsp, err := w.ExecWithTimeout(ctx, rqs) + rsp, err := w.ExecWithTimeout(ctx, p) if err != nil { return sp.errEncoder(err, w) } // worker want's to be terminated - if rsp.Body == nil && rsp.Context != nil && string(rsp.Context) == StopRequest { - w.State().Set(internal.StateInvalid) - err = w.Stop() - if err != nil { - sp.events.Push(events.WorkerEvent{Event: events.EventWorkerError, Worker: w, Payload: errors.E(op, err)}) - } + if len(rsp.Body) == 0 && string(rsp.Context) == StopRequest { + sp.stopWorker(&w) + return sp.ExecWithContext(ctx, p) + } - return sp.ExecWithContext(ctx, rqs) + err = sp.checkMaxJobs(&w) + if err != nil { + return payload.Payload{}, errors.E(op, err) } - if sp.cfg.MaxJobs != 0 && w.State().NumExecs() >= sp.cfg.MaxJobs { - err = sp.ww.AllocateNew() + return rsp, nil +} + +func (sp *StaticPool) stopWorker(w *worker.SyncWorker) { + const op = errors.Op("static_pool_stop_worker") + (*w).State().Set(internal.StateInvalid) + err := (*w).Stop() + if err != nil { + sp.events.Push(events.WorkerEvent{Event: events.EventWorkerError, Worker: *w, Payload: errors.E(op, err)}) + } +} + +// checkMaxJobs check for worker number of executions and kill workers if that number more than sp.cfg.MaxJobs +func (sp *StaticPool) checkMaxJobs(w *worker.SyncWorker) error { + const op = errors.Op("static_pool_check_max_jobs") + if sp.cfg.MaxJobs != 0 && (*w).State().NumExecs() >= sp.cfg.MaxJobs { + err := sp.ww.AllocateNew() if err != nil { - return payload.Payload{}, errors.E(op, err) + return errors.E(op, err) } } else { - sp.ww.PushWorker(w) + sp.ww.PushWorker(*w) } - - return rsp, nil + return nil } func (sp *StaticPool) getWorker(ctxGetFree context.Context, op errors.Op) (worker.SyncWorker, error) { diff --git a/pkg/pool/static_pool_test.go b/pkg/pool/static_pool_test.go index f66895dc..348f5297 100755 --- a/pkg/pool/static_pool_test.go +++ b/pkg/pool/static_pool_test.go @@ -489,6 +489,84 @@ func Test_Static_Pool_Slow_Destroy(t *testing.T) { p.Destroy(context.Background()) } +func Test_StaticPool_NoFreeWorkers(t *testing.T) { + ctx := context.Background() + block := make(chan struct{}, 1) + + listener := func(event interface{}) { + if ev, ok := event.(events.PoolEvent); ok { + if ev.Event == events.EventNoFreeWorkers { + block <- struct{}{} + } + } + } + + p, err := Initialize( + ctx, + // sleep for the 3 seconds + func() *exec.Cmd { return exec.Command("php", "../../tests/sleep.php", "pipes") }, + pipe.NewPipeFactory(), + Config{ + Debug: false, + NumWorkers: 1, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + Supervisor: nil, + }, + AddListeners(listener), + ) + assert.NoError(t, err) + assert.NotNil(t, p) + + go func() { + _, _ = p.ExecWithContext(ctx, payload.Payload{Body: []byte("hello")}) + }() + + time.Sleep(time.Second) + res, err := p.ExecWithContext(ctx, payload.Payload{Body: []byte("hello")}) + assert.Error(t, err) + assert.Nil(t, res.Context) + assert.Nil(t, res.Body) + + <-block + + p.Destroy(ctx) +} + +// identical to replace but controlled on worker side +func Test_Static_Pool_WrongCommand1(t *testing.T) { + p, err := Initialize( + context.Background(), + func() *exec.Cmd { return exec.Command("phg", "../../tests/slow-destroy.php", "echo", "pipes") }, + pipe.NewPipeFactory(), + Config{ + NumWorkers: 5, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + ) + + assert.Error(t, err) + assert.Nil(t, p) +} + +// identical to replace but controlled on worker side +func Test_Static_Pool_WrongCommand2(t *testing.T) { + p, err := Initialize( + context.Background(), + func() *exec.Cmd { return exec.Command("php", "", "echo", "pipes") }, + pipe.NewPipeFactory(), + Config{ + NumWorkers: 5, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + ) + + assert.Error(t, err) + assert.Nil(t, p) +} + func Benchmark_Pool_Echo(b *testing.B) { ctx := context.Background() p, err := Initialize( 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()) +} diff --git a/plugins/checker/plugin.go b/plugins/checker/plugin.go index 407cb2fa..59a37613 100644 --- a/plugins/checker/plugin.go +++ b/plugins/checker/plugin.go @@ -7,7 +7,7 @@ import ( "github.com/gofiber/fiber/v2" fiberLogger "github.com/gofiber/fiber/v2/middleware/logger" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/logger" diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go index 249d2e57..b1c68d89 100644 --- a/plugins/http/plugin.go +++ b/plugins/http/plugin.go @@ -13,7 +13,7 @@ import ( "sync" "github.com/hashicorp/go-multierror" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/interfaces/pool" "github.com/spiral/roadrunner/v2/interfaces/worker" diff --git a/plugins/informer/plugin.go b/plugins/informer/plugin.go index 3391ee01..7200c51f 100644 --- a/plugins/informer/plugin.go +++ b/plugins/informer/plugin.go @@ -1,7 +1,7 @@ package informer import ( - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/interfaces/worker" "github.com/spiral/roadrunner/v2/plugins/logger" diff --git a/plugins/logger/plugin.go b/plugins/logger/plugin.go index 719770c0..141ede64 100644 --- a/plugins/logger/plugin.go +++ b/plugins/logger/plugin.go @@ -1,7 +1,7 @@ package logger import ( - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/plugins/config" "go.uber.org/zap" diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index 859f3d24..fefe92bd 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -9,7 +9,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/logger" diff --git a/plugins/resetter/plugin.go b/plugins/resetter/plugin.go index 611cb363..ee0deda6 100644 --- a/plugins/resetter/plugin.go +++ b/plugins/resetter/plugin.go @@ -1,7 +1,7 @@ package resetter import ( - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/plugins/logger" ) diff --git a/plugins/rpc/plugin.go b/plugins/rpc/plugin.go index 84ebb3d0..55b24cd1 100644 --- a/plugins/rpc/plugin.go +++ b/plugins/rpc/plugin.go @@ -5,7 +5,7 @@ import ( "net/rpc" "sync/atomic" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2/plugins/config" diff --git a/plugins/static/plugin.go b/plugins/static/plugin.go index fa2bcfbe..6e6fa67d 100644 --- a/plugins/static/plugin.go +++ b/plugins/static/plugin.go @@ -30,13 +30,19 @@ type Plugin struct { func (s *Plugin) Init(cfg config.Configurer, log logger.Logger) error { const op = errors.Op("static_plugin_init") if !cfg.Has(RootPluginName) { + return errors.E(op, errors.Disabled) } + err := cfg.UnmarshalKey(RootPluginName, &s.cfg) if err != nil { return errors.E(op, errors.Disabled, err) } + m := make(map[string]interface{}) + m["http:static"] = nil + cfg.Overwrite(m) + if s.cfg.Static == nil { return errors.E(op, errors.Disabled) } diff --git a/tests/plugins/checker/configs/.rr-checker-init.yaml b/tests/plugins/checker/configs/.rr-checker-init.yaml index 36130382..5149d27c 100755 --- a/tests/plugins/checker/configs/.rr-checker-init.yaml +++ b/tests/plugins/checker/configs/.rr-checker-init.yaml @@ -15,7 +15,7 @@ status: address: "127.0.0.1:34333" logs: mode: development - level: debug + level: error http: debug: true address: 127.0.0.1:11933 diff --git a/tests/plugins/checker/plugin_test.go b/tests/plugins/checker/plugin_test.go index c346d91a..5e391158 100644 --- a/tests/plugins/checker/plugin_test.go +++ b/tests/plugins/checker/plugin_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2/plugins/checker" "github.com/spiral/roadrunner/v2/plugins/config" diff --git a/tests/plugins/config/config_test.go b/tests/plugins/config/config_test.go index 6d95ba70..364960db 100755 --- a/tests/plugins/config/config_test.go +++ b/tests/plugins/config/config_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/stretchr/testify/assert" ) diff --git a/tests/plugins/gzip/plugin_test.go b/tests/plugins/gzip/plugin_test.go index d525dcc6..66767364 100644 --- a/tests/plugins/gzip/plugin_test.go +++ b/tests/plugins/gzip/plugin_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/gzip" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" diff --git a/tests/plugins/headers/headers_plugin_test.go b/tests/plugins/headers/headers_plugin_test.go index a2ad3357..82a99dd1 100644 --- a/tests/plugins/headers/headers_plugin_test.go +++ b/tests/plugins/headers/headers_plugin_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/headers" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" diff --git a/tests/plugins/http/http_plugin_test.go b/tests/plugins/http/http_plugin_test.go index 72ae05a0..c530f7d1 100644 --- a/tests/plugins/http/http_plugin_test.go +++ b/tests/plugins/http/http_plugin_test.go @@ -17,7 +17,7 @@ import ( "time" "github.com/golang/mock/gomock" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2/interfaces/events" "github.com/spiral/roadrunner/v2/plugins/config" diff --git a/tests/plugins/informer/informer_test.go b/tests/plugins/informer/informer_test.go index d9fc2143..41f1e21a 100644 --- a/tests/plugins/informer/informer_test.go +++ b/tests/plugins/informer/informer_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/informer" diff --git a/tests/plugins/kv/boltdb/configs/.rr-init.yaml b/tests/plugins/kv/boltdb/configs/.rr-init.yaml index 8cfa20e9..bc404d8c 100644 --- a/tests/plugins/kv/boltdb/configs/.rr-init.yaml +++ b/tests/plugins/kv/boltdb/configs/.rr-init.yaml @@ -13,7 +13,7 @@ server: logs: mode: development - level: debug + level: error http: address: 127.0.0.1:44933 diff --git a/tests/plugins/kv/boltdb/plugin_test.go b/tests/plugins/kv/boltdb/plugin_test.go index 5548402d..3a4542ff 100644 --- a/tests/plugins/kv/boltdb/plugin_test.go +++ b/tests/plugins/kv/boltdb/plugin_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2/plugins/config" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" @@ -23,7 +23,7 @@ import ( ) func TestBoltDb(t *testing.T) { - cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel)) + cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.ErrorLevel)) assert.NoError(t, err) cfg := &config.Viper{ diff --git a/tests/plugins/kv/memcached/configs/.rr-init.yaml b/tests/plugins/kv/memcached/configs/.rr-init.yaml index 66ed75cf..34fb4a7d 100644 --- a/tests/plugins/kv/memcached/configs/.rr-init.yaml +++ b/tests/plugins/kv/memcached/configs/.rr-init.yaml @@ -13,7 +13,7 @@ server: logs: mode: development - level: debug + level: error http: address: 127.0.0.1:44933 diff --git a/tests/plugins/kv/memcached/plugin_test.go b/tests/plugins/kv/memcached/plugin_test.go index d4cb58bb..3878ef67 100644 --- a/tests/plugins/kv/memcached/plugin_test.go +++ b/tests/plugins/kv/memcached/plugin_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2/plugins/config" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" @@ -23,7 +23,7 @@ import ( ) func TestMemcache(t *testing.T) { - cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel)) + cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.ErrorLevel)) assert.NoError(t, err) cfg := &config.Viper{ diff --git a/tests/plugins/kv/memory/configs/.rr-init.yaml b/tests/plugins/kv/memory/configs/.rr-init.yaml index e352fad2..7af2d65f 100644 --- a/tests/plugins/kv/memory/configs/.rr-init.yaml +++ b/tests/plugins/kv/memory/configs/.rr-init.yaml @@ -13,7 +13,7 @@ server: logs: mode: development - level: debug + level: error http: address: 127.0.0.1:44933 diff --git a/tests/plugins/kv/memory/plugin_test.go b/tests/plugins/kv/memory/plugin_test.go index ee01fabb..528403d0 100644 --- a/tests/plugins/kv/memory/plugin_test.go +++ b/tests/plugins/kv/memory/plugin_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2/plugins/config" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" @@ -23,7 +23,7 @@ import ( ) func TestInMemory(t *testing.T) { - cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel)) + cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.ErrorLevel)) assert.NoError(t, err) cfg := &config.Viper{ diff --git a/tests/plugins/logger/.rr.yaml b/tests/plugins/logger/.rr.yaml index cb555ec3..5ab359d3 100644 --- a/tests/plugins/logger/.rr.yaml +++ b/tests/plugins/logger/.rr.yaml @@ -1,3 +1,3 @@ logs: mode: development - level: debug
\ No newline at end of file + level: error
\ No newline at end of file diff --git a/tests/plugins/logger/logger_test.go b/tests/plugins/logger/logger_test.go index cc788be3..63f233ee 100644 --- a/tests/plugins/logger/logger_test.go +++ b/tests/plugins/logger/logger_test.go @@ -6,7 +6,7 @@ import ( "sync" "testing" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/logger" "github.com/stretchr/testify/assert" diff --git a/tests/plugins/metrics/metrics_test.go b/tests/plugins/metrics/metrics_test.go index c94d51bc..4e81a65f 100644 --- a/tests/plugins/metrics/metrics_test.go +++ b/tests/plugins/metrics/metrics_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/logger" diff --git a/tests/plugins/redis/redis_plugin_test.go b/tests/plugins/redis/redis_plugin_test.go index eba05752..96a191a1 100644 --- a/tests/plugins/redis/redis_plugin_test.go +++ b/tests/plugins/redis/redis_plugin_test.go @@ -10,7 +10,7 @@ import ( "github.com/alicebob/miniredis/v2" "github.com/golang/mock/gomock" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/redis" "github.com/spiral/roadrunner/v2/tests/mocks" diff --git a/tests/plugins/reload/reload_plugin_test.go b/tests/plugins/reload/reload_plugin_test.go index 81ac3c44..9007541b 100644 --- a/tests/plugins/reload/reload_plugin_test.go +++ b/tests/plugins/reload/reload_plugin_test.go @@ -14,7 +14,7 @@ import ( "time" "github.com/golang/mock/gomock" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/plugins/config" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" diff --git a/tests/plugins/resetter/resetter_test.go b/tests/plugins/resetter/resetter_test.go index 89dd43c7..6e206c7d 100644 --- a/tests/plugins/resetter/resetter_test.go +++ b/tests/plugins/resetter/resetter_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/logger" diff --git a/tests/plugins/rpc/rpc_test.go b/tests/plugins/rpc/rpc_test.go index 98959b28..49d3b3f1 100644 --- a/tests/plugins/rpc/rpc_test.go +++ b/tests/plugins/rpc/rpc_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/logger" diff --git a/tests/plugins/server/server_plugin_test.go b/tests/plugins/server/server_plugin_test.go index d63b0ccd..f600832a 100644 --- a/tests/plugins/server/server_plugin_test.go +++ b/tests/plugins/server/server_plugin_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/logger" "github.com/spiral/roadrunner/v2/plugins/server" diff --git a/tests/plugins/static/configs/.rr-http-static-disabled.yaml b/tests/plugins/static/configs/.rr-http-static-disabled.yaml index e31baffc..9f04b8a9 100644 --- a/tests/plugins/static/configs/.rr-http-static-disabled.yaml +++ b/tests/plugins/static/configs/.rr-http-static-disabled.yaml @@ -11,7 +11,7 @@ http: debug: true address: 127.0.0.1:21234 max_request_size: 1024 - middleware: [ "gzip", "static" ] + middleware: [ "gzip" ] trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ] uploads: forbid: [ ".php", ".exe", ".bat" ] @@ -19,10 +19,9 @@ http: dir: "abc" #not exists forbid: [ ".php", ".htaccess" ] request: - "Example-Request-Header": "Value" - # Automatically add headers to every response. + Example-Request-Header: "Value" response: - "X-Powered-By": "RoadRunner" + X-Powered-By: "RoadRunner" pool: num_workers: 2 max_jobs: 0 diff --git a/tests/plugins/static/configs/.rr-http-static-files-disable.yaml b/tests/plugins/static/configs/.rr-http-static-files-disable.yaml index deb408db..3d4d50b9 100644 --- a/tests/plugins/static/configs/.rr-http-static-files-disable.yaml +++ b/tests/plugins/static/configs/.rr-http-static-files-disable.yaml @@ -11,7 +11,7 @@ http: debug: true address: 127.0.0.1:45877 max_request_size: 1024 - middleware: [ "gzip", "static" ] + middleware: [ "gzip" ] trusted_subnets: [ "10.0.0.0/8", "127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "::1/128", "fc00::/7", "fe80::/10" ] uploads: forbid: [ ".php", ".exe", ".bat" ] @@ -19,10 +19,10 @@ http: dir: "../../../tests" forbid: [ ".php" ] request: - "Example-Request-Header": "Value" + Example-Request-Header: "Value" # Automatically add headers to every response. response: - "X-Powered-By": "RoadRunner" + X-Powered-By: "RoadRunner" pool: num_workers: 2 max_jobs: 0 diff --git a/tests/plugins/static/static_plugin_test.go b/tests/plugins/static/static_plugin_test.go index 49721e44..d43ef765 100644 --- a/tests/plugins/static/static_plugin_test.go +++ b/tests/plugins/static/static_plugin_test.go @@ -13,7 +13,7 @@ import ( "time" "github.com/golang/mock/gomock" - "github.com/spiral/endure" + endure "github.com/spiral/endure/pkg/container" "github.com/spiral/roadrunner/v2/plugins/config" "github.com/spiral/roadrunner/v2/plugins/gzip" httpPlugin "github.com/spiral/roadrunner/v2/plugins/http" @@ -209,8 +209,9 @@ func TestStaticDisabled(t *testing.T) { func staticDisabled(t *testing.T) { _, r, err := get("http://localhost:21234/sample.txt") //nolint:bodyclose - assert.Error(t, err) - assert.Nil(t, r) + assert.NoError(t, err) + assert.NotNil(t, r) + assert.Empty(t, r.Header.Get("X-Powered-By")) } func TestStaticFilesDisabled(t *testing.T) { |