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

Introducing options.cloud #3348

Merged
merged 2 commits into from
Feb 13, 2024
Merged

Introducing options.cloud #3348

merged 2 commits into from
Feb 13, 2024

Conversation

olegbespalov
Copy link
Contributor

@olegbespalov olegbespalov commented Sep 21, 2023

What?

This is an attempt to introduce the new option cloud, which should start the process of sunsetting the options.ext.loadimpact

Why?

The options.ext.loadimpact is the legacy option, and we should migrate from it to something more neutral like cloud

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make ci-like-lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

Closes #1155

@olegbespalov olegbespalov added this to the v0.48.0 milestone Sep 22, 2023
@olegbespalov olegbespalov changed the title WIP: Introducing options.cloud Introducing options.cloud Sep 22, 2023
@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2023

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (9dbf343) 73.55% compared to head (de0815c) 73.56%.
Report is 2 commits behind head on master.

❗ Current head de0815c differs from pull request most recent head bb6f6c5. Consider uploading reports for the commit bb6f6c5 to get more accurate results

Files Patch % Lines
cloudapi/config.go 80.00% 5 Missing and 3 partials ⚠️
cmd/cloud.go 75.00% 1 Missing and 1 partial ⚠️
cmd/login_cloud.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3348      +/-   ##
==========================================
+ Coverage   73.55%   73.56%   +0.01%     
==========================================
  Files         277      277              
  Lines       20201    20228      +27     
==========================================
+ Hits        14858    14881      +23     
- Misses       4396     4399       +3     
- Partials      947      948       +1     
Flag Coverage Δ
macos 73.48% <79.66%> (+0.01%) ⬆️
ubuntu ?
windows 73.42% <79.66%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@olegbespalov olegbespalov self-assigned this Oct 10, 2023
@olegbespalov olegbespalov force-pushed the feat/refactor-cloud-options branch 3 times, most recently from c968699 to 75f526e Compare October 12, 2023 12:00
@olegbespalov olegbespalov marked this pull request as ready for review October 12, 2023 12:25
@olegbespalov olegbespalov added the documentation-needed A PR which will need a separate PR for documentation label Oct 13, 2023
Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olegbespalov did a first cycle, thanks for the great work 🙇

cloudapi/config.go Outdated Show resolved Hide resolved
cloudapi/config.go Outdated Show resolved Hide resolved
}

// Original comment
// TODO: Important! Separate configs and fix the whole 2 configs mess!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explicit this comment a bit more, please? I'm not getting what is the suggestion here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue that I'm not getting this comment to, it's an original comment that was presented in the place around.

TBH for the case of refactoring that I did it wasn't so relevant, but on the other side I'm not comfortable removing it.

@@ -158,6 +162,9 @@ type Config struct {

// Deprecated: Remove this when migration from the cloud output v1 will be completed
MaxMetricSamplesPerPackage null.Int `json:"maxMetricSamplesPerPackage" envconfig:"K6_CLOUD_MAX_METRIC_SAMPLES_PER_PACKAGE"`

// WarningMessage is a string that will be shown to the user if the config has some invalid values.
WarningMessage string `json:"-"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WarningMessage string `json:"-"`
WarningMessage []string `json:"-"`

Considering we are adding this mechanism, should we instead have some sort of form to support a list? Also, why not have them as a result of the Consolidation function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, we could start small, and if we see the need to extend it, but that particular place I don't mind if you think this serve some future needs I could convert to the array

if err := json.Unmarshal(source, &tmpConfig); err != nil {
return err
}
// Only take out the ProjectID, Name and Token from the options.cloud (or legacy loadimpact struct) map:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me reading this comment that we are taking out only part of the available fields. The question now I have is why? I guess it has a reason, can you clarify it, please? As it isn't clear to me just reading the code.

And if it has then probably it can be directly part of the comment of the function explaining what should be the expected return.

As a reference I evaluate this list still valid for the as configurable options. https://k6.io/docs/cloud/creating-and-running-a-test/cloud-scripting-extras/cloud-options/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloudapi/config.go Outdated Show resolved Hide resolved
cmd/archive_test.go Outdated Show resolved Hide resolved
cloudapi/config_test.go Outdated Show resolved Hide resolved
cmd/cloud.go Show resolved Hide resolved
cmd/login_cloud.go Outdated Show resolved Hide resolved
cloudapi/config.go Outdated Show resolved Hide resolved
cloudapi/config.go Outdated Show resolved Hide resolved
codebien
codebien previously approved these changes Oct 18, 2023
Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort 🙇

@olegbespalov olegbespalov removed the documentation-needed A PR which will need a separate PR for documentation label Oct 19, 2023
@olegbespalov olegbespalov mentioned this pull request Oct 19, 2023
7 tasks
@olegbespalov
Copy link
Contributor Author

@codebien I've extracted warnings (or referings) of the options.cloud to the #3407. The reason is that it could be so that we could be in a state where we can merge this PR, but not in the state where we should actively tell customers to use the options.cloud . Feel free to bring your opinion.

codebien
codebien previously approved these changes Oct 20, 2023
Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've extracted warnings (or referings) of the options.cloud to the #3407

Yep, I like the idea. LGTM

mstoykov
mstoykov previously approved these changes Nov 1, 2023
Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👏

but I have not tried to break it extensively locally.

My main feedback is that I still am of the opinion that if options.cloud and options.ext.loadimpact exist - this should lead to an early error instead of one of them taking precedence.

There is IMO no reason someone will have both and at best it will be confusing to users which one they need to change.

@olegbespalov olegbespalov modified the milestones: v0.49.0, v0.50.0 Jan 10, 2024
@olegbespalov olegbespalov requested a review from a team as a code owner January 17, 2024 12:44
@codebien codebien removed the request for review from a team January 18, 2024 11:07
@olegbespalov
Copy link
Contributor Author

Okay, @codebien, here is an explicit request for a review of this (and #3407) PRs ☺️

codebien
codebien previously approved these changes Feb 5, 2024
mstoykov
mstoykov previously approved these changes Feb 8, 2024
olegbespalov and others added 2 commits February 13, 2024 09:29
Co-authored-by: Ivan <2103732+codebien@users.noreply.github.com>
@olegbespalov
Copy link
Contributor Author

@codebien @mstoykov please re-approve. The PR was rebased because of the deletion of the cloud v1

Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving with the assumption we have a green CI we have 🎉

@olegbespalov olegbespalov merged commit b5a6feb into master Feb 13, 2024
24 checks passed
@olegbespalov olegbespalov deleted the feat/refactor-cloud-options branch February 13, 2024 13:30
@yorugac
Copy link
Contributor

yorugac commented Feb 19, 2024

Hello 👋 Just for understanding of this change: can a user specify both the loadimpact and cloud at the same time? E.g. put the name in loadimpact and distribution and project ID in cloud?

@olegbespalov
Copy link
Contributor Author

hey @yorugac . Nope, mixing isn't acceptable. If the options.cloud exists, we'll use it as the source; otherwise, we fall back to the options.ext.loadimpact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor how cloud options are specified in the script file
5 participants