@@ -49,6 +49,8 @@ $ [sudo] make test pdb=1
4949$ [sudo] make test test=repos/delphi/delphi-epidata/integrations/acquisition
5050```
5151
52+ You can read the commands executed by the Makefile [ here] ( dev/local/Makefile ) .
53+
5254## Rapid Iteration and Bind Mounts
5355
5456To reduce friction, we
@@ -83,56 +85,52 @@ You can test your changes manually by:
83852 . querying the API using your client of choice (` curl ` is handy for sanity
8486 checks)
8587
86- Here's a full example based on the ` fluview ` endpoint:
88+ What follows is a worked demonstration based on the ` fluview ` endpoint. Before
89+ starting, make sure that you have the ` delphi_database_epidata ` ,
90+ ` delphi_web_epidata ` , and ` delphi_redis ` containers running; if you don't, see
91+ the Makefile instructions above.
8792
88- 1 . Populate the database (particularly the ` fluview ` table) with some fake
89- data. For example:
93+ First, let's insert some fake data into the ` fluview ` table:
9094
9195``` bash
96+ # If you have the mysql client installed locally:
9297echo ' insert into fluview values \
9398 (0, "2020-04-07", 202021, 202020, "nat", 1, 2, 3, 4, 3.14159, 1.41421, \
9499 10, 11, 12, 13, 14, 15)' | \
95- mysql --user=user --password=pass \
100+ mysql --user=user --password=pass \
96101 --port 13306 --host 127.0.0.1 epidata
97- ```
98-
99- Note that the host and port given above are "external" values, which are
100- locally visible. You'll need the ` mysql ` client installed locally to run the
101- above command.
102102
103- In case you don't have the ` mysql ` client installed on your machine and
104- don't want to install it, you can simply use the binary that's bundled with
105- the ` mariadb ` docker image, which you should already have from building the
106- ` delphi_database ` image. In that case, use the "internal" values, which are
107- visible to containers on the same virtual network. For example:
108-
109- ``` bash
103+ # If you do not have mysql locally, you can use a Docker image that has it:
110104echo ' insert into fluview values \
111- (0, "2020-04-07", 202021, 202020, "nat", 1, 2, 3, 4, 3.14159, 1.41421, \
112- 10, 11, 12, 13, 14, 15)' | \
113- docker run --rm -i --network delphi-net mariadb \
114- mysql --user=user --password=pass \
115- --port 3306 --host delphi_database_epidata epidata
105+ (0, "2020-04-07", 202021, 202020, "nat", 1, 2, 3, 4, 3.14159, 1.41421, \
106+ 10, 11, 12, 13, 14, 15)' | \
107+ docker run --rm -i --network delphi-net percona:ps-8 \
108+ mysql --user=user --password=pass \
109+ --port 3306 --host delphi_database_epidata epidata
116110```
117111
118- Note that for these inserts, absence of command-line output is a sign of
119- success. On the other hand, output after the insertion likely indicates
120- failure (like, for example, attempting to insert a duplicate unique key).
112+ (The host and port given in the first command are "external" values, which are
113+ locally visible. In the second command, we use the Docker "internal" values,
114+ which are visible to containers on the same virtual network. Port 3306 on the
115+ outside of the container is mapped to 13360, which can be seen in the Makefile.)
116+
117+ For the inserts above, absence of command-line output is a sign of success. On
118+ the other hand, output after the insertion likely indicates failure (like, for
119+ example, attempting to insert a duplicate unique key).
121120
122- 2 . Query the API directly:
121+ Next, you can query the API directly (and parse with Python's JSON tool) :
123122
124123``` bash
125124curl -s \
126125 ' http://localhost:10080/epidata/api.php?source=fluview&epiweeks=202020®ions=nat' | \
127126python3 -m json.tool
128127```
129128
130- The pipe to python's built-in JSON formatter is optional, but handy. You
131- should expect to see the following response from the server :
129+ You should expect to see the following response from the server, which is the
130+ data you inserted earlier :
132131
133132``` json
134133{
135- "result" : 1 ,
136134 "epidata" : [
137135 {
138136 "release_date" : " 2020-04-07" ,
@@ -153,6 +151,7 @@ should expect to see the following response from the server:
153151 "ili" : 1.41421
154152 }
155153 ],
154+ "result" : 1 ,
156155 "message" : " success"
157156}
158157```
@@ -161,8 +160,12 @@ Alternatively, you could query the API using one of the available client
161160libraries. However, this would require you to modify the base URL within the
162161client's code, and there is some additional amount of boilerplate involved in
163162calling the client and displaying the result. For these reasons, client
164- libraries are better candidates for automated integration tests (and unit
165- tests, in the case of the python client) than one-off manual tests.
163+ libraries are better candidates for automated integration tests (and unit tests,
164+ in the case of the python client) than one-off manual tests.
165+
166+ Our API integration tests use this same Docker image and network setup, but
167+ truncate the database tables before running tests, so any manual changes to the
168+ database will be lost after running integration tests.
166169
167170## Instrumentation with Sentry
168171
0 commit comments