diff --git a/docker/docker-compose.cht-couchdb.yml b/docker/docker-compose.cht-couchdb.yml index 6bc06056..a2f4f69c 100644 --- a/docker/docker-compose.cht-couchdb.yml +++ b/docker/docker-compose.cht-couchdb.yml @@ -4,7 +4,7 @@ services: couchdb: image: public.ecr.aws/medic/cht-couchdb:4.1.0-alpha volumes: - - ${COUCHDB_DATA:-./srv}:/opt/couchdb/data + - couchdb-data:/opt/couchdb/data - cht-credentials:/opt/couchdb/etc/local.d/ environment: - "COUCHDB_USER=${COUCHDB_USER:-admin}" @@ -24,6 +24,7 @@ services: volumes: cht-credentials: + couchdb-data: networks: cht-net: diff --git a/mediator/README.md b/mediator/README.md index 75b60113..b04bc502 100644 --- a/mediator/README.md +++ b/mediator/README.md @@ -18,4 +18,4 @@ docker run --network --name mediator -rm -p 5005:5005 med 1. Run `npm dev` to start the mediator with watch mode. All code is in the `src` folder. The `dist` folder is generated by the build process. 1. Navigate to `/mediator` folder. Run `npm install` to install the dependencies. 1. Run `npm run unit-test` to run unit tests. -1. Run `npm run e2e-test` to run e2e tests. (When running subsequent e2e tests locally, be aware to delete `/cht-interoperability/docker/srv` directory created by the CHT.) +1. Run `npm run e2e-test` to run e2e tests. diff --git a/mediator/test/e2e-test.sh b/mediator/test/e2e-test.sh index d6a95399..ff3922a5 100755 --- a/mediator/test/e2e-test.sh +++ b/mediator/test/e2e-test.sh @@ -6,19 +6,33 @@ MEDIATORDIR="${BASEDIR}/mediator" export NODE_ENV=integration export NODE_TLS_REJECT_UNAUTHORIZED=0 -# Cleanup from last test, in case of interruptions +retry_startup() { + max_attempts=5 + count=0 + until ./startup.sh init || [ $count -eq $max_attempts ]; do + echo "Attempt $((count+1)) of $max_attempts to start containers failed, retrying in 30 seconds..." + count=$((count+1)) + sleep 30 + done + + if [ $count -eq $max_attempts ]; then + echo "Failed to start containers after $max_attempts attempts." + exit 1 + fi +} + +echo 'Cleanup from last test, in case of interruptions...' cd $BASEDIR ./startup.sh destroy -# Starting the interoperability containers +echo 'Starting the interoperability containers...' cd $BASEDIR -./startup.sh init +retry_startup -# Waiting for configurator to finish echo 'Waiting for configurator to finish...' docker container wait chis-interop-configurator-1 -# Executing mediator e2e tests +echo 'Executing mediator e2e tests...' cd $MEDIATORDIR export OPENHIM_API_URL='https://localhost:8080' export FHIR_URL='http://localhost:5001' @@ -31,7 +45,7 @@ export CHT_USERNAME='admin' export CHT_PASSWORD='password' npm test ltfu-flow.spec.ts -# Cleanup +echo 'Cleanup after test...' unset NODE_ENV unset NODE_TLS_REJECT_UNAUTHORIZED unset OPENHIM_API_URL