Add a test suite

This adds a test suite to be executed using `linuxkit/rtf`.
This is installed in the top-level Makefile

The tests are written in shell script and cover the following cases:

- Kernel Config is OK!
- Kernel Modules can be built and loaded
- QEMU can build and run kernel+initrd, iso-bios and iso-uefi
- That we can build for all other supported output formats
- That all of the examples in `./examples` can be built
- The LTP tests can be run (if `-l slow` is provided)

The virtsock and docker-bench tests were migrated but no test has been
written as yet as AFAICT they are still a WIP

Signed-off-by: Dave Tucker <dt@docker.com>
This commit is contained in:
Dave Tucker
2017-05-02 09:57:34 +01:00
committed by Dave Tucker
parent 7027dc814c
commit ce2bdea399
53 changed files with 1123 additions and 66 deletions

2
test/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
_results
cases/_tmp

View File

@@ -1,11 +1,13 @@
.PHONY: default pr all
default: check-deps kernel-config
pr: check-deps kernel-config ../artifacts/test.img.tar.gz
all: check-deps kernel-config ltp ../artifacts/test.img.tar.gz ../artifacts/test-ltp.img.tar.gz
default: check-deps test
pr: check-deps test-pr
# TODO: all should point to test-all once ltp is no longer required
all: check-deps test-pr ltp
MOBY:=$(shell command -v moby 2> /dev/null)
LINUXKIT:=$(shell command -v linuxkit 2> /dev/null)
RTF:=$(shell command -v rtf 2> /dev/null)
.PHONY: check-deps
check-deps:
@@ -15,54 +17,31 @@ endif
ifndef LINUXKIT
$(error "linuxkit binary not found. please install it.")
endif
ifndef RTF
$(error "rtf is not available. please install it!")
endif
# TODO: Remove this section once we no longer depend on this in CI
### -------
define check_test_log
@cat $1 |grep -q 'test suite PASSED'
endef
../artifacts:
mkdir -p $@
test-kernel-config-initrd.img: $(MOBY) cases/test-kernel-config.yml
$(MOBY) build --pull cases/test-kernel-config.yml
# uses qemu
.PHONY: kernel-config
kernel-config: $(LINUXKIT) test-kernel-config-initrd.img test-kernel-config-kernel test-kernel-config-cmdline
$(LINUXKIT) run qemu test-kernel-config 2>&1 | tee test.log
$(call check_test_log, test.log)
# qemu only at this time
.PHONY: qemu-efi
efi: $(LINUXKIT) test-kernel-config-efi.iso
$(LINUXKIT) run qemu -uefi test-kernel-config | tee test-efi.log
$(call check_test_log, test-efi.log)
# For GCP tests
../artifacts/test.img.tar.gz: test-kernel-config.img.tar.gz | ../artifacts
mv test-kernel-config.img.tar.gz ../artifacts/test.img.tar.gz
.PHONY: gcp
gcp: export CLOUDSDK_IMAGE_NAME?=test-kernel-config
gcp: $(LINUXKIT) ../test.img.tar.gz
$(LINUXKIT) push gcp ../artifacts/test.img.tar.gz
$(LINUXKIT) run gcp $(CLOUDSDK_IMAGE_NAME) | tee test-gcp.log
$(call check_test_log, test-gcp.log)
# For LTP tests
test-ltp.img.tar.gz: $(MOBY) cases/test-ltp.yml
$(MOBY) build --pull cases/test-ltp.yml
../artifacts/test-ltp.img.tar.gz: test-ltp.img.tar.gz | ../artifacts
mv test-ltp.img.tar.gz ../artifacts
.PHONY: ltp
ltp: export CLOUDSDK_IMAGE_NAME?=test-ltp
ltp: $(LINUXKIT) test-ltp.img.tar.gz
$(LINUXKIT) push gcp ../artifacts/test-ltp.img.tar.gz
$(MOBY) build --pull cases/020_stress/000_ltp/test-ltp.yml
$(LINUXKIT) push gcp test-ltp.img.tar.gz
$(LINUXKIT) run gcp -skip-cleanup -machine n1-highcpu-4 $(CLOUDSDK_IMAGE_NAME) | tee test-ltp.log
$(call check_test_log, test-ltp.log)
### ------
.PHONY: clean
clean:
rm -rf bin *.log *-kernel *-cmdline *.img *.iso *.tar.gz *.qcow2 *.vhd *.vmx *.vmdk
test:
@rtf -l build -x run
test-pr:
@rtf -vvv -l build -x run
test-all:
@rtf -vvv -x -l build,slow run

19
test/README.md Normal file
View File

@@ -0,0 +1,19 @@
Linuxkit Tests Labels
=====================
## Usage of Artifacts vs Temporary Directory
As the Build Machines have no secrets they will not be able to test running the build output on any cloud providers.
In this instance, the build tests should copy their output to the `LINUXKIT_ARTIFACTS_DIRECTORY`
## Labels
The `gcp` label is applied when the system where the tests are being run meets the requirements for using Google Cloud Platform.
These requirements are:
- The system has the necessary `CLOUDSDK_*` environment variables exported
- The system has either keys for a GCP service account or is able to use application default credentials
The `packet.net` label is applied when a system is able to create machines on Packet.net
The `vmware` label is used when the machine has VMware Workstation or Fusion installed

View File

@@ -21,7 +21,6 @@ onboot:
- name: check-kernel-config
image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c"
readonly: true
services:
- name: poweroff
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
pid: host
@@ -31,6 +30,3 @@ services:
readonly: true
outputs:
- format: kernel+initrd
- format: iso-bios
- format: iso-efi
- format: gcp-img

View File

@@ -0,0 +1,23 @@
#!/bin/sh
# SUMMARY: Test the kernel configuration is suitable for running Docker
# LABELS:
# REPEAT:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() {
find . -iname "test-kernel-config*" -not -iname "*.yml" -exec rm -rf {} \;
}
trap clean_up EXIT
# Test code goes here
moby build test-kernel-config
RESULT="$(linuxkit run qemu test-kernel-config)"
echo "${RESULT}" | grep -q "suite PASSED"
exit 0

View File

@@ -13,5 +13,12 @@ onboot:
- /lib/modules:/lib/modules
capabilities:
- all
- name: poweroff
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
pid: host
command: ["/bin/sh", "/poweroff.sh", "3"]
capabilities:
- CAP_SYS_BOOT
readonly: true
outputs:
- format: kernel+initrd

View File

@@ -0,0 +1,28 @@
#!/bin/sh
# SUMMARY: Test build and insertion of kernel modules
# LABELS:
# REPEAT:
# AUTHOR: Rolf Neugebauer <rolf.neugebauer@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME="kmod-test"
clean_up() {
docker rmi ${IMAGE_NAME} || true
find . -iname "kmod*" -not -iname "*.yml" -exec rm -rf {} \;
}
trap clean_up EXIT
# Make sure we have the latest kernel image
docker pull linuxkit/kernel:4.9.x
# Build a package
docker build -t ${IMAGE_NAME} .
# Build a LinuxKit image with kernel module (and test script)
moby build kmod
# Run it
linuxkit run qemu kmod | grep -q "Hello LinuxKit"

View File

@@ -0,0 +1,37 @@
#!/bin/sh
# SUMMARY: LinuxKit configuration tests
# LABELS:
# For the top level group.sh also specify a 'NAME:' comment
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
group_init() {
# Group initialisation code goes here
return 0
}
group_deinit() {
# Group de-initialisation code goes here
return 0
}
CMD=$1
case $CMD in
init)
group_init
res=$?
;;
deinit)
group_deinit
res=$?
;;
*)
res=1
;;
esac
exit $res

View File

@@ -0,0 +1,28 @@
#!/bin/sh
# SUMMARY: Test building an image for qemu
# LABELS: build
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=test-qemu-build
clean_up() {
# remove any files, containers, images etc
find . -iname "${IMAGE_NAME}*" -not -iname "*.yml" -exec rm {} \;
}
trap clean_up EXIT
# Test code goes here
moby build -name "${IMAGE_NAME}" test.yml
[ -f "${IMAGE_NAME}-kernel" ] || exit 1
[ -f "${IMAGE_NAME}-initrd.img" ] || exit 1
[ -f "${IMAGE_NAME}-cmdline" ]|| exit 1
find . -iname "${IMAGE_NAME}-*" -exec cp {} "${LINUXKIT_TMPDIR}/{}" \;
exit 0

View File

@@ -0,0 +1,31 @@
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init:
- linuxkit/init:f71c3b30ac1ba4ef16c160c89610fa4976f9752f
- linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9
- linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed
onboot:
- name: dhcpcd
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
binds:
- /var:/var
- /tmp/etc:/etc
capabilities:
- CAP_NET_ADMIN
- CAP_NET_BIND_SERVICE
- CAP_NET_RAW
net: host
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: poweroff
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
pid: host
command: ["/bin/sh", "/poweroff.sh", "10"]
capabilities:
- CAP_SYS_BOOT
readonly: true
trust:
image:
- linuxkit/kernel
outputs:
- format: kernel+initrd

View File

@@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Test running an image with qemu
# LABELS:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=test-qemu-build
clean_up() {
# remove any files, containers, images etc
rm -rf "${LINUXKIT_TMPDIR:?}/${IMAGE_NAME:?}*" || true
}
trap clean_up EXIT
# Test code goes here
[ -f "${LINUXKIT_TMPDIR}/${IMAGE_NAME}-kernel" ] || exit 1
linuxkit run qemu "${LINUXKIT_TMPDIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit"
exit 0

View File

@@ -0,0 +1,26 @@
#!/bin/sh
# SUMMARY: Test building an ISO image for qemu
# LABELS: build
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=test-qemu-build
clean_up() {
# remove any files, containers, images etc
find . -iname "${IMAGE_NAME}*" -not -iname "*.yml" -exec rm {} \;
}
trap clean_up EXIT
# Test code goes here
moby build -name "${IMAGE_NAME}" test.yml
[ -f "${IMAGE_NAME}.iso" ] || exit 1
cp "${IMAGE_NAME}.iso" "${LINUXKIT_TMPDIR}/"
exit 0

View File

@@ -0,0 +1,31 @@
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init:
- linuxkit/init:f71c3b30ac1ba4ef16c160c89610fa4976f9752f
- linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9
- linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed
onboot:
- name: dhcpcd
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
binds:
- /var:/var
- /tmp/etc:/etc
capabilities:
- CAP_NET_ADMIN
- CAP_NET_BIND_SERVICE
- CAP_NET_RAW
net: host
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: poweroff
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
pid: host
command: ["/bin/sh", "/poweroff.sh", "10"]
capabilities:
- CAP_SYS_BOOT
readonly: true
trust:
image:
- linuxkit/kernel
outputs:
- format: iso-bios

View File

@@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Test running an ISO image with qemu
# LABELS:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=test-qemu-build
clean_up() {
# remove any files, containers, images etc
rm -rf "${LINUXKIT_TMPDIR:?}/${IMAGE_NAME:?}*" || true
}
trap clean_up EXIT
# Test code goes here
[ -f "${LINUXKIT_TMPDIR}/${IMAGE_NAME}.iso" ] || exit 1
linuxkit run qemu -iso "${LINUXKIT_TMPDIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit"
exit 0

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# SUMMARY: Test building a UEFI image for qemu
# LABELS: build
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=test-qemu-build
clean_up() {
# remove any files, containers, images etc
find . -iname "${IMAGE_NAME}*" -not -iname "*.yml" -exec rm {} \;
}
trap clean_up EXIT
# Test code goes here
moby build -name "${IMAGE_NAME}" test.yml
[ -f "${IMAGE_NAME}-efi.iso" ] || exit 1
cp "${IMAGE_NAME}-efi.iso" "${LINUXKIT_TMPDIR}/"
exit 0

View File

@@ -0,0 +1,31 @@
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init:
- linuxkit/init:f71c3b30ac1ba4ef16c160c89610fa4976f9752f
- linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9
- linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed
onboot:
- name: dhcpcd
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
binds:
- /var:/var
- /tmp/etc:/etc
capabilities:
- CAP_NET_ADMIN
- CAP_NET_BIND_SERVICE
- CAP_NET_RAW
net: host
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: poweroff
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
pid: host
command: ["/bin/sh", "/poweroff.sh", "10"]
capabilities:
- CAP_SYS_BOOT
readonly: true
trust:
image:
- linuxkit/kernel
outputs:
- format: iso-efi

View File

@@ -0,0 +1,31 @@
#!/bin/sh
# SUMMARY: Test running a UEFI image with qemu
# LABELS:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=test-qemu-build
clean_up() {
# remove any files, containers, images etc
rm -rf "${LINUXKIT_TMPDIR:?}/${IMAGE_NAME:?}*" || true
}
trap clean_up EXIT
if command -v qemu; then
if [ ! -f /usr/share/ovmf/bios.bin ]; then
exit RT_CANCEL
fi
fi
# Test code goes here
[ -f "${LINUXKIT_TMPDIR}/${IMAGE_NAME}-efi.iso" ] || exit 1
linuxkit run qemu -uefi "${LINUXKIT_TMPDIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit"
exit 0

View File

@@ -0,0 +1,35 @@
#!/bin/sh
# SUMMARY: Linuxkit Qemu Tests
# LABELS:
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
group_init() {
# Group initialisation code goes here
return 0
}
group_deinit() {
# Group de-initialisation code goes here
return 0
}
CMD=$1
case $CMD in
init)
group_init
res=$?
;;
deinit)
group_deinit
res=$?
;;
*)
res=1
;;
esac
exit $res

View File

@@ -0,0 +1,37 @@
#!/bin/sh
# SUMMARY: LinuxKit Hyperkit tests
# LABELS: darwin
# For the top level group.sh also specify a 'NAME:' comment
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
group_init() {
# Group initialisation code goes here
return 0
}
group_deinit() {
# Group de-initialisation code goes here
return 0
}
CMD=$1
case $CMD in
init)
group_init
res=$?
;;
deinit)
group_deinit
res=$?
;;
*)
res=1
;;
esac
exit $res

View File

@@ -0,0 +1,27 @@
#!/bin/sh
# SUMMARY: Test building an image for GCP
# LABELS: build
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=gcp
clean_up() {
# remove any files, containers, images etc
rm -rf ${IMAGE_NAME}*
}
trap clean_up EXIT
# Test code goes here
moby build -name "${IMAGE_NAME}" test.yml
[ -f "${IMAGE_NAME}.img.tar.gz" ] || exit 1
# As build and run on different machines, copy to the artifacts directory
cp -f "${IMAGE_NAME}.img.tar.gz" "${LINUXKIT_ARTIFACTS_DIR}/test.img.tar.gz"
exit 0

View File

@@ -0,0 +1,34 @@
# FIXME: This should use the minimal example
# We continue to use the kernel-config-test as CI is currently expecting to see a success message
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0"
init:
- linuxkit/init:deea956a9ab07bf262083e93a86930bdc610cc2f
- linuxkit/runc:2649198589ef0020d99f613adaeda45ce0093a38
- linuxkit/containerd:cf2614f5a96c569a0bd4bd54e054a65ba17d167f
- linuxkit/ca-certificates:3344cdca1bc59fdfa17bd7f0fcbf491b9dbaa288
onboot:
- name: dhcpcd
image: "linuxkit/dhcpcd:2def74ab3f9233b4c09ebb196ba47c27c08b0ed8"
binds:
- /var:/var
- /tmp:/etc
capabilities:
- CAP_NET_ADMIN
- CAP_NET_BIND_SERVICE
- CAP_NET_RAW
net: host
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: check-kernel-config
image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c"
readonly: true
- name: poweroff
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
pid: host
command: ["/bin/sh", "/poweroff.sh", "3"]
capabilities:
- CAP_SYS_BOOT
readonly: true
outputs:
- format: gcp-img

View File

@@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Test running an image with qemu
# LABELS: gcp
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=test
clean_up() {
# remove any files, containers, images etc
echo "Nothing to cleanup..."
}
trap clean_up EXIT
# Test code goes here
[ -f "${LINUXKIT_ARTIFACTS_DIR}/${IMAGE_NAME}.img.tar.gz" ] || exit 1
linuxkit run gcp "${LINUXKIT_ARTIFACTS_DIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit"
exit 0

View File

@@ -0,0 +1,37 @@
#!/bin/sh
# SUMMARY: LinuxKit configuration tests
# LABELS:
# For the top level group.sh also specify a 'NAME:' comment
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
group_init() {
# Group initialisation code goes here
return 0
}
group_deinit() {
# Group de-initialisation code goes here
return 0
}
CMD=$1
case $CMD in
init)
group_init
res=$?
;;
deinit)
group_deinit
res=$?
;;
*)
res=1
;;
esac
exit $res

View File

@@ -0,0 +1,27 @@
#!/bin/sh
# SUMMARY: Test building an image for packet.net
# LABELS: build
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=packet
clean_up() {
# remove any files, containers, images etc
rm -rf ${IMAGE_NAME}*
}
trap clean_up EXIT
# Test code goes here
moby build --name "${IMAGE_NAME}" test.yml
[ -f "${IMAGE_NAME}-kernel" ] || exit 1
# As build and run on different machines, copy to the artifacts directory
find . -iname "${IMAGE_NAME}-*" -exec cp {} "${LINUXKIT_ARTFACTS_DIR}/{}" \;
exit 0

View File

@@ -0,0 +1,31 @@
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init:
- linuxkit/init:f71c3b30ac1ba4ef16c160c89610fa4976f9752f
- linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9
- linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed
onboot:
- name: dhcpcd
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
binds:
- /var:/var
- /tmp/etc:/etc
capabilities:
- CAP_NET_ADMIN
- CAP_NET_BIND_SERVICE
- CAP_NET_RAW
net: host
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: poweroff
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
pid: host
command: ["/bin/sh", "/poweroff.sh", "10"]
capabilities:
- CAP_SYS_BOOT
readonly: true
trust:
image:
- linuxkit/kernel
outputs:
- format: kernel+initrd

View File

@@ -0,0 +1,37 @@
#!/bin/sh
# SUMMARY: LinuxKit configuration tests
# LABELS:
# For the top level group.sh also specify a 'NAME:' comment
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
group_init() {
# Group initialisation code goes here
return 0
}
group_deinit() {
# Group de-initialisation code goes here
return 0
}
CMD=$1
case $CMD in
init)
group_init
res=$?
;;
deinit)
group_deinit
res=$?
;;
*)
res=1
;;
esac
exit $res

View File

@@ -0,0 +1,27 @@
#!/bin/sh
# SUMMARY: Test building an image for VMware
# LABELS: build
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=vmware
clean_up() {
# remove any files, containers, images etc
rm -rf ${IMAGE_NAME}*
}
trap clean_up EXIT
# Test code goes here
moby build --name "${IMAGE_NAME}" test.yml
[ -f "${IMAGE_NAME}.vmdk" ] || exit 1
# As build and run on different machines, copy to the artifacts directory
cp "${IMAGE_NAME}.vmdk" "${LINUXKIT_ARTIFACTS_DIR}/"
exit 0

View File

@@ -0,0 +1,31 @@
kernel:
image: "linuxkit/kernel:4.9.x"
cmdline: "console=ttyS0 console=tty0 page_poison=1"
init:
- linuxkit/init:f71c3b30ac1ba4ef16c160c89610fa4976f9752f
- linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9
- linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed
onboot:
- name: dhcpcd
image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a"
binds:
- /var:/var
- /tmp/etc:/etc
capabilities:
- CAP_NET_ADMIN
- CAP_NET_BIND_SERVICE
- CAP_NET_RAW
net: host
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: poweroff
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
pid: host
command: ["/bin/sh", "/poweroff.sh", "10"]
capabilities:
- CAP_SYS_BOOT
readonly: true
trust:
image:
- linuxkit/kernel
outputs:
- format: vmdk

View File

@@ -0,0 +1,37 @@
#!/bin/sh
# SUMMARY: LinuxKit platform tests
# LABELS:
# For the top level group.sh also specify a 'NAME:' comment
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
group_init() {
# Group initialisation code goes here
return 0
}
group_deinit() {
# Group de-initialisation code goes here
return 0
}
CMD=$1
case $CMD in
init)
group_init
res=$?
;;
deinit)
group_deinit
res=$?
;;
*)
res=1
;;
esac
exit $res

View File

@@ -15,7 +15,6 @@ onboot:
- /etc/ltp/baseline:/etc/ltp/baseline
capabilities:
- all
services:
- name: poweroff
image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084"
pid: host
@@ -26,7 +25,4 @@ files:
- path: /etc/ltp/baseline
contents: "100"
outputs:
- format: kernel+initrd
- format: iso-bios
- format: iso-efi
- format: gcp-img

View File

@@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Run the Linux Testing Project tests
# LABELS: slow, gcp
# REPEAT:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() {
find . -iname "test-ltp*" -not -iname "*.yml" -exec rm -rf {} \;
}
trap clean_up EXIT
# Test code goes here
moby build test-ltp
linuxkit push test-ltp.img.tar.gz
RESULT="$(linuxkit run gcp -skip-cleanup -machine n1-highcpu-4 test-ltp)"
echo "${RESULT}" | grep -q "suite has passed"
exit 0

View File

@@ -0,0 +1,4 @@
#!/bin/sh
# LABELS: windows, skip
# FIXME: Write this test!!!

View File

@@ -0,0 +1,37 @@
#!/bin/sh
# SUMMARY: LinuxKit stress tests
# LABELS:
# For the top level group.sh also specify a 'NAME:' comment
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
group_init() {
# Group initialisation code goes here
return 0
}
group_deinit() {
# Group de-initialisation code goes here
return 0
}
CMD=$1
case $CMD in
init)
group_init
res=$?
;;
deinit)
group_deinit
res=$?
;;
*)
res=1
;;
esac
exit $res

View File

@@ -0,0 +1,4 @@
#!/bin/sh
# LABELS: skip
# FIXME: Write this test!!!

View File

@@ -0,0 +1,37 @@
#!/bin/sh
# SUMMARY: LinuxKit security tests
# LABELS:
# For the top level group.sh also specify a 'NAME:' comment
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
#. "${RT_PROJECT_ROOT}/_lib/lib.sh"
group_init() {
# Group initialisation code goes here
return 0
}
group_deinit() {
# Group de-initialisation code goes here
return 0
}
CMD=$1
case $CMD in
init)
group_init
res=$?
;;
deinit)
group_deinit
res=$?
;;
*)
res=1
;;
esac
exit $res

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# SUMMARY: Test the minimal example
# LABELS:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=minimal
clean_up() {
# remove any files, containers, images etc
rm -rf ${IMAGE_NAME}*
}
trap clean_up EXIT
# Test code goes here
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
exit 0

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# SUMMARY: Test the docker example
# LABELS:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=docker
clean_up() {
# remove any files, containers, images etc
rm -rf ${IMAGE_NAME}*
}
trap clean_up EXIT
# Test code goes here
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
exit 0

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# SUMMARY: Test the sshd example
# LABELS:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=sshd
clean_up() {
# remove any files, containers, images etc
rm -rf ${IMAGE_NAME}*
}
trap clean_up EXIT
# Test code goes here
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
exit 0

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# SUMMARY: Test the redis-os example
# LABELS:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=redis-os
clean_up() {
# remove any files, containers, images etc
rm -rf ${IMAGE_NAME}*
}
trap clean_up EXIT
# Test code goes here
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
exit 0

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# SUMMARY: Test the swap example
# LABELS:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=swap
clean_up() {
# remove any files, containers, images etc
rm -rf ${IMAGE_NAME}*
}
trap clean_up EXIT
# Test code goes here
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
exit 0

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# SUMMARY: Test the node_exporter example
# LABELS:
# AUTHOR: Dave Tucker <dt@docker.com>
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
IMAGE_NAME=node_exporter
clean_up() {
# remove any files, containers, images etc
rm -rf ${IMAGE_NAME}*
}
trap clean_up EXIT
# Test code goes here
moby build "${LINUXKIT_EXAMPLES_DIR}/${IMAGE_NAME}.yml"
exit 0

15
test/cases/_lib/lib.sh Normal file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
# Source the main regression test library if present
[ -f "${RT_LIB}" ] && . "${RT_LIB}"
# Temporary directory for tests to use.
LINUXKIT_TMPDIR="${RT_PROJECT_ROOT}/_tmp"
LINUXKIT_ARTIFACTS_DIR="${RT_PROJECT_ROOT}/../../artifacts"
# The top-level group.sh of the project creates a env.sh file
# containing environment variables for tests. Source it if present.
[ -f "${LINUXKIT_TMPDIR}/env.sh" ] && . "${LINUXKIT_TMPDIR}/env.sh"
# FIXME: Should source the rtf/lib/lib.sh instead
RT_CANCEL=253

41
test/cases/group.sh Normal file
View File

@@ -0,0 +1,41 @@
#!/bin/sh
# NAME: linuxkit
# SUMMARY: LinuxKit Regression Tests
# LABELS:
# Source libraries. Uncomment if needed/defined
# . "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
group_init() {
# Group initialisation code goes here
[ -r "${LINUXKIT_TMPDIR}" ] && rm -rf "${LINUXKIT_TMPDIR}"
mkdir "${LINUXKIT_TMPDIR}"
[ -r "${LINUXKIT_ARTIFACTS_DIR}" ] && rm -rf "${LINUXKIT_ARTIFACTS_DIR}"
mkdir "${LINUXKIT_ARTIFACTS_DIR}"
echo "export LINUXKIT_EXAMPLES_DIR=${RT_PROJECT_ROOT}/../../examples" >> "${LINUXKIT_TMPDIR}/env.sh"
return 0
}
group_deinit() {
# Group de-initialisation code goes here
return 0
}
CMD=$1
case $CMD in
init)
group_init
res=$?
;;
deinit)
group_deinit
res=$?
;;
*)
res=1
;;
esac
exit $res

View File

@@ -1,10 +0,0 @@
#! /bin/sh
# Make sure we have the latest kernel image
docker pull linuxkit/kernel:4.9.x
# Build a package
docker build -t kmod-test .
# Build a LinuxKit image with kernel module (and test script)
moby build kmod
# Run it
linuxkit run kmod