Skip to content

Commit

Permalink
feat: Adding run groups support (#8)
Browse files Browse the repository at this point in the history
* feat: Adding run groups support

* feat: Adding metadata support

* feat: Adding metadata support

* PR comments
  • Loading branch information
xoscar authored Apr 3, 2024
1 parent 0360da7 commit ecf11ad
Show file tree
Hide file tree
Showing 126 changed files with 625 additions and 31,444 deletions.
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# xk6-tracetest

This extension adds tracetest support to [k6](https://github.com/grafana/k6)!
This extension adds Tracetest support to [k6](https://github.com/grafana/k6)!

That means that if you're testing an instrumented system, you can use this extension to trigger test runs.

Expand Down Expand Up @@ -29,22 +29,36 @@ $ go install go.k6.io/xk6/cmd/xk6@latest
$ xk6 build --with github.com/kubeshop/xk6-tracetest@latest
```

## Available Variables
3. Run a script:

```bash
$ ./k6 run examples/list-pokemons.js --env XK6_TRACETEST_API_TOKEN=<your token> -o xk6-tracetest

```
## Example

To run a full example take a look at the fully flesh demo we have for you in the Tracetest main mono repo: [examples/tracetest-k6](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-k6)

## Using the binary with Tracetest Core

Moving forward the latest updates will be only available from the tracetest App, if you want to keep using it with the OpenSource version make sure to build it with the version supporting it.

1. Build the binary:

```bash
$ xk6 build --with github.com/kubeshop/[email protected] # OSS supported version
```

### Available Variables

If you want to configure the tracetest k6 binary you can do it by using any of the following environment variables

- **XK6_TRACETEST_SERVER_URL:** Updates the tracetest server url for API interactions (can be overwritten by the script config)
- **XK6_TRACETEST_SERVER_PATH:** Updates the tracetest server path for API interactions (can be overwritten by the script config)
- **XK6_TRACETEST_SERVER_PATH:** Updates the tracetest server token that will be used to authenticate with the server (can be overwritten by the script config)
- **XK6_TRACETEST_TOKEN:** Updates the tracetest server token that will be used to authenticate with the server (can be overwritten by the script config)

You can also set a default tracetest endpoint when running the k6 binary by using the following option:

`./k6 run examples/test-from-id.js -o xk6-tracetest=<server-url>`

## Example

To run a full example take a look at the fully flesh demo we have for you in the Tracetest main mono repo: [examples/tracetest-k6](https://github.com/kubeshop/tracetest/tree/main/examples/tracetest-k6)
`./k6 run examples/list-pokemons.js -o xk6-tracetest=<server-url>`

## Running on https://app.tracetest.io

`./k6 run examples/test-from-id.js --env XK6_TRACETEST_API_TOKEN=<your token> -o xk6-tracetest=https://api.tracetest.io`
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ export const options = {
};

const http = new Http();
const testId = "c80sJ_4SR";
const tracetest = Tracetest();
tracetest.updateFromConfig({
api_token: "your-api-token",
});

export default function () {
const url = "http://localhost:8081/pokemon?take=5";
Expand All @@ -20,12 +16,9 @@ export default function () {
tracetest.runTest(
response.trace_id,
{
test_id: testId,
variable_name: "TRACE_ID",
should_wait: true,
},
{
id: "123",
url,
method: "GET",
}
Expand Down
41 changes: 0 additions & 41 deletions examples/test-from-id-queue.js

This file was deleted.

61 changes: 0 additions & 61 deletions examples/test-from-id.js

This file was deleted.

34 changes: 20 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
module github.com/kubeshop/xk6-tracetest

go 1.19
go 1.21

toolchain go1.21.6

require (
github.com/davecgh/go-spew v1.1.1
github.com/dop251/goja v0.0.0-20230531210528-d7324b2d74f7
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/kubeshop/tracetest v0.16.2-rc.1
github.com/sirupsen/logrus v1.9.0
go.k6.io/k6 v0.45.1
go.opentelemetry.io/contrib/propagators/aws v1.12.0
go.opentelemetry.io/contrib/propagators/b3 v1.12.0
go.opentelemetry.io/contrib/propagators/b3 v1.17.0
go.opentelemetry.io/contrib/propagators/jaeger v1.12.0
go.opentelemetry.io/contrib/propagators/ot v1.12.0
go.opentelemetry.io/otel v1.11.2
go.opentelemetry.io/otel/trace v1.11.2
go.opentelemetry.io/otel v1.19.0
go.opentelemetry.io/otel/trace v1.19.0
)

require (
Expand All @@ -23,12 +27,13 @@ require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/dlclark/regexp2 v1.9.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible // indirect
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/klauspost/compress v1.17.3 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
Expand All @@ -37,17 +42,18 @@ require (
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.20.2 // indirect
github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/teris-io/shortid v0.0.0-20220617161101-71ec9f2aa569 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
go.opentelemetry.io/otel/sdk v1.11.2 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
gopkg.in/guregu/null.v3 v3.3.0 // indirect
)
Loading

0 comments on commit ecf11ad

Please sign in to comment.