Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k6-core compatibility: Fix Group and Tag usage #1357

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/mstoykov/k6-taskqueue-lib v0.1.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
go.k6.io/k6 v0.51.0
go.k6.io/k6 v0.51.1-0.20240529085517-bdbe5b52d1f5
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
golang.org/x/net v0.23.0
Expand All @@ -29,6 +29,7 @@ require (
github.com/chromedp/sysutil v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.9.0 // indirect
github.com/evanw/esbuild v0.21.2 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ github.com/dop251/goja v0.0.0-20240220182346-e401ed450204 h1:O7I1iuzEA7SG+dK8ocO
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4=
github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y=
github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM=
github.com/evanw/esbuild v0.21.2 h1:CLplcGi794CfHLVmUbvVfTMKkykm+nyIHU8SU60KUTA=
github.com/evanw/esbuild v0.21.2/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down Expand Up @@ -137,8 +139,8 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.k6.io/k6 v0.51.0 h1:TdMpPNwYuvtmBF1APoKFHuMnNzdIMI/XLaPklSjrIUw=
go.k6.io/k6 v0.51.0/go.mod h1:72d4MKuvKiRnkbPBGOk/gbz1aAcbKycX+GIlU7IOpuA=
go.k6.io/k6 v0.51.1-0.20240529085517-bdbe5b52d1f5 h1:cJBN6CjQVgxjmKduTN3VmEbZxruGnLO6Ip79FAf84Gw=
go.k6.io/k6 v0.51.1-0.20240529085517-bdbe5b52d1f5/go.mod h1:YvtuIbREVgWl7DuAT0IZqaiw4SxxRqLOXdlgkXkR0rU=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8=
Expand Down
17 changes: 7 additions & 10 deletions k6ext/k6test/vu.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
k6common "go.k6.io/k6/js/common"
k6eventloop "go.k6.io/k6/js/eventloop"
k6modulestest "go.k6.io/k6/js/modulestest"
"go.k6.io/k6/lib"
k6lib "go.k6.io/k6/lib"
k6executor "go.k6.io/k6/lib/executor"
k6testutils "go.k6.io/k6/lib/testutils"
Expand Down Expand Up @@ -158,18 +159,13 @@ func NewVU(tb testing.TB, opts ...any) *VU {

logger := k6testutils.NewLogger(tb)

root, err := k6lib.NewGroup("", nil)
require.NoError(tb, err)

testRT := k6modulestest.NewRuntime(tb)
testRT.VU.InitEnvField.LookupEnv = lookupFunc
testRT.VU.EventsField = k6common.Events{
Global: k6event.NewEventSystem(100, logger),
Local: k6event.NewEventSystem(100, logger),
}

tags := testRT.VU.InitEnvField.Registry.RootTagSet()

state := &k6lib.State{
Options: k6lib.Options{
MaxRedirects: null.IntFrom(10),
Expand All @@ -191,11 +187,12 @@ func NewVU(tb testing.TB, opts ...any) *VU {
},
},
},
Logger: logger,
Group: root,
BufferPool: k6lib.NewBufferPool(),
Samples: samples,
Tags: k6lib.NewVUStateTags(tags.With("group", root.Path)),
Logger: logger,
BufferPool: k6lib.NewBufferPool(),
Samples: samples,
Tags: k6lib.NewVUStateTags(
testRT.VU.InitEnvField.Registry.RootTagSet().With("group", lib.RootGroupPath),
),
BuiltinMetrics: k6metrics.RegisterBuiltinMetrics(k6metrics.NewRegistry()),
TracerProvider: tracerProvider,
}
Expand Down
Loading