mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
test: ensure ctr works in getty container
This is based on examples/getty.yml modified to drop console=tty0 from the command line since we will be capturing/logging only the serial so want everything to go there. Also updates the getty example to pickup the latest containerd and ca-certificates as used in the top level linuxkit.yml. Fix a typo in the containerd test too. Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
parent
fb4c168af7
commit
3809391545
@ -4,8 +4,8 @@ kernel:
|
||||
init:
|
||||
- linuxkit/init:17693d233dd009b2a3a8d23673cb85969e1dce80
|
||||
- linuxkit/runc:3a4e6cbf15470f62501b019b55e1caac5ee7689f
|
||||
- linuxkit/containerd:b1766e4c4c09f63ac4925a6e4612852a93f7e73b
|
||||
- linuxkit/ca-certificates:eabc5a6e59f05aa91529d80e9a595b85b046f935
|
||||
- linuxkit/containerd:a33cdcf50b8107ffe14c92802c460fe7ada39acd
|
||||
- linuxkit/ca-certificates:75cf419fb58770884c3464eb687ec8dfc704169d
|
||||
onboot:
|
||||
- name: sysctl
|
||||
image: "linuxkit/sysctl:3aa6bc663c2849ef239be7d941d3eaf3e6fcc018"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Run contianerd test
|
||||
# SUMMARY: Run containerd test
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
|
22
test/cases/040_packages/007_getty-containerd/test-ctr.yml
Normal file
22
test/cases/040_packages/007_getty-containerd/test-ctr.yml
Normal file
@ -0,0 +1,22 @@
|
||||
kernel:
|
||||
image: "linuxkit/kernel:4.9.x"
|
||||
cmdline: "console=ttyS0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:17693d233dd009b2a3a8d23673cb85969e1dce80
|
||||
- linuxkit/runc:3a4e6cbf15470f62501b019b55e1caac5ee7689f
|
||||
- linuxkit/containerd:a33cdcf50b8107ffe14c92802c460fe7ada39acd
|
||||
- linuxkit/ca-certificates:75cf419fb58770884c3464eb687ec8dfc704169d
|
||||
onboot:
|
||||
- name: dhcpcd
|
||||
image: "linuxkit/dhcpcd:7d2b8aaaf20c24ad7d11a5ea2ea5b4a80dc966f1"
|
||||
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
|
||||
services:
|
||||
- name: getty
|
||||
image: "linuxkit/getty:9f27c1272b6d128c9a09745e916f151d09cb0d27"
|
||||
files:
|
||||
- path: etc/getty.shadow
|
||||
# sample sets password for root to "abcdefgh" (without quotes)
|
||||
contents: 'root:$6$6tPd2uhHrecCEKug$8mKfcgfwguP7f.BLdZsT1Wz7WIIJOBY1oUFHzIv9/O71M2J0EPdtFqFGTxB1UK5ejqQxRFQ.ZSG9YXR0SNsc11:17322:0:::::'
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
96
test/cases/040_packages/007_getty-containerd/test.exp
Executable file
96
test/cases/040_packages/007_getty-containerd/test.exp
Executable file
@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env expect
|
||||
spawn linuxkit run test-ctr
|
||||
set pid [exp_pid]
|
||||
set timeout 60
|
||||
set prompt ":~# "
|
||||
|
||||
expect {
|
||||
timeout {
|
||||
puts "FAILED boot"
|
||||
exec kill -9 $pid
|
||||
exit 1
|
||||
}
|
||||
"Welcome to LinuxKit" {
|
||||
puts "SUCCESS boot"
|
||||
}
|
||||
}
|
||||
expect {
|
||||
timeout {
|
||||
puts "FAILED login user"
|
||||
exec kill -9 $pid
|
||||
exit 1
|
||||
}
|
||||
"ogin: " {
|
||||
send "root\n"
|
||||
}
|
||||
}
|
||||
expect {
|
||||
timeout {
|
||||
puts "FAILED login pass"
|
||||
exec kill -9 $pid
|
||||
exit 1
|
||||
}
|
||||
"assword: " {
|
||||
send "abcdefgh\n"
|
||||
}
|
||||
}
|
||||
|
||||
expect {
|
||||
timeout {
|
||||
puts "FAILED dist pull"
|
||||
exec kill -9 $pid
|
||||
exit 1
|
||||
}
|
||||
$prompt {
|
||||
send "dist pull docker.io/library/redis:alpine\n"
|
||||
}
|
||||
}
|
||||
expect {
|
||||
timeout {
|
||||
puts "FAILED dist pull"
|
||||
exec kill -9 $pid
|
||||
exit 1
|
||||
}
|
||||
$prompt {
|
||||
puts "SUCCESS dist pull"
|
||||
send "ctr run -t docker.io/library/redis:alpine test\n"
|
||||
}
|
||||
}
|
||||
expect {
|
||||
timeout {
|
||||
puts "FAILED ctr run"
|
||||
exec kill -9 $pid
|
||||
exit 1
|
||||
}
|
||||
"The server is now ready to accept connections on port 6379" {
|
||||
puts "SUCCESS ctr run"
|
||||
# Ctrl-C
|
||||
send "\003"
|
||||
}
|
||||
}
|
||||
expect {
|
||||
timeout {
|
||||
puts "FAILED kill ctr"
|
||||
exec kill -9 $pid
|
||||
exit 1
|
||||
}
|
||||
$prompt {
|
||||
send "poweroff -f\n"
|
||||
}
|
||||
}
|
||||
expect {
|
||||
timeout {
|
||||
puts "FAILED poweroff"
|
||||
exec kill -9 $pid
|
||||
exit 1
|
||||
}
|
||||
"Power down" {
|
||||
puts "SUCCESS poweroff"
|
||||
}
|
||||
eof {
|
||||
puts "SUCCESS poweroff"
|
||||
}
|
||||
}
|
||||
set waitval [wait -i $spawn_id]
|
||||
set exval [lindex $waitval 3]
|
||||
exit $exval
|
24
test/cases/040_packages/007_getty-containerd/test.sh
Executable file
24
test/cases/040_packages/007_getty-containerd/test.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that ctr can run containers
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=test-ctr
|
||||
|
||||
clean_up() {
|
||||
find . -iname "test-ctr*" -not -iname "*.yml" -exec rm -rf {} \;
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
moby build "${NAME}.yml"
|
||||
[ -f "${NAME}-kernel" ] || exit 1
|
||||
[ -f "${NAME}-initrd.img" ] || exit 1
|
||||
[ -f "${NAME}-cmdline" ]|| exit 1
|
||||
./test.exp
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user