mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-18 17:01:07 +00:00
test cases for volumes
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
parent
a5085fc9ea
commit
38a0cb6376
15
test/cases/000_build/070_volumes/000_rw_on_rw/check.sh
Executable file
15
test/cases/000_build/070_volumes/000_rw_on_rw/check.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
function failed {
|
||||
printf "rw_on_rw test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# check that the files we created are there and have the contents
|
||||
|
||||
[ -d /vola ] || failed
|
||||
[ -e /vola/mytestfile ] || failed
|
||||
[ "$(cat /vola/mytestfile)" == "file" ] || failed
|
||||
printf "rw_on_rw test suite PASSED\n" >&1
|
26
test/cases/000_build/070_volumes/000_rw_on_rw/test.sh
Executable file
26
test/cases/000_build/070_volumes/000_rw_on_rw/test.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that writing to a volume makes it visible
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -ex
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=volume_rw_on_rw
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-* ${DISK}
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
|
||||
linuxkit build --format kernel+initrd --name ${NAME} test.yml
|
||||
RESULT="$(linuxkit run ${NAME})"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
31
test/cases/000_build/070_volumes/000_rw_on_rw/test.yml
Normal file
31
test/cases/000_build/070_volumes/000_rw_on_rw/test.yml
Normal file
@ -0,0 +1,31 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:6.6.13
|
||||
cmdline: "console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:872d2e1be745f1acb948762562cf31c367303a3b
|
||||
- linuxkit/runc:6062483d748609d505f2bcde4e52ee64a3329f5f
|
||||
onboot:
|
||||
- name: test1
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /write.sh:/write.sh
|
||||
- vola:/vola
|
||||
command: ["sh", "-c", "/write.sh"]
|
||||
- name: test2
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
- vola:/vola
|
||||
command: ["sh", "-c", "/check.sh"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:401dc53c604c0b2179ed0369a6968fd4179cc176
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
volumes:
|
||||
- name: vola
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
mode: "0700"
|
||||
- path: write.sh
|
||||
source: ./write.sh
|
||||
mode: "0700"
|
5
test/cases/000_build/070_volumes/000_rw_on_rw/write.sh
Executable file
5
test/cases/000_build/070_volumes/000_rw_on_rw/write.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
echo -n "file" > /vola/mytestfile
|
15
test/cases/000_build/070_volumes/001_ro_on_ro/check.sh
Executable file
15
test/cases/000_build/070_volumes/001_ro_on_ro/check.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
function failed {
|
||||
printf "ro_on_ro test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# this should fail as it is read-only
|
||||
echo -n "file" > /vola/mytestfile || true
|
||||
|
||||
[ -e /vola/mytestfile ] && failed
|
||||
|
||||
printf "ro_on_ro test suite PASSED\n" >&1
|
26
test/cases/000_build/070_volumes/001_ro_on_ro/test.sh
Executable file
26
test/cases/000_build/070_volumes/001_ro_on_ro/test.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that writing to a volume makes it visible
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -ex
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=volume_ro_on_ro
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-* ${DISK}
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
|
||||
linuxkit build --format kernel+initrd --name ${NAME} test.yml
|
||||
RESULT="$(linuxkit run ${NAME})"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
23
test/cases/000_build/070_volumes/001_ro_on_ro/test.yml
Normal file
23
test/cases/000_build/070_volumes/001_ro_on_ro/test.yml
Normal file
@ -0,0 +1,23 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:6.6.13
|
||||
cmdline: "console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:872d2e1be745f1acb948762562cf31c367303a3b
|
||||
- linuxkit/runc:6062483d748609d505f2bcde4e52ee64a3329f5f
|
||||
onboot:
|
||||
- name: test
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
- vola:/vola:ro
|
||||
command: ["sh", "-c", "/check.sh"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:401dc53c604c0b2179ed0369a6968fd4179cc176
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
volumes:
|
||||
- name: vola
|
||||
readonly: true
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
mode: "0700"
|
15
test/cases/000_build/070_volumes/002_rw_on_ro/check.sh
Executable file
15
test/cases/000_build/070_volumes/002_rw_on_ro/check.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
function failed {
|
||||
printf "rw_on_ro test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# this should fail as it is read-only
|
||||
echo -n "file" > /vola/mytestfile || true
|
||||
|
||||
[ -e /vola/mytestfile ] && failed
|
||||
|
||||
printf "rw_on_ro test suite PASSED\n" >&1
|
29
test/cases/000_build/070_volumes/002_rw_on_ro/test.sh
Executable file
29
test/cases/000_build/070_volumes/002_rw_on_ro/test.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that writing to a volume makes it visible
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -ex
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=volume_rw_on_r0
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-* ${DISK}
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
|
||||
set +e
|
||||
linuxkit build --format kernel+initrd --name ${NAME} test.yml
|
||||
retcode=$?
|
||||
set -e
|
||||
|
||||
# the build should fail, as we have are mounting a read-only volume as read-write in a container
|
||||
if [ $retcode -eq 0 ]; then
|
||||
exit 1
|
||||
fi
|
23
test/cases/000_build/070_volumes/002_rw_on_ro/test.yml
Normal file
23
test/cases/000_build/070_volumes/002_rw_on_ro/test.yml
Normal file
@ -0,0 +1,23 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:6.6.13
|
||||
cmdline: "console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:872d2e1be745f1acb948762562cf31c367303a3b
|
||||
- linuxkit/runc:6062483d748609d505f2bcde4e52ee64a3329f5f
|
||||
onboot:
|
||||
- name: test
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
- vola:/vola
|
||||
command: ["sh", "-c", "/check.sh"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:401dc53c604c0b2179ed0369a6968fd4179cc176
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
volumes:
|
||||
- name: vola
|
||||
readonly: true
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
mode: "0700"
|
14
test/cases/000_build/070_volumes/003_ro_on_rw/check.sh
Executable file
14
test/cases/000_build/070_volumes/003_ro_on_rw/check.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
function failed {
|
||||
printf "ro_on_rw test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# the file should not exist, as it was mounted read-only
|
||||
|
||||
[ -d /vola ] || failed
|
||||
[ -e /vola/mytestfile ] && failed
|
||||
printf "ro_on_rw test suite PASSED\n" >&1
|
26
test/cases/000_build/070_volumes/003_ro_on_rw/test.sh
Executable file
26
test/cases/000_build/070_volumes/003_ro_on_rw/test.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that writing to a volume makes it visible
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -ex
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=volume_ro_on_rw
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-* ${DISK}
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
|
||||
linuxkit build --format kernel+initrd --name ${NAME} test.yml
|
||||
RESULT="$(linuxkit run ${NAME})"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
28
test/cases/000_build/070_volumes/003_ro_on_rw/test.yml
Normal file
28
test/cases/000_build/070_volumes/003_ro_on_rw/test.yml
Normal file
@ -0,0 +1,28 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:6.6.13
|
||||
cmdline: "console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:872d2e1be745f1acb948762562cf31c367303a3b
|
||||
- linuxkit/runc:6062483d748609d505f2bcde4e52ee64a3329f5f
|
||||
onboot:
|
||||
- name: test1
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /write.sh:/write.sh
|
||||
- vola:/vola:ro
|
||||
command: ["sh", "-c", "/write.sh"]
|
||||
- name: test2
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
- vola:/vola:ro
|
||||
command: ["sh", "-c", "/check.sh"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:401dc53c604c0b2179ed0369a6968fd4179cc176
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
volumes:
|
||||
- name: vola
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
mode: "0700"
|
15
test/cases/000_build/070_volumes/003_ro_on_rw/write.sh
Executable file
15
test/cases/000_build/070_volumes/003_ro_on_rw/write.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
function failed {
|
||||
printf "ro_on_ro test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# this should fail as it is read-only
|
||||
echo -n "file" > /vola/mytestfile || true
|
||||
|
||||
[ -e /vola/mytestfile ] && failed
|
||||
|
||||
printf "ro_on_ro test suite PASSED\n" >&1
|
16
test/cases/000_build/070_volumes/004_blank/check.sh
Executable file
16
test/cases/000_build/070_volumes/004_blank/check.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
function failed {
|
||||
printf "blank volume test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# check that no files exist
|
||||
|
||||
[ -d /vola ] || failed
|
||||
|
||||
contents=$(ls -A /vola)
|
||||
[ -z "$contents" ] || failed
|
||||
printf "blank volume test suite PASSED\n" >&1
|
26
test/cases/000_build/070_volumes/004_blank/test.sh
Executable file
26
test/cases/000_build/070_volumes/004_blank/test.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that writing to a volume makes it visible
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -ex
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=volume_blank
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-* ${DISK}
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
|
||||
linuxkit build --format kernel+initrd --name ${NAME} test.yml
|
||||
RESULT="$(linuxkit run ${NAME})"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
22
test/cases/000_build/070_volumes/004_blank/test.yml
Normal file
22
test/cases/000_build/070_volumes/004_blank/test.yml
Normal file
@ -0,0 +1,22 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:6.6.13
|
||||
cmdline: "console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:872d2e1be745f1acb948762562cf31c367303a3b
|
||||
- linuxkit/runc:6062483d748609d505f2bcde4e52ee64a3329f5f
|
||||
onboot:
|
||||
- name: test
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
- vola:/vola
|
||||
command: ["sh", "-c", "/check.sh"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:401dc53c604c0b2179ed0369a6968fd4179cc176
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
volumes:
|
||||
- name: vola
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
mode: "0700"
|
17
test/cases/000_build/070_volumes/005_image/check.sh
Executable file
17
test/cases/000_build/070_volumes/005_image/check.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
function failed {
|
||||
printf "blank volume test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# check that no files exist
|
||||
|
||||
[ -d /vola ] || failed
|
||||
|
||||
contents=$(ls -A /vola)
|
||||
[ -n "$contents" ] || failed
|
||||
[ -e "/vola/bin/busybox" ] || failed
|
||||
printf "blank volume test suite PASSED\n" >&1
|
26
test/cases/000_build/070_volumes/005_image/test.sh
Executable file
26
test/cases/000_build/070_volumes/005_image/test.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that writing to a volume makes it visible
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -ex
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=volume_image
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-* ${DISK}
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
|
||||
linuxkit build --format kernel+initrd --name ${NAME} test.yml
|
||||
RESULT="$(linuxkit run ${NAME})"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
23
test/cases/000_build/070_volumes/005_image/test.yml
Normal file
23
test/cases/000_build/070_volumes/005_image/test.yml
Normal file
@ -0,0 +1,23 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:6.6.13
|
||||
cmdline: "console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:872d2e1be745f1acb948762562cf31c367303a3b
|
||||
- linuxkit/runc:6062483d748609d505f2bcde4e52ee64a3329f5f
|
||||
onboot:
|
||||
- name: test
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
- vola:/vola
|
||||
command: ["sh", "-c", "/check.sh"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:401dc53c604c0b2179ed0369a6968fd4179cc176
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
volumes:
|
||||
- name: vola
|
||||
image: alpine:3.19
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
mode: "0700"
|
17
test/cases/000_build/070_volumes/006_mount_types/check.sh
Executable file
17
test/cases/000_build/070_volumes/006_mount_types/check.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
function failed {
|
||||
printf "blank volume test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# check that no files exist
|
||||
|
||||
[ -d /vola ] || failed
|
||||
|
||||
contents=$(ls -A /vola)
|
||||
[ -n "$contents" ] || failed
|
||||
[ -e "/vola/bin/busybox" ] || failed
|
||||
printf "blank volume test suite PASSED\n" >&1
|
26
test/cases/000_build/070_volumes/006_mount_types/test.sh
Executable file
26
test/cases/000_build/070_volumes/006_mount_types/test.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that writing to a volume makes it visible
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -ex
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=volume_mount_types
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-* ${DISK}
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
|
||||
linuxkit build --format kernel+initrd --name ${NAME} test.yml
|
||||
RESULT="$(linuxkit run ${NAME})"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
38
test/cases/000_build/070_volumes/006_mount_types/test.yml
Normal file
38
test/cases/000_build/070_volumes/006_mount_types/test.yml
Normal file
@ -0,0 +1,38 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:6.6.13
|
||||
cmdline: "console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:872d2e1be745f1acb948762562cf31c367303a3b
|
||||
- linuxkit/runc:6062483d748609d505f2bcde4e52ee64a3329f5f
|
||||
onboot:
|
||||
- name: testbinds
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
- vola:/vola
|
||||
command: ["sh", "-c", "/check.sh"]
|
||||
- name: testmounts
|
||||
image: alpine:3.20
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
mounts:
|
||||
- type: bind
|
||||
source: vola
|
||||
destination: /vola
|
||||
command: ["sh", "-c", "/check.sh"]
|
||||
- name: testbindadds
|
||||
image: alpine:3.20
|
||||
binds.add:
|
||||
- /check.sh:/check.sh
|
||||
- vola:/vola
|
||||
command: ["sh", "-c", "/check.sh"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:401dc53c604c0b2179ed0369a6968fd4179cc176
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
volumes:
|
||||
- name: vola
|
||||
image: alpine:3.19
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
mode: "0700"
|
Loading…
Reference in New Issue
Block a user