@@ -33,14 +33,16 @@ DEFAULT_SPAWN_RATE := 1
3333DEFAULT_RUN_TIME := 5m
3434DEFAULT_HOST := http://127.0.0.1:9081
3535
36+ # Default endpoint to test
37+ DEFAULT_ENDPOINT := /
38+
3639# Function to generate Locust configuration file
3740# Usage: $(call generate_locust_config,filename_suffix,processes,users,spawn_rate,run_time,description)
3841define generate_locust_config
3942 @printf "$(YELLOW ) Setting up $(2 ) configuration...$(NC ) \n"
4043 @echo "# Locust configuration file - $(5)" > $(LOCUST_CONFIG_FILE)$(1); \
4144 echo "[locust]" >> $(LOCUST_CONFIG_FILE)$(1); \
42- echo "locustfile = ./locustfiles" >> $(LOCUST_CONFIG_FILE)$(1); \
43- echo "headless = true" >> $(LOCUST_CONFIG_FILE)$(1); \
45+ echo "locustfile = ./locustfiles/deployment_max_rps_single_endpoint.py" >> $(LOCUST_CONFIG_FILE)$(1); \
4446 if [ -f $(LOCUST_CONFIG_FILE) ]; then \
4547 echo "host = $$(grep "host = " $(LOCUST_CONFIG_FILE) | cut -d= -f2 | xargs)" >> $(LOCUST_CONFIG_FILE)$(1); \
4648 else \
@@ -69,11 +71,12 @@ define create_locust_config
6971 run_time=$${run_time:-$(DEFAULT_RUN_TIME ) }; \
7072 read -p "Host to load test [$(DEFAULT_HOST ) ]: " host; \
7173 host=$${host:-$(DEFAULT_HOST ) }; \
74+ read -p "Endpoint to test [$(DEFAULT_ENDPOINT ) ]: " endpoint; \
75+ endpoint=$${endpoint:-$(DEFAULT_ENDPOINT ) }; \
7276 echo; \
7377 echo "# Locust configuration file - Autogenerated" > $(LOCUST_CONFIG_FILE); \
7478 echo "[locust]" >> $(LOCUST_CONFIG_FILE); \
75- echo "locustfile = deployment_max_rps_test.py" >> $(LOCUST_CONFIG_FILE); \
76- echo "headless = true" >> $(LOCUST_CONFIG_FILE); \
79+ echo "locustfile = ./locustfiles/deployment_max_rps_single_endpoint.py" >> $(LOCUST_CONFIG_FILE); \
7780 echo "host = $$host" >> $(LOCUST_CONFIG_FILE); \
7881 echo "users = $$users" >> $(LOCUST_CONFIG_FILE); \
7982 echo "spawn-rate = $$spawn_rate" >> $(LOCUST_CONFIG_FILE); \
@@ -104,22 +107,22 @@ define prompt_for_credentials
104107endef
105108
106109
107- test-deployment : _check_venv_active # # runs deployment test on deploy
110+ test-deployment : _check_venv_active # # runs deployment test on deploy, optionally pass endpoint=path to test specific endpoint
108111 @$(call prompt_for_credentials)
109112 @$(call create_locust_config)
110113 @printf " $( YELLOW) Starting Locust...$( NC) \n"
111114 @export $$(cat $(AUTH_CREDS_FILE ) | xargs ) && \
112- locust --config $(LOCUST_CONFIG_FILE )
115+ locust --config $(LOCUST_CONFIG_FILE ) $( if $( endpoint ) ,--endpoint $( endpoint ) ,--endpoint $( DEFAULT_ENDPOINT ) )
113116
114- test-deployment-ci : _check_venv_active # # runs deployment test on CI
117+ test-deployment-ci : _check_venv_active # # runs deployment test on CI, optionally pass endpoint=path to test specific endpoint
115118 @$(call prompt_for_credentials)
116119 @$(call create_locust_config)
117120 @printf " $( YELLOW) Starting Locust headless...$( NC) \n"
118121 @export $$(cat $(AUTH_CREDS_FILE ) | xargs ) && \
119122 locust --config $(LOCUST_CONFIG_FILE ) \
120- --headless
123+ --headless $( if $( endpoint ) ,--endpoint $( endpoint ) ,--endpoint $( DEFAULT_ENDPOINT ) )
121124
122- test-deployment-with-grafana : _check_venv_active grafana-dashboards-up # # runs deployment test with Grafana integration
125+ test-deployment-with-grafana : _check_venv_active grafana-dashboards-up # # runs deployment test with Grafana integration, optionally pass endpoint=path to test specific endpoint
123126 @$(call prompt_for_credentials)
124127 @$(call create_locust_config)
125128 @printf " $( YELLOW) Starting Locust with Grafana integration...$( NC) \n"
@@ -130,7 +133,7 @@ test-deployment-with-grafana: _check_venv_active grafana-dashboards-up ## runs d
130133 --pgport $(PG_PORT ) \
131134 --pguser $(PG_USER ) \
132135 --pgpassword=$(PG_PASSWORD ) \
133- --timescale
136+ --timescale $( if $( endpoint ) ,--endpoint $( endpoint ) ,--endpoint $( DEFAULT_ENDPOINT ) )
134137
135138
136139
@@ -164,11 +167,12 @@ update-locust-config: ## Update the Locust configuration file
164167 run_time=$$ {run_time:-$(DEFAULT_RUN_TIME ) }; \
165168 read -p " Host to load test [$( DEFAULT_HOST) ]: " host; \
166169 host=$$ {host:-$(DEFAULT_HOST ) }; \
170+ read -p " Endpoint to test [$( DEFAULT_ENDPOINT) ]: " endpoint; \
171+ endpoint=$$ {endpoint:-$(DEFAULT_ENDPOINT ) }; \
167172 echo ; \
168173 echo " # Locust configuration file - Autogenerated" > $(LOCUST_CONFIG_FILE ) ; \
169174 echo " [locust]" >> $(LOCUST_CONFIG_FILE ) ; \
170- echo " locustfile = deployment_max_rps_test.py" >> $(LOCUST_CONFIG_FILE ) ; \
171- echo " headless = true" >> $(LOCUST_CONFIG_FILE ) ; \
175+ echo " locustfile = ./locustfiles/deployment_max_rps_single_endpoint.py" >> $(LOCUST_CONFIG_FILE ) ; \
172176 echo " host = $$ host" >> $(LOCUST_CONFIG_FILE ) ; \
173177 echo " users = $$ users" >> $(LOCUST_CONFIG_FILE ) ; \
174178 echo " spawn-rate = $$ spawn_rate" >> $(LOCUST_CONFIG_FILE ) ; \
0 commit comments