-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Populate __ENV.K6_CLOUDRUN_TEST_RUN_ID on local executions of k6 cloud run #4092
Conversation
Note that the approach followed here won't make But I'd be very happy to see any suggestions or ideas for possible workarounds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a couple of nit comments behind, but none of them blocking, I'd be happy with this merged as-is. Great work!
cmd/outputs_cloud.go
Outdated
raw, err := cloudConfToRawMessage(conf) | ||
if err != nil { | ||
return fmt.Errorf("could not serialize cloud configuration: %w", err) | ||
} | ||
|
||
test.derivedConfig.Collectors[builtinOutputCloud.String()] = raw | ||
|
||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually needed ? I guess maybe if we save it to disk, but not otherwise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm lacking historical context here (about when and how those overrides are used), but in case there's overrides from Cloud, I guess we might want those to be applied and "sent" to the Cloud output 🤔
If not, I'm happy with removing the entire if
block and just ignore overrides from Cloud here.
@joanlopez maybe first rebase though as there have been a few changes including to the CI that mean theat you will have more lint failures. |
Please @andrewslotin, @mstoykov, That's mainly because that would require a larger refactor, to completely move the creation of the test run outside of the Cloud output, as I did in master...k6/cloud, but that would mean "making the Cloud output even a more special output", and @mstoykov discouraged that. Otherwise, I don't think there's any way we can modify the environment from within the Cloud output particularly, and reflect that to the test's environment. But I'm open for suggestions/ideas, if any. PS: @olegbespalov adding you as a reviewer, cause I think @oleiade won't be able to follow up on this PR for now. |
f891588
to
893b760
Compare
@joanlopez, since |
I agree, I just wanted to make it clear so w'all set proper expectations. |
cmd/cloud_run.go
Outdated
// If the "K6_CLOUDRUN_TEST_RUN_ID" is set, then it means that this code is being executed in the k6 Cloud. | ||
// Therefore, we don't need to continue with the test run creation, as we don't need to create any test run. | ||
// This should technically never happen, as k6, when executed in the Cloud, it uses the standard "run" | ||
// command "locally", but we add this early return just in case, for safety. | ||
// | ||
// If not, we know this execution requires a test run to be created in the Cloud. | ||
// So, we create it as part of the process of loading and configuring the test. | ||
if _, isSet := c.runCmd.gs.Env[testRunIDKey]; !isSet { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just drop this part for now and maybe add it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just lets remoe the one if
cmd/cloud_run.go
Outdated
// If the "K6_CLOUDRUN_TEST_RUN_ID" is set, then it means that this code is being executed in the k6 Cloud. | ||
// Therefore, we don't need to continue with the test run creation, as we don't need to create any test run. | ||
// This should technically never happen, as k6, when executed in the Cloud, it uses the standard "run" | ||
// command "locally", but we add this early return just in case, for safety. | ||
// | ||
// If not, we know this execution requires a test run to be created in the Cloud. | ||
// So, we create it as part of the process of loading and configuring the test. | ||
if _, isSet := c.runCmd.gs.Env[testRunIDKey]; !isSet { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree
Co-authored-by: Oleg Bespalov <[email protected]>
What?
It populates the
__ENV.K6_CLOUDRUN_TEST_RUN_ID
, which is the environment variable that contains the test run id on Cloud executions, with the corresponding value for local executions streaming results to the Cloud:k6 cloud run --local-execution
.Why?
Because this unlocks different projects we have ongoing, currently blocked by the lack of a mechanism to read that variable on local executions streaming results to the Cloud.
Checklist
make lint
) and all checks pass.make tests
) and all tests pass.Related PR(s)/Issue(s)
Contributes to #4041