Skip to content

Commit fb37deb

Browse files
authored
Merge pull request #122 from grafana/feature/output-name-constant
Rename output name to web-dashboard
2 parents 8b103a0 + de4a4a3 commit fb37deb

File tree

6 files changed

+45
-37
lines changed

6 files changed

+45
-37
lines changed

README.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ By using the **xk6-dashboard** output extension you can access metrics from [k6]
1818

1919
The test run report can be exported to a responsive self-contained HTML file, which can be displayed even without an Internet connection.
2020

21+
>[!Warning]
22+
> You are currently looking at the documentation of the next version on the master branch, which does not correspond in all respects to the operation of the last release. Select the tag corresponding to the release for more precise documentation.
23+
>
24+
> Major differences:
25+
> - The output name has changed, in previous versions it was `dashboard`, from the next version it will be `web-dashboard`. The documentation already reflects this.
26+
> - Screenshots may differ.
27+
2128
**Screenshots**
2229

2330
*Overview*
@@ -92,7 +99,7 @@ Then:
9299
Without parameters the dashboard will be accessible on port `5665` with any web browser: http://127.0.0.1:5665
93100

94101
```plain
95-
$ ./k6 run --out dashboard script.js
102+
$ ./k6 run --out web-dashboard script.js
96103
97104
/\ |‾‾| /‾‾/ /‾‾/
98105
/\ / \ | |/ / / /
@@ -102,10 +109,10 @@ $ ./k6 run --out dashboard script.js
102109
103110
execution: local
104111
script: script.js
105-
output: dashboard (:5665) http://127.0.0.1:5665
112+
output: web-dashboard http://127.0.0.1:5665
106113
```
107114

108-
> Using `--out dashboard=open` will automatically open a new browser window.
115+
> Using `--out web-dashboard=open` will automatically open a new browser window.
109116
110117
## Exit
111118

@@ -118,7 +125,7 @@ In certain environments, it is not allowed that the k6 process does not exit aft
118125
The output extension accepts parameters in a standard query string format:
119126

120127
```
121-
k6 run --out 'dashboard=param1=value1&param2=value2&param3=value3'
128+
k6 run --out 'web-dashboard=param1=value1&param2=value2&param3=value3'
122129
```
123130

124131
> Note the apostrophes (`'`) around the `--out` parameter! You should use it to escape `&` characters from the shell (or use backslash before `&`).
@@ -175,17 +182,17 @@ The dashboard will accessible on port `5665` with any web browser: http://127.0.
175182
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.
176183

177184
```plain
178-
k6 run --out dashboard=export=test-report.html script.js
185+
k6 run --out web-dashboard=export=test-report.html script.js
179186
```
180187

181188
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.
182189

183-
By using the `--export` switch of the `dashboard replay` command, the report can also be generated afterwards from the previously saved JSON format result (`--out json=test-result.json`).
190+
By using the `--export` switch of the `web-dashboard replay` command, the report can also be generated afterwards from the previously saved JSON format result (`--out json=test-result.json`).
184191

185192
The report can also be viewed and downloaded from the dashboard UI using the buttons on the "Report" tab.
186193

187194
```plain
188-
k6 dashboard replay --export test-report.html test-result.json
195+
k6 web-dashboard replay --export test-report.html test-result.json
189196
```
190197

191198
*Example HTML report*
@@ -210,15 +217,15 @@ Two kind of events will be emitted:
210217

211218
## Command Line
212219

213-
The xk6-dashboard extension adds a `dashboard` command to the k6 command line:
220+
The xk6-dashboard extension adds a `web-dashboard` command to the k6 command line:
214221

215222
```sh
216-
$ ./k6 dashboard --help
223+
$ ./k6 web-dashboard --help
217224

218225
xk6-dashboard commands
219226

220227
Usage:
221-
k6 dashboard [command]
228+
k6 web-dashboard [command]
222229

223230
Available Commands:
224231
aggregate convert saved json output to recorded dashboard events
@@ -228,20 +235,20 @@ Available Commands:
228235
Flags:
229236
-h, --help help for dashboard
230237

231-
Use "k6 dashboard [command] --help" for more information about a command.
238+
Use "k6 web-dashboard [command] --help" for more information about a command.
232239
```
233240

234241
At the moment, the `dashboard` command has three subcommand, `replay` (which can be used to play back dashboard events previously saved with `record` parameter), `aggregate` (which can be used to convert test run results previously saved in JSON format from k6 to dashboard events format NDJSON) and `report` (which can be used to generate report from dashboard events previously saved with `record` parameter).
235242

236243

237244
```sh
238-
$ ./k6 dashboard replay --help
245+
$ ./k6 web-dashboard replay --help
239246

240247
The replay command load the recorded dashboard events (NDJSON format) and replay it for the dashboard UI.
241248
The compressed file will be automatically decompressed if the file extension is .gz
242249

243250
Usage:
244-
k6 dashboard replay file [flags]
251+
k6 web-dashboard replay file [flags]
245252

246253
Flags:
247254
--host string Hostname or IP address for HTTP endpoint (default: '', empty, listen on all interfaces)
@@ -252,13 +259,13 @@ Flags:
252259
```
253260
254261
```
255-
$ ./k6 dashboard aggregate --help
262+
$ ./k6 web-dashboard aggregate --help
256263

257264
The aggregate command converts the file saved by json output to dashboard format events file.
258265
The files will be automatically compressed/decompressed if the file extension is .gz
259266

260267
Usage:
261-
k6 dashboard aggregate input-file output-file [flags]
268+
k6 web-dashboard aggregate input-file output-file [flags]
262269

263270
Flags:
264271
--period 1m Event emitting frequency, example: 1m (default 10s)
@@ -267,13 +274,13 @@ Flags:
267274
```
268275
269276
```
270-
$ ./k6 dashboard report --help
277+
$ ./k6 web-dashboard report --help
271278

272279
The report command loads recorded dashboard events (NDJSON format) and creates a report.
273280
The compressed events file will be automatically decompressed if the file extension is .gz
274281

275282
Usage:
276-
k6 dashboard report events-file report-file [flags]
283+
k6 web-dashboard report events-file report-file [flags]
277284

278285
Flags:
279286
--open Open browser window with generated report
@@ -284,22 +291,22 @@ To visualize the result of a previous test run (using events file):
284291
285292
```
286293
./k6 run --out dashboard=record=test_result.ndjson script.js
287-
./k6 dashboard replay test_result.ndjson
294+
./k6 web-dashboard replay test_result.ndjson
288295
```
289296
290297
To visualize the result of a previous test run (using json output):
291298
292299
```sh
293300
./k6 run --out json=test_result.json script.js
294-
./k6 dashboard aggregate test_result.json test_result.ndjson
295-
./k6 dashboard replay test_result.ndjson
301+
./k6 web-dashboard aggregate test_result.json test_result.ndjson
302+
./k6 web-dashboard replay test_result.ndjson
296303
```
297304
298305
To generate report from previous test run (using events file):
299306
300307
```
301-
./k6 run --out dashboard=record=test_result.ndjson script.js
302-
./k6 dashboard report test_result.ndjson test_result_report.html
308+
./k6 run --out web-dashboard=record=test_result.ndjson script.js
309+
./k6 web-dashboard report test_result.ndjson test_result_report.html
303310
```
304311
305312
### Docker
@@ -310,14 +317,14 @@ You can also use pre-built k6 image within a Docker container. In order to do th
310317
311318
```plain
312319
docker run -v $(pwd):/work -v /tmp:/tmp/work -it --rm ghcr.io/grafana/xk6-dashboard:latest run --out=json=/tmp/work/test_result.json.gz /work/script.js
313-
docker run -v /tmp:/tmp/work -p 5665:5665 -it --rm ghcr.io/grafana/xk6-dashboard:latest dashboard replay /tmp/work/test_result.json.gz
320+
docker run -v /tmp:/tmp/work -p 5665:5665 -it --rm ghcr.io/grafana/xk6-dashboard:latest web-dashboard replay /tmp/work/test_result.json.gz
314321
```
315322
316323
**Windows**
317324
318325
```plain
319326
docker run -v %cd%:/work -v %USERPROFILE%\AppData\Local\Temp:/tmp/work -it --rm ghcr.io/grafana/xk6-dashboard:latest run --out=json=/tmp/work/test_result.json.gz /work/script.js
320-
docker run -v %USERPROFILE%\AppData\Local\Temp:/tmp/work -p 5665:5665 -it --rm ghcr.io/grafana/xk6-dashboard:latest dashboard replay /tmp/work/test_result.json.gz
327+
docker run -v %USERPROFILE%\AppData\Local\Temp:/tmp/work -p 5665:5665 -it --rm ghcr.io/grafana/xk6-dashboard:latest web-dashboard replay /tmp/work/test_result.json.gz
321328
```
322329
323330
The dashboard will accessible on port `5665` with any web browser: http://127.0.0.1:5665

dashboard/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func NewCommand(gs *state.GlobalState) *cobra.Command {
3838
}
3939

4040
dashboardCmd := &cobra.Command{ //nolint:exhaustruct
41-
Use: "dashboard",
41+
Use: OutputName,
4242
Short: "xk6-dashboard commands",
4343
}
4444

dashboard/command_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func Test_buildRootCmd(t *testing.T) {
2525

2626
assert.NotNil(t, cmd)
2727

28-
rep, _, err := cmd.Find([]string{"dashboard", "replay"})
28+
rep, _, err := cmd.Find([]string{"web-dashboard", "replay"})
2929

3030
assert.NoError(t, err)
3131
assert.NotNil(t, rep)
@@ -49,7 +49,7 @@ func Test_buildRootCmd_reply(t *testing.T) {
4949

5050
assert.NotNil(t, cmd)
5151

52-
rep, _, err := cmd.Find([]string{"dashboard", "replay"})
52+
rep, _, err := cmd.Find([]string{"web-dashboard", "replay"})
5353

5454
assert.NoError(t, err)
5555

@@ -71,7 +71,7 @@ func Test_buildRootCmd_reply_error(t *testing.T) {
7171

7272
assert.NotNil(t, cmd)
7373

74-
rep, _, err := cmd.Find([]string{"dashboard", "replay"})
74+
rep, _, err := cmd.Find([]string{"web-dashboard", "replay"})
7575

7676
assert.NoError(t, err)
7777

@@ -93,7 +93,7 @@ func Test_buildRootCmd_report(t *testing.T) {
9393

9494
assert.NotNil(t, cmd)
9595

96-
rep, _, err := cmd.Find([]string{"dashboard", "report"})
96+
rep, _, err := cmd.Find([]string{"web-dashboard", "report"})
9797

9898
assert.NoError(t, err)
9999

dashboard/extension.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ type extension struct {
4646

4747
var _ output.Output = (*extension)(nil)
4848

49+
// OutputName defines the output name for dashnoard extension.
50+
const OutputName = "web-dashboard"
51+
4952
// New creates new dashboard extension instance.
5053
func New(params output.Params) (output.Output, error) {
5154
assets := newCustomizedAssets(new(process).fromParams(params))

magefiles/magefile.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func out(script string) string {
8484
report := filepath.Join(workdir, slug(script)+"-report.html")
8585
record := filepath.Join(workdir, slug(script)+"-record.ndjson.gz")
8686

87-
return "dashboard=export=" + report + "&record=" + record
87+
return "web-dashboard=export=" + report + "&record=" + record
8888
}
8989

9090
func jsonout(script string) string {
@@ -102,7 +102,7 @@ func Replay(script string) error {
102102

103103
return sh.Run(
104104
"xk6",
105-
"dashboard",
105+
"web-dashboard",
106106
"replay",
107107
record,
108108
)
@@ -120,9 +120,9 @@ func Testdata() error {
120120
"json="+gz,
121121
filepath.Join("scripts", "test.js"),
122122
"--out",
123-
"dashboard=port=-1&period=2s&record="+strings.ReplaceAll(out, ".json", ".ndjson"),
123+
"web-dashboard=port=-1&period=2s&record="+strings.ReplaceAll(out, ".json", ".ndjson"),
124124
"--out",
125-
"dashboard=port=-1&period=2s&record="+strings.ReplaceAll(gz, ".json", ".ndjson"),
125+
"web-dashboard=port=-1&period=2s&record="+strings.ReplaceAll(gz, ".json", ".ndjson"),
126126
)
127127
}
128128

register.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@ import (
1515
"go.k6.io/k6/output"
1616
)
1717

18-
const name = "dashboard"
19-
2018
func init() {
2119
gs := state.NewGlobalState(context.Background())
2220

23-
if len(gs.CmdArgs) > 1 && gs.CmdArgs[1] == name {
21+
if len(gs.CmdArgs) > 1 && gs.CmdArgs[1] == dashboard.OutputName {
2422
execute(gs)
2523
}
2624

2725
register()
2826
}
2927

3028
func register() {
31-
output.RegisterExtension(name, dashboard.New)
29+
output.RegisterExtension(dashboard.OutputName, dashboard.New)
3230
}
3331

3432
func execute(gs *state.GlobalState) {

0 commit comments

Comments
 (0)