3636# pdb=1 Drops you into debug mode upon test failure, if running tests.
3737# test= Only runs tests in the directories provided here, e.g.
3838# repos/delphi/delphi-epidata/tests/acquisition/covidcast
39+ # sql= Overrides the default SQL connection string.
3940
4041
4142# Set optional argument defaults
@@ -49,6 +50,12 @@ ifndef test
4950 test=repos/delphi/delphi-epidata/tests repos/delphi/delphi-epidata/integrations
5051endif
5152
53+ ifdef sql
54+ sqlalchemy_uri:=$(sql)
55+ else
56+ sqlalchemy_uri:=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata
57+ endif
58+
5259SHELL: =/bin/sh
5360
5461# Get the Makefile's absolute path: https://stackoverflow.com/a/324782/4784655
7885
7986 @# Run the web server
8087 @docker run --rm -p 127.0.0.1:10080:80 \
81- --env "SQLALCHEMY_DATABASE_URI=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata " \
88+ --env "SQLALCHEMY_DATABASE_URI=$(sqlalchemy_uri) " \
8289 --env "FLASK_SECRET=abc" --env "FLASK_PREFIX=/epidata" --env "LOG_DEBUG" \
8390 --network delphi-net --name delphi_web_epidata \
8491 delphi_web_epidata >$(LOG_WEB) 2>&1 &
@@ -123,7 +130,7 @@ test:
123130 @docker run -i --rm --network delphi-net \
124131 --mount type=bind,source=$(CWD ) repos/delphi/delphi-epidata,target=/usr/src/app/repos/delphi/delphi-epidata,readonly \
125132 --mount type=bind,source=$(CWD ) repos/delphi/delphi-epidata/src,target=/usr/src/app/delphi/epidata,readonly \
126- --env " SQLALCHEMY_DATABASE_URI=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata " \
133+ --env " SQLALCHEMY_DATABASE_URI=$( sqlalchemy_uri ) " \
127134 --env " FLASK_SECRET=abc" \
128135 delphi_web_python python -m pytest --import-mode importlib $(pdb ) $(test ) | tee test_output_$(NOW ) .log
129136
@@ -132,7 +139,7 @@ bash:
132139 @docker run -it --rm --network delphi-net \
133140 --mount type=bind,source=$(CWD ) repos/delphi/delphi-epidata,target=/usr/src/app/repos/delphi/delphi-epidata,readonly \
134141 --mount type=bind,source=$(CWD ) repos/delphi/delphi-epidata/src,target=/usr/src/app/delphi/epidata,readonly \
135- --env " SQLALCHEMY_DATABASE_URI=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata " \
142+ --env " SQLALCHEMY_DATABASE_URI=$( sqlalchemy_uri ) " \
136143 --env " FLASK_SECRET=abc" \
137144 delphi_web_python bash
138145
0 commit comments