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

After running the locust, on UI can not see any aggregation report, although the request is successful #1953

Closed
Aiu-Spring opened this issue Dec 7, 2021 · 5 comments

Comments

@Aiu-Spring
Copy link

Aiu-Spring commented Dec 7, 2021

Describe the bug

After pycharm executes the lock command, it goes to localhost: 8089 to configure concurrency and starts the pressure test. However, after the pressure test, the aggregation report page does not display any requests, although pycharm detects that the requests are successful

Expected behavior

It is hoped that the aggregation report can be displayed normally, and the data output by other performance is normal. The aggregation report can be generated and downloaded normally

Actual behavior

No requests are displayed, and it is unclear at the UI level how well the request action performs

Steps to reproduce

Environment

  • OS:Window10
  • Python version:3.9.7
  • Locust version: 2.5.0
  • Locust command line that you ran:locust -f .\loadtest\Loadtest-Suite.py
  • Locust file contents (anonymized if necessary):
    `class GetResume(TaskSet):
    @task
    def get_collection_id(self):
    headers = {
    "Accept": "application/json"
    }
    params = {
    "c": "web",
    "pageNumber": 0,
    "pageSize": 2
    }
    response = self.client.get("xxxxxxx", params=params,
    headers=headers,
    catch_response=True, verify=False)
    for i in range(1, 1000):
    print(f"test time is {i}" + " status_code is:" + str(response.status_code))
    if "Success" in response.text:
    response.success()
    else:
    response.failure("failed")

class Website(HttpUser):
tasks = [GetResume]
min_wait = 1000
max_wait = 2000
host = "xxxxxxxxx"`
image

@Aiu-Spring Aiu-Spring added the bug label Dec 7, 2021
@cyberw
Copy link
Collaborator

cyberw commented Dec 7, 2021

Have you checked the command line output? Try formatting your code, I cant really read it...

@Aiu-Spring
Copy link
Author

Aiu-Spring commented Dec 8, 2021

output is 'status_code is : 200'
code:
`class GetResume(TaskSet):

@task  
def get_collection_id(self):
    headers = {
        "Accept": "application/json"
    }
    params = {
        "c": "web",
        "pageNumber": 0,
        "pageSize": 2
    }
    response = self.client.request("GET", url="/a/r/api/v1/collection/list", params=params, headers=headers,
                                   catch_response=True)
     for i in range(1, 1000):
            print(f"test time is {i}" + " status_code is:" + str(response.status_code))
    if response.status_code == 200:
        response.success()
    else:
        response.failure("failed")

class Website(HttpUser):
tasks = [GetResume]
min_wait = 1000
max_wait = 2000
`

@cyberw
Copy link
Collaborator

cyberw commented Dec 8, 2021

If you use catch_response you must use a with-block and do the response.success()/.failure() in that block. See http://docs.locust.io/en/latest/writing-a-locustfile.html#validating-responses

@Aiu-Spring
Copy link
Author

OK got it, after use the with-block had fixed it . Tx

@cyberw cyberw closed this as completed Dec 8, 2021
@cyberw cyberw added the invalid label Dec 8, 2021
cyberw added a commit that referenced this issue Dec 8, 2021
…s() without using a with block (helps with some misunderstandings, e.g. #1953)
cyberw added a commit that referenced this issue Dec 8, 2021
…s() without using a with block (helps with some misunderstandings, e.g. #1953)
cyberw added a commit that referenced this issue Dec 8, 2021
…s() without using a with block (helps with some misunderstandings, e.g. #1953)
cyberw added a commit that referenced this issue Dec 8, 2021
…s() without using a with block (helps with some misunderstandings, e.g. #1953)
cyberw added a commit that referenced this issue Dec 8, 2021
…s() without using a with block (helps with some misunderstandings, e.g. #1953)
@cyberw
Copy link
Collaborator

cyberw commented Dec 8, 2021

Sorry about the never ending commits/force-pushes :P

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

No branches or pull requests

2 participants