HIRS/.ci/system-tests/run_system_tests.sh

83 lines
2.7 KiB
Bash
Raw Normal View History

#!/bin/bash
2021-11-16 21:51:42 +00:00
#########################################################################################
# Script to run the System Tests for HIRS TPM 2.0 Provisoner
#
#########################################################################################
aca_container=hirs-aca1
tpm2_container=hirs-provisioner1-tpm2
testResult="passed";
issuerCert=../setup/certs/ca.crt
hirs_aca_log=/var/log/tomcat/HIRS_AttestationCA.log
2021-11-16 21:51:42 +00:00
# Source files for Docker Variables and helper scripts
. ./.ci/docker/.env
2021-11-16 21:51:42 +00:00
set -a
2021-11-16 21:51:42 +00:00
echo "******** Setting up for HIRS System Tests for TPM 2.0 ******** "
# expand dmi files for mounting to the provisioner containers
unzip -q .ci/system-tests/profiles/laptop/laptop_dmi.zip -d .ci/system-tests/profiles/laptop/
# Start System Testing Docker Environment
2022-01-25 15:54:54 +00:00
pushd .ci/docker > /dev/null
2021-11-16 21:51:42 +00:00
docker-compose -f docker-compose-system-test.yml up -d
2022-01-25 15:54:54 +00:00
popd > /dev/null
pushd .ci/system-tests > /dev/null
2021-11-16 21:51:42 +00:00
source sys_test_common.sh
echo "ACA Container info: $(checkContainerStatus $aca_container)";
echo "TPM2 Provisioner Container info: $(checkContainerStatus $tpm2_container)";
2021-11-16 21:51:42 +00:00
# Install HIRS provioner and setup tpm2 emulator
2022-01-26 17:08:29 +00:00
docker exec $tpm2_container /HIRS/.ci/setup/setup_tpm2provisioner.sh
2021-11-16 21:51:42 +00:00
# ********* Execute system tests here, add tests as needed *************
echo "******** Setup Complete Begin HIRS System Tests ******** "
2021-11-16 21:51:42 +00:00
source aca_policy_tests.sh
2022-02-01 22:43:12 +00:00
source platform_cert_tests.sh
source rim_system_tests.sh
2022-02-01 22:43:12 +00:00
2021-11-16 21:51:42 +00:00
echo "******** HIRS System Tests Complete ******** "
2021-11-16 21:51:42 +00:00
# collecting ACA logs for archiving
echo "Collecting ACA logs ....."
docker exec $aca_container mkdir -p /HIRS/logs/aca/;
docker exec $aca_container cp -a /var/log/tomcat/. /HIRS/logs/aca/;
docker exec $aca_container chmod -R 777 /HIRS/logs/;
echo "Collecting provisioner logs"
docker exec $tpm2_container mkdir -p /HIRS/logs/provisioner/;
docker exec $tpm2_container cp -a /var/log/hirs/provisioner/. /HIRS/logs/provisioner/;
docker exec $tpm2_container chmod -R 777 /HIRS/logs/;
2021-11-16 21:51:42 +00:00
# Display container log
echo ""
2021-11-16 21:51:42 +00:00
echo "===========HIRS Tests and Log collection complete ==========="
echo ""
2021-11-16 21:51:42 +00:00
echo "End of System Tests for TPM 2.0, cleaning up..."
echo ""
# Clean up services and network
2022-01-25 15:54:54 +00:00
popd > /dev/null
pushd .ci/docker
docker-compose -f docker-compose-system-test.yml down -v
2022-01-25 15:54:54 +00:00
popd > /dev/null
2021-11-16 21:51:42 +00:00
# Clean up dangling containers
echo "Cleaning up dangling containers..."
echo ""
docker container prune --force
echo ""
echo "New value of test status is ${TEST_STATUS}"
# Return container exit code
if [[ ${TEST_STATUS} == "0" ]]; then
echo "SUCCESS: System Tests for TPM 2.0 passed"
echo "TEST_STATUS=0" >> $GITHUB_ENV
exit 0;
else
echo "FAILURE: System Tests for TPM 2.0 failed"
echo "TEST_STATUS=1" >> $GITHUB_ENV
exit 1
fi