Skip to content

Commit a54624e

Browse files
committed
test: work around CI infrastructure failures
The CircleCI nested virt often fails to boot the VM. This patch catches the infrastructure failures and retries up to 5 times. Signed-off-by: David Scott <[email protected]>
1 parent 9e0b0b1 commit a54624e

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ test/vmlinuz test/initrd.gz:
189189
@cd test; ./tinycore.sh
190190

191191
test: $(TARGET) test/vmlinuz test/initrd.gz
192-
@(cd test && ./test_linux.exp)
192+
@(cd test && ./retry-infra-failure 5 ./test_linux.exp)
193193

194194
test-qcow: $(TARGET) test/vmlinuz test/initrd.gz
195-
@(cd test && ./test_linux_qcow.exp)
195+
@(cd test && ./retry-infra-failure 5 ./test_linux_qcow.exp)
196196

197197

198198
## ----------- ##

test/retry-infra-failure

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
retries=$1
4+
command=$2
5+
6+
ret=0
7+
for((i=0;i<$retries;i++))
8+
do
9+
$command
10+
ret=$?
11+
# Use exit code 2 to mean infra failure, need to retry.
12+
if [ "$ret" != 2 ]; then
13+
exit $ret
14+
fi
15+
done
16+
17+
echo "Persistent failure after $retries tries."
18+
exit $ret

test/test_linux.exp

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set timeout 20
1515

1616
expect {
1717
timeout {puts "FAIL boot"; exec kill -9 $pid; exit 1}
18+
"Kernel panic - not syncing: IO-APIC + timer doesn't work" {puts "INFRA nested virtualization failed"; exec kill -9 $pid; exit 2}
1819
"\r\ntc@box:~$ "
1920
}
2021
send "sudo mount /dev/sda1 /mnt/sda1\r\n"

test/test_linux_qcow.exp

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set timeout 20
2222

2323
expect {
2424
timeout {puts "FAIL boot"; exec kill -9 $pid; exit 1}
25+
"Kernel panic - not syncing: IO-APIC + timer doesn't work" {puts "INFRA nested virtualization failed"; exec kill -9 $pid; exit 2}
2526
"\r\ntc@box:~$ "
2627
}
2728
send "echo 'This is a block device' > /dev/sda\r\n"

0 commit comments

Comments
 (0)