Skip to content

Commit 6166887

Browse files
author
Ian Campbell
committed
CI: Try booting something
Signed-off-by: Ian Campbell <[email protected]>
1 parent 9740eec commit 6166887

File tree

3 files changed

+194
-6
lines changed

3 files changed

+194
-6
lines changed

.circleci/config.yml

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ image_build: &image_build
3737
- image: debian:stretch
3838
# image builds seem to need a bit more grunt (RAM) than usual. Possibly getting OOM killed, which https://github.com/moby/tool/pull/191 might help.
3939
# NB: This will become a paid for feature at some point soon (with plenty of warning), so is not a long term solution.
40-
# small 1.0 2GB
41-
# medium (default) 2.0 4GB pass: fail:5
42-
# medium+ 3.0 6GB pass: fail:2
43-
# large 4.0 8GB pass:2 fail:
44-
# xlarge 8.0 16GB
40+
# small 1.0 2GB
41+
# medium (default) 2.0 4GB pass: fail:5
42+
# medium+ 3.0 6GB pass: fail:2
43+
# large 4.0 8GB pass:2 fail:
44+
# xlarge 8.0 16GB
4545
resource_class: large
4646
steps:
4747
- run:
@@ -99,6 +99,26 @@ image_build: &image_build
9999
root: /workspace
100100
paths: images
101101

102+
image_boot: &image_boot
103+
docker:
104+
- image: debian:stretch
105+
steps:
106+
- run:
107+
name: Configure $PATH
108+
command: echo 'export PATH=/workspace/bin:$PATH' >> $BASH_ENV
109+
- run:
110+
name: Install packages
111+
# ca-certificates are needed for attach_workspace (and git over https)
112+
command: apt-get update && apt-get install -y ca-certificates curl expect git make openssh-client qemu strace
113+
- attach_workspace:
114+
at: /workspace
115+
- checkout
116+
- run:
117+
name: Test boot
118+
command: |
119+
cp /workspace/images/kube-$KUBE_RUNTIME-$KUBE_NETWORK/kube-{master,node}.iso .
120+
./test.exp
121+
102122
version: 2
103123
jobs:
104124
dependencies:
@@ -240,6 +260,30 @@ jobs:
240260
- KUBE_RUNTIME: cri-containerd
241261
- KUBE_NETWORK: bridge
242262

263+
boot-docker-weave:
264+
<<: *image_boot
265+
environment:
266+
- KUBE_RUNTIME: docker
267+
- KUBE_NETWORK: weave
268+
269+
#boot-docker-bridge:
270+
# <<: *image_boot
271+
# environment:
272+
# - KUBE_RUNTIME: docker
273+
# - KUBE_NETWORK: bridge
274+
275+
#boot-cri-containerd-weave:
276+
# <<: *image_boot
277+
# environment:
278+
# - KUBE_RUNTIME: cri-containerd
279+
# - KUBE_NETWORK: weave
280+
281+
boot-cri-containerd-bridge:
282+
<<: *image_boot
283+
environment:
284+
- KUBE_RUNTIME: cri-containerd
285+
- KUBE_NETWORK: bridge
286+
243287
push-pkgs-to-hub:
244288
docker:
245289
- image: debian:stretch
@@ -332,6 +376,22 @@ workflows:
332376
- pkg-kubelet
333377
- pkg-cri-containerd
334378

379+
- boot-docker-weave:
380+
requires:
381+
- image-docker-weave
382+
383+
#- boot-docker-bridge:
384+
# requires:
385+
# - image-docker-bridge
386+
387+
#- boot-cri-containerd-weave:
388+
# requires:
389+
# - image-cri-containerd-weave
390+
391+
- boot-cri-containerd-bridge:
392+
requires:
393+
- image-cri-containerd-bridge
394+
335395
- push-pkgs-to-hub:
336396
# We want everything to have passed, which is a bit
337397
# tedious. Some of these are already covered transitively,
@@ -346,3 +406,7 @@ workflows:
346406
- image-docker-bridge
347407
- image-cri-containerd-weave
348408
- image-cri-containerd-bridge
409+
- boot-docker-weave
410+
#- boot-docker-bridge
411+
#- boot-cri-containerd-weave
412+
- boot-cri-containerd-bridge

ssh_into_kubelet.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sshopts="-o LogLevel=FATAL \
44
-o StrictHostKeyChecking=no \
55
-o UserKnownHostsFile=/dev/null \
66
-o IdentitiesOnly=yes \
7-
$SSHOPTS"
7+
${SSHOPTS:-}"
88

99
case $(uname -s) in
1010
Linux)

test.exp

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/usr/bin/env expect
2+
3+
set con_prompt "(ns: getty) linuxkit-*:*# "
4+
set ssh_prompt "linuxkit-*:*# "
5+
6+
proc kill args {
7+
foreach what $args {
8+
global $what
9+
if [info exists $what] {
10+
upvar #0 $what sid
11+
set pid [exp_pid -i $sid]
12+
puts "killing $what ($sid) = $pid"
13+
exec /bin/kill $pid
14+
close $sid
15+
} else {
16+
puts "not killing $what (not started)"
17+
}
18+
}
19+
}
20+
21+
proc boot_linuxkit {} {
22+
global lk_sid
23+
# medium circle CI has 4G of RAM, use 3.5G for VM
24+
spawn env {KUBE_RUN_ARGS=-publish 2222:22} KUBE_MEM=3584 KUBE_DISK=8G KUBE_CLEAR_STATE=y KUBE_MASTER_UNTAINT=y ./boot.sh
25+
set lk_sid $spawn_id
26+
puts "INFO lk ($lk_sid) is pid [exp_pid -i $lk_sid]"
27+
}
28+
29+
proc ssh_into_kubelet {} {
30+
global ssh_sid
31+
spawn env {SSHOPTS=-p 2222 -o ConnectTimeout=5 -o LogLevel=DEBUG} ./ssh_into_kubelet.sh localhost
32+
set ssh_sid $spawn_id
33+
puts "INFO ssh ($ssh_sid) is pid [exp_pid -i $ssh_sid]"
34+
}
35+
36+
proc await_prompt {sidvar promptvar step} {
37+
upvar #0 $sidvar sid $promptvar prompt
38+
expect -i $sid -timeout 60 \
39+
$prompt {
40+
puts "SUCCESS $step"
41+
} timeout {
42+
puts "FAIL $step (timeout)"
43+
kill ssh_sid lk_sid
44+
exit 1
45+
} eof {
46+
puts "FAIL $step (eof)"
47+
kill ssh_sid lk_sid
48+
exit 1
49+
}
50+
}
51+
52+
proc await_con_prompt {step} {
53+
global lk_sid con_prompt
54+
await_prompt lk_sid con_prompt $step
55+
}
56+
57+
proc await_ssh_prompt {step} {
58+
global ssh_sid ssh_prompt
59+
await_prompt ssh_sid ssh_prompt $step
60+
}
61+
62+
boot_linuxkit
63+
64+
await_con_prompt "boot"
65+
66+
send -i $lk_sid "ifconfig eth0\n"
67+
await_con_prompt "ifconfig"
68+
69+
ssh_into_kubelet
70+
# provide ssh_sid as an indirect, allowing ssh to be respawned, which
71+
# changes the id, we need this in case ssh cannot immediately connect.
72+
expect -i ssh_sid -timeout 180 \
73+
$ssh_prompt {
74+
puts "SUCCESS connected to ssh"
75+
} "read: Connection reset by peer" {
76+
# ssh happened too soon, wait a bit.
77+
puts "RETRY ssh (conn reset)"
78+
wait -i $ssh_sid
79+
sleep 3
80+
ssh_into_kubelet
81+
exp_continue -continue_timer
82+
} eof {
83+
puts "RETRY ssh (eof)"
84+
wait -i $ssh_sid
85+
sleep 3
86+
ssh_into_kubelet
87+
exp_continue -continue_timer
88+
} timeout {
89+
puts "FAIL ssh (timeout)"
90+
kill ssh_sid lk_sid
91+
exit 1
92+
}
93+
94+
puts "RUN kubeadm-init.sh"
95+
send -i ssh_sid "kubeadm-init.sh\n"
96+
97+
expect -i $ssh_sid -timeout 180 \
98+
"Your Kubernetes master has initialized successfully!" {
99+
puts "SUCCESS cluster initialised!"
100+
} timeout {
101+
puts "FAIL kubeadm-init.sh (timeout)"
102+
kill ssh_sid lk_sid
103+
exit 1
104+
} eof {
105+
puts "FAIL kubeadm-init.sh (eof)"
106+
kill ssh_sid lk_sid
107+
exit 1
108+
}
109+
110+
await_ssh_prompt "kubeadm-init.sh"
111+
112+
puts "RUN poweroff -f"
113+
send -i $lk_sid "poweroff -f\n"
114+
115+
expect -i $lk_sid -timeout 60 \
116+
"Power down" {
117+
puts "SUCCESS poweroff"
118+
} eof {
119+
puts "SUCCESS poweroff"
120+
} timeout {
121+
puts "FAILED poweroff (timeout)"
122+
kill ssh_sid
123+
exit 1
124+
}

0 commit comments

Comments
 (0)