Skip to content

Commit 0e8366f

Browse files
author
Joe Ellis
committed
Add installation tests to GitHub CI
Signed-off-by: Joe Ellis <[email protected]>
1 parent 49a2a3f commit 0e8366f

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,11 @@ jobs:
4242
run: docker build -t tpm-provider e2e_tests/provider_cfg/tpm
4343
- name: Run the container to execute the test script
4444
run: docker run -v $(pwd):/tmp/parsec -w /tmp/parsec tpm-provider /tmp/parsec/ci.sh tpm
45+
46+
installation-tests:
47+
name: Installation tests
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v1
51+
- name: Build and run the container
52+
run: e2e_tests/install/run-installation-tests.sh

e2e_tests/install/context/run-tests.sh

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,22 @@ function test_ping_parsec() {
1010
usermod -a -G parsec-clients test-user-1
1111

1212
su test-user-1 <<' EOSU'
13-
cd $HOME
13+
set -eu
14+
cd ${HOME}
1415
curl https://sh.rustup.rs -sSf | bash -s -- -y
15-
export PATH="$HOME/.cargo/bin:$PATH"
16+
export PATH="${HOME}/.cargo/bin:$PATH"
1617
1718
git clone https://github.com/parallaxsecond/parsec-tool.git
1819
cd parsec-tool
1920
cargo build
21+
22+
set +e
2023
cargo run -- ping
21-
exit $?
22-
EOSU
2324
24-
TEST_PASSED=$([[ $? -eq 0 ]])
25-
return ${TEST_PASSED}
25+
# This test passes if the above command pinged the Parsec service
26+
# successfully.
27+
[ $? -eq 0 ]
28+
EOSU
2629
}
2730
2831
function test_ping_parsec_not_in_group() {
@@ -32,19 +35,21 @@ function test_ping_parsec_not_in_group() {
3235
useradd -m test-user-2
3336
3437
su test-user-2 <<' EOSU'
35-
cd $HOME
38+
set -eu
39+
cd ${HOME}
3640
curl https://sh.rustup.rs -sSf | bash -s -- -y
37-
export PATH="$HOME/.cargo/bin:$PATH"
41+
export PATH="${HOME}/.cargo/bin:$PATH"
3842
3943
git clone https://github.com/parallaxsecond/parsec-tool.git
4044
cd parsec-tool
4145
cargo build
46+
47+
set +e
4248
cargo run -- ping
43-
exit $?
44-
EOSU
4549
46-
TEST_PASSED=$([[ $? -ne 0 ]])
47-
return ${TEST_PASSED}
50+
# This test passes if the above command failed to ping the Parsec service.
51+
[ $? -ne 0 ]
52+
EOSU
4853
}
4954
5055
function init_parsec() {
@@ -54,11 +59,6 @@ function init_parsec() {
5459
5560
# Start the Parsec service as user parsec.
5661
su parsec -c 'systemctl --user start parsec'
57-
if [[ $? -ne 0 ]]; then
58-
echo "Failed to start Parsec service, cannot continue."
59-
exit 1
60-
fi
61-
6262
}
6363
6464
function main() {
@@ -73,12 +73,14 @@ function main() {
7373
NUM_FAILED=0
7474
for i in "${!TESTS[@]}"; do
7575
TEST_NAME="${TESTS[$i]}"
76+
echo "=== RUNNING TEST ${TEST_NAME} ==="
7677
if ${TESTS[$i]}; then
7778
echo "${TEST_NAME} passed."
7879
else
7980
echo "${TEST_NAME} failed!"
8081
NUM_FAILED=$((NUM_FAILED + 1))
8182
fi
83+
echo "" # spacing
8284
done
8385
8486
if [[ ${NUM_FAILED} -eq 0 ]]; then

0 commit comments

Comments
 (0)