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

self.quit() fails test doesn't stop #1726

Closed
Paszymaja opened this issue Mar 10, 2021 · 3 comments
Closed

self.quit() fails test doesn't stop #1726

Paszymaja opened this issue Mar 10, 2021 · 3 comments
Labels

Comments

@Paszymaja
Copy link

Describe the bug

When running Locust sometimes the self.quit() fails and the test doesn't stop. This is a problem for us because we are running it inside the Argo workflow so this step never ends.

Full Traceback:

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 334, in shape_worker
    self.quit()
  File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 362, in quit
    self.stop()
  File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 413, in stop
    super().stop()
  File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 354, in stop
    self.stop_users(self.user_count)
  File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 223, in stop_users
    user = g.args[0]
IndexError: tuple index out of range
<REDACTED_DATE> <Greenlet at 0x7f88ca99fae0: <bound method Runner.shape_worker of <locust.runners.LocalRunner object at 0x7f88cabaffd0>>> failed with IndexError

Expected behavior

Locust should exit and maybe return an error.

Actual behavior

After the error locust is still working and sending requests. Pipeline with test never ends.

Steps to reproduce

I wasn't able to reproduce it 100% of the time. I would love to get some general direction if this is a known problem with our Locust file, Locust or maybe something else. Any help would be great. Our Locust file deployed inside Docker:

import math
from locust import HttpUser, TaskSet, task, between
from locust import LoadTestShape
import os


class UserBehavior(TaskSet):
    @task
    def pollute_memory(self):
        abc = self.client.get("/cars")

class WebsiteUser(HttpUser):
    tasks = [UserBehavior]
    wait_time = between(1, 3)

class SinusWave(LoadTestShape):
    ramp_up_time = os.getenv('RAMP_UP_TIME')
    ramp_up_slope = os.getenv('RAMP_UP_SLOPE')
    amplitude = os.getenv('STABLE_AMPLITUDE')
    frequency = os.getenv('STABLE_FREQUENCY')
    offset = os.getenv("STABLE_OFFSET")
    time_limit = os.getenv('STABLE_MAX_TIME_LIMIT_IN_S')
    ramp_up_value = 0

    def tick(self):
        run_time = round(self.get_run_time())
        if run_time < int(self.time_limit):

            if run_time < int(self.ramp_up_time):
                self.ramp_up_value = float(self.ramp_up_slope) * run_time
                return (round(self.ramp_up_value), 1)
            else:
                user_count = float(self.amplitude) * math.sin((float(self.frequency) * run_time) + float(self.offset)) + float(self.ramp_up_value)
                if user_count <= 0:
                    user_count = float(self.ramp_up_value) # Minimal value of sinus
                return (round(user_count), 20) #(user_count, spawn_rate - number of users to start per second)
        else:
            return None

Environment

  • OS: Kubernetes/Docker
  • Python version: 3.8
  • Locust version: 1.4.3
  • Locust command line that you ran: locust --host="http://${HOSTNAME}" --headless
@cyberw
Copy link
Collaborator

cyberw commented Mar 11, 2021

Try now with latest master.

@Paszymaja
Copy link
Author

Thank you for a fast fix. Right now everything works as it should. Waiting for full release :)

@cyberw
Copy link
Collaborator

cyberw commented Mar 15, 2021

👍 Let me know if it happens again (maybe the new logging will hint at the actual underlying issue)

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

No branches or pull requests

2 participants