locust icon indicating copy to clipboard operation
locust copied to clipboard

When there is an error in the FAILURES of the front-end page when there is a worker, there is no escape.

Open GeraldWhitehead opened this issue 10 months ago β€’ 4 comments

Prerequisites

Description

I'm using locust with 2.25.0 and have the same problem on 2.24.1, when I run locust -f 1_gloria_test.py --web-login, there is an error reported, and the page data displays fine as follows image But when I have a worker, the page doesn't show the data correctly. master: locust -f 1_gloria_test.py --master worker: locust -f 1_gloria_test.py --worker After running, the front-end data looks like this image

Command line

locust -f 1_gloria_test.py --master

Locustfile contents

import jmespath
from locust import HttpUser, task, TaskSet


class UserStressTest(TaskSet):

    @task(1)
    def task_3_1(self):

        request = {'method': 'GET', 'path': '/cg/v1/case/group/1',
                   'header': {'token': '5153abd76ae0a492beb2ee5f37b91035', 'Content-Type': 'application/json'},
                   'data': {}}

        with self.client.get(request['path'], headers=request['header'], params=None, timeout=10,
                             catch_response=True) as response:

            resp = {
                "status_code": response.status_code,
                "headers": response.headers,
                "body": response.json()}
            try:
                # 断言
                assert jmespath.search('status_code', resp) in [200], {resp['status_code']}
                assert jmespath.search('body.data[0].name', resp) in ['test'], f"断言倱θ΄₯οΌŒθΏ”ε›žε€Ό:{resp['body']}"

            except Exception as ex:
                response.failure(ex)


class TestLocustFile(HttpUser):
    host = "http://127.0.0.1:9998"
    tasks = [UserStressTest]


Python version

3.11.0

Locust version

2.25.0

Operating system

amzn2023.x86_64

GeraldWhitehead avatar Apr 15 '24 02:04 GeraldWhitehead

Hi!

There's a ton of stuff going on in your locsustfile :)

Can you remove everything that isnt relevant to your problem? Simplify it to something like:

class AuthUser(UserMixin):
    @task
    def t(self):
        with self.client.post(..., catch_response=True) as response:
            assert False, "<message that breaks the UI>"

cyberw avatar Apr 15 '24 07:04 cyberw

Hi!

There's a ton of stuff going on in your locsustfile :)

Can you remove everything that isnt relevant to your problem? Simplify it to something like:

class AuthUser(UserMixin):
    @task
    def t(self):
        with self.client.post(..., catch_response=True) as response:
            assert False, "<message that breaks the UI>"

HI Simplifications have been made and problems remain

GeraldWhitehead avatar Apr 15 '24 07:04 GeraldWhitehead

Thanks! I will investigate. Probably this weekend or something...

cyberw avatar Apr 15 '24 08:04 cyberw

Thanks

Thanks

GeraldWhitehead avatar Apr 15 '24 08:04 GeraldWhitehead

Thanks! I will investigate. Probably this weekend or something...

Any results on this question, please? Now every time I get an error it affects my viewing of the error message!

GeraldWhitehead avatar May 11 '24 11:05 GeraldWhitehead

Try with the latest prerelease build now (pip install --pre -U locust). I tried to fix it in #2710 and #2712.

cyberw avatar May 13 '24 15:05 cyberw

pip install --pre -U locust

Verified, problem fixed, thanks!

GeraldWhitehead avatar May 14 '24 03:05 GeraldWhitehead