Skip to content

Commit

Permalink
Merge pull request #15 from szkiba/feature/testing
Browse files Browse the repository at this point in the history
add some tests
  • Loading branch information
szkiba authored May 2, 2023
2 parents b646376 + b7999fa commit b05d8fb
Show file tree
Hide file tree
Showing 74 changed files with 1,687 additions and 1,367 deletions.
27 changes: 2 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
# MIT License
# SPDX-FileCopyrightText: 2023 Iván Szkiba
#
# Copyright (c) 2021 Iván Szkiba
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# SPDX-License-Identifier: MIT

name: Build
on:
Expand All @@ -39,11 +21,6 @@ jobs:
with:
fetch-depth: 0

- name: Lint Go Code
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1

- name: Build
id: build
uses: szkiba/xk6bundler@v0
Expand Down
27 changes: 2 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
# MIT License
# SPDX-FileCopyrightText: 2023 Iván Szkiba
#
# Copyright (c) 2021 Iván Szkiba
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# SPDX-License-Identifier: MIT

name: Release
on:
Expand All @@ -42,11 +24,6 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Lint Go Code
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1

- name: Build
id: build
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: 2023 Iván Szkiba
#
# SPDX-License-Identifier: MIT

name: Test
on:
push:
branches:
- master
tags:
- "v*"
pull_request:
jobs:
test:
strategy:
matrix:
platform:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{matrix.platform}}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x

- name: Checkout code
uses: actions/checkout@v3

- name: Lint
if: ${{ matrix.platform == 'ubuntu-latest' }}
uses: magefile/mage-action@v1
with:
version: latest
args: lint

- name: Test
uses: magefile/mage-action@v1
with:
version: latest
args: test

- name: Upload Coverage
if: ${{ matrix.platform == 'ubuntu-latest' }}
uses: codecov/codecov-action@v2

- name: Generate Go Report Card
if: ${{ matrix.platform == 'ubuntu-latest' }}
uses: creekorful/goreportcard-action@v1.0
18 changes: 7 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
# custom binary
# SPDX-FileCopyrightText: 2023 Iván Szkiba
#
# SPDX-License-Identifier: MIT

k6

# taskfile.io
coverage.txt

.task

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

bin
node_modules
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
23 changes: 3 additions & 20 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
# MIT License
# SPDX-FileCopyrightText: 2021 - 2023 Iván Szkiba
#
# Copyright (c) 2021 Iván Szkiba
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# SPDX-License-Identifier: MIT

linters:
presets:
Expand All @@ -31,6 +13,7 @@ linters:
enable:
- exportloopref
disable:
- testpackage
- nolintlint
- gochecknoglobals
- gochecknoinits
Expand Down
9 changes: 9 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

A [k6 extension](https://k6.io/docs/extensions/) that enables creating web based metrics dashboard for [k6](https://k6.io).

Using **xk6-dashboard** output extension you can access metrics from [k6](https://k6.io) process via [Server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events). All custom [k6](https://k6.io) metrics ([Counter](https://k6.io/docs/javascript-api/k6-metrics/counter/),[Gauge](https://k6.io/docs/javascript-api/k6-metrics/gauge/),[Rate](https://k6.io/docs/javascript-api/k6-metrics/rate/),[Trend](https://k6.io/docs/javascript-api/k6-metrics/trend/)) and [build-in metrics](https://k6.io/docs/using-k6/metrics/#built-in-metrics) will be accessible in event stream.
By using **xk6-dashboard** output extension you can access metrics from [k6](https://k6.io) process via [Server-sent events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events). All custom [k6](https://k6.io) metrics ([Counter](https://k6.io/docs/javascript-api/k6-metrics/counter/),[Gauge](https://k6.io/docs/javascript-api/k6-metrics/gauge/),[Rate](https://k6.io/docs/javascript-api/k6-metrics/rate/),[Trend](https://k6.io/docs/javascript-api/k6-metrics/trend/)) and [build-in metrics](https://k6.io/docs/using-k6/metrics/#built-in-metrics) will be accessible in the event stream.

**Screenshots**

![k6 dashboard snapshot](screenshots/../screenshot/k6-dashboard-snapshot.png)
![k6 dashboard snapshot](screenshot/k6-dashboard-snapshot.png)

![k6 dashboard cumulative](screenshots/../screenshot/k6-dashboard-cumulative.png)
![k6 dashboard cumulative](screenshot/k6-dashboard-cumulative.png)


**Table of Contents**
Expand Down Expand Up @@ -45,7 +45,7 @@ Then:

## Usage

Without parameters the dashboard will accessible on port `5665` with any web browser: http://127.0.0.1:5665
Without parameters the dashboard will be accessible on port `5665` with any web browser: http://127.0.0.1:5665

```plain
$ ./k6 run --out dashboard script.js
Expand All @@ -61,9 +61,11 @@ $ ./k6 run --out dashboard script.js
output: dashboard (:5665) http://127.0.0.1:5665
```

> Using `--out dashboard=open` will automatically open a new browser window.
## Parameters

The output extension accept parameters in a standard query string format:
The output extension accepts parameters in a standard query string format:

```
k6 run --out 'dashboard=param1=value1&param2=value2&param3=value3'
Expand All @@ -78,10 +80,11 @@ parameter | description
host | Hostname or IP address for HTTP endpoint (default: "", empty, listen on all interfaces)
port | TCP port for HTTP endpoint (default: `5665`), example: `8080`
period | Event emitting frequency (default: `10s`), example: `1m`
open | Set to `true` (or empty) for opening browser window automatically

## Docker

You can also use pre-built k6 image within a Docker container. To do that, you'll need to execute something more-or-less like the following:
You can also use pre-built k6 image within a Docker container. In order to do that, you will need to execute something like the following:

**Linux**

Expand All @@ -103,9 +106,9 @@ The `/events` endpoint (default: http://127.0.0.1:5665/events) is a standard SSE

Events will be emitted periodically, based on `period` parameter (default: `10s`). The event's `data` is a JSON object, with metric names as property names and metric values as property values. The format is similar to [List Metrics](https://k6.io/docs/misc/k6-rest-api/#list-metrics) response format from [k6 REST API](https://k6.io/docs/misc/k6-rest-api/).

Two kind of events emitted:
Two kind of events will be emitted:
- `snapshot` contains metric values from last period
- `cumulative` contains cumulative metric values from the test start
- `cumulative` contains cumulative metric values from the test starting point

**Example events**

Expand Down
83 changes: 0 additions & 83 deletions Taskfile.yml

This file was deleted.

39 changes: 0 additions & 39 deletions assets/ui/dist/index.html

This file was deleted.

Loading

0 comments on commit b05d8fb

Please sign in to comment.