Skip to content

Commit 844818b

Browse files
authored
chore: add moar testing (#1359)
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
1 parent 3837de4 commit 844818b

File tree

11 files changed

+1984
-38
lines changed

11 files changed

+1984
-38
lines changed

.github/workflows/smoke-deploy-lab.yaml

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
---
12
name: Running hyperconverged smoke tests
23

3-
on:
4+
"on":
45
workflow_dispatch:
56
inputs:
67
acmeEmail:
@@ -39,6 +40,20 @@ on:
3940
- "test"
4041
- "deploy"
4142
- "cleanup"
43+
run_tests:
44+
description: Run post-deployment tests
45+
required: false
46+
default: true
47+
type: boolean
48+
test_level:
49+
description: Test level to run
50+
required: false
51+
default: "quick"
52+
type: choice
53+
options:
54+
- "quick"
55+
- "standard"
56+
- "full"
4257
pull_request:
4358
paths:
4459
- ansible/**
@@ -54,6 +69,7 @@ env:
5469
ACME_EMAIL: cloud@example.local
5570
OS_IMAGE: "Ubuntu 24.04"
5671
SSH_USERNAME: "ubuntu"
72+
TEST_LEVEL: "quick"
5773

5874
jobs:
5975
smoke-deploy:
@@ -81,6 +97,7 @@ jobs:
8197
if: ${{ github.event_name == 'pull_request' || contains(fromJSON('["deploy", "test"]'), github.event.inputs.mode) }}
8298
run: |
8399
eval "$(ssh-agent -s)"
100+
export TEST_LEVEL="${{ github.event.inputs.test_level }}"
84101
scripts/hyperconverged-lab.sh
85102
86103
- name: Retrieve Keys
@@ -106,6 +123,71 @@ jobs:
106123
} >> $GITHUB_STEP_SUMMARY
107124
fi
108125
126+
- name: Upload Test Results
127+
if: ${{ always() && (github.event_name == 'pull_request' || (github.event.inputs.run_tests == 'true' && contains(fromJSON('["deploy", "test"]'), github.event.inputs.mode))) }}
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: test-results-${{ github.run_number }}
131+
path: test-results/
132+
if-no-files-found: ignore
133+
retention-days: 30
134+
135+
- name: Publish Test Summary
136+
if: ${{ always() && (github.event_name == 'pull_request' || (github.event.inputs.run_tests == 'true' && contains(fromJSON('["deploy", "test"]'), github.event.inputs.mode))) }}
137+
run: |
138+
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
139+
echo "" >> $GITHUB_STEP_SUMMARY
140+
141+
if [ -f test-results/aggregate-results.txt ]; then
142+
echo "### Test Suite Summary" >> $GITHUB_STEP_SUMMARY
143+
echo "" >> $GITHUB_STEP_SUMMARY
144+
echo "| Test Suite | Status |" >> $GITHUB_STEP_SUMMARY
145+
echo "|------------|--------|" >> $GITHUB_STEP_SUMMARY
146+
147+
while IFS=: read -r suite status; do
148+
status=$(echo "$status" | xargs)
149+
if [ "$status" = "PASSED" ]; then
150+
echo "| $suite | :white_check_mark: PASSED |" >> $GITHUB_STEP_SUMMARY
151+
else
152+
echo "| $suite | :x: FAILED |" >> $GITHUB_STEP_SUMMARY
153+
fi
154+
done < test-results/aggregate-results.txt
155+
156+
echo "" >> $GITHUB_STEP_SUMMARY
157+
fi
158+
159+
# Parse XML results if available
160+
if ls test-results/*.xml >/dev/null 2>&1; then
161+
echo "### Detailed Test Results" >> $GITHUB_STEP_SUMMARY
162+
echo "" >> $GITHUB_STEP_SUMMARY
163+
164+
for xml_file in test-results/*.xml; do
165+
if [ -f "$xml_file" ]; then
166+
suite_name=$(grep -o 'name="[^"]*"' "$xml_file" | head -1 | sed 's/name="//;s/"//')
167+
echo "#### $suite_name" >> $GITHUB_STEP_SUMMARY
168+
echo "" >> $GITHUB_STEP_SUMMARY
169+
echo "| Test | Status |" >> $GITHUB_STEP_SUMMARY
170+
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
171+
172+
grep -o '<testcase name="[^"]*"' "$xml_file" | sed 's/<testcase name="//;s/"$//' | while read test; do
173+
if grep -q "name=\"${test}\".*<failure" "$xml_file"; then
174+
echo "| $test | :x: Failed |" >> $GITHUB_STEP_SUMMARY
175+
elif grep -q "name=\"${test}\".*<skipped" "$xml_file"; then
176+
echo "| $test | :warning: Skipped |" >> $GITHUB_STEP_SUMMARY
177+
else
178+
echo "| $test | :white_check_mark: Passed |" >> $GITHUB_STEP_SUMMARY
179+
fi
180+
done
181+
182+
echo "" >> $GITHUB_STEP_SUMMARY
183+
fi
184+
done
185+
fi
186+
187+
if [ ! -f test-results/aggregate-results.txt ] && ! ls test-results/*.xml >/dev/null 2>&1; then
188+
echo "_No test results available_" >> $GITHUB_STEP_SUMMARY
189+
fi
190+
109191
- name: Cleanup the lab
110192
if: ${{ always() && (github.event_name == 'pull_request' || contains(fromJSON('["cleanup", "test"]'), github.event.inputs.mode)) }}
111193
run: scripts/hyperconverged-lab-uninstall.sh

openstack-components.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
---
2-
# This file is used to determine which services will be installed automatically
3-
# via the hyperconverged lab and in a future release the genestack-installed.
42
components:
53
keystone: true
64
glance: true

scripts/hyperconverged-lab.sh

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ RUN_EXTRAS=0
88
INCLUDE_LIST=()
99
EXCLUDE_LIST=()
1010

11+
export TEST_LEVEL="${TEST_LEVEL:-off}"
12+
1113
function installYq() {
1214
export VERSION=v4.2.0
1315
export BINARY=yq_linux_amd64
@@ -1232,41 +1234,6 @@ echo "Installing OpenStack"
12321234
sudo /opt/genestack/bin/setup-openstack.sh
12331235
EOC
12341236

1235-
# Run Genestack post setup
1236-
ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
1237-
set -e
1238-
sudo bash <<HERE
1239-
sudo /opt/genestack/bin/setup-openstack-rc.sh
1240-
source /opt/genestack/scripts/genestack.rc
1241-
if ! openstack --os-cloud default flavor show ${LAB_NAME_PREFIX}-test; then
1242-
openstack --os-cloud default flavor create ${LAB_NAME_PREFIX}-test \
1243-
--public \
1244-
--ram 2048 \
1245-
--disk 10 \
1246-
--vcpus 2
1247-
fi
1248-
if ! openstack --os-cloud default network show flat; then
1249-
openstack --os-cloud default network create \
1250-
--share \
1251-
--availability-zone-hint az1 \
1252-
--external \
1253-
--provider-network-type flat \
1254-
--provider-physical-network physnet1 \
1255-
flat
1256-
fi
1257-
if ! openstack --os-cloud default subnet show flat_subnet; then
1258-
openstack --os-cloud default subnet create \
1259-
--subnet-range 192.168.102.0/24 \
1260-
--gateway 192.168.102.1 \
1261-
--dns-nameserver 1.1.1.1 \
1262-
--allocation-pool start=192.168.102.100,end=192.168.102.109 \
1263-
--dhcp \
1264-
--network flat \
1265-
flat_subnet
1266-
fi
1267-
HERE
1268-
EOC
1269-
12701237
# Extra operations...
12711238
install_k9s() {
12721239
echo "Installing k9s"
@@ -1320,6 +1287,53 @@ if [[ "$RUN_EXTRAS" -eq 1 ]]; then
13201287
install_preconf_octavia
13211288
fi
13221289

1290+
if [[ ! "${TEST_LEVEL}" == "off" ]]; then
1291+
echo "Running tests at level: ${TEST_LEVEL}"
1292+
1293+
ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t ${SSH_USERNAME}@${JUMP_HOST_VIP} \
1294+
"sudo TEST_RESULTS_DIR=/tmp/test-results /opt/genestack/scripts/tests/run-all-tests.sh ${TEST_LEVEL}"
1295+
1296+
mkdir -p test-results
1297+
scp -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${SSH_USERNAME}@${JUMP_HOST_VIP}:/tmp/test-results/*.xml ./test-results/ 2>/dev/null || echo "No test result XML files found"
1298+
scp -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${SSH_USERNAME}@${JUMP_HOST_VIP}:/tmp/test-results/*.txt ./test-results/ 2>/dev/null || echo "No test result text files found"
1299+
else
1300+
echo "Skipping tests as TEST_LEVEL is set to 'off'"
1301+
echo "Run Generic Genestack post setup"
1302+
ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
1303+
set -e
1304+
sudo bash <<HERE
1305+
sudo /opt/genestack/bin/setup-openstack-rc.sh
1306+
source /opt/genestack/scripts/genestack.rc
1307+
if ! openstack --os-cloud default flavor show ${LAB_NAME_PREFIX}-test; then
1308+
openstack --os-cloud default flavor create ${LAB_NAME_PREFIX}-test \
1309+
--public \
1310+
--ram 2048 \
1311+
--disk 10 \
1312+
--vcpus 2
1313+
fi
1314+
if ! openstack --os-cloud default network show flat; then
1315+
openstack --os-cloud default network create \
1316+
--share \
1317+
--availability-zone-hint az1 \
1318+
--external \
1319+
--provider-network-type flat \
1320+
--provider-physical-network physnet1 \
1321+
flat
1322+
fi
1323+
if ! openstack --os-cloud default subnet show flat_subnet; then
1324+
openstack --os-cloud default subnet create \
1325+
--subnet-range 192.168.102.0/24 \
1326+
--gateway 192.168.102.1 \
1327+
--dns-nameserver 1.1.1.1 \
1328+
--allocation-pool start=192.168.102.100,end=192.168.102.109 \
1329+
--dhcp \
1330+
--network flat \
1331+
flat_subnet
1332+
fi
1333+
HERE
1334+
EOC
1335+
fi
1336+
13231337
{ cat | tee /tmp/output.txt; } <<EOF
13241338
The lab is now ready for use and took ${SECONDS} seconds to complete.
13251339
This is the jump host address ${JUMP_HOST_VIP}, write this down.

0 commit comments

Comments
 (0)