Skip to content

Commit 028196b

Browse files
committed
iterate
1 parent 7210571 commit 028196b

File tree

2 files changed

+84
-12
lines changed

2 files changed

+84
-12
lines changed

tests/performance2/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
# Ignore locust configuration
44
.locust.conf
55
.locust.conf_no_grafana
6+
.locust.conf_light
7+
.locust.conf_heavy

tests/performance2/Makefile

Lines changed: 82 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ define create_locust_config
2525
printf "$(YELLOW)First time setup: Creating Locust configuration file$(NC)\n"; \
2626
read -p "Number of processes [4]: " processes; \
2727
processes=$${processes:-4}; \
28+
read -p "Number of users [10]: " users; \
29+
users=$${users:-10}; \
30+
read -p "Spawn rate [1]: " spawn_rate; \
31+
spawn_rate=$${spawn_rate:-1}; \
32+
read -p "Run time [10s]: " run_time; \
33+
run_time=$${run_time:-10s}; \
2834
read -p "Host to load test [http://localhost:8080]: " host; \
2935
host=$${host:-http://localhost:8080}; \
3036
echo; \
@@ -33,9 +39,9 @@ define create_locust_config
3339
echo "locustfile = deployment_max_rps_test.py" >> $(LOCUST_CONFIG_FILE); \
3440
echo "headless = true" >> $(LOCUST_CONFIG_FILE); \
3541
echo "host = $$host" >> $(LOCUST_CONFIG_FILE); \
36-
echo "users = 10" >> $(LOCUST_CONFIG_FILE); \
37-
echo "spawn-rate = 1" >> $(LOCUST_CONFIG_FILE); \
38-
echo "run-time = 10s" >> $(LOCUST_CONFIG_FILE); \
42+
echo "users = $$users" >> $(LOCUST_CONFIG_FILE); \
43+
echo "spawn-rate = $$spawn_rate" >> $(LOCUST_CONFIG_FILE); \
44+
echo "run-time = $$run_time" >> $(LOCUST_CONFIG_FILE); \
3945
echo "processes = $$processes" >> $(LOCUST_CONFIG_FILE); \
4046
echo "" >> $(LOCUST_CONFIG_FILE); \
4147
echo "[logging]" >> $(LOCUST_CONFIG_FILE); \
@@ -52,6 +58,12 @@ define create_locust_config_no_grafana
5258
printf "$(YELLOW)First time setup: Creating Locust configuration file (no Grafana)$(NC)\n"; \
5359
read -p "Number of processes [4]: " processes; \
5460
processes=$${processes:-4}; \
61+
read -p "Number of users [10]: " users; \
62+
users=$${users:-10}; \
63+
read -p "Spawn rate [1]: " spawn_rate; \
64+
spawn_rate=$${spawn_rate:-1}; \
65+
read -p "Run time [10s]: " run_time; \
66+
run_time=$${run_time:-10s}; \
5567
read -p "Host to load test [http://localhost:8080]: " host; \
5668
host=$${host:-http://localhost:8080}; \
5769
echo; \
@@ -60,9 +72,9 @@ define create_locust_config_no_grafana
6072
echo "locustfile = deployment_max_rps_test.py" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
6173
echo "headless = false" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
6274
echo "host = $$host" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
63-
echo "users = 10" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
64-
echo "spawn-rate = 1" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
65-
echo "run-time = 10s" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
75+
echo "users = $$users" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
76+
echo "spawn-rate = $$spawn_rate" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
77+
echo "run-time = $$run_time" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
6678
echo "processes = $$processes" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
6779
echo "" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
6880
printf "$(GREEN)Locust configuration file (no Grafana) created. It won't be asked again.$(NC)\n"; \
@@ -109,6 +121,52 @@ test-deployment-no-grafana: _check_venv_active ## runs deployment test without G
109121
@export $$(cat $(AUTH_CREDS_FILE) | xargs) && \
110122
locust --config $(LOCUST_CONFIG_FILE)_no_grafana
111123

124+
test-deployment-light: _check_venv_active ## runs a light load test with 5 users, 1 spawn rate and 10s runtime
125+
@$(call prompt_for_credentials)
126+
@printf "$(YELLOW)Creating light test configuration...$(NC)\n"
127+
@echo "# Locust configuration file - Light Test" > $(LOCUST_CONFIG_FILE)_light; \
128+
echo "[locust]" >> $(LOCUST_CONFIG_FILE)_light; \
129+
echo "locustfile = deployment_max_rps_test.py" >> $(LOCUST_CONFIG_FILE)_light; \
130+
echo "headless = true" >> $(LOCUST_CONFIG_FILE)_light; \
131+
echo "host = $$(grep "host = " $(LOCUST_CONFIG_FILE) | cut -d= -f2 | xargs)" >> $(LOCUST_CONFIG_FILE)_light; \
132+
echo "users = 5" >> $(LOCUST_CONFIG_FILE)_light; \
133+
echo "spawn-rate = 1" >> $(LOCUST_CONFIG_FILE)_light; \
134+
echo "run-time = 10s" >> $(LOCUST_CONFIG_FILE)_light; \
135+
echo "processes = 2" >> $(LOCUST_CONFIG_FILE)_light; \
136+
echo "" >> $(LOCUST_CONFIG_FILE)_light; \
137+
echo "[logging]" >> $(LOCUST_CONFIG_FILE)_light; \
138+
echo "level = INFO" >> $(LOCUST_CONFIG_FILE)_light;
139+
@printf "$(YELLOW)Starting Locust with light load...$(NC)\n"
140+
@export $$(cat $(AUTH_CREDS_FILE) | xargs) && \
141+
locust --config $(LOCUST_CONFIG_FILE)_light \
142+
--grafana-url http://$(HOST_IP):3000/ \
143+
--pghost $(HOST_IP) \
144+
--pgpassword=password \
145+
--pguser=postgres
146+
147+
test-deployment-heavy: _check_venv_active ## runs a heavy load test with 50 users, 5 spawn rate and 60s runtime
148+
@$(call prompt_for_credentials)
149+
@printf "$(YELLOW)Creating heavy test configuration...$(NC)\n"
150+
@echo "# Locust configuration file - Heavy Test" > $(LOCUST_CONFIG_FILE)_heavy; \
151+
echo "[locust]" >> $(LOCUST_CONFIG_FILE)_heavy; \
152+
echo "locustfile = deployment_max_rps_test.py" >> $(LOCUST_CONFIG_FILE)_heavy; \
153+
echo "headless = true" >> $(LOCUST_CONFIG_FILE)_heavy; \
154+
echo "host = $$(grep "host = " $(LOCUST_CONFIG_FILE) | cut -d= -f2 | xargs)" >> $(LOCUST_CONFIG_FILE)_heavy; \
155+
echo "users = 50" >> $(LOCUST_CONFIG_FILE)_heavy; \
156+
echo "spawn-rate = 5" >> $(LOCUST_CONFIG_FILE)_heavy; \
157+
echo "run-time = 60s" >> $(LOCUST_CONFIG_FILE)_heavy; \
158+
echo "processes = 4" >> $(LOCUST_CONFIG_FILE)_heavy; \
159+
echo "" >> $(LOCUST_CONFIG_FILE)_heavy; \
160+
echo "[logging]" >> $(LOCUST_CONFIG_FILE)_heavy; \
161+
echo "level = INFO" >> $(LOCUST_CONFIG_FILE)_heavy;
162+
@printf "$(YELLOW)Starting Locust with heavy load...$(NC)\n"
163+
@export $$(cat $(AUTH_CREDS_FILE) | xargs) && \
164+
locust --config $(LOCUST_CONFIG_FILE)_heavy \
165+
--grafana-url http://$(HOST_IP):3000/ \
166+
--pghost $(HOST_IP) \
167+
--pgpassword=password \
168+
--pguser=postgres
169+
112170
clear-credentials: ## Clear the cached authentication credentials
113171
@if [ -f $(AUTH_CREDS_FILE) ]; then \
114172
rm $(AUTH_CREDS_FILE); \
@@ -130,6 +188,12 @@ update-locust-config: ## Update the Locust configuration file
130188
@printf "$(YELLOW)Updating Locust configuration:$(NC)\n"
131189
@read -p "Number of processes [4]: " processes; \
132190
processes=$${processes:-4}; \
191+
read -p "Number of users [10]: " users; \
192+
users=$${users:-10}; \
193+
read -p "Spawn rate [1]: " spawn_rate; \
194+
spawn_rate=$${spawn_rate:-1}; \
195+
read -p "Run time [10s]: " run_time; \
196+
run_time=$${run_time:-10s}; \
133197
read -p "Host to load test [http://localhost:8080]: " host; \
134198
host=$${host:-http://localhost:8080}; \
135199
echo; \
@@ -138,9 +202,9 @@ update-locust-config: ## Update the Locust configuration file
138202
echo "locustfile = deployment_max_rps_test.py" >> $(LOCUST_CONFIG_FILE); \
139203
echo "headless = true" >> $(LOCUST_CONFIG_FILE); \
140204
echo "host = $$host" >> $(LOCUST_CONFIG_FILE); \
141-
echo "users = 10" >> $(LOCUST_CONFIG_FILE); \
142-
echo "spawn-rate = 1" >> $(LOCUST_CONFIG_FILE); \
143-
echo "run-time = 10s" >> $(LOCUST_CONFIG_FILE); \
205+
echo "users = $$users" >> $(LOCUST_CONFIG_FILE); \
206+
echo "spawn-rate = $$spawn_rate" >> $(LOCUST_CONFIG_FILE); \
207+
echo "run-time = $$run_time" >> $(LOCUST_CONFIG_FILE); \
144208
echo "processes = $$processes" >> $(LOCUST_CONFIG_FILE); \
145209
echo "" >> $(LOCUST_CONFIG_FILE); \
146210
echo "[logging]" >> $(LOCUST_CONFIG_FILE); \
@@ -151,6 +215,12 @@ update-locust-config-no-grafana: ## Update the Locust configuration file (no Gra
151215
@printf "$(YELLOW)Updating Locust configuration (no Grafana):$(NC)\n"
152216
@read -p "Number of processes [4]: " processes; \
153217
processes=$${processes:-4}; \
218+
read -p "Number of users [10]: " users; \
219+
users=$${users:-10}; \
220+
read -p "Spawn rate [1]: " spawn_rate; \
221+
spawn_rate=$${spawn_rate:-1}; \
222+
read -p "Run time [10s]: " run_time; \
223+
run_time=$${run_time:-10s}; \
154224
read -p "Host to load test [http://localhost:8080]: " host; \
155225
host=$${host:-http://localhost:8080}; \
156226
echo; \
@@ -159,9 +229,9 @@ update-locust-config-no-grafana: ## Update the Locust configuration file (no Gra
159229
echo "locustfile = deployment_max_rps_test.py" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
160230
echo "headless = true" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
161231
echo "host = $$host" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
162-
echo "users = 10" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
163-
echo "spawn-rate = 1" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
164-
echo "run-time = 10s" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
232+
echo "users = $$users" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
233+
echo "spawn-rate = $$spawn_rate" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
234+
echo "run-time = $$run_time" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
165235
echo "processes = $$processes" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
166236
echo "" >> $(LOCUST_CONFIG_FILE)_no_grafana; \
167237
echo "[logging]" >> $(LOCUST_CONFIG_FILE)_no_grafana; \

0 commit comments

Comments
 (0)