summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/plugins/checker/configs/.rr-checker-init.yaml3
-rw-r--r--tests/plugins/checker/plugin_test.go10
-rw-r--r--tests/plugins/gzip/plugin_test.go4
-rw-r--r--tests/plugins/http/http_plugin_test.go2
-rw-r--r--tests/plugins/static/static_plugin_test.go71
5 files changed, 18 insertions, 72 deletions
diff --git a/tests/plugins/checker/configs/.rr-checker-init.yaml b/tests/plugins/checker/configs/.rr-checker-init.yaml
index 11804a21..dca86efe 100755
--- a/tests/plugins/checker/configs/.rr-checker-init.yaml
+++ b/tests/plugins/checker/configs/.rr-checker-init.yaml
@@ -5,13 +5,12 @@ server:
command: "php ../../http/client.php echo pipes"
user: ""
group: ""
- env:
- "RR_HTTP": "true"
relay: "pipes"
relay_timeout: "20s"
status:
address: "127.0.0.1:34333"
+
logs:
mode: development
level: error
diff --git a/tests/plugins/checker/plugin_test.go b/tests/plugins/checker/plugin_test.go
index 5e391158..569e73a1 100644
--- a/tests/plugins/checker/plugin_test.go
+++ b/tests/plugins/checker/plugin_test.go
@@ -14,12 +14,12 @@ import (
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"
httpPlugin "github.com/spiral/roadrunner/v2/plugins/http"
"github.com/spiral/roadrunner/v2/plugins/logger"
rpcPlugin "github.com/spiral/roadrunner/v2/plugins/rpc"
"github.com/spiral/roadrunner/v2/plugins/server"
+ "github.com/spiral/roadrunner/v2/plugins/status"
"github.com/stretchr/testify/assert"
)
@@ -37,7 +37,7 @@ func TestStatusHttp(t *testing.T) {
&logger.ZapLogger{},
&server.Plugin{},
&httpPlugin.Plugin{},
- &checker.Plugin{},
+ &status.Plugin{},
)
assert.NoError(t, err)
@@ -95,7 +95,7 @@ const resp = `Service: http: Status: 200
Service: rpc not found`
func checkHTTPStatus(t *testing.T) {
- req, err := http.NewRequest("GET", "http://127.0.0.1:34333/v1/health?plugin=http&plugin=rpc", nil)
+ req, err := http.NewRequest("GET", "http://127.0.0.1:34333/health?plugin=http&plugin=rpc", nil)
assert.NoError(t, err)
r, err := http.DefaultClient.Do(req)
@@ -124,7 +124,7 @@ func TestStatusRPC(t *testing.T) {
&logger.ZapLogger{},
&server.Plugin{},
&httpPlugin.Plugin{},
- &checker.Plugin{},
+ &status.Plugin{},
)
assert.NoError(t, err)
@@ -182,7 +182,7 @@ func checkRPCStatus(t *testing.T) {
assert.NoError(t, err)
client := rpc.NewClientWithCodec(goridgeRpc.NewClientCodec(conn))
- st := &checker.Status{}
+ st := &status.Status{}
err = client.Call("status.Status", "http", &st)
assert.NoError(t, err)
diff --git a/tests/plugins/gzip/plugin_test.go b/tests/plugins/gzip/plugin_test.go
index 3e3db0f8..9a9c760b 100644
--- a/tests/plugins/gzip/plugin_test.go
+++ b/tests/plugins/gzip/plugin_test.go
@@ -34,7 +34,7 @@ func TestGzipPlugin(t *testing.T) {
&logger.ZapLogger{},
&server.Plugin{},
&httpPlugin.Plugin{},
- &gzip.Gzip{},
+ &gzip.Plugin{},
)
assert.NoError(t, err)
@@ -126,7 +126,7 @@ func TestMiddlewareNotExist(t *testing.T) {
mockLogger,
&server.Plugin{},
&httpPlugin.Plugin{},
- &gzip.Gzip{},
+ &gzip.Plugin{},
)
assert.NoError(t, err)
diff --git a/tests/plugins/http/http_plugin_test.go b/tests/plugins/http/http_plugin_test.go
index bca8a2f1..cfc5bc01 100644
--- a/tests/plugins/http/http_plugin_test.go
+++ b/tests/plugins/http/http_plugin_test.go
@@ -1028,7 +1028,7 @@ logs:
mockLogger.EXPECT().Debug(gomock.Any()).AnyTimes()
mockLogger.EXPECT().Debug("worker destructed", "pid", gomock.Any()).MinTimes(1)
mockLogger.EXPECT().Debug("worker constructed", "pid", gomock.Any()).MinTimes(1)
- mockLogger.EXPECT().Debug("", "remote", gomock.Any(), "ts", gomock.Any(), "resp.status", gomock.Any(), "method", gomock.Any(), "uri", gomock.Any()).MinTimes(1)
+ mockLogger.EXPECT().Debug("201 GET http://localhost:34999/?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1)
mockLogger.EXPECT().Debug("WORLD", "pid", gomock.Any()).MinTimes(1)
mockLogger.EXPECT().Debug("worker event received", "event", events.EventWorkerLog, "worker state", gomock.Any()).MinTimes(1)
mockLogger.EXPECT().Error(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() // placeholder for the workerlogerror
diff --git a/tests/plugins/static/static_plugin_test.go b/tests/plugins/static/static_plugin_test.go
index d43ef765..38562537 100644
--- a/tests/plugins/static/static_plugin_test.go
+++ b/tests/plugins/static/static_plugin_test.go
@@ -38,7 +38,7 @@ func TestStaticPlugin(t *testing.T) {
&logger.ZapLogger{},
&server.Plugin{},
&httpPlugin.Plugin{},
- &gzip.Gzip{},
+ &gzip.Plugin{},
&static.Plugin{},
)
assert.NoError(t, err)
@@ -138,7 +138,7 @@ func serveStaticSample(t *testing.T) {
_ = r.Body.Close()
}
-func TestStaticDisabled(t *testing.T) {
+func TestStaticDisabled_Error(t *testing.T) {
cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.ErrorLevel))
assert.NoError(t, err)
@@ -152,66 +152,11 @@ func TestStaticDisabled(t *testing.T) {
&logger.ZapLogger{},
&server.Plugin{},
&httpPlugin.Plugin{},
- &gzip.Gzip{},
+ &gzip.Plugin{},
&static.Plugin{},
)
assert.NoError(t, err)
-
- err = cont.Init()
- if err != nil {
- t.Fatal(err)
- }
-
- ch, err := cont.Serve()
- assert.NoError(t, err)
-
- sig := make(chan os.Signal, 1)
- signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
-
- wg := &sync.WaitGroup{}
- wg.Add(1)
-
- stopCh := make(chan struct{}, 1)
-
- go func() {
- defer wg.Done()
- for {
- select {
- case e := <-ch:
- assert.Fail(t, "error", e.Error.Error())
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- case <-sig:
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- return
- case <-stopCh:
- // timeout
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- return
- }
- }
- }()
-
- time.Sleep(time.Second)
- t.Run("StaticDisabled", staticDisabled)
-
- stopCh <- struct{}{}
- wg.Wait()
-}
-
-func staticDisabled(t *testing.T) {
- _, r, err := get("http://localhost:21234/sample.txt") //nolint:bodyclose
- assert.NoError(t, err)
- assert.NotNil(t, r)
- assert.Empty(t, r.Header.Get("X-Powered-By"))
+ assert.Error(t, cont.Init())
}
func TestStaticFilesDisabled(t *testing.T) {
@@ -228,7 +173,7 @@ func TestStaticFilesDisabled(t *testing.T) {
&logger.ZapLogger{},
&server.Plugin{},
&httpPlugin.Plugin{},
- &gzip.Gzip{},
+ &gzip.Plugin{},
&static.Plugin{},
)
assert.NoError(t, err)
@@ -306,7 +251,9 @@ func TestStaticFilesForbid(t *testing.T) {
mockLogger.EXPECT().Debug("worker destructed", "pid", gomock.Any()).AnyTimes()
mockLogger.EXPECT().Debug("worker constructed", "pid", gomock.Any()).AnyTimes()
- mockLogger.EXPECT().Debug("", "remote", gomock.Any(), "ts", gomock.Any(), "resp.status", gomock.Any(), "method", gomock.Any(), "uri", gomock.Any()).AnyTimes()
+ mockLogger.EXPECT().Debug("201 GET http://localhost:34653/http?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1)
+ mockLogger.EXPECT().Debug("201 GET http://localhost:34653/client.XXX?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1)
+ mockLogger.EXPECT().Debug("201 GET http://localhost:34653/client.php?hello=world", "remote", "127.0.0.1", "elapsed", gomock.Any()).MinTimes(1)
mockLogger.EXPECT().Error("file open error", "error", gomock.Any()).AnyTimes()
mockLogger.EXPECT().Error(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() // placeholder for the workerlogerror
@@ -315,7 +262,7 @@ func TestStaticFilesForbid(t *testing.T) {
mockLogger,
&server.Plugin{},
&httpPlugin.Plugin{},
- &gzip.Gzip{},
+ &gzip.Plugin{},
&static.Plugin{},
)
assert.NoError(t, err)