locust常用的配置參數【locust版本:V1.1.1】


locust 官網文檔地址:https://docs.locust.io/en/stable/configuration.html

執行命令如:

master:

locust -f D:\api_locust\fm_api\locust_api\***x.py --master --master-bind-port 9800 --headless -u 500 -r 200 --expect-worker 10 -t 1m -s 5 --csv D:\locustlog\

slave:

locust -f D:\api_locust\fm_api\locust_api\***x.py --master-host localhost --master-port 9800 --headless --worker

 

詳細參數:

Command line Configfile Description 中文對照
-f, --locustfile locustfile

Python module file to import,

e.g. ‘../other.py’. Default: locustfile

需要執行腳本的文件及路徑
-H, --host host

Host to load test in the following

format: http://10.21.32.33

壓測主機的host
-u, --users users

Number of concurrent Locust users.

Only used together with –headless

壓測並發用戶數,

只能與-headless參數一起使用

-r, --hatch-rate hatch-rate

The rate per second in which users are spawned.

Only used together with –headless

每秒啟動用戶數,

僅與–headless一起使用

-t, --run-time run-time

Stop after the specified amount of time,

e.g. (300s, 20m, 3h, 1h30m, etc.).

Only used together with –headless

壓測執行時間,

僅與–headless一起使用

--web-host web-host

Host to bind the web interface to.

Defaults to ‘*’ (all interfaces)

網頁上執行壓測的host,

默認為*

--web-port, -P web-port Port on which to run web host 網頁上執行壓測的端口
--headless headless

Disable the web interface,

and instead start the load test immediately.

Requires -u and -t to be specified.

不支持網頁壓測,需要指定

-u,-t參數一起使用

--web-auth web-auth

Turn on Basic Auth for the web interface.

Should be supplied in the following

format: username:password

網頁執行壓測認證,

格式為:username:password

--tls-cert tls-cert

Optional path to TLS certificate to

use to serve over HTTPS

通過HTTPS服務的TLS證書的路徑
--tls-key tls-key

Optional path to TLS private key to

use to serve over HTTPS

通過HTTPS服務的TLS私鑰的路徑
--master master

Set locust to run in distributed mode

with this process as master

分布式運行的master進程
--master-bind-host master-bind-host

Interfaces (hostname, ip) that locust master

should bind to.

Only used when running with –master.

Defaults to * (all available interfaces).

master進程運行的host,

默認為*,只能與-master一起使用

--master-bind-port master-bind-port

Port that locust master should bind to.

Only used when running with –master.

Defaults to 5557

master進程運行的端口,

默認為5557,只能與-master一起使用

--expect-workers expect-workers

How many workers master should expect

to connect before starting the test

(only when –headless used).

分布式壓測的slave個數,

只能與–headless參數一起使用

--worker worker

Set locust to run in distributed mode

with this process as worker

slave壓測進程
--master-host master-host

Host or IP address of locust master for

distributed load testing.

Only used when running

with –worker. Defaults to 127.0.0.1.

salve壓測進程配置的master進程的host,

只能與-worker一起使用

--master-port master-port

The port to connect to that is used by the

locust master for distributed load testing.

Only used when running with

–worker. Defaults to 5557.

salve壓測進程配置的master進程的端口,

默認為5557,只能與-worker一起使用

-T, --tags tags

List of tags to include in the test,

so only tasks with any matching tags will be executed

需要被執行的標簽
-E, --exclude-tags exclude-tags

List of tags to exclude from the test,

so only tasks with no matching tags will be executed

需要被過濾的標簽
--csv csv

Store current request stats to files in CSV format.

Setting this option will generate three files:

[CSV_PREFIX]_stats.csv,

[CSV_PREFIX]_stats_history.csv ,

[CSV_PREFIX]_failures.csv

將請求的統計數據存到csv文件里,

該參數會保存三個csv文件

--csv-full-history csv-full-history

Store each stats entry in CSV

format to _stats_history.csv file

將每個統計條目存

到 _stats_history.csv 文件

--print-stats print-stats Print stats in the console 在控制台中打印統計信息
--only-summary only-summary Only print the summary stats 只打印匯總統計
--reset-stats reset-stats

Reset statistics once hatching has been completed. 

should be set on both master and workers

when running in distributed mode

重置統計信息,master和slave

同時設置才生效

--skip-log-setup skip-log-setup

Disable Locust’s logging setup. Instead,

the configuration is provided by the

Locust test or Python defaults.

禁用日志
--loglevel, -L loglevel

Choose between

DEBUG/INFO/WARNING/ERROR/CRITICAL.

Default is INFO.

記錄日志級別,默認info
--logfile logfile Path to log file. If not set, log will go to stdout/stderr 日志記錄目錄,默認在/stdout/stderr
--step-load step-load

Enable Step Load mode to monitor how performance

metrics varies when user load increases.

Requires –step-users and –step-time to be specified.

分布式壓測逐步增加模式
--step-users step-users

User count to increase by step in Step Load mode.

Only used together with –step-load

逐步增加的用戶數,

只能和--step-load參數使用

--step-time step-time

Step duration in Step Load mode,

e.g. (300s, 20m, 3h, 1h30m, etc.).

Only used together with –step-load

逐步增加的壓測時長,

只能和--step-load參數使用

--exit-code-on-error exit-code-on-error

Sets the process exit code to use

when a test result contain any failure or error

配置退出執行標簽,

當程序執行出錯包含這個標簽時

-s, --stop-timeout stop-timeout

Number of seconds to wait for a simulated

user to complete any executing task before exiting.

Default is to terminate immediately.

This parameter only needs to be specified for the

master process when running Locust distributed.

設置等待模擬用戶完成任務時間,

默認立即退出

 

僅供參考,翻譯不准確的參考官網~


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM