From 8e96b7bca6708551678f661843ab93d08d600561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Mon, 5 Feb 2024 11:17:42 +0100 Subject: [PATCH 1/2] fix: Using the name "dashboard" to avoid a name conflict with the built-in web-dashboard --- README.md | 8 ++++---- register.go | 4 +++- register_test.go | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b965f3c..13d3f83 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ For more build options and how to use xk6, check out the [xk6 documentation]([xk Without parameters the dashboard will be accessible on port `5665` with any web browser: http://127.0.0.1:5665 ```plain -$ ./k6 run --out web-dashboard script.js +$ ./k6 run --out dashboard script.js /\ |‾‾| /‾‾/ /‾‾/ /\ / \ | |/ / / / @@ -91,7 +91,7 @@ $ ./k6 run --out web-dashboard script.js execution: local script: script.js - output: web-dashboard http://127.0.0.1:5665 + output: dashboard http://127.0.0.1:5665 ``` The k6 process waits to exit as long as there is at least one open browser window for the dashboard extension. In this way, the report can be downloaded, for example, even after the test has been completed. @@ -103,7 +103,7 @@ In certain environments, it is not allowed that the k6 process does not exit aft The output extension accepts parameters in a standard query string format: ``` -k6 run --out 'web-dashboard=param1=value1¶m2=value2¶m3=value3' +k6 run --out 'dashboard=param1=value1¶m2=value2¶m3=value3' ``` > Note the apostrophes (`'`) around the `--out` parameter! You should use it to escape `&` characters from the shell (or use backslash before `&`). @@ -139,7 +139,7 @@ K6_WEB_DASHBOARD_TAG | Precomputed metric tag name(s) (default: "group"), The test run report can be exported to a responsive self-contained HTML file. For export, the file name must be specified in the `export` parameter. If the file name ends with `.gz`, the HTML report will automatically be gzip compressed. ```plain -k6 run --out web-dashboard=export=test-report.html script.js +k6 run --out dashboard=export=test-report.html script.js ``` The exported HTML report file does not contain external dependencies, so it can be displayed even without an Internet connection. Graphs can be zoomed by selecting a time interval. If necessary, the report can be printed or converted to PDF format. diff --git a/register.go b/register.go index 8767ffc..f95401f 100644 --- a/register.go +++ b/register.go @@ -12,6 +12,8 @@ import ( "go.k6.io/k6/output" ) +const outputName = "dashboard" + func init() { - output.RegisterExtension(dashboard.OutputName, dashboard.New) + output.RegisterExtension(outputName, dashboard.New) } diff --git a/register_test.go b/register_test.go index b04b06c..46d1845 100644 --- a/register_test.go +++ b/register_test.go @@ -18,6 +18,6 @@ func TestRegister(t *testing.T) { t.Parallel() assert.Panics(t, func() { - output.RegisterExtension(dashboard.OutputName, dashboard.New) + output.RegisterExtension(outputName, dashboard.New) }) // already registered } From 3d6b19cabf302032af7ba7ba093895b2768ecfec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Mon, 5 Feb 2024 14:22:56 +0100 Subject: [PATCH 2/2] output name changed back to dashboard --- magefiles/magefile.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/magefiles/magefile.go b/magefiles/magefile.go index c452cc8..92fdd12 100644 --- a/magefiles/magefile.go +++ b/magefiles/magefile.go @@ -93,7 +93,7 @@ func out(script string) string { report := filepath.Join(workdir, slug(script)+"-report.html") record := filepath.Join(workdir, slug(script)+"-record.ndjson.gz") - return "web-dashboard=export=" + report + "&record=" + record + return "dashboard=export=" + report + "&record=" + record } func jsonout(script string) string { @@ -128,9 +128,9 @@ func Testdata() error { "json="+gz, filepath.Join("scripts", "test.js"), "--out", - "web-dashboard=port=-1&period=2s&record="+strings.ReplaceAll(out, ".json", ".ndjson"), + "dashboard=port=-1&period=2s&record="+strings.ReplaceAll(out, ".json", ".ndjson"), "--out", - "web-dashboard=port=-1&period=2s&record="+strings.ReplaceAll(gz, ".json", ".ndjson"), + "dashboard=port=-1&period=2s&record="+strings.ReplaceAll(gz, ".json", ".ndjson"), ) }