locustio / locust

Write scalable load tests in plain Python 🚗💨
https://locust.cloud
MIT License
25.1k stars 3k forks source link

Form field for users, spawn rate, and run time still visible in UI although CustomShape defined without use_common_options. #2924

Closed fikrapdso closed 1 month ago

fikrapdso commented 1 month ago

Prerequisites

Description

in documenttions it mention

When using shapes, the the Users, Spawn Rate and Run Time options will be hidden from the UI, and if you specify them on command line Locust will log a warning

But I am still able to see those fields in UI.

image

Command line

locust -f scripts/websocket_load_test.py --logfile halo.txt

Locustfile contents

# locustfile.py
import json
import logging
import os
import time

import websocket
from locust import HttpUser
from locust import LoadTestShape
from locust import TaskSet
from locust import between
from locust import task
from locust_plugins.users.socketio import SocketIOUser

DUMMY_COURSE_SLUG = os.getenv("DUMMY_COURSE_SLUG", default="xx")
DUMMY_CHAPTER_SLUG = os.getenv("DUMMY_CHAPTER_SLUG", default="yy")
DUMMY_EXERCISE_SLUG = os.getenv("DUMMY_EXERCISE_SLUG", default="zz")
BASE_URL = os.getenv("BASE_URL", default="ws://localhost:3001")
URL = "ws://localhost:3001/"

class StepLoadShape(LoadTestShape):  # Define a new LoadTestShape class
    stages = []
    for minute in range(5):
        duration = minute * 60
        users = minute * 2
        stages.append(
            {
                "duration": duration,
                "users": users,
                "spawn_rate": 1,
            },
        )

    def tick(self):
        run_time = self.get_run_time()

        for stage in self.stages:
            if run_time < stage["duration"]:
                tick_data = (
                    stage["users"],
                    stage["spawn_rate"],
                )
                return tick_data

        return None

class MySocketIOUser(SocketIOUser):
    wait_time = between(20, 20)

    @task
    def my_task(self):
        logging.info("task")

Python version

python 3.12

Locust version

2.31.8

Operating system

Mac os

cyberw commented 1 month ago

@andrewbaldwin44 Maybe you can take a look at this when you're back?