[lxc-devel] [lxd/master] Speed up testsuite
stgraber on Github
lxc-bot at linuxcontainers.org
Thu Dec 20 06:21:29 UTC 2018
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/20181220/83113554/attachment.bin>
-------------- next part --------------
From 6408d39d97dd4f6fee1616ff5b0f2120c278bde4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Dec 2018 00:04:01 -0500
Subject: [PATCH 1/9] tests: Add env variable to skip static analysis
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/README.md | 3 ++-
test/suites/static_analysis.sh | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/test/README.md b/test/README.md
index b7a615ded7..b75635d283 100644
--- a/test/README.md
+++ b/test/README.md
@@ -13,11 +13,12 @@ To run only the integration tests, run from the test directory:
Name | Default | Description
:-- | :--- | :----------
LXD\_BACKEND | dir | What backend to test against (btrfs, ceph, dir, lvm, zfs, or random)
-LXD\_CEPH\_CLUSTER | ceph | The name of the ceph cluster to create osd pools in. Only used if "\${LXD_BACKEND}" = "ceph".
+LXD\_CEPH\_CLUSTER | ceph | The name of the ceph cluster to create osd pools in
LXD\_CONCURRENT | 0 | Run concurrency tests, very CPU intensive
LXD\_DEBUG | 0 | Run lxd, lxc and the shell in debug mode (very verbose)
LXD\_INSPECT | 0 | Don't teardown the test environment on failure
LXD\_LOGS | "" | Path to a directory to copy all the LXD logs to
LXD\_OFFLINE | 0 | Skip anything that requires network access
+LXD\_SKIP\_STATIC | "" | Skip static analysis tests
LXD\_TEST\_IMAGE | "" (busybox test image) | Path to an image tarball to use instead of the default busybox image
LXD\_TMPFS | 0 | Sets up a tmpfs for the whole testsuite to run on (fast but needs memory)
diff --git a/test/suites/static_analysis.sh b/test/suites/static_analysis.sh
index 8ef94b5066..338805808d 100644
--- a/test/suites/static_analysis.sh
+++ b/test/suites/static_analysis.sh
@@ -3,6 +3,11 @@ safe_pot_hash() {
}
test_static_analysis() {
+ if [ -n "${LXD_SKIP_STATIC:-}" ]; then
+ echo "==> SKIP: Asked to skip static analysis"
+ return
+ fi
+
(
set -e
From dec68a323a8da1a3c415fe689da566f9af47b8e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Dec 2018 00:12:35 -0500
Subject: [PATCH 2/9] tests: Reduce sleeps in proxy tests
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/suites/proxy.sh | 90 ++++++++++++++++++++++----------------------
1 file changed, 45 insertions(+), 45 deletions(-)
diff --git a/test/suites/proxy.sh b/test/suites/proxy.sh
index a4b37cd5b1..431f235eba 100644
--- a/test/suites/proxy.sh
+++ b/test/suites/proxy.sh
@@ -22,10 +22,10 @@ test_proxy_device_tcp() {
lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=tcp:127.0.0.1:4321 bind=host
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -37,10 +37,10 @@ test_proxy_device_tcp() {
lxc restart -f proxyTester
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -52,10 +52,10 @@ test_proxy_device_tcp() {
lxc config device set proxyTester proxyDev connect tcp:127.0.0.1:1337
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:1337 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -71,12 +71,12 @@ test_proxy_device_tcp() {
NSENTER_PID=$!
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4322 exec:/bin/cat &
NSENTER_PID1=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
ECHO1=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT2}")
- kill -9 "${NSENTER_PID1}" || true
+ kill -9 "${NSENTER_PID1}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -165,10 +165,10 @@ test_proxy_device_unix() {
exec nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}").sock",unlink-early exec:/bin/cat
) &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - unix:"${HOST_SOCK#$(pwd)/}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -186,10 +186,10 @@ test_proxy_device_unix() {
exec nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}").sock",unlink-early exec:/bin/cat
) &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - unix:"${HOST_SOCK#$(pwd)/}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -207,10 +207,10 @@ test_proxy_device_unix() {
exec nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}")-2.sock",unlink-early exec:/bin/cat
) &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - unix:"${HOST_SOCK#$(pwd)/}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -242,10 +242,10 @@ test_proxy_device_tcp_unix() {
exec nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}").sock",unlink-early exec:/bin/cat
) &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -261,10 +261,10 @@ test_proxy_device_tcp_unix() {
exec nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}").sock",unlink-early exec:/bin/cat
) &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -280,10 +280,10 @@ test_proxy_device_tcp_unix() {
exec nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat unix-listen:"lxdtest-$(basename "${LXD_DIR}")-2.sock",unlink-early exec:/bin/cat
) &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -309,10 +309,10 @@ test_proxy_device_unix_tcp() {
lxc config device add proxyTester proxyDev proxy "listen=unix:${HOST_SOCK}" connect=tcp:127.0.0.1:4321 bind=host
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - unix:"${HOST_SOCK#$(pwd)/}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -326,10 +326,10 @@ test_proxy_device_unix_tcp() {
lxc restart -f proxyTester
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - unix:"${HOST_SOCK#$(pwd)/}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -343,10 +343,10 @@ test_proxy_device_unix_tcp() {
lxc config device set proxyTester proxyDev connect tcp:127.0.0.1:1337
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat tcp-listen:1337 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - unix:"${HOST_SOCK#$(pwd)/}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -374,10 +374,10 @@ test_proxy_device_udp() {
lxc config device add proxyTester proxyDev proxy "listen=udp:127.0.0.1:$HOST_UDP_PORT" connect=udp:127.0.0.1:4321 bind=host
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - udp:127.0.0.1:"${HOST_UDP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -389,10 +389,10 @@ test_proxy_device_udp() {
lxc restart -f proxyTester
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - udp:127.0.0.1:"${HOST_UDP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -404,10 +404,10 @@ test_proxy_device_udp() {
lxc config device set proxyTester proxyDev connect udp:127.0.0.1:1337
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:1337 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - udp:127.0.0.1:"${HOST_UDP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -433,10 +433,10 @@ test_proxy_device_unix_udp() {
lxc config device add proxyTester proxyDev proxy "listen=unix:${HOST_SOCK}" connect=udp:127.0.0.1:4321 bind=host
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - unix:"${HOST_SOCK#$(pwd)/}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -450,10 +450,10 @@ test_proxy_device_unix_udp() {
lxc restart -f proxyTester
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - unix:"${HOST_SOCK#$(pwd)/}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -467,10 +467,10 @@ test_proxy_device_unix_udp() {
lxc config device set proxyTester proxyDev connect udp:127.0.0.1:1337
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:1337 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - unix:"${HOST_SOCK#$(pwd)/}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -498,10 +498,10 @@ test_proxy_device_tcp_udp() {
lxc config device add proxyTester proxyDev proxy "listen=tcp:127.0.0.1:$HOST_TCP_PORT" connect=udp:127.0.0.1:4321 bind=host
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -513,10 +513,10 @@ test_proxy_device_tcp_udp() {
lxc restart -f proxyTester
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:4321 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
@@ -528,10 +528,10 @@ test_proxy_device_tcp_udp() {
lxc config device set proxyTester proxyDev connect udp:127.0.0.1:1337
nsenter -n -U -t "$(lxc query /1.0/containers/proxyTester/state | jq .pid)" -- socat udp-listen:1337 exec:/bin/cat &
NSENTER_PID=$!
- sleep 1
+ sleep 0.1
ECHO=$( (echo "${MESSAGE}" ; sleep 0.1) | socat - tcp:127.0.0.1:"${HOST_TCP_PORT}")
- kill -9 "${NSENTER_PID}" || true
+ kill -9 "${NSENTER_PID}" 2>/dev/null || true
if [ "${ECHO}" != "${MESSAGE}" ]; then
cat "${LXD_DIR}/logs/proxyTester/proxy.proxyDev.log"
From 0d8d76324e81dcedd6bbe28b71f3e458d49c5088 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Dec 2018 00:14:10 -0500
Subject: [PATCH 3/9] tests: Remove sleep in console test
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/suites/console.sh | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/test/suites/console.sh b/test/suites/console.sh
index e724517911..66c967598d 100644
--- a/test/suites/console.sh
+++ b/test/suites/console.sh
@@ -15,20 +15,17 @@ test_console() {
lxc start cons1
- # Let the init system come up.
- sleep 2
-
# Make sure there's something in the console ringbuffer.
echo 'some content' | lxc exec cons1 -- tee /dev/console
echo 'some more content' | lxc exec cons1 -- tee /dev/console
# Retrieve the ringbuffer contents.
- lxc console cons1 --show-log
+ lxc console cons1 --show-log | grep 'some content'
lxc stop --force cons1
# Retrieve on-disk representation of the console ringbuffer.
- lxc console cons1 --show-log
+ lxc console cons1 --show-log | grep 'some more content'
lxc delete --force cons1
}
From 43045512e6d1d13a078b215b5f2a230fdd8fc8b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Dec 2018 00:23:36 -0500
Subject: [PATCH 4/9] tests: Reduce delays in devlxd test
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/suites/devlxd.sh | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/test/suites/devlxd.sh b/test/suites/devlxd.sh
index 35e8a13dda..9581fcf4de 100644
--- a/test/suites/devlxd.sh
+++ b/test/suites/devlxd.sh
@@ -25,13 +25,6 @@ test_devlxd() {
lxc exec devlxd devlxd-client monitor > "${TEST_DIR}/devlxd.log" &
client=$!
- sleep 3
- lxc config set devlxd user.foo baz
- lxc config set devlxd security.nesting false
- lxc config device add devlxd mnt disk source="${TEST_DIR}" path=/mnt
- lxc config device remove devlxd mnt
-
- kill -9 "${client}"
(
cat << EOF
metadata:
@@ -63,7 +56,32 @@ type: device
EOF
) > "${TEST_DIR}/devlxd.expected"
- [ "$(md5sum "${TEST_DIR}/devlxd.log" | cut -d' ' -f1)" = "$(md5sum "${TEST_DIR}/devlxd.expected" | cut -d' ' -f1)" ]
+ MATCH=0
+
+ # shellcheck disable=SC2034
+ for i in $(seq 5); do
+ lxc config set devlxd user.foo bar
+ lxc config set devlxd security.nesting true
+
+ true > "${TEST_DIR}/devlxd.log"
+
+ lxc config set devlxd user.foo baz
+ lxc config set devlxd security.nesting false
+ lxc config device add devlxd mnt disk source="${TEST_DIR}" path=/mnt
+ lxc config device remove devlxd mnt
+
+ if [ "$(tr -d '\0' < "${TEST_DIR}/devlxd.log" | md5sum | cut -d' ' -f1)" != "$(md5sum "${TEST_DIR}/devlxd.expected" | cut -d' ' -f1)" ]; then
+ sleep 1
+ continue
+ fi
+
+ MATCH=1
+ break
+ done
+
+ kill -9 "${client}"
lxc delete devlxd --force
+
+ [ "${MATCH}" = "1" ] || false
}
From 80ab52ca3ae57f8b794812e767903ebca75a55f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Dec 2018 00:25:41 -0500
Subject: [PATCH 5/9] tests: Speed up basic tests
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/suites/basic.sh | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/test/suites/basic.sh b/test/suites/basic.sh
index e21f8424f9..9d71661b34 100644
--- a/test/suites/basic.sh
+++ b/test/suites/basic.sh
@@ -326,7 +326,7 @@ test_basic_usage() {
lxc exec foo ip link show | grep eth0
# check that we can get the return code for a non- wait-for-websocket exec
- op=$(my_curl -X POST "https://${LXD_ADDR}/1.0/containers/foo/exec" -d '{"command": ["sleep", "1"], "environment": {}, "wait-for-websocket": false, "interactive": false}' | jq -r .operation)
+ op=$(my_curl -X POST "https://${LXD_ADDR}/1.0/containers/foo/exec" -d '{"command": ["echo", "test"], "environment": {}, "wait-for-websocket": false, "interactive": false}' | jq -r .operation)
[ "$(my_curl "https://${LXD_ADDR}${op}/wait" | jq -r .metadata.metadata.return)" != "null" ]
# test file transfer
@@ -478,10 +478,6 @@ test_basic_usage() {
[ "${REBOOTED}" = "true" ]
- # Workaround for LXC bug which causes LXD to double-start containers
- # on reboot
- sleep 2
-
lxc stop foo --force || true
! lxc list | grep -q foo || false
From 77205423a33022ce83be022d3863e4f7559a62ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Dec 2018 00:26:42 -0500
Subject: [PATCH 6/9] tests: Reduce sleep in network test
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/suites/network.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/suites/network.sh b/test/suites/network.sh
index fe1152ab79..7d669b37f7 100644
--- a/test/suites/network.sh
+++ b/test/suites/network.sh
@@ -58,7 +58,7 @@ test_network() {
# shellcheck disable=SC2034
for i in $(seq 10); do
lxc info nettest | grep -q fd42 && SUCCESS=1 && break
- sleep 1
+ sleep 0.5
done
[ "${SUCCESS}" = "0" ] && (echo "Container static IP wasn't applied" && false)
From 5ff9a7b0d23ed883a93c8aabb81e5b905baad18b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Dec 2018 00:28:42 -0500
Subject: [PATCH 7/9] tests: Reduce teardown delays
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/includes/lxd.sh | 3 +--
test/includes/storage.sh | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/test/includes/lxd.sh b/test/includes/lxd.sh
index 984b90b47d..0e31fd0629 100644
--- a/test/includes/lxd.sh
+++ b/test/includes/lxd.sh
@@ -246,7 +246,6 @@ kill_lxd() {
"$lxd_backend"_teardown "${daemon_dir}"
# Wipe the daemon directory
- sleep 2
wipe "${daemon_dir}"
# Remove the daemon from the list
@@ -271,7 +270,7 @@ shutdown_lxd() {
# Wait for any cleanup activity that might be happening right
# after the websocket is closed.
- sleep 2
+ sleep 0.5
}
wait_for() {
diff --git a/test/includes/storage.sh b/test/includes/storage.sh
index e42b29c596..c45c87111a 100644
--- a/test/includes/storage.sh
+++ b/test/includes/storage.sh
@@ -91,13 +91,13 @@ deconfigure_loop_device() {
loopdev="${2}"
success=0
# shellcheck disable=SC2034
- for i in $(seq 10); do
+ for i in $(seq 20); do
if losetup -d "${loopdev}"; then
success=1
break
fi
- sleep 0.5
+ sleep 0.1
done
if [ "${success}" = "0" ]; then
From a12a5961492f811e5588a99cc9fd98f07f328951 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Dec 2018 00:30:21 -0500
Subject: [PATCH 8/9] tests: Drop startup sleep for cluster
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/includes/clustering.sh | 2 --
1 file changed, 2 deletions(-)
diff --git a/test/includes/clustering.sh b/test/includes/clustering.sh
index 808d7ebe22..166bc84e19 100644
--- a/test/includes/clustering.sh
+++ b/test/includes/clustering.sh
@@ -130,7 +130,6 @@ spawn_lxd_and_bootstrap_cluster() {
echo "==> Spawn bootstrap cluster node in ${ns} with storage driver ${driver}"
LXD_NETNS="${ns}" spawn_lxd "${LXD_DIR}" false
- sleep 1
(
set -e
@@ -219,7 +218,6 @@ spawn_lxd_and_join_cluster() {
echo "==> Spawn additional cluster node in ${ns} with storage driver ${driver}"
LXD_ALT_CERT=1 LXD_NETNS="${ns}" spawn_lxd "${LXD_DIR}" false
- sleep 1
(
set -e
From 9c5392295b6f0f7f8aaebb5d3dd584bcd4b60228 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 20 Dec 2018 00:33:22 -0500
Subject: [PATCH 9/9] tests: Reduce clustering delays
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/suites/clustering.sh | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/test/suites/clustering.sh b/test/suites/clustering.sh
index 4dee4438ff..39a86f5c60 100644
--- a/test/suites/clustering.sh
+++ b/test/suites/clustering.sh
@@ -120,7 +120,7 @@ test_clustering_membership() {
# detected as down.
LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.offline_threshold 5
LXD_DIR="${LXD_THREE_DIR}" lxd shutdown
- sleep 10
+ sleep 5
LXD_DIR="${LXD_TWO_DIR}" lxc cluster list | grep "node3" | grep -q "OFFLINE"
LXD_DIR="${LXD_TWO_DIR}" lxc config set cluster.offline_threshold 20
@@ -132,7 +132,7 @@ test_clustering_membership() {
# Sleep a bit to let a heartbeat occur and update the list of raft nodes
# everywhere, showing that node 4 has been promoted to database node.
- sleep 8
+ sleep 5
LXD_DIR="${LXD_TWO_DIR}" lxc cluster list | grep "node4" | grep -q "YES"
# Now the preseeded network can be deleted, and all nodes are
@@ -160,7 +160,7 @@ test_clustering_membership() {
LXD_DIR="${LXD_FOUR_DIR}" lxd shutdown
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_FIVE_DIR}/unix.socket"
rm -f "${LXD_FOUR_DIR}/unix.socket"
rm -f "${LXD_THREE_DIR}/unix.socket"
@@ -310,7 +310,7 @@ test_clustering_containers() {
# containers.
LXD_DIR="${LXD_THREE_DIR}" lxc config set cluster.offline_threshold 5
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
- sleep 10
+ sleep 5
LXD_DIR="${LXD_ONE_DIR}" lxc list | grep foo | grep -q ERROR
LXD_DIR="${LXD_ONE_DIR}" lxc config set cluster.offline_threshold 20
@@ -330,7 +330,7 @@ test_clustering_containers() {
LXD_DIR="${LXD_THREE_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_THREE_DIR}/unix.socket"
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_ONE_DIR}/unix.socket"
@@ -493,7 +493,7 @@ test_clustering_storage() {
# Shutdown node 3, and wait for it to be considered offline.
LXD_DIR="${LXD_THREE_DIR}" lxc config set cluster.offline_threshold 5
LXD_DIR="${LXD_THREE_DIR}" lxd shutdown
- sleep 10
+ sleep 5
# Move the container back to node2, even if node3 is offline
LXD_DIR="${LXD_ONE_DIR}" lxc move bar --target node2
@@ -612,7 +612,7 @@ test_clustering_storage() {
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_ONE_DIR}/unix.socket"
@@ -684,7 +684,7 @@ test_clustering_network() {
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_ONE_DIR}/unix.socket"
@@ -774,7 +774,7 @@ test_clustering_upgrade() {
LXD_DIR="${LXD_THREE_DIR}" lxd shutdown
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_THREE_DIR}/unix.socket"
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_ONE_DIR}/unix.socket"
@@ -822,7 +822,7 @@ test_clustering_publish() {
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_ONE_DIR}/unix.socket"
@@ -891,7 +891,7 @@ EOF
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_ONE_DIR}/unix.socket"
@@ -920,7 +920,6 @@ test_clustering_join_api() {
chmod +x "${LXD_TWO_DIR}"
ns2="${prefix}2"
LXD_ALT_CERT=1 LXD_NETNS="${ns2}" spawn_lxd "${LXD_TWO_DIR}" false
- sleep 1
op=$(curl --unix-socket "${LXD_TWO_DIR}/unix.socket" -X PUT "lxd/1.0/cluster" -d "{\"server_name\":\"node2\",\"enabled\":true,\"member_config\":[{\"entity\": \"storage-pool\",\"name\":\"data\",\"key\":\"source\",\"value\":\"\"}],\"server_address\":\"10.1.1.102:8443\",\"cluster_address\":\"10.1.1.101:8443\",\"cluster_certificate\":\"${cert}\",\"cluster_password\":\"sekret\"}" | jq -r .operation)
curl --unix-socket "${LXD_TWO_DIR}/unix.socket" "lxd${op}/wait"
@@ -929,7 +928,7 @@ test_clustering_join_api() {
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_ONE_DIR}/unix.socket"
@@ -984,6 +983,7 @@ test_clustering_shutdown_nodes() {
wait "$(cat two.pid)"
LXD_DIR="${LXD_THREE_DIR}" lxd shutdown
wait "$(cat three.pid)"
+
# Make sure the database is not available to the first node
sleep 5
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
@@ -1046,7 +1046,7 @@ test_clustering_projects() {
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_ONE_DIR}/unix.socket"
@@ -1119,7 +1119,7 @@ test_clustering_address() {
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_ONE_DIR}/unix.socket"
@@ -1259,7 +1259,7 @@ test_clustering_image_replication() {
LXD_DIR="${LXD_ONE_DIR}" lxd shutdown
LXD_DIR="${LXD_TWO_DIR}" lxd shutdown
LXD_DIR="${LXD_THREE_DIR}" lxd shutdown
- sleep 2
+ sleep 0.5
rm -f "${LXD_ONE_DIR}/unix.socket"
rm -f "${LXD_TWO_DIR}/unix.socket"
rm -f "${LXD_THREE_DIR}/unix.socket"
More information about the lxc-devel
mailing list