From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: [PATCH 05/12] test: Use --config-net for namespace setup Date: Fri, 23 Sep 2022 17:20:31 +1000 Message-ID: <20220923072038.1667106-6-david@gibson.dropbear.id.au> In-Reply-To: <20220923072038.1667106-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7144670407263548274==" --===============7144670407263548274== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The setup functions for passt_in_ns and two_guests perform some fairly slow dhclient calls to configure the network in the namespace before starting the guest. This isn't really part of the tests, just necessary for the operations later. We can simplify and speed this up a bit by using pasta's '--config-net' option to configure the networking for us. As a bonus this means we have at least a minimal test of the --config-net option itself. Signed-off-by: David Gibson --- test/lib/setup | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/test/lib/setup b/test/lib/setup index dee7b46..668fee8 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -132,7 +132,7 @@ setup_passt_in_ns() { [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" [ ${TRACE} -eq 1 ] && __opts=3D"${__opts} --trace" =20 - context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003= ,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P ${STATESETUP}/pasta.pid $= {NSHOLDER} ${STATESETUP}/ns.hold hold" + context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003= ,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P ${STATESETUP}/pasta.pid -= -config-net ${NSHOLDER} ${STATESETUP}/ns.hold hold" wait_for [ -f "${STATESETUP}/pasta.pid" ] __ns_pid=3D$(${NSHOLDER} ${STATESETUP}/ns.hold pid) =20 @@ -140,11 +140,6 @@ setup_passt_in_ns() { context_setup_nsenter ns "-t ${__ns_pid} -U -n -p --preserve-credentials" context_setup_nsenter passt "-t ${__ns_pid} -U -n -p --preserve-credentials" =20 - __ifname=3D$(context_run ns "ip -j link show | jq -rM '.[] | select(.link_t= ype =3D=3D \"ether\").ifname'") - context_run ns "/sbin/dhclient -4 --no-pid ${__ifname}" - sleep 2 - context_run ns "/sbin/dhclient -6 --no-pid ${__ifname}" - __opts=3D [ ${PCAP} -eq 1 ] && __opts=3D"${__opts} -p ${LOGDIR}/passt_in_pasta.pcap" [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" @@ -201,7 +196,7 @@ setup_two_guests() { [ ${PCAP} -eq 1 ] && __opts=3D"${__opts} -p ${LOGDIR}/pasta_1.pcap" [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" [ ${TRACE} -eq 1 ] && __opts=3D"${__opts} --trace" - context_run_bg pasta_1 "./pasta ${__opts} -P ${STATESETUP}/pasta_1.pid -t 1= 0001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ${STATESE= TUP}/ns1.hold hold" + context_run_bg pasta_1 "./pasta ${__opts} -P ${STATESETUP}/pasta_1.pid -t 1= 0001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 --config-net ${NSHOLD= ER} ${STATESETUP}/ns1.hold hold" __ns1_pid=3D$(${NSHOLDER} ${STATESETUP}/ns1.hold pid) context_setup_nsenter passt_1 -U -n -p --preserve-credentials -t ${__ns1_pi= d} =20 @@ -209,7 +204,7 @@ setup_two_guests() { [ ${PCAP} -eq 1 ] && __opts=3D"${__opts} -p ${LOGDIR}/pasta_2.pcap" [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" [ ${TRACE} -eq 1 ] && __opts=3D"${__opts} --trace" - context_run_bg pasta_2 "./pasta ${__opts} -P ${STATESETUP}/pasta_2.pid -t 1= 0004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ${STATESE= TUP}/ns2.hold hold" + context_run_bg pasta_2 "./pasta ${__opts} -P ${STATESETUP}/pasta_2.pid -t 1= 0004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 --config-net ${NSHOLD= ER} ${STATESETUP}/ns2.hold hold" __ns2_pid=3D$(${NSHOLDER} ${STATESETUP}/ns2.hold pid) context_setup_nsenter passt_2 -U -n -p --preserve-credentials -t ${__ns2_pi= d} =20 @@ -218,12 +213,6 @@ setup_two_guests() { =20 __ifname=3D"$(context_run qemu_1 "ip -j link show | jq -rM '.[] | select(.l= ink_type =3D=3D \"ether\").ifname'")" =20 - context_run qemu_1 "/sbin/dhclient -4 --no-pid ${__ifname}" - context_run qemu_2 "/sbin/dhclient -4 --no-pid ${__ifname}" - sleep 2 - context_run qemu_1 "/sbin/dhclient -6 --no-pid ${__ifname}" - context_run qemu_2 "/sbin/dhclient -6 --no-pid ${__ifname}" - __opts=3D [ ${PCAP} -eq 1 ] && __opts=3D"${__opts} -p ${LOGDIR}/passt_1.pcap" [ ${DEBUG} -eq 1 ] && __opts=3D"${__opts} -d" --=20 2.37.3 --===============7144670407263548274==--