Locust環境 ローカル確認

負荷試験環境

MAC

環境

  • 準備
brew install libev
brew install python
python3 -m pip install locustio
$vi ~/.bash_profile
export PATH=/usr/local/bin:$PATH
source ~/.bash_profile
python3 -m pip install locustio
# ファイル名を指定する場合
$ locust -f locust_files/my_locust_file.py --host=http://localhost:8080

動作確認

テストケース

from locust import HttpLocust, TaskSequence, seq_task, between
from locust.clients import HttpSession



def doctors(l):
    l.client.get("/api/v1/hoge/"+hoge+"/hoge")


class ScenarioTask(TaskSequence):

    # ()内の数値=実行順番
    @seq_task(1)
    def doctors(self):
        doctors(self)


class WebsiteUser(HttpLocust):
    task_set = ScenarioTask

    # タスク間の時間。1~3秒でランダム秒数で実施する
    wait_time = between(1.0, 3.0)