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

Add test run id to RootModule #1232

Merged
merged 3 commits into from
Mar 4, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions browser/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type (
initOnce *sync.Once
tracesMetadata map[string]string
filePersister filePersister
testRunID string
}

// JSModule exposes the properties available to the JS script.
Expand Down Expand Up @@ -91,6 +92,7 @@ func (m *RootModule) NewModuleInstance(vu k6modules.VU) k6modules.Instance {
),
taskQueueRegistry: newTaskQueueRegistry(vu),
filePersister: m.filePersister,
testRunID: m.testRunID,
}),
Devices: common.GetDevices(),
NetworkProfiles: common.GetNetworkProfiles(),
Expand Down Expand Up @@ -126,6 +128,9 @@ func (m *RootModule) initialize(vu k6modules.VU) {
if err != nil {
k6ext.Abort(vu.Context(), "failed to create file persister: %v", err)
}
if e, ok := initEnv.LookupEnv(env.K6TestRunID); ok && e != "" {
m.testRunID = e
}
inancgumus marked this conversation as resolved.
Show resolved Hide resolved
}

func startDebugServer() {
Expand Down
2 changes: 2 additions & 0 deletions browser/modulevu.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type moduleVU struct {
*taskQueueRegistry

filePersister

testRunID string
}

// browser returns the VU browser instance for the current iteration.
Expand Down
7 changes: 7 additions & 0 deletions env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ const (
ScreenshotsOutput = "K6_BROWSER_SCREENSHOTS_OUTPUT"
)

// Infrastructural.
const (
inancgumus marked this conversation as resolved.
Show resolved Hide resolved
// K6TestRunID represents the test run id. Note: this was taken from
// k6.
K6TestRunID = "K6_CLOUD_PUSH_REF_ID"
)

// LookupFunc defines a function to look up a key from the environment.
type LookupFunc func(key string) (string, bool)

Expand Down