From 9373106791570b4b918535aedc2974161fefd238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Peliz=C3=A4us?= Date: Fri, 11 Jul 2025 14:13:14 +0200 Subject: [PATCH 1/3] test/includes: Launch interactive join in separate terminals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test output is very convoluted as it prints together the output of all systems joining the cluster (as well as the initiator). By running it in separate terminals we can ensure the outputs are not mixed. Signed-off-by: Julian Pelizäus --- test/includes/microcloud.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/includes/microcloud.sh b/test/includes/microcloud.sh index f7b217d71..a2fbfc309 100644 --- a/test/includes/microcloud.sh +++ b/test/includes/microcloud.sh @@ -222,10 +222,25 @@ $(true) # workaround for set -e set -x fi - # Spawn joiner child processes, and capture the exit code. for member in ${joiners}; do - lxc exec "${member}" -- sh -c "tee in | (microcloud join 2>&1 3>debug; echo \$? > code) | tee out" <<< "${setup}" & + tmux new-session -d -s "${member}" lxc exec "${member}" -- sh -c "tee in | (microcloud join 2>&1 3>debug; echo \$? > code) | tee out" + + retries=0 + + # Wait until CLI is in testing mode. + while [[ ! "$(tmux capture-pane -t "${member}" -pS -)" =~ "MicroCloud CLI is in testing mode" ]]; do + if [ "${retries}" -gt 30 ]; then + echo "Failed waiting for test console on ${member} to become ready" + exit 1 + fi + + retries="$((retries+1))" + sleep 1 + done + + # Send the interactive test inputs, a newline and EOF. + tmux send-keys -t "${member}" "${setup}" Enter C-d done # Set up microcloud with the initiator. From 35cb160b1734a575818aa3434b76dcf3c9836d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Peliz=C3=A4us?= Date: Fri, 11 Jul 2025 14:13:33 +0200 Subject: [PATCH 2/3] test/includes: Remove newlines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julian Pelizäus --- test/includes/microcloud.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/includes/microcloud.sh b/test/includes/microcloud.sh index a2fbfc309..1182a6150 100644 --- a/test/includes/microcloud.sh +++ b/test/includes/microcloud.sh @@ -207,7 +207,6 @@ join_session(){ LOOKUP_IFACE="enp5s0" fi - # Select the first usable address and enter the passphrase. setup="$([ -n "${LOOKUP_IFACE}" ] && printf "table:filter %s" "${LOOKUP_IFACE}") # filter the lookup interface $([ -n "${LOOKUP_IFACE}" ] && printf "table:select") # select the interface @@ -255,7 +254,6 @@ $(true) # workaround for set -e done fi - for joiner in ${joiners} ; do [ "$(lxc file pull "${joiner}"/root/code -)" = "${code}" ] done From 39bcb5b8a9e9edc0f71c0088984adc337231329e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Peliz=C3=A4us?= Date: Fri, 11 Jul 2025 15:09:50 +0200 Subject: [PATCH 3/3] test/includes: Cleanup left over tmux sessions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Usually the joiners exit before the initiator. However during failures (e.g. test inputs) the joiners might still be running after the initiator exited out. Signed-off-by: Julian Pelizäus --- test/includes/microcloud.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/includes/microcloud.sh b/test/includes/microcloud.sh index 1182a6150..aade11c41 100644 --- a/test/includes/microcloud.sh +++ b/test/includes/microcloud.sh @@ -246,13 +246,12 @@ $(true) # workaround for set -e microcloud_interactive "${mode}" "${initiator}" code="$?" - # Kill the childs if they are still running. - child_processes="$(jobs -pr)" - if [ -n "${child_processes}" ]; then - for p in ${child_processes}; do - kill -9 "${p}" - done - fi + # Kill the tmux sessions if they are still running. + # The '#S' filter returns only the session's names. + # Suppress errors in case the list of sessions is empty. + for session in $(tmux list-sessions -F '#S' 2>/dev/null); do + tmux kill-session -t "${session}" + done for joiner in ${joiners} ; do [ "$(lxc file pull "${joiner}"/root/code -)" = "${code}" ]