forked from LINBIT/virter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-run.toml
86 lines (75 loc) · 2.23 KB
/
test-run.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
version = 1
[values]
ContainerImage = "ssh"
# Check that rsync steps work
[[steps]]
[steps.rsync]
source = "data/"
dest = "/virter"
# Check that container steps work
[[steps]]
[steps.container]
image = "{{ .ContainerImage }}"
command = ["sh", "-exc", """
mkdir -p /virter/out
test -n "$TARGETS"
IFS=,; for t in $TARGETS; do
# Some old SSH versions only support the now deprecated ssh-rsa signature
test "$t" = "$(ssh -o "PubkeyAcceptedKeyTypes +ssh-rsa" -o "HostKeyAlgorithms +ssh-rsa" $t hostname -s)"
scp -o "PubkeyAcceptedKeyTypes +ssh-rsa" -o "HostKeyAlgorithms +ssh-rsa" -r $t:/virter/example.txt example.txt
sha256sum -c /virter/workspace/data/example.txt.sha256sum
mv example.txt /virter/out/example-$t.txt
done
"""]
[steps.container.copy]
source = "/virter/out"
dest = "{{ .OutDir }}"
# Checks that the previous container step copied files as expected
[[steps]]
[steps.container]
image = "{{ .ContainerImage }}"
command = ["sh", "-exc", """
IFS=,; for t in $TARGETS; do
test -f "/virter/workspace/{{ .OutDir }}/out/example-$t.txt"
done
"""]
# Checks that shell steps work as expected
[[steps]]
[steps.shell]
script = '''
set -ex
test -f /virter/example.txt
cd /virter
sha256sum -c example.txt.sha256sum
command -v systemctl || exit 1
# Need to reset this state, as ifup fails when devices are configured that do not exist on the node.
systemctl reset-failed "network*.service" || true
while true; do
running=$(systemctl is-system-running || true)
[ "$running" = initializing -o "$running" = starting ] && { sleep 1; continue; }
[ "$running" = running ] && break
echo "System in unexpected state '$running'; failed units:" 1>&2
systemctl list-units --failed 1>&2
exit 1
done
NR_ADDRS=0
while read IDX NAME ; do
case "$NAME" in
lo)
# skip loopback interface
;;
eth*|enp*s0)
# Should have IP address, and be online
ip -oneline -4 addr show dev $NAME | grep -q "inet" || exit 1
ip -oneline link show dev $NAME | grep -q "state UP" || exit 1
NR_ADDRS=$(($NR_ADDRS + 1))
;;
*)
echo Unexpected network interface $NAME 1>&2
exit 1
;;
esac
done < <(ip -oneline link show | grep -oP "^\d+:\s\w+")
# Should have two networks configured
test $NR_ADDRS -eq 2
'''