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

validate setupTimeout option #3898

Merged

Conversation

tsukasaI
Copy link
Contributor

@tsukasaI tsukasaI commented Aug 15, 2024

What?

Validate setuptimeout option

Why?

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make 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)

#1174

Manual test

Make t.js.

import http from 'k6/http';

export function setup() {
  console.log("setup called")
}

export default function() {
  const response = http.get("http://test.loadimpact.com");
};

Run this command with setupTimeone is 0s, and obtain error.

$ K6_SETUP_TIMEOUT=0s go run . run t.js

          /\      |‾‾| /‾‾/   /‾‾/   
     /\  /  \     |  |/  /   /  /    
    /  \/    \    |     (   /   ‾‾\  
   /          \   |  |\  \ |  (‾)  | 
  / __________ \  |__| \__\ \_____/ .io

ERRO[0000] setupTimeout must be positive                
exit status 104

@tsukasaI tsukasaI requested a review from a team as a code owner August 15, 2024 13:14
@tsukasaI tsukasaI requested review from mstoykov and olegbespalov and removed request for a team August 15, 2024 13:14
@tsukasaI tsukasaI changed the title disable K6_SETUP_TIMEOUT option when 0 disable setup function when setupTimeout option is 0 Aug 16, 2024
@tsukasaI tsukasaI changed the title disable setup function when setupTimeout option is 0 disable setup function when setupTimeout option is 0s Aug 16, 2024
@mstoykov
Copy link
Contributor

👋 @tsukasaI this PR is now empty. I guessed you tried to revert them before making the changes discussed in the issue, but those have not been pushed.

Just pointing this out in case you think that was done and are waiting on us to review this - there is currently no code to review.

@tsukasaI tsukasaI marked this pull request as draft August 31, 2024 02:47
@tsukasaI
Copy link
Contributor Author

Oh, sorry.
Just converted Draft.

@tsukasaI tsukasaI changed the title disable setup function when setupTimeout option is 0s validate setupTimeout option Aug 31, 2024
@tsukasaI tsukasaI marked this pull request as ready for review August 31, 2024 08:58
lib/options.go Outdated
Comment on lines 410 to 412
if opts.SetupTimeout.Valid && opts.SetupTimeout.Duration <= 0 {
return o, errors.New("setupTimeout must be positive")
} else if opts.SetupTimeout.Valid {
Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't think changing Apply signature is warranted.

We do validation checks for most of the options, and they all happen in the respected places instead of in Apply - so please do not change the signature of Apply - that will also make the change a lot smaller

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mstoykov
Thank you for comment.

I updated to move in Validate method.
Is it reasonable?

@olegbespalov olegbespalov added the awaiting user waiting for user to respond label Sep 4, 2024
mstoykov
mstoykov previously approved these changes Sep 9, 2024
@mstoykov mstoykov removed the awaiting user waiting for user to respond label Sep 9, 2024
@mstoykov mstoykov added this to the v0.54.0 milestone Sep 9, 2024
lib/options.go Outdated Show resolved Hide resolved
Copy link
Contributor

@olegbespalov olegbespalov left a comment

Choose a reason for hiding this comment

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

@tsukasaI LGTM! Thank you for your contribution!

@olegbespalov olegbespalov merged commit e0c36d3 into grafana:master Sep 10, 2024
22 checks passed
@tsukasaI tsukasaI deleted the feature/diable-setup-with-timeout-0 branch September 10, 2024 12:05
@olegbespalov olegbespalov added the documentation-needed A PR which will need a separate PR for documentation label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation-needed A PR which will need a separate PR for documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants