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

84 lines
2.9 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 ******** "
2022-03-09 20:00:19 +00:00
# Expand linux dmi files to mount to the provisioner container to simulate device component
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
2022-04-20 15:25:30 +00:00
# Build, Package, and Install HIRS ACA (2+ minutes) then wait for systems tests...
docker exec $aca_container sh -c "/HIRS/.ci/setup/container/setup_aca.sh"
2022-04-20 15:25:30 +00:00
echo "ACA Loaded!"
echo "ACA Container info: $(checkContainerStatus $aca_container)";
2021-11-16 21:51:42 +00:00
# Install HIRS provioner and setup tpm2 emulator
docker exec $tpm2_container /HIRS/.ci/setup/container/setup_tpm2provisioner.sh
echo "TPM2 Provisioner Container info: $(checkContainerStatus $tpm2_container)";
2021-11-16 21:51:42 +00:00
# ********* Execute system tests here, add tests as needed *************
echo "******** Setup Complete Begin HIRS System Tests ******** "
source tests/aca_policy_tests.sh
source tests/platform_cert_tests.sh
source tests/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/;
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
2022-03-09 20:00:19 +00:00
pushd .ci/docker > /dev/null
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