[lxc-devel] [lxd/master] Testsuite improvements
stgraber on Github
lxc-bot at linuxcontainers.org
Wed Nov 23 02:56:09 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161123/d0a6f2f9/attachment.bin>
-------------- next part --------------
From a5c31460d140b8c5bc56cd6ce96bf82e953e4333 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 22 Nov 2016 21:21:26 -0500
Subject: [PATCH 1/2] test: Implement LXD_VERBOSE
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
test/main.sh | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/test/main.sh b/test/main.sh
index c6d8bac..6d69479 100755
--- a/test/main.sh
+++ b/test/main.sh
@@ -7,8 +7,15 @@ export "LC_ALL=C"
# Force UTC for consistency
export "TZ=UTC"
-if [ -n "${LXD_DEBUG:-}" ]; then
+if [ -n "${LXD_VERBOSE:-}" ] || [ -n "${LXD_DEBUG:-}" ]; then
set -x
+fi
+
+if [ -n "${LXD_VERBOSE:-}" ]; then
+ DEBUG="--verbose"
+fi
+
+if [ -n "${LXD_DEBUG:-}" ]; then
DEBUG="--debug"
fi
@@ -91,7 +98,7 @@ spawn_lxd() {
echo "==> Setting trust password"
LXD_DIR="${lxddir}" lxc config set core.trust_password foo
- if [ -n "${LXD_DEBUG:-}" ]; then
+ if [ -n "${DEBUG:-}" ]; then
set -x
fi
@@ -132,7 +139,7 @@ lxc_remote() {
if [ "${injected}" = "0" ]; then
cmd="${cmd} ${DEBUG-}"
fi
- if [ -n "${LXD_DEBUG:-}" ]; then
+ if [ -n "${DEBUG:-}" ]; then
set -x
fi
eval "${cmd}"
@@ -295,7 +302,7 @@ kill_lxd() {
cleanup() {
# Allow for failures and stop tracing everything
set +ex
- LXD_DEBUG=
+ DEBUG=
# Allow for inspection
if [ -n "${LXD_INSPECT:-}" ]; then
From b80652fb052bb5e3384973089a4dc4e8a2c97f2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 22 Nov 2016 21:54:00 -0500
Subject: [PATCH 2/2] test: Cleanup leftover containers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This way we don't have leftover containers running while we move on to
the next testsuite.
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
test/suites/basic.sh | 9 +++++----
test/suites/devlxd.sh | 2 +-
test/suites/migration.sh | 7 ++++---
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/test/suites/basic.sh b/test/suites/basic.sh
index 2cbf0ee..9dcd9d3 100644
--- a/test/suites/basic.sh
+++ b/test/suites/basic.sh
@@ -61,7 +61,7 @@ test_basic_usage() {
lxc image export splitimage "${LXD_DIR}"
[ "${sum}" = "$(cat "${LXD_DIR}/meta-${sum}.tar.xz" "${LXD_DIR}/${sum}.tar.xz" | sha256sum | cut -d' ' -f1)" ]
-
+
# Delete the split image and exported files
rm "${LXD_DIR}/${sum}.tar.xz"
rm "${LXD_DIR}/meta-${sum}.tar.xz"
@@ -74,7 +74,7 @@ test_basic_usage() {
lxc image export splitimage "${LXD_DIR}"
[ "${sum}" = "$(cat "${LXD_DIR}/meta-${sum}.tar.xz" "${LXD_DIR}/${sum}.tar.xz" | sha256sum | cut -d' ' -f1)" ]
-
+
# Delete the split image and exported files
rm "${LXD_DIR}/${sum}.tar.xz"
rm "${LXD_DIR}/meta-${sum}.tar.xz"
@@ -110,7 +110,7 @@ test_basic_usage() {
curl -k -s --cert "${LXD_CONF}/client3.crt" --key "${LXD_CONF}/client3.key" -X GET "https://${LXD_ADDR}/1.0/images" | grep "/1.0/images/" && false
lxc image delete foo-image
-# Test image compression on publish
+ # Test image compression on publish
lxc publish bar --alias=foo-image-compressed --compression=bzip2 prop=val1
lxc image show foo-image-compressed | grep val1
curl -k -s --cert "${LXD_CONF}/client3.crt" --key "${LXD_CONF}/client3.key" -X GET "https://${LXD_ADDR}/1.0/images" | grep "/1.0/images/" && false
@@ -258,6 +258,7 @@ test_basic_usage() {
lxc list last-used-at-test --format json | jq -r '.[].last_used_at' | grep '1970-01-01T00:00:00Z'
lxc start last-used-at-test
lxc list last-used-at-test --format json | jq -r '.[].last_used_at' | grep -v '1970-01-01T00:00:00Z'
+ lxc delete last-used-at-test --force
# check that we can set the environment
lxc exec foo pwd | grep /root
@@ -342,7 +343,7 @@ test_basic_usage() {
lxc start lxd-seccomp-test
init=$(lxc info lxd-seccomp-test | grep Pid | cut -f2 -d" ")
[ "$(grep Seccomp "/proc/${init}/status" | cut -f2)" -eq "0" ]
- lxc stop --force lxd-seccomp-test
+ lxc delete --force lxd-seccomp-test
# make sure that privileged containers are not world-readable
lxc profile create unconfined
diff --git a/test/suites/devlxd.sh b/test/suites/devlxd.sh
index 3e4f138..722d247 100644
--- a/test/suites/devlxd.sh
+++ b/test/suites/devlxd.sh
@@ -18,5 +18,5 @@ test_devlxd() {
lxc config set devlxd user.foo bar
lxc exec devlxd devlxd-client user.foo | grep bar
- lxc stop devlxd --force
+ lxc delete devlxd --force
}
diff --git a/test/suites/migration.sh b/test/suites/migration.sh
index ee7a473..675049f 100644
--- a/test/suites/migration.sh
+++ b/test/suites/migration.sh
@@ -47,6 +47,7 @@ test_migration() {
if [ "${LXD_BACKEND}" != "lvm" ]; then
[ -d "${LXD2_DIR}/containers/nonlive3/rootfs/bin" ]
fi
+ lxc_remote delete l2:nonlive3 --force
lxc_remote copy l2:nonlive l2:nonlive2
# should have the same base image tag
@@ -60,11 +61,11 @@ test_migration() {
lxc_remote start l1:nonlive2
lxc_remote list l1: | grep RUNNING | grep nonlive2
- lxc_remote stop l1:nonlive2 --force
+ lxc_remote delete l1:nonlive2 l2:nonlive2 --force
lxc_remote start l2:nonlive
lxc_remote list l2: | grep RUNNING | grep nonlive
- lxc_remote stop l2:nonlive --force
+ lxc_remote delete l2:nonlive --force
if ! which criu >/dev/null 2>&1; then
echo "==> SKIP: live migration with CRIU (missing binary)"
@@ -78,5 +79,5 @@ test_migration() {
lxc_remote stop --stateful l1:migratee
lxc_remote start l1:migratee
- lxc_remote stop --force l1:migratee
+ lxc_remote delete --force l1:migratee
}
More information about the lxc-devel
mailing list