2019-01-15 17:46:06 +00:00
|
|
|
#!/bin/bash
|
2021-11-16 21:51:42 +00:00
|
|
|
#########################################################################################
|
2024-06-07 10:28:25 +00:00
|
|
|
# Script to Locally run the System Tests for HIRS TPM 2.0 Provisoner
|
|
|
|
# *** INTENDED FOR LOCAL SYSTEM TESTING, NOT FOR WORKFLOW RUNS ***
|
|
|
|
# Notes for running manually/locally
|
2024-05-01 18:20:51 +00:00
|
|
|
# 1. Uncomment the "cd ../.." line below to make working directory = /HIRS/
|
|
|
|
# 2. Run with the desired HIRS branch as an argument (i.e. $./run_system_tests.sh main)
|
2021-11-16 21:51:42 +00:00
|
|
|
#########################################################################################
|
2024-06-07 10:28:25 +00:00
|
|
|
#cd ../..
|
2024-05-01 18:20:51 +00:00
|
|
|
|
|
|
|
# Setting variables
|
2021-11-16 21:51:42 +00:00
|
|
|
aca_container=hirs-aca1
|
|
|
|
tpm2_container=hirs-provisioner1-tpm2
|
2019-01-15 17:46:06 +00:00
|
|
|
|
|
|
|
# Start System Testing Docker Environment
|
2024-05-01 18:20:51 +00:00
|
|
|
echo "******** Setting up for HIRS System Tests for TPM 2.0 ******** "
|
|
|
|
docker compose -f ./.ci/docker/docker-compose-system-test.yml up -d
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2024-05-03 16:40:16 +00:00
|
|
|
# Setting up and Starting ACA + Switching to current/desired branch in ACA Container
|
2024-06-07 10:28:25 +00:00
|
|
|
docker exec $aca_container sh -c "/tmp/auto_clone_branch $1 > /dev/null 2>&1 \
|
|
|
|
&& echo 'ACA Container Current Branch: ' && git branch \
|
|
|
|
&& /hirs/package/linux/aca/aca_setup.sh --unattended 1> /dev/null \
|
|
|
|
&& /tmp/hirs_add_aca_tls_path_to_os.sh 1> /dev/null \
|
|
|
|
&& /hirs/package/linux/aca/aca_bootRun.sh 1> /dev/null" &
|
2024-05-03 16:40:16 +00:00
|
|
|
|
|
|
|
# Switching to current/desired branch in Provisioner Container
|
2024-06-07 10:28:25 +00:00
|
|
|
docker exec $tpm2_container sh -c "/tmp/auto_clone_branch $1 > /dev/null 2>&1 \
|
|
|
|
&& echo 'Provisioner Container Current Branch: ' && git branch"
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2024-05-01 18:20:51 +00:00
|
|
|
# Install HIRS Provisioner.Net and setup tpm2 simulator.
|
|
|
|
# In doing so, tests a single provision between Provisioner.Net and ACA.
|
2024-06-07 10:28:25 +00:00
|
|
|
echo "Launching provisioner setup"
|
|
|
|
docker exec $tpm2_container sh /hirs/.ci/setup/container/setup_tpm2provisioner_dotnet.sh
|
|
|
|
|
|
|
|
# Initiating System Tests
|
|
|
|
echo "******** Setup Complete. Beginning HIRS System Tests. ******** "
|
|
|
|
./.ci/system-tests/tests/aca_policy_tests.sh
|
|
|
|
#./.ci/system-tests/tests/platform_cert_tests.sh
|
|
|
|
#./.ci/system-tests/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 ******** "
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2024-05-01 18:20:51 +00:00
|
|
|
# Collecting ACA and Provisioner.Net logs for workflow artifact
|
|
|
|
echo "*** Extracting ACA and Provisioner.Net logs ..."
|
2024-06-07 10:28:25 +00:00
|
|
|
docker exec $aca_container sh -c "mkdir -p /HIRS/logs/aca/ && cp -arp /var/log/hirs/* /HIRS/logs/aca/"
|
|
|
|
docker exec $tpm2_container sh -c "mkdir -p /HIRS/logs/provisioner/ && cp -ap hirs*.log /HIRS/logs/provisioner/ && chmod -R 777 /HIRS/logs"
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2019-02-01 11:00:10 +00:00
|
|
|
# Clean up services and network
|
2024-05-01 18:20:51 +00:00
|
|
|
echo "*** Exiting and removing Docker containers and network ..."
|
|
|
|
docker compose -f ./.ci/docker/docker-compose-system-test.yml down -v
|
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
# Return container exit code
|
|
|
|
if [[ ${TEST_STATUS} == "0" ]]; then
|
2024-05-01 18:20:51 +00:00
|
|
|
echo "******** SUCCESS: System Tests for TPM 2.0 passed ********"
|
2021-11-16 21:51:42 +00:00
|
|
|
echo "TEST_STATUS=0" >> $GITHUB_ENV
|
|
|
|
exit 0;
|
|
|
|
else
|
2024-05-01 18:20:51 +00:00
|
|
|
echo "******** FAILURE: System Tests for TPM 2.0 failed ********"
|
2021-11-16 21:51:42 +00:00
|
|
|
echo "TEST_STATUS=1" >> $GITHUB_ENV
|
2024-05-01 18:20:51 +00:00
|
|
|
exit 1
|
2024-06-07 10:28:25 +00:00
|
|
|
fi
|