33#
44include ../../scripts/common.Makefile
55
6+ # Check that given variables are set and all have non-empty values,
7+ # die with an error otherwise.
8+ #
9+ # Params:
10+ # 1. Variable name(s) to test.
11+ # 2. (optional) Error message to print.
12+ check_defined = \
13+ $(strip $(foreach 1,$1, \
14+ $(call __check_defined,$1,$(strip $(value 2) ) ) ) )
15+ __check_defined = \
16+ $(if $(value $1) ,, \
17+ $(error Undefined $1$(if $2, ($2) ) ) )
18+
619.PHONY : requirements
720requirements : # # compiles pip requirements (.in -> .txt)
821 @$(MAKE_C ) requirements reqs
@@ -13,17 +26,30 @@ requirements: ## compiles pip requirements (.in -> .txt)
1326 @echo " WARNING ##### $< is newer than $@ ####" ; diff -uN $@ $< ; false ; ,\
1427 @echo " WARNING ##### $@ does not exist, cloning $< as $@ ############" ; cp $< $@ )
1528
29+ .PHONY : build
30+ build :
31+ docker buildx build --tag local/locust:latest .
32+
33+ .PHONY : up
34+ up :
35+ @$(call check_defined, target, please define target file when calling $@ - e.g. ```make $@ target=MY_LOCUST_FILE.py```)
36+ @export TARGET=$(target ) ; \
37+ docker-compose --file docker-compose.yml up
38+
39+ down :
40+ docker-compose --file docker-compose.yml down
1641
1742.PHONY : install
1843install-dev : _check_venv_active # # installs dependencies
1944 # installing requirements
2045 pip-sync requirements/dev.txt
2146
47+ locusfile =$(if $(target ) ,$(target ) ,locusfile.py)
2248
2349.PHONY : start
2450start : _check_venv_active .env # # starts locust, a scriptable and scalable performance testing tool
2551 # Open http://localhost:8089/
26- locust --locustfile locustfile.py --host http://127.0.0.1:9081 --users 3 --spawn-rate 1
52+ locust --locustfile $( locusfile ) --host http://127.0.0.1:9081 --users 3 --spawn-rate 1
2753
2854
2955.PHONY : list
0 commit comments