[lxc-devel] [lxd/master] test: add LXD running Docker tests

brauner on Github lxc-bot at linuxcontainers.org
Wed May 3 15:52:06 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 769 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170503/20240c2b/attachment.bin>
-------------- next part --------------
From e5bc2b6f178dba7912ec6dfc5586d28e0cdb49f9 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 3 May 2017 17:42:54 +0200
Subject: [PATCH] test: add LXD running Docker tests

This implements a minimal test for running Docker in LXD. The binaries are
always the ones from current Docker master which are built after a new commit
is pushed.

Currently the test only check if the daemon starts up correctly and whether an
image can be pulled.  Until Docker vendors a version of runc that includes a
fix for the non-dumpable bug there's really not a lot more for us to test.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 test/main.sh          |  1 +
 test/suites/docker.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)
 create mode 100644 test/suites/docker.sh

diff --git a/test/main.sh b/test/main.sh
index d470070..bcd010c 100755
--- a/test/main.sh
+++ b/test/main.sh
@@ -627,5 +627,6 @@ run_test test_storage "storage"
 run_test test_lxd_autoinit "lxd init auto"
 run_test test_storage_profiles "storage profiles"
 run_test test_container_import "container import"
+run_test test_docker "LXD running Docker"
 
 TEST_RESULT=success
diff --git a/test/suites/docker.sh b/test/suites/docker.sh
new file mode 100644
index 0000000..c164f25
--- /dev/null
+++ b/test/suites/docker.sh
@@ -0,0 +1,68 @@
+test_docker() {
+  # shellcheck disable=2039
+  local lxd_backend
+  lxd_backend=$(storage_backend "$LXD_DIR")
+
+  if [ -n "${LXD_OFFLINE:-}" ]; then
+    echo "LXD is not connected to the internet. Skipping..."
+    return
+  fi
+
+  lxc launch ubuntu:xenial docker1
+  # Give time to connect to network
+  sleep 5s
+
+  lxc exec docker1 -- apt update --yes --force-yes
+  lxc exec docker1 -- apt install docker.io --yes --force-yes
+  lxc exec docker1 -- systemctl stop docker.service
+  lxc exec docker1 -- systemctl stop docker.socket
+
+  # Download binaries built from current git head of the Docker repo.
+  lxc exec docker1 -- wget https://master.dockerproject.org/linux/amd64/docker
+  lxc exec docker1 -- wget https://master.dockerproject.org/linux/amd64/dockerd
+  lxc exec docker1 -- wget https://master.dockerproject.org/linux/amd64/docker-containerd
+  lxc exec docker1 -- wget https://master.dockerproject.org/linux/amd64/docker-containerd-shim
+  lxc exec docker1 -- wget https://master.dockerproject.org/linux/amd64/docker-init
+  lxc exec docker1 -- wget https://master.dockerproject.org/linux/amd64/docker-proxy
+  lxc exec docker1 -- wget https://master.dockerproject.org/linux/amd64/docker-runc
+
+  # client
+  lxc exec docker1 -- cp docker /usr/bin/docker
+  lxc exec docker1 -- chmod +x /usr/bin/docker
+
+  # daemon
+  lxc exec docker1 -- cp dockerd /usr/bin/dockerd
+  lxc exec docker1 -- chmod +x /usr/bin/dockerd
+
+  # another daemon
+  lxc exec docker1 -- cp docker-containerd /usr/bin/docker-containerd
+  lxc exec docker1 -- chmod +x /usr/bin/docker-containerd
+
+  # another binary
+  lxc exec docker1 -- cp docker-containerd-shim /usr/bin/docker-containerd-shim
+  lxc exec docker1 -- chmod +x /usr/bin/docker-containerd-shim
+
+  # yet another binary
+  lxc exec docker1 -- cp docker-init /usr/bin/docker-init
+  lxc exec docker1 -- chmod +x /usr/bin/docker-init
+
+  # yet yet another binary
+  lxc exec docker1 -- cp docker-proxy /usr/bin/docker-proxy
+  lxc exec docker1 -- chmod +x /usr/bin/docker-proxy
+
+  # yet yet yet another binary
+  lxc exec docker1 -- cp docker-runc /usr/sbin/docker-runc
+  lxc exec docker1 -- chmod +x /usr/sbin/docker-runc
+
+  lxc exec docker1 -- systemctl start docker
+  # Check if the Docker daemon successfully started and is active.
+  [ "$(lxc exec docker1 -- systemctl is-active docker)" = "active" ]
+
+  # Test whether we can pull a simple Docker image.
+  lxc exec docker1 -- docker pull busybox:latest
+
+  # Test whether we can remove a simple Docker image.
+  lxc exec docker1 -- docker rmi busybox:latest
+
+  lxc delete -f docker1
+}


More information about the lxc-devel mailing list