Skip to content

Commit

Permalink
fix(#132): fix e2e tests (#133)
Browse files Browse the repository at this point in the history
Co-authored-by: Maria Lorena Rodriguez Viruel <[email protected]>
Co-authored-by: Maria Lorena Rodriguez Viruel <[email protected]>
  • Loading branch information
3 people authored Sep 19, 2024
1 parent 2938b1b commit 6318b9f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docker/docker-compose.cht-couchdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -24,6 +24,7 @@ services:

volumes:
cht-credentials:
couchdb-data:

networks:
cht-net:
Expand Down
2 changes: 1 addition & 1 deletion mediator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ docker run --network <openhim-network-name> --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.
26 changes: 20 additions & 6 deletions mediator/test/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down

0 comments on commit 6318b9f

Please sign in to comment.