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

The locust chart shows that data is still being recorded after the timed run time expires #2910

Open
2 tasks done
zhenhuaplan opened this issue Sep 25, 2024 · 4 comments
Open
2 tasks done
Labels

Comments

@zhenhuaplan
Copy link

zhenhuaplan commented Sep 25, 2024

Prerequisites

Description

When I started locust, I set a scheduled operation task for 2.5 hours. After the completion of the task, the report shows that the task is executed in 2024/9/23 22:01:07 to 2024/9/24 00:31:07. However, when I check the report on the web interface at 2024/9/24 08:09:00, Found that the timeline of the chart goes straight to 2024/9/24 08:09:00

I use the following command
image

image
image

Command line

locust -f ./locust_run.py --master --master-bind-port=8682 --web-port=8677

Locustfile contents

import sys
from os.path import dirname
from os.path import join

# 初始化项目路径
per_path = dirname(__file__)
project_path = dirname(per_path)
sys.path.append(project_path)
aurora_path = dirname(dirname(project_path))
sys.path.append(aurora_path)

# 基础导包
from queue import Queue
from copy import copy
from locust import FastHttpUser, between
from locust import events
from 配置中心.业务路由 import xenv
from 应用基础库.性能测试.数据服务前置 import data_share_setup

# 测试脚本导入
from 测试用例.xxxx测试脚本 import MainCasePaper

# 请求时间间隔
start, end = 0, 3
data = Queue()


# 定义User实例
class MyUser(FastHttpUser):
    """用户类"""

    # abstract = True # 是否有子类
    wait_time = between(start, end)
    # 测试脚本注册
    tasks = [MainCasePaper]

    # host = 'https://xxxxx.xxxx/xxx' # 生产域名
    host = 'https://xx.x.x.xxxx:xxxx/xxx' # 生产内网IP

    # 读取共享数据(浅拷贝原因: event回调函数在后面执行加载数据)
    share_data = copy(data)
    network_timeout = 10

    # 加载纸质中奖票
    ticket_data = Queue()
    with open(join(per_path,'数据中心','zz_ls_djp_copy.txt'),'r') as fp:
        for i in fp:
            ticket_data.put_nowait(i.rstrip('\n'))


@events.init.add_listener
def on_locust_init(environment, **kw):
    """前置初始化操作"""
    # 地址拼接
    config_path = join(per_path, '参数配置', '参数配置.sh')
    data_path = join(per_path, '数据中心', '数据池.csv')
    data_share_path = join(aurora_path, '应用基础库', '性能测试', '数据共享服务.py')
    # 数据共享服务启动
    data_share_setup(environment, data, config_path, data_path, data_share_path)

Python version

3.9.9

Locust version

2.31.6

Operating system

Huawei Cloud EulerOS (Linux)

@PlanetartRoc
Copy link

PlanetartRoc commented Oct 14, 2024

Same issue.

I commented out a line to fix this:
locust version: 2.31.8
./locust/html.py
line 55:

    failures_statistics = sort_stats(stats.errors)
    exceptions_statistics = [
        {**exc, "nodes": ", ".join(exc["nodes"])} for exc in environment.runner.exceptions.values()
    ]

    #update_stats_history(environment.runner, end_ts)    #this line
    history = stats.history

    is_distributed = isinstance(environment.runner, MasterRunner)
    user_spawned = (
        environment.runner.reported_user_classes_count if is_distributed else environment.runner.user_classes_count
    )

I think this is a way to update the results as you perform the loadtest, but the loadtest is over when you get the report, so you should not update.
And then the report is normal and I'm not sure if it will cause any other problems, but I haven't found anything so far

@zhenhuaplan
Copy link
Author

zhenhuaplan commented Oct 14, 2024

Good,But this seems to raise new questions,After I refresh the Locust web interface,No data is displayed on the statistics screen
image

@cyberw
Copy link
Collaborator

cyberw commented Oct 14, 2024

@andrewbaldwin44 and I are pretty busy at the moment. @PlanetartRoc 's fix looks promising (feel free to make a PR) and @zhenhuaplan second issue is also worth investigating.

@PlanetartRoc
Copy link

Good,But this seems to raise new questions,After I refresh the Locust web interface,No data is displayed on the statistics screen image

This problem should not be related to the html.py.

When the loadtest stops, the list of data will be empty, suspected to be related to the front-end judgment of the loadtest of the test execution state

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

3 participants