From 4b0ca4a68dca15463f1fa20237694a108eb67347 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Tue, 24 Oct 2023 16:00:55 +0800 Subject: [PATCH] init --- docker-compose.yml | 30 ++++++++++++++++++++++++++++++ locustfile.py | 7 +++++++ 2 files changed, 37 insertions(+) create mode 100644 docker-compose.yml create mode 100644 locustfile.py diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e7b71fc --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3' + +services: + master: + image: locustio/locust:latest + ports: + - "8089:8089" + volumes: + - .:/mnt/locust + working_dir: /mnt/locust + command: -f locustfile.py --master -H http://master:8089 + networks: + - locust + + worker: + image: locustio/locust:latest + volumes: + - .:/mnt/locust + working_dir: /mnt/locust + command: -f locustfile.py --worker --master-host master + deploy: + mode: replicated + replicas: 4 + networks: + - locust + + +networks: + locust: + driver: bridge \ No newline at end of file diff --git a/locustfile.py b/locustfile.py new file mode 100644 index 0000000..5e03886 --- /dev/null +++ b/locustfile.py @@ -0,0 +1,7 @@ +from locust import HttpUser, task + + +class HelloWorldUser(HttpUser): + @task + def hello_world(self): + self.client.get("/") \ No newline at end of file