diff options
author | Valery Piashchynski <[email protected]> | 2021-01-19 13:48:43 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-19 13:48:43 +0300 |
commit | 9bb05ec11065e765d14701f3f0c6aef19640dff7 (patch) | |
tree | 10e88d11ac3571c701d06e3671e6e2b538d879ed | |
parent | a9a206b31e272e0508fff496e9641c4db291ddb7 (diff) |
Uniform debug message from the http hanlder
Update tests
Signed-off-by: Valery Piashchynski <[email protected]>
-rwxr-xr-x | Makefile | 2 | ||||
-rw-r--r-- | cmd/cli/workers.go | 7 | ||||
-rw-r--r-- | plugins/http/plugin.go | 8 | ||||
-rw-r--r-- | tests/plugins/http/configs/.rr-resetter.yaml | 2 | ||||
-rw-r--r-- | tests/plugins/http/http_plugin_test.go | 2 | ||||
-rw-r--r-- | tests/plugins/static/static_plugin_test.go | 2 |
6 files changed, 13 insertions, 10 deletions
@@ -24,7 +24,6 @@ uninstall: ## Uninstall locally installed RR rm -f /usr/local/bin/rr test_coverage: - go clean -testcache docker-compose -f tests/docker-compose.yaml up -d rm -rf coverage mkdir coverage @@ -58,7 +57,6 @@ test_coverage: docker-compose -f tests/docker-compose.yaml down test: ## Run application tests - go clean -testcache docker-compose -f tests/docker-compose.yaml up -d go test -v -race -cover -tags=debug -covermode=atomic ./utils go test -v -race -cover -tags=debug -covermode=atomic ./pkg/pipe diff --git a/cmd/cli/workers.go b/cmd/cli/workers.go index 03639aa4..47dd2a85 100644 --- a/cmd/cli/workers.go +++ b/cmd/cli/workers.go @@ -17,9 +17,8 @@ import ( "github.com/spiral/roadrunner/v2/tools" ) -var ( - interactive bool -) +// use interactive mode +var interactive bool const InformerList string = "informer.List" const InformerWorkers string = "informer.Workers" @@ -42,7 +41,7 @@ func init() { root.AddCommand(workersCommand) } -func workersHandler(cmd *cobra.Command, args []string) error { +func workersHandler(_ *cobra.Command, args []string) error { const op = errors.Op("workers cobra handler") // get RPC client client, err := RPCClient() diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go index 222bf852..559205a3 100644 --- a/plugins/http/plugin.go +++ b/plugins/http/plugin.go @@ -115,7 +115,13 @@ func (s *Plugin) Init(cfg config.Configurer, log logger.Logger, server server.Se func (s *Plugin) logCallback(event interface{}) { if ev, ok := event.(ResponseEvent); ok { - s.log.Debug("http handler response received", "elapsed", ev.Elapsed().String(), "remote address", ev.Request.RemoteAddr) + s.log.Debug("", + "remote", ev.Request.RemoteAddr, + "ts", ev.Elapsed().String(), + "resp.status", ev.Response.Status, + "method", ev.Request.Method, + "uri", ev.Request.URI, + ) } } diff --git a/tests/plugins/http/configs/.rr-resetter.yaml b/tests/plugins/http/configs/.rr-resetter.yaml index 88c54858..5f5203d2 100644 --- a/tests/plugins/http/configs/.rr-resetter.yaml +++ b/tests/plugins/http/configs/.rr-resetter.yaml @@ -26,5 +26,5 @@ http: destroy_timeout: 60s logs: mode: development - level: error + level: debug diff --git a/tests/plugins/http/http_plugin_test.go b/tests/plugins/http/http_plugin_test.go index 88857df5..54e26480 100644 --- a/tests/plugins/http/http_plugin_test.go +++ b/tests/plugins/http/http_plugin_test.go @@ -963,7 +963,7 @@ logs: mockLogger.EXPECT().Info("worker destructed", "pid", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Info("worker constructed", "pid", gomock.Any()).MinTimes(1) - mockLogger.EXPECT().Debug("http handler response received", "elapsed", gomock.Any(), "remote address", "127.0.0.1").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().Info("WORLD", "pid", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Debug("worker event received", "event", events.EventWorkerLog, "worker state", gomock.Any()).MinTimes(1) mockLogger.EXPECT().Info(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 74daaa16..a411193d 100644 --- a/tests/plugins/static/static_plugin_test.go +++ b/tests/plugins/static/static_plugin_test.go @@ -304,7 +304,7 @@ func TestStaticFilesForbid(t *testing.T) { mockLogger := mocks.NewMockLogger(controller) mockLogger.EXPECT().Info("worker constructed", "pid", gomock.Any()).AnyTimes() - mockLogger.EXPECT().Debug("http handler response received", "elapsed", gomock.Any(), "remote address", "127.0.0.1").AnyTimes() + mockLogger.EXPECT().Debug("", "remote", gomock.Any(), "ts", gomock.Any(), "resp.status", gomock.Any(), "method", gomock.Any(), "uri", gomock.Any()).AnyTimes() mockLogger.EXPECT().Error("file open error", "error", gomock.Any()).AnyTimes() mockLogger.EXPECT().Info(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes() // placeholder for the workerlogerror |