locustio / locust

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

When using exclude-tags to exclude more than two tags, this setting will not take effect #2994

Closed zhuwenxing closed 4 days ago

zhuwenxing commented 4 days ago

Prerequisites

Description

When using exclude-tags to exclude more than two tags, this setting will not take effect.

❯ locust -f locust_test.py --exclude-tags get,post --headless 
[2024-11-21 11:34:00,872] wxzhu-macbook-pro/INFO/locust.main: Starting Locust 2.32.3
[2024-11-21 11:34:00,877] wxzhu-macbook-pro/INFO/locust.main: No run time limit set, use CTRL+C to interrupt
Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         0     0(0.00%) |      0       0       0      0 |    0.00        0.00

[2024-11-21 11:34:00,879] wxzhu-macbook-pro/INFO/locust.runners: Ramping to 1 users at a rate of 1.00 per second
[2024-11-21 11:34:00,879] wxzhu-macbook-pro/INFO/locust.runners: All users spawned: {"TestUser": 1} (1 total users)
Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /get                                                                               1     0(0.00%) |    911     911     911    911 |    0.00        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         1     0(0.00%) |    911     911     911    911 |    0.00        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /get                                                                               1     0(0.00%) |    911     911     911    911 |    0.00        0.00
POST     /post                                                                              1     0(0.00%) |    279     279     279    279 |    0.00        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         2     0(0.00%) |    595     279     911    280 |    0.00        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /get                                                                               1     0(0.00%) |    911     911     911    911 |    0.33        0.00
POST     /post                                                                              2     0(0.00%) |    492     279     705    280 |    0.00        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         3     0(0.00%) |    631     279     911    710 |    0.33        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /get                                                                               1     0(0.00%) |    911     911     911    911 |    0.17        0.00
POST     /post                                                                              4     0(0.00%) |    421     228     705    280 |    0.33        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         5     0(0.00%) |    519     228     911    470 |    0.50        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /get                                                                               1     0(0.00%) |    911     911     911    911 |    0.12        0.00
POST     /post                                                                              5     0(0.00%) |    389     228     705    280 |    0.38        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         6     0(0.00%) |    476     228     911    280 |    0.50        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /get                                                                               1     0(0.00%) |    911     911     911    911 |    0.12        0.00
POST     /post                                                                              5     0(0.00%) |    389     228     705    280 |    0.38        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         6     0(0.00%) |    476     228     911    280 |    0.50        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /get                                                                               2     0(0.00%) |   1098     911    1286    911 |    0.10        0.00
POST     /post                                                                              5     0(0.00%) |    389     228     705    280 |    0.50        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         7     0(0.00%) |    592     228    1286    470 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /get                                                                               3     0(0.00%) |    826     280    1286    910 |    0.10        0.00
GET      /html                                                                              1     0(0.00%) |    336     336     336    336 |    0.00        0.00
POST     /post                                                                              5     0(0.00%) |    389     228     705    280 |    0.40        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------

If exclude-tags is set to only one tag, it works correctly.

❯ locust -f locust_test.py --exclude-tags get --headless 
[2024-11-21 11:44:15,052] wxzhu-macbook-pro/INFO/locust.main: Starting Locust 2.32.3
[2024-11-21 11:44:15,055] wxzhu-macbook-pro/INFO/locust.main: No run time limit set, use CTRL+C to interrupt
Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         0     0(0.00%) |      0       0       0      0 |    0.00        0.00

[2024-11-21 11:44:15,057] wxzhu-macbook-pro/INFO/locust.runners: Ramping to 1 users at a rate of 1.00 per second
[2024-11-21 11:44:15,057] wxzhu-macbook-pro/INFO/locust.runners: All users spawned: {"TestUser": 1} (1 total users)
Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              1     0(0.00%) |   1204    1204    1204   1204 |    0.00        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         1     0(0.00%) |   1204    1204    1204   1204 |    0.00        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              2     0(0.00%) |    707     209    1204    210 |    0.00        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         2     0(0.00%) |    707     209    1204    210 |    0.00        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              3     0(0.00%) |    700     209    1204    690 |    0.50        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         3     0(0.00%) |    700     209    1204    690 |    0.50        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              4     0(0.00%) |    585     209    1204    240 |    0.60        0.00
POST     /post                                                                              1     0(0.00%) |    203     203     203    203 |    0.00        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         5     0(0.00%) |    509     203    1204    240 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              4     0(0.00%) |    585     209    1204    240 |    0.57        0.00
POST     /post                                                                              2     0(0.00%) |    202     201     203    201 |    0.00        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         6     0(0.00%) |    458     201    1204    210 |    0.57        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              4     0(0.00%) |    585     209    1204    240 |    0.50        0.00
POST     /post                                                                              3     0(0.00%) |    300     201     496    201 |    0.12        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         7     0(0.00%) |    463     201    1204    240 |    0.62        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              5     0(0.00%) |    606     209    1204    690 |    0.40        0.00
POST     /post                                                                              3     0(0.00%) |    300     201     496    201 |    0.20        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                         8     0(0.00%) |    491     201    1204    240 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              6     0(0.00%) |    539     209    1204    240 |    0.30        0.00
POST     /post                                                                              4     0(0.00%) |    279     201     496    201 |    0.30        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        10     0(0.00%) |    435     201    1204    220 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              6     0(0.00%) |    539     209    1204    240 |    0.30        0.00
POST     /post                                                                              5     0(0.00%) |    329     201     529    220 |    0.30        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        11     0(0.00%) |    444     201    1204    240 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              7     0(0.00%) |    495     209    1204    240 |    0.20        0.00
POST     /post                                                                              5     0(0.00%) |    329     201     529    220 |    0.40        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        12     0(0.00%) |    426     201    1204    230 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              7     0(0.00%) |    495     209    1204    240 |    0.20        0.00
POST     /post                                                                              6     0(0.00%) |    314     201     529    220 |    0.40        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        13     0(0.00%) |    411     201    1204    240 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              8     0(0.00%) |    459     208    1204    230 |    0.30        0.00
POST     /post                                                                              6     0(0.00%) |    314     201     529    220 |    0.30        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        14     0(0.00%) |    397     201    1204    230 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              8     0(0.00%) |    459     208    1204    230 |    0.30        0.00
POST     /post                                                                              7     0(0.00%) |    357     201     613    240 |    0.30        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        15     0(0.00%) |    411     201    1204    240 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              8     0(0.00%) |    459     208    1204    230 |    0.20        0.00
POST     /post                                                                              8     0(0.00%) |    367     201     613    240 |    0.30        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        16     0(0.00%) |    413     201    1204    240 |    0.50        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                              9     0(0.00%) |    440     208    1204    240 |    0.20        0.00
POST     /post                                                                              8     0(0.00%) |    367     201     613    240 |    0.30        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        17     0(0.00%) |    406     201    1204    240 |    0.50        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                             10     0(0.00%) |    439     208    1204    240 |    0.20        0.00
POST     /post                                                                              9     0(0.00%) |    349     201     613    240 |    0.30        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        19     0(0.00%) |    397     201    1204    240 |    0.50        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                             10     0(0.00%) |    439     208    1204    240 |    0.20        0.00
POST     /post                                                                             10     0(0.00%) |    335     201     613    220 |    0.40        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        20     0(0.00%) |    387     201    1204    240 |    0.60        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                             10     0(0.00%) |    439     208    1204    240 |    0.20        0.00
POST     /post                                                                             11     0(0.00%) |    324     201     613    220 |    0.30        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        21     0(0.00%) |    379     201    1204    240 |    0.50        0.00

Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET      /html                                                                             10     0(0.00%) |    439     208    1204    240 |    0.20        0.00
POST     /post                                                                             12     0(0.00%) |    314     201     613    210 |    0.40        0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
         Aggregated                                                                        22     0(0.00%) |    371     201    1204    230 |    0.60        0.00

Command line

locust -f locust_test.py --exclude-tags get,post --headless

Locustfile contents

from locust import HttpUser, task, tag, between
import logging

# Configure logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

class TestUser(HttpUser):
    # Set base URL to httpbin
    host = "https://httpbin.org"
    wait_time = between(1, 2)

    @tag('get')
    @task
    def test_get(self):
        logger.debug("Executing GET request task - tags: api,get")
        # The /get endpoint will return detailed request information
        response = self.client.get("/get")
        if response.status_code == 200:
            logger.debug(f"GET request successful: {response.json()}")

    @tag('post')
    @task
    def test_post(self):
        logger.debug("Executing POST request task - tags: api,post")
        # Send some test data
        data = {"name": "test", "value": "123"}
        # The /post endpoint will return the sent data and request information
        response = self.client.post("/post", json=data)
        if response.status_code == 200:
            logger.debug(f"POST request successful: {response.json()}")

    @tag('web')
    @task
    def test_html(self):
        logger.debug("Executing HTML request task - tags: web")
        # The /html endpoint will return a test HTML page
        response = self.client.get("/html")
        if response.status_code == 200:
            logger.debug("HTML request successful")

Python version

3.10.15

Locust version

2.32.3

Operating system

MacBook Pro 2020

cyberw commented 4 days ago

Use space (not commas) to separate tags on the command line. Then it should work!

zhuwenxing commented 4 days ago

Yes, it works!