A shared electronic document management API.
This will run the service locally. It starts the database and localstack containers then start the service via a bash script. It connects to the dev version of hmpps-auth.
Run the following commands from the root directory of the project:
- docker compose -f docker-compose-local.yml pull
- docker compose -f docker-compose-local.yml up --no-start
- docker compose -f docker-compose-local.yml start db localstack clamav
- ./run-local.sh
The tests use test containers to spin up dependent services (clamAV, postgres, localstack) so make sure Docker is running. There is also an integration test for uploading a "file infected with a virus" The file can be found src/test/resources/test_data/eicar.txt. Windows defender will delete this file so it must be excluded from the scan. Open Windows defender and add the following exclusions:
- folder: src/test/resources/test_data (after this you may need to recover the eicar.txt within that folder)
- file: src/test/resources/test_data/eicar.txt (can delete the folder exclusion above now)
After these two are done run a gradle task which will build the project (./gradlew check
), this will likely popup another windows defender issue. Then exclude the following:
- folder: build/tmp
- folder: build/resources/test/test_data (may need to run a build task after this)
- file: build/resources/test/test_data/eicar.txt (can delete the folder exclusion above now)
This will ensure the file is not deleted on the file system and during the test too.
To run the test execute the following command:
./gradlew check
IMPORTANT: Inform the cloud platform team before running load tests against any environment.
- Install JMeter using brew:
brew install jmeter
- Open the JMeter GUI:
jmeter
- Use the plugin manager (Options -> Plugins Manager or the icon on the top right) to install the Custom JMeter Functions plugin
- Close JMeter and run the following command to open the test plan and specify required properties:
JVM_ARGS="-Xms1024m -Xmx1024m" jmeter -t load-test.jmx -Jbase_protocol='http' -Jbase_server_name='localhost' -Jbase_port='8080' -Jauth_server_name='<auth_server_name>' -Jclient_id='<client_id>' -Jclient_secret='<client_secret>'
rm -rf load-test-* \
&& JVM_ARGS="-Xms1024m -Xmx1024m" jmeter -n -t load-test.jmx -l load-test-results.jtl -e -o load-test-results -Jbase_protocol='http' -Jbase_server_name='localhost' -Jbase_port='8080' -Jauth_server_name='<auth_server_name>' -Jclient_id='<client_id>' -Jclient_secret='<client_secret>' \
&& open load-test-results/index.html