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

Stuck in infinite loop when specifying iterations and VUs #812

Closed
AlexGustafsson opened this issue Oct 16, 2018 · 3 comments · Fixed by #1007
Closed

Stuck in infinite loop when specifying iterations and VUs #812

AlexGustafsson opened this issue Oct 16, 2018 · 3 comments · Fixed by #1007
Assignees
Labels
Milestone

Comments

@AlexGustafsson
Copy link

Environment

OS: macOS 10.13.6 (17G65)
k6: v0.22.1

What happens

I get stuck in an infinite loop giving me the following output:

running [=====================================================>----] 9429 / 10000
running [======================================================>---] 9648 / 10000
running [========================================================>-] 9927 / 10000
running [========================================================>-] 9994 / 10000
running [========================================================>-] 9994 / 10000
running [========================================================>-] 9994 / 10000
running [========================================================>-] 9994 / 10000
running [========================================================>-] 9994 / 10000
...

Note: the amount of finished iterations seem to vary in the last tens.

How to replicate

  1. Download binary to working directory
  2. Write the following script to script.js (adapted from the docs)
import http from "k6/http";
import { check, sleep } from "k6";

export let options = {
 stages: [
    { duration: "30s", target: 20 },
    { duration: "1m30s", target: 10  },
    { duration: "20s", target: 0 },
  ]
};

export default function() {
  let res = http.get("http://localhost:3000");
  check(res, {
    "status was 200": (r) => r.status == 200
  });
}
  1. Run using ./k6 run --iterations 10000 --vus 100 script.js
  2. Watch it get stuck during the last few iterations
@na--
Copy link
Member

na-- commented Oct 16, 2018

Ah, I this seems to be because you use both --iterations and also have stages configured in the exported options. If you wait for 2 minutes and 20 seconds (the sum of the stages' duration), the test will finish. And k6 will only make 1000 http requests, so the execution finishes when it's supposed to (whenever one of the end conditions is reached), but then k6 just waits there without exiting... And the problem seems to only happen with stages, not with duration, here's a shorter self-contained example that reproduces the issue without any CLI flags:

import http from "k6/http";

export let options = {
    vus: 10,
    iterations: 100,
    stages: [
        { duration: "60s", target: 20 },
    ],
};

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

Again, when you wait for a minute, k6 will exit successfully, so I'll remove the high prio issue tag. But

@na-- na-- removed the high prio label Oct 16, 2018
@AlexGustafsson
Copy link
Author

@na— Thank you for the quick response and thorough explanation! Closing as this is expected behaviour.

@na--
Copy link
Member

na-- commented Oct 16, 2018

Wait, that's still a bug, even if it's not a major one 😄 I'll leave the issue open so we don't forget to fix it.

@na-- na-- reopened this Oct 16, 2018
@na-- na-- mentioned this issue May 15, 2019
39 tasks
@na-- na-- self-assigned this Aug 27, 2019
@na-- na-- added this to the v1.0.0 milestone Aug 27, 2019
@na-- na-- modified the milestones: v1.0.0, v0.27.0 May 21, 2020
@na-- na-- closed this as completed in #1007 Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants