2019-02-04 19:26:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Script to run the System Tests for HIRS TPM 2.0 Provisioner
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
echo ""
|
2019-09-11 11:55:24 +00:00
|
|
|
echo "System Tests TPM 2.0 Starting..."
|
2019-02-04 19:26:54 +00:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
# Start System Testing Docker Environment
|
|
|
|
cd .ci/docker
|
|
|
|
|
|
|
|
docker-compose -f docker-compose-tpm2.yml up -d
|
|
|
|
|
|
|
|
tpm2_container_id="$(docker ps -aqf "name=hirs-aca-provisioner-tpm2")"
|
2019-12-23 10:28:26 +00:00
|
|
|
echo "TPM 2.0 Container ID: $tpm2_container_id"
|
2019-02-04 19:26:54 +00:00
|
|
|
|
|
|
|
tpm2_container_status="$(docker inspect $tpm2_container_id --format='{{.State.Status}}')"
|
2019-12-23 10:28:26 +00:00
|
|
|
echo "TPM 2.0 Container Status: $tpm2_container_status"
|
2019-02-04 19:26:54 +00:00
|
|
|
|
|
|
|
while [[ $tpm2_container_status == "running" ]]
|
|
|
|
do
|
2019-06-12 14:38:57 +00:00
|
|
|
sleep 20
|
2019-02-04 19:26:54 +00:00
|
|
|
|
|
|
|
# Add status message, so Travis will not time out.
|
|
|
|
# It may timeout if it hasn't received output for more than 10 minutes.
|
|
|
|
echo "Still running tests, please wait..."
|
|
|
|
|
|
|
|
tpm2_container_status="$(docker inspect $tpm2_container_id --format='{{.State.Status}}')"
|
|
|
|
done
|
|
|
|
|
2019-04-08 10:57:22 +00:00
|
|
|
# Store container exit code
|
2019-02-04 19:26:54 +00:00
|
|
|
tpm2_container_exit_code="$(docker inspect $tpm2_container_id --format='{{.State.ExitCode}}')"
|
2019-12-23 10:28:26 +00:00
|
|
|
echo "TPM 2.0 Container Exit Code: $tpm2_container_exit_code"
|
2019-02-04 19:26:54 +00:00
|
|
|
|
2019-04-08 10:57:22 +00:00
|
|
|
# Display container log
|
2019-02-04 19:26:54 +00:00
|
|
|
echo ""
|
|
|
|
echo "===========hirs-aca-provisioner-tpm2 System Tests Log:==========="
|
|
|
|
docker logs $tpm2_container_id
|
|
|
|
|
|
|
|
echo ""
|
2019-09-11 11:55:24 +00:00
|
|
|
echo "End of System Tests TPM 2.0, cleaning up..."
|
2019-02-04 19:26:54 +00:00
|
|
|
echo ""
|
|
|
|
# Clean up services and network
|
|
|
|
docker-compose down
|
|
|
|
|
2019-04-08 10:57:22 +00:00
|
|
|
# Clean up dangling containers
|
|
|
|
echo "Cleaning up dangling containers..."
|
|
|
|
echo ""
|
|
|
|
docker ps -a
|
|
|
|
echo ""
|
|
|
|
docker container prune --force
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
# Return container exit code
|
2019-02-04 19:26:54 +00:00
|
|
|
if [[ $tpm2_container_exit_code == 0 ]]
|
|
|
|
then
|
2019-09-11 11:55:24 +00:00
|
|
|
echo "SUCCESS: System Tests TPM 2.0 passed"
|
2019-02-04 19:26:54 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-09-11 11:55:24 +00:00
|
|
|
echo "ERROR: System Tests TPM 2.0 failed"
|
2019-02-04 19:26:54 +00:00
|
|
|
exit 1
|