[PATCH v2 00/11] Improve command dispatch in test scripts
Sorry for the resend, but I found and fixed a couple of warts in this series. The test scripts need to dispatch commands in various different contexts: on the host, in namespaces, and in guests. Currently this is done by running each context in a tmux pane and simulating typing into that pane using tmux commands. This has a number of problems: * It's slow * Getting the results from programs is tricky and error prone. We can misparse output if: * The window isn't large enough * Commands produce output which looks like a shell prompt * The shell doesn't have the prompt we expect * A accidental keypress while the tests are running can mess up the test run * We have to issue explicit "echo $?" commands to check if things succeeded This series adds a new subsystem to the test scripts for dispatching commands which accurately preserves output (both stdout and stderr), and exit codes. Most of the testsuite is converted to this new system. For now the distro tests still rely on the old approach, since they have some complications that require additional handling. That does, alas, mean we have some ugly transitional code remaining. Oh well, we should be able to clean that up at some point. This series is pased on the previous series cleaning up the performance tests. Changes since v1: * Removed a couple of commented debugging lines in patch 9/11 * Removed a no longer necessary pipe-pane in patch 9/11 David Gibson (11): test: Correctly match "background" with "wait" commands test: Context execution helpers test: Allow a tmux pane to watch commands executed in contexts test: Integration of old-style pane execution and new context execution test: Issue host commands via context for most tests test: Use new-style contexts for passt pane in the pasta and passt tests test: Add nsholder utility test: Extend context system to run commands in namespace for pasta tests test: Use context system for guest commands test: Use context system for two_guests tests test: Use new-style command issue for passt_in_ns tests test/.gitignore | 3 + test/Makefile | 13 +- test/lib/context | 125 +++++++++++++++++ test/lib/layout | 61 +++------ test/lib/setup | 274 +++++++++++++++++++------------------- test/lib/term | 84 ++++++++++++ test/lib/test | 138 ++++++++----------- test/nsholder.c | 117 ++++++++++++++++ test/passt.mbuto | 32 ++++- test/run | 1 + test/shutdown/passt | 4 +- test/shutdown/passt_in_ns | 4 +- test/tcp/passt | 2 + test/tcp/passt_in_ns | 17 ++- test/tcp/pasta | 1 - test/udp/passt | 1 + test/udp/passt_in_ns | 5 +- test/udp/pasta | 1 - 18 files changed, 606 insertions(+), 277 deletions(-) create mode 100644 test/lib/context create mode 100644 test/nsholder.c -- 2.37.3
Our test DSL has a number of paired commands to run something in the
background in a pane, then later to wait for it to complete. However, in
some of the tests we have these mismatched - starting a command in one
pane, then waiting for it in another.
We appear to get away with this for some reason, but it's not correct and
future changes make it cause more problems.
Signed-off-by: David Gibson
For the tests, we need to run commands in various contexts: in the host,
in a guest or in a namespace. Currently we do this by running each context
in a tmux pane, and using tmux commands to type the commands into the
relevant pane, then screen-scrape the output for the results if we need
them.
This is very fragile, because we have to make various assumptions to parse
the output. Those can break if a shell doesn't have the prompt we expect,
if the tmux pane is too small or in various other conditions.
This starts some library functions for a new "context" system, that
provides a common way to invoke commands in a given context, in a way that
properly preserves stdout, stderr and the process return code.
Signed-off-by: David Gibson
We're moving to a new way of the tests dispatching commands to running in
contexts (host, guest, namespace, etc.). As we make this transition,
though, we still want the user to be able to watch the commands running
in a context, as they previously could from the commands issued in the
pane.
Add a helper to set up a pane to watch a context's log to allow this. In
some cases we currently issue commands from several different logical
contexts in the same pane, so allow a pane to watch several contexts at
once. Also use tail's --retry option to allow starting the watch before
we've initialized the context which will be useful in some cases.
Signed-off-by: David Gibson
Nit:
On Thu, 8 Sep 2022 11:49:12 +1000
David Gibson
We're moving to a new way of the tests dispatching commands to running in contexts (host, guest, namespace, etc.). As we make this transition, though, we still want the user to be able to watch the commands running in a context, as they previously could from the commands issued in the pane.
Add a helper to set up a pane to watch a context's log to allow this. In some cases we currently issue commands from several different logical contexts in the same pane, so allow a pane to watch several contexts at once. Also use tail's --retry option to allow starting the watch before we've initialized the context which will be useful in some cases.
Signed-off-by: David Gibson
--- test/lib/term | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/lib/term b/test/lib/term index ddabf8d..fa34873 100755 --- a/test/lib/term +++ b/test/lib/term @@ -241,6 +241,24 @@ pane_status() { return ${__status} }
+# pane_watch_context() - Set up pane to watch commands executing in context(s) +# $1: Pane number +# $2: Description (for pane label) +# $@: Context name or names +pane_watch_contexts() { + __pane_number="${1}" + __desc="${2}" + shift 2 + __name="${2}" + + tmux select-pane -t ${__pane_number} -T "${__desc}" + __cmd="tail -f --retry" + for c; do + __cmd="${__cmd} ${LOGDIR}/context_${c}.log"
Mixed tab and spaces. -- Stefano
On Fri, Sep 09, 2022 at 05:18:43PM +0200, Stefano Brivio wrote:
Nit:
On Thu, 8 Sep 2022 11:49:12 +1000 David Gibson
wrote: We're moving to a new way of the tests dispatching commands to running in contexts (host, guest, namespace, etc.). As we make this transition, though, we still want the user to be able to watch the commands running in a context, as they previously could from the commands issued in the pane.
Add a helper to set up a pane to watch a context's log to allow this. In some cases we currently issue commands from several different logical contexts in the same pane, so allow a pane to watch several contexts at once. Also use tail's --retry option to allow starting the watch before we've initialized the context which will be useful in some cases.
Signed-off-by: David Gibson
--- test/lib/term | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/lib/term b/test/lib/term index ddabf8d..fa34873 100755 --- a/test/lib/term +++ b/test/lib/term @@ -241,6 +241,24 @@ pane_status() { return ${__status} }
+# pane_watch_context() - Set up pane to watch commands executing in context(s) +# $1: Pane number +# $2: Description (for pane label) +# $@: Context name or names +pane_watch_contexts() { + __pane_number="${1}" + __desc="${2}" + shift 2 + __name="${2}" + + tmux select-pane -t ${__pane_number} -T "${__desc}" + __cmd="tail -f --retry" + for c; do + __cmd="${__cmd} ${LOGDIR}/context_${c}.log"
Mixed tab and spaces.
Oops, fixed. I finally got around to changing my emacs config to change sh-basic-offset to 8 by default, so this should be less likely to happen in future. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
We're creating a system for tests to more reliably execute commands in
various contexts (e.g. host, guest, namespace). That transition is going
to happen over a number of steps though, so in the meantime we need to deal
with both the old-style issuing of commands via typing into and screen
scraping tmux panels, and the new-style system for executing commands in
context.
Introduce some transitional helpers which will issue a command via context
if the requested context is initialized, but will otherwise fall back to
the old style tmux panel based method. Re-implement the various test DSL
commands in terms of these new helpers.
Signed-off-by: David Gibson
Convert most of the tests to use the new-style system for issuing commands
for all host commands. We leave the distro tests for now: they use
the same pane for both host and guest commands which we'll need some more
things to deal with.
Signed-off-by: David Gibson
Nit:
On Thu, 8 Sep 2022 11:49:14 +1000
David Gibson
Convert most of the tests to use the new-style system for issuing commands for all host commands. We leave the distro tests for now: they use the same pane for both host and guest commands which we'll need some more things to deal with.
Signed-off-by: David Gibson
--- test/lib/layout | 20 ++++++++++---------- test/lib/setup | 47 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/test/lib/layout b/test/lib/layout index 2d6b197..09c213a 100644 --- a/test/lib/layout +++ b/test/lib/layout @@ -31,8 +31,12 @@ layout_host() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + if context_exists host; then + pane_watch_contexts 0 host host + else + tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" + tmux select-pane -t ${PANE_HOST} -T "host" + fi
info_layout "host commands only"
@@ -64,8 +68,7 @@ layout_pasta() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + pane_watch_contexts ${PANE_HOST} host host
tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log" tmux select-pane -t ${PANE_PASST} -T "pasta" @@ -100,8 +103,7 @@ layout_passt() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + pane_watch_contexts ${PANE_HOST} host host
tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log" tmux select-pane -t ${PANE_PASST} -T "passt" @@ -141,8 +143,7 @@ layout_passt_in_pasta() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + pane_watch_contexts ${PANE_HOST} host host
tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log" tmux select-pane -t ${PANE_PASST} -T "passt in pasta (namespace)" @@ -189,8 +190,7 @@ layout_two_guests() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + pane_watch_contexts ${PANE_HOST} host host
tmux pipe-pane -O -t ${PANE_PASST_1} "cat >> ${LOGDIR}/pane_passt_1.log" tmux select-pane -t ${PANE_PASST_1} -T "passt #1 in namespace #1" diff --git a/test/lib/setup b/test/lib/setup index 42f03c1..9b5e9ff 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -20,6 +20,8 @@ VMEM="$((${__mem_kib} / 1024 / 4))"
# setup_build() - Set up pane layout for build tests setup_build() { + context_setup_host host + layout_host }
@@ -30,6 +32,8 @@ setup_distro() {
# setup_passt() - Start qemu and passt setup_passt() { + context_setup_host host + layout_passt
# Ports: @@ -63,17 +67,12 @@ setup_passt() { " -netdev socket,fd=5,id=hostnet0" \ ' -pidfile passt_qemu.pid' pane_status GUEST - - # Set things up to reduce problems parsing host command output - pane_run HOST "PS1='$ '" - pane_wait HOST - # Non-bash shells will fail this, but also don't need it, so ignore errors - pane_run HOST "bind 'set enable-bracketed-paste off'" - pane_wait HOST }
# setup_pasta() - Create a network and user namespace, connect pasta to it setup_pasta() { + context_setup_host host + layout_pasta
pane_run NS 'echo $$' @@ -105,6 +104,8 @@ setup_pasta() {
# setup_passt_in_ns() - Set up namespace (with pasta), run qemu and passt into it setup_passt_in_ns() { + context_setup_host host + layout_passt_in_pasta
# Ports: @@ -182,17 +183,12 @@ setup_passt_in_ns() { " -netdev socket,fd=5,id=hostnet0" \ ' -pidfile passt_in_ns_qemu.pid' pane_status GUEST - - # Set things up to reduce problems parsing host command output - pane_run HOST "PS1='$ '" - pane_wait HOST - # Non-bash shells will fail this, but also don't need it, so ignore errors - pane_run HOST "bind 'set enable-bracketed-paste off'" - pane_wait HOST }
# setup_two_guests() - Set up two namespace, run qemu and passt in both of them setup_two_guests() { + context_setup_host host + layout_two_guests
# Ports: @@ -290,9 +286,21 @@ setup_two_guests() { pane_status GUEST_2 }
+# teardown_context_watch() - Remove contexts and stop panes watching them +# $1: Pane number watching +# $@: Context names +teardown_context_watch() { + __pane="$1" + shift + for __c ; do
Whitespace between ; and do is the most common coding style from POSIX references, but otherwise inconsistent with everything else in these files (and, say, with pane_watch_contexts() in 3/11) -- I'd drop it. -- Stefano
On Fri, Sep 09, 2022 at 05:18:48PM +0200, Stefano Brivio wrote:
Nit:
On Thu, 8 Sep 2022 11:49:14 +1000 David Gibson
wrote: Convert most of the tests to use the new-style system for issuing commands for all host commands. We leave the distro tests for now: they use the same pane for both host and guest commands which we'll need some more things to deal with.
Signed-off-by: David Gibson
--- test/lib/layout | 20 ++++++++++---------- test/lib/setup | 47 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/test/lib/layout b/test/lib/layout index 2d6b197..09c213a 100644 --- a/test/lib/layout +++ b/test/lib/layout @@ -31,8 +31,12 @@ layout_host() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + if context_exists host; then + pane_watch_contexts 0 host host + else + tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" + tmux select-pane -t ${PANE_HOST} -T "host" + fi
info_layout "host commands only"
@@ -64,8 +68,7 @@ layout_pasta() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + pane_watch_contexts ${PANE_HOST} host host
tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log" tmux select-pane -t ${PANE_PASST} -T "pasta" @@ -100,8 +103,7 @@ layout_passt() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + pane_watch_contexts ${PANE_HOST} host host
tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log" tmux select-pane -t ${PANE_PASST} -T "passt" @@ -141,8 +143,7 @@ layout_passt_in_pasta() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + pane_watch_contexts ${PANE_HOST} host host
tmux pipe-pane -O -t ${PANE_PASST} "cat >> ${LOGDIR}/pane_passt.log" tmux select-pane -t ${PANE_PASST} -T "passt in pasta (namespace)" @@ -189,8 +190,7 @@ layout_two_guests() { tmux send-keys -t ${PANE_INFO} -N 100 C-m tmux select-pane -t ${PANE_INFO} -T "test log"
- tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" - tmux select-pane -t ${PANE_HOST} -T "host" + pane_watch_contexts ${PANE_HOST} host host
tmux pipe-pane -O -t ${PANE_PASST_1} "cat >> ${LOGDIR}/pane_passt_1.log" tmux select-pane -t ${PANE_PASST_1} -T "passt #1 in namespace #1" diff --git a/test/lib/setup b/test/lib/setup index 42f03c1..9b5e9ff 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -20,6 +20,8 @@ VMEM="$((${__mem_kib} / 1024 / 4))"
# setup_build() - Set up pane layout for build tests setup_build() { + context_setup_host host + layout_host }
@@ -30,6 +32,8 @@ setup_distro() {
# setup_passt() - Start qemu and passt setup_passt() { + context_setup_host host + layout_passt
# Ports: @@ -63,17 +67,12 @@ setup_passt() { " -netdev socket,fd=5,id=hostnet0" \ ' -pidfile passt_qemu.pid' pane_status GUEST - - # Set things up to reduce problems parsing host command output - pane_run HOST "PS1='$ '" - pane_wait HOST - # Non-bash shells will fail this, but also don't need it, so ignore errors - pane_run HOST "bind 'set enable-bracketed-paste off'" - pane_wait HOST }
# setup_pasta() - Create a network and user namespace, connect pasta to it setup_pasta() { + context_setup_host host + layout_pasta
pane_run NS 'echo $$' @@ -105,6 +104,8 @@ setup_pasta() {
# setup_passt_in_ns() - Set up namespace (with pasta), run qemu and passt into it setup_passt_in_ns() { + context_setup_host host + layout_passt_in_pasta
# Ports: @@ -182,17 +183,12 @@ setup_passt_in_ns() { " -netdev socket,fd=5,id=hostnet0" \ ' -pidfile passt_in_ns_qemu.pid' pane_status GUEST - - # Set things up to reduce problems parsing host command output - pane_run HOST "PS1='$ '" - pane_wait HOST - # Non-bash shells will fail this, but also don't need it, so ignore errors - pane_run HOST "bind 'set enable-bracketed-paste off'" - pane_wait HOST }
# setup_two_guests() - Set up two namespace, run qemu and passt in both of them setup_two_guests() { + context_setup_host host + layout_two_guests
# Ports: @@ -290,9 +286,21 @@ setup_two_guests() { pane_status GUEST_2 }
+# teardown_context_watch() - Remove contexts and stop panes watching them +# $1: Pane number watching +# $@: Context names +teardown_context_watch() { + __pane="$1" + shift + for __c ; do
Whitespace between ; and do is the most common coding style from POSIX references, but otherwise inconsistent with everything else in these files (and, say, with pane_watch_contexts() in 3/11) -- I'd drop it.
Adjusted, thanks. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Convert the pasta and passt tests to use new-style context execution
for the things that run in the "passt" frame. Don't touch the
passt_in_ns or two_guests tests yet, because they run passt inside a
namespace which introduces some additional complications we have yet
to handle.
Signed-off-by: David Gibson
In our test scripts we need to do some ugly parsing of /proc and/or pstree
output in order to get the PIDs of processes running in namespaces so that
we can connect to those namespaces with nsenter or pasta.
This is actually a pretty tricky problem with standard tools. To determine
the PID from the outside of the namespace we need to know how the process
of interest is related to the unshare or pasta process (child? one of
several children? grandchild?) as well as then parsing /proc or ps output.
This is slightly awkward now, and will get worse with future changes I'd
like to make to have processes are dispatched.
The obvious solution would be to have the process of interest (which we
control) report its own PID, but that doesn't work easily, because it is in
a PID namepace and sees only its local PID not the global PID we need to
address it from outside.
To handle this, add a small custom tool, "nsholder". This takes a path
and a mode parameter. In "hold" mode it will create a unix domain socket
bound to the path and listening. In "pid" mode it will get the "hold"ing
process's pid via the unix socket using SO_PEERCRED, which translates
between PID namespaces. In "stop" mode it will send a message to the
socket causing the "hold"ing process to clean up and exit.
Signed-off-by: David Gibson
Nit:
On Thu, 8 Sep 2022 11:49:16 +1000
David Gibson
[...]
diff --git a/test/nsholder.c b/test/nsholder.c new file mode 100644 index 0000000..bfe3611 --- /dev/null +++ b/test/nsholder.c @@ -0,0 +1,117 @@ +#define _GNU_SOURCE
It would be nice to have a licence and copyright notice here. From my perspective it's not necessarily needed (it would default to AGPLv3 and you as copyright holder), but might cause some trouble to packagers. -- Stefano
On Fri, Sep 09, 2022 at 05:18:58PM +0200, Stefano Brivio wrote: 11;rgb:ffff/ffff/ffff> Nit:
On Thu, 8 Sep 2022 11:49:16 +1000 David Gibson
wrote: [...]
diff --git a/test/nsholder.c b/test/nsholder.c new file mode 100644 index 0000000..bfe3611 --- /dev/null +++ b/test/nsholder.c @@ -0,0 +1,117 @@ +#define _GNU_SOURCE
It would be nice to have a licence and copyright notice here. From my perspective it's not necessarily needed (it would default to AGPLv3 and you as copyright holder), but might cause some trouble to packagers.
Good point. I added those notices and an informational banner. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Extend the context system to allow commands to be run in a namespace
created with unshare, and use it for the namespace used in the pasta tests.
Signed-off-by: David Gibson
Extends the context system in the test scripts to allow executing commands
within a guest. Do this without requiring an existing network in the guest
by using socat to run ssh via a vsock connection.
We do need some additional "sleep"s in the tests, because the new
faster dispatch means that sometimes we attempt to connect before
socat has managed to listen.
For now, only use this for the plain "passt" tests. The "passt_in_ns" and
other tests have additional complications we still need to deal with.
Signed-off-by: David Gibson
Now that we have all the pieces we need for issuing commands both into
namespaces and into guests, we can use those to convert the two_guests to
using only the new style context command issue.
Signed-off-by: David Gibson
Put the pieces together to use the new style context based dispatch for
the passt_in_pasta tests.
Signed-off-by: David Gibson
On Thu, 8 Sep 2022 11:49:20 +1000
David Gibson
Put the pieces together to use the new style context based dispatch for the passt_in_pasta tests.
Signed-off-by: David Gibson
[...]
+++ b/test/lib/setup
[...]
@@ -156,21 +147,18 @@ setup_passt_in_ns() { [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
if [ ${VALGRIND} -eq 1 ]; then - pane_run PASST "make clean" - pane_status PASST - pane_run PASST "make valgrind" - pane_status PASST - pane_run PASST "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" + context_run passt "make clean" + context_run passt "make valgrind" + context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" else - pane_run PASST "make clean" - pane_status PASST - pane_run PASST "make" - pane_status PASST - pane_run PASST "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" + context_run passt "make clean" + context_run passt "make" + context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" fi sleep 5
- pane_run GUEST './qrap 5 qemu-system-$(uname -m)' \ + GUEST_CID=94557
While this seems to be perfectly valid: is it supposed to be random, or a specific number for a reason I'm missing...? -- Stefano
On Fri, Sep 09, 2022 at 05:19:02PM +0200, Stefano Brivio wrote:
On Thu, 8 Sep 2022 11:49:20 +1000 David Gibson
wrote: Put the pieces together to use the new style context based dispatch for the passt_in_pasta tests.
Signed-off-by: David Gibson
[...]
+++ b/test/lib/setup
[...]
@@ -156,21 +147,18 @@ setup_passt_in_ns() { [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
if [ ${VALGRIND} -eq 1 ]; then - pane_run PASST "make clean" - pane_status PASST - pane_run PASST "make valgrind" - pane_status PASST - pane_run PASST "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" + context_run passt "make clean" + context_run passt "make valgrind" + context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" else - pane_run PASST "make clean" - pane_status PASST - pane_run PASST "make" - pane_status PASST - pane_run PASST "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" + context_run passt "make clean" + context_run passt "make" + context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" fi sleep 5
- pane_run GUEST './qrap 5 qemu-system-$(uname -m)' \ + GUEST_CID=94557
While this seems to be perfectly valid: is it supposed to be random, or a specific number for a reason I'm missing...?
It's entirely arbitrary - I went with as close a visual approximation of 'passt' as I could manage with digits (which isn't very close at all). -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
On Sat, 10 Sep 2022 16:47:28 +1000
David Gibson
On Fri, Sep 09, 2022 at 05:19:02PM +0200, Stefano Brivio wrote:
On Thu, 8 Sep 2022 11:49:20 +1000 David Gibson
wrote: Put the pieces together to use the new style context based dispatch for the passt_in_pasta tests.
Signed-off-by: David Gibson
[...]
+++ b/test/lib/setup
[...]
@@ -156,21 +147,18 @@ setup_passt_in_ns() { [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
if [ ${VALGRIND} -eq 1 ]; then - pane_run PASST "make clean" - pane_status PASST - pane_run PASST "make valgrind" - pane_status PASST - pane_run PASST "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" + context_run passt "make clean" + context_run passt "make valgrind" + context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" else - pane_run PASST "make clean" - pane_status PASST - pane_run PASST "make" - pane_status PASST - pane_run PASST "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" + context_run passt "make clean" + context_run passt "make" + context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid" fi sleep 5
- pane_run GUEST './qrap 5 qemu-system-$(uname -m)' \ + GUEST_CID=94557
While this seems to be perfectly valid: is it supposed to be random, or a specific number for a reason I'm missing...?
It's entirely arbitrary - I went with as close a visual approximation of 'passt' as I could manage with digits (which isn't very close at all).
Hah, sorry, of course. I would say it's actually the most acceptable translation of passt in leetspeek: https://en.wikipedia.org/wiki/Leet#Orthography ...never mind. -- Stefano
On Thu, 8 Sep 2022 11:49:09 +1000
David Gibson
Sorry for the resend, but I found and fixed a couple of warts in this series.
The test scripts need to dispatch commands in various different contexts: on the host, in namespaces, and in guests. Currently this is done by running each context in a tmux pane and simulating typing into that pane using tmux commands. This has a number of problems:
* It's slow * Getting the results from programs is tricky and error prone. We can misparse output if: * The window isn't large enough * Commands produce output which looks like a shell prompt * The shell doesn't have the prompt we expect * A accidental keypress while the tests are running can mess up the test run * We have to issue explicit "echo $?" commands to check if things succeeded
This series adds a new subsystem to the test scripts for dispatching commands which accurately preserves output (both stdout and stderr), and exit codes.
Most of the testsuite is converted to this new system. For now the distro tests still rely on the old approach, since they have some complications that require additional handling. That does, alas, mean we have some ugly transitional code remaining. Oh well, we should be able to clean that up at some point.
This series is pased on the previous series cleaning up the performance tests.
Changes since v1: * Removed a couple of commented debugging lines in patch 9/11 * Removed a no longer necessary pipe-pane in patch 9/11
In general, this looks like a big improvement, and I would try to apply it basically as it is (I haven't run the tests yet). There are a few nits that might need to be addressed. I can fix them up on merge, unless you re-spin this, but I'd need some help with the comment on 11/11. -- Stefano
On Fri, Sep 09, 2022 at 05:21:27PM +0200, Stefano Brivio wrote:
On Thu, 8 Sep 2022 11:49:09 +1000 David Gibson
wrote: Sorry for the resend, but I found and fixed a couple of warts in this series.
The test scripts need to dispatch commands in various different contexts: on the host, in namespaces, and in guests. Currently this is done by running each context in a tmux pane and simulating typing into that pane using tmux commands. This has a number of problems:
* It's slow * Getting the results from programs is tricky and error prone. We can misparse output if: * The window isn't large enough * Commands produce output which looks like a shell prompt * The shell doesn't have the prompt we expect * A accidental keypress while the tests are running can mess up the test run * We have to issue explicit "echo $?" commands to check if things succeeded
This series adds a new subsystem to the test scripts for dispatching commands which accurately preserves output (both stdout and stderr), and exit codes.
Most of the testsuite is converted to this new system. For now the distro tests still rely on the old approach, since they have some complications that require additional handling. That does, alas, mean we have some ugly transitional code remaining. Oh well, we should be able to clean that up at some point.
This series is pased on the previous series cleaning up the performance tests.
Changes since v1: * Removed a couple of commented debugging lines in patch 9/11 * Removed a no longer necessary pipe-pane in patch 9/11
In general, this looks like a big improvement, and I would try to apply it basically as it is (I haven't run the tests yet).
There are a few nits that might need to be addressed. I can fix them up on merge, unless you re-spin this, but I'd need some help with the comment on 11/11.
I'll send a respin next week when I can re-run the tests. This weekend I've realized another problem with the current testsuite: it reacts very poorly if the host has no IPv6 connectivity. Unusually for Australia I do have IPv6 at home, but not while I'm travelling with mobile data. I could get it using a VPN, of course, but it's a hassle. Anyway, that's another reason why having a more controlled artificial network environment for the tests would be valuable; I'll tackle that when I can. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
participants (2)
-
David Gibson
-
Stefano Brivio