|
| 1 | +## Containerized integration testing |
| 2 | + |
| 3 | +Hi! Congatulations on making it this far. By now you should know how to launch a |
| 4 | +full node for local development using `devnev`. To take a step further this are |
| 5 | +the steps you need to follow to run and implement integration tests using |
| 6 | +`devenv` |
| 7 | + |
| 8 | +### Running integration tests. |
| 9 | + |
| 10 | +starting at `devenv`, `pushd integration`. In this directory you will find |
| 11 | +scripts in the `/bin` folder. The ones you will be using are `build` and `test`. |
| 12 | +`test` is how you are expected to run the suite. run `bin/build` and `popd`. |
| 13 | +Back in devenv run `integration/bin/test`. |
| 14 | + |
| 15 | +### Adding grouping filters |
| 16 | + |
| 17 | +In `/devenv/integration/test` there is a filter array that determines how many |
| 18 | +nodes are going to be spun and what tests are going to run in parallel inside |
| 19 | +the node. |
| 20 | + |
| 21 | +```bash |
| 22 | +filters=("package(romeo)" "test(deposit_parse)" "test(deposit_output)") |
| 23 | +``` |
| 24 | + |
| 25 | +Use nextest's DSL to group up your integration tests. Add new filters as you see |
| 26 | +fit. |
| 27 | + |
| 28 | +### Adding node readiness checks. |
| 29 | + |
| 30 | +In `devenv/integration/docker/entrypoint` you can add checks to wait until a |
| 31 | +node is ready to take tests. |
| 32 | + |
| 33 | +In this snip we wait until the stacks api is responsive and burchain block |
| 34 | +height is 205. |
| 35 | + |
| 36 | +```bash |
| 37 | +STACKS=$PROJECT_NAME-stacks-1 |
| 38 | +API_URL=http://$STACKS:20443/v2/info |
| 39 | + |
| 40 | +# makes sure the node is ready before proceeding |
| 41 | +# stacks node get info |
| 42 | +echo "Waiting on Stacks API" |
| 43 | +while ! curl -s $API_URL >/dev/null; do |
| 44 | + sleep 1 |
| 45 | +done |
| 46 | + |
| 47 | +DEV_READY_HEIGHT=205 |
| 48 | + |
| 49 | +# bitcoind get info |
| 50 | +echo "Waiting on burn block height $DEV_READY_HEIGHT" |
| 51 | +while [ "$(curl -s $API_URL | jq '.burn_block_height')" -lt $DEV_READY_HEIGHT ]; do |
| 52 | + sleep 2 |
| 53 | +done |
| 54 | +``` |
0 commit comments