From be2a7898e9de236da7c42d1fb37a5a2017ac192b Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Mon, 21 Feb 2022 13:35:45 +0100 Subject: test: Add demo for Podman with pasta ...showing setup steps, some peculiarities as --net option, and a general side-to-side comparison with slirp4netns(1), including "quick" TCP and UDP throughput and latency benchmarks. Signed-off-by: Stefano Brivio --- README.md | 11 +- test/demo/podman | 842 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/lib/layout | 38 ++- test/lib/setup | 21 +- test/lib/term | 10 + test/lib/test | 35 +++ test/run | 8 + 7 files changed, 959 insertions(+), 6 deletions(-) create mode 100644 test/demo/podman diff --git a/README.md b/README.md index 51cc870..16e91b9 100644 --- a/README.md +++ b/README.md @@ -398,9 +398,14 @@ is fully configurable with command line options. ### pasta -

+
+
use pasta to create and connect a namespace
+
use Podman with pasta
+
### passt diff --git a/test/demo/podman b/test/demo/podman new file mode 100644 index 0000000..cd7c1ef --- /dev/null +++ b/test/demo/podman @@ -0,0 +1,842 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/demo/podman - Show pasta operation with Podman +# +# Copyright (c) 2022 Red Hat GmbH +# Author: Stefano Brivio + +onlyfor podman + +set OPTS -Z -w 4M -l 1M -P 2 -t5 --pacing-timer 10000 +set OPTS_10s -Z -w 4M -l 1M -P 2 -t10 --pacing-timer 10000 + +say This is an overview of +em Podman +say using +em pasta +say . +nl +nl +sleep 3 + +say Let's fetch Podman +sleep 1 +tempdir TEMPDIR +host git -C __TEMPDIR__ clone https://github.com/containers/podman.git +sleep 1 + +say , patch it +sleep 1 +host cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __TEMPDIR__/podman +host cd __TEMPDIR__/podman +host patch -p1 < 0001-libpod-Add-pasta-networking-mode.patch +sleep 1 + +say , and build it. +host make +sleep 1 + +nl +nl +say By default, for +em rootless +say mode, Podman will pick +nl +em slirp4netns +say to operate the network. +nl +nl +say Let's start a container with it +sleep 1 + +ns1 cd __TEMPDIR__/podman +ns1b ./bin/podman run --rm -ti alpine sh +sleep 2 + +say , +nl +say and one with +em pasta +say instead. + +ns2 cd __TEMPDIR__/podman +ns2b ./bin/podman run --net=pasta --rm -ti alpine sh +sleep 2 + +nl +nl +say We can observe some practical differences: +nl + +ns1b ip ad sh +sleep 3 +say - slirp4netns uses a predefined IPv4 address +hl NS1 +sleep 2 + +ns2b ip ad sh +sleep 3 +say , +nl +say pasta copies addresses from the host +hl NS2 +sleep 2 + +nl +say - pasta enables IPv6 by default +hl NS2 +sleep 2 + +nl +say - slirp4netns uses +em tap0 +say as interface name +hl NS1 +sleep 2 + +say , pasta +nl +say takes an interface name from the host +hl NS2 +sleep 2 + +nl +say - same for routes: + +ns1b ip ro sh +sleep 3 +say slirp4netns defines its own +nl +say gateway address +hl NS1 +sleep 2 + +say , pasta copies it from the host +ns2b ip ro sh +ns2b ip -6 ro sh +sleep 5 + +nl +nl +say Let's check connectivity... +sleep 2 +ns1b wget risotto.milane.se +ns2b wget myfinge.rs +sleep 2 +say fine. +sleep 5 +nl +nl + +say Let's run a service in the container. We didn't +nl +say configure port forwarding. With default options, +nl +say pasta detects services bound inside and outside +nl +say the container and forwards ports accordingly, so +nl +say we don't need to restart it. Let's restart the +nl +say container running with slirp4netns... +sleep 5 + +ns1b exit +sleep 2 +ns1b podman run --rm -p 8080:8080/tcp -ti alpine sh +sleep 5 + +nl +nl +say and now actually start the service +ns1b apk add thttpd +ns2b apk add thttpd +ns1b >index.html cat << EOF +ns1b Hello via slirp4netns +ns1b EOF +ns2b >index.html cat << EOF +ns2b Hello via pasta +ns2b EOF +ns1b thttpd -p 8080 +ns2b thttpd -p 8081 + +sleep 3 +say , then check +nl +say that it's accessible. +sleep 3 + +hostb lynx http://127.0.0.1:8080/ +sleep 5 +hostb q +hostb lynx http://[::1]:8081/ +sleep 5 +hostb q +sleep 2 + +nl +nl +say What about performance, you might ask. +nl +say For simplicity, we'll measure between init +nl +say namespace (the "host") and container. To do +nl +say that, we need to allow the container direct +nl +say access to the host, which needs an extra option +nl +say in slirp4netns. Let's restart that container, +nl +say while also mapping ports for iperf3 and neper, +nl +say and enabling IPv6 for slirp4netns (experimental) +nl +say too. +sleep 3 + +ns1 exit + +ns1b podman run --rm --net=slirp4netns:allow_host_loopback=true,enable_ipv6=true -p 5201-5202:5201-5202/tcp -p 5201-5202:5201-5202/udp -ti alpine sh +sleep 5 +nl +nl +say pasta allows that by default, so we wouldn't need +nl +say to touch the container using pasta, but let's +nl +say take the chance to look at passing extra options +nl +say there as well. +nl +nl +ns2 exit + +say Options after '--net-pasta:' are the same as +nl +say documented for the command line of pasta(1). +nl +say For example, we can enable packet captures +sleep 3 +ns2b ./bin/podman run --net=pasta:--pcap,demo.pcap --rm -ti alpine sh +sleep 5 + +say , +nl +say and generate some traffic we can look at. +nl +sleep 2 +ns2b wget -O - lameexcu.se +sleep 2 +hostb tshark -r demo.pcap tcp +sleep 5 + +nl +say But back to performance now. By the way, +nl +say pasta doesn't detect bound UDP ports +nl +say periodically (only when it starts), so we +nl +say have to pass the ones we need explicitly. +nl +sleep 2 +ns2b exit +sleep 1 +ns2b ./bin/podman run --net=pasta:-U,5214 -p 5204:5204/udp --rm -ti alpine sh +sleep 5 + +nl +say In slirp4netns mode, Podman enables by +nl +say default the port forwarder from 'rootlesskit' +nl +say for better performance. +nl +say However, it can't be used for non-local +nl +say mappings (traffic without loopback source +nl +em and +say destination) because it doesn't preserve +nl +say the correct source address as it forwards +nl +say packets to the container. +sleep 3 +nl +nl +say We'll check non-loopback mappings first for +nl +say both pasta and slirp4netns, then restart the +nl +say slirp4netns container with rootlesskit and +nl +say switch to loopback mappings. pasta doesn't +nl +say have this limitation. +nl +nl +say One last note: slirp4netns doesn't support +nl +say forwarding of IPv6 ports (to the container): +nl +say github.com/rootless-containers/slirp4netns/issues/253 +nl +say so we'll skip IPv6 tests for slirp4netns as +nl +say port forwarder (on the path to the container). + +sleep 5 +ns1 exit +ns1b podman run --rm --net=slirp4netns:allow_host_loopback=true,enable_ipv6=true,port_handler=slirp4netns -p 5201-5202:5201-5202/tcp -p 5201-5202:5201-5202/udp -ti alpine sh +sleep 3 + +nl +nl +say We'll use iperf3(1) for throughput +sleep 2 +ns1b apk add iperf3 jq bc +ns2b apk add iperf3 jq bc +sleep 2 +say and static +nl +say builds of neper (github.com/google/neper) for +nl +say latency. +ns1 wget lameexcu.se/tcp_rr; chmod 755 tcp_rr +ns2 wget lameexcu.se/tcp_rr; chmod 755 tcp_rr +ns1 wget lameexcu.se/tcp_crr; chmod 755 tcp_crr +ns2 wget lameexcu.se/tcp_crr; chmod 755 tcp_crr +ns1 wget lameexcu.se/udp_rr; chmod 755 udp_rr +ns2 wget lameexcu.se/udp_rr; chmod 755 udp_rr +sleep 5 + +nl +nl +say Everything is set now, let's start +sleep 2 +hout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname' +hout ADDR4 ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local' +hout ADDR6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local' +hout GW4 ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway' +hout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway' + +nl +nl +resize INFO D 15 +info Throughput in Gbps, latency in µs +info non-loopback (tap) connections +th mode slirp4netns pasta + +tr TCP/IPv6 to ns +#ns1b (iperf3 -s1J -p 5201 | jq -rM ".end.sum_received.bits_per_second" >t1) & +#ns1b iperf3 -s1J -p 5202 | jq -rM ".end.sum_received.bits_per_second" >t2 +#hostb iperf3 -c __ADDR6__ -p 5201 __OPTS_10s__ & iperf3 -c __ADDR6__ -p 5202 __OPTS_10s__ +#sleep 15 +#ns1b +#ns1out BW echo "$(cat t1) + $(cat t2)" | bc -l +#bw __BW__ 0.0 0.0 +bw - +ns2b (iperf3 -s1J -p 5203 | jq -rM ".end.sum_received.bits_per_second" >t1) & +ns2b iperf3 -s1J -p 5204 | jq -rM ".end.sum_received.bits_per_second" >t2 +hostb iperf3 -c __ADDR6__ -p 5203 -t5 -l 1M -Z & iperf3 -c __ADDR6__ -p 5204 -t5 -l 1M -Z +sleep 10 +ns2b +ns2out BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +hostb + +tl RR latency +#ns1b ./tcp_rr -6 --nolog -C 5201 -P 5202 +#sleep 2 +#hout LAT tcp_rr --nolog -c -H __ADDR6__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +#lat __LAT__ 100000 100000 +lat - +ns2b ./tcp_rr -6 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT tcp_rr --nolog -c -H __ADDR6__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl CRR latency +#ns1b ./tcp_crr -6 --nolog -C 5201 -P 5202 +#sleep 2 +#hout LAT tcp_crr --nolog -c -H __ADDR6__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +#lat __LAT__ 100000 100000 +lat - +ns2b ./tcp_crr -6 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT tcp_crr --nolog -c -H __ADDR6__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl TCP/IPv4 to ns +ns1b (iperf3 -s1J -p 5201 | jq -rM ".end.sum_received.bits_per_second" >t1) & +ns1b iperf3 -s1J -p 5202 | jq -rM ".end.sum_received.bits_per_second" >t2 +hostb iperf3 -c __ADDR4__ -p 5201 __OPTS__ & iperf3 -c __ADDR4__ -p 5202 __OPTS__ +sleep 10 +ns1b +ns1out BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +ns2b (iperf3 -s1J -p 5203 | jq -rM ".end.sum_received.bits_per_second" >t1) & +ns2b iperf3 -s1J -p 5204 | jq -rM ".end.sum_received.bits_per_second" >t2 +hostb iperf3 -c __ADDR4__ -p 5203 __OPTS__ & iperf3 -c __ADDR4__ -p 5204 __OPTS__ +sleep 10 +ns2b +ns2out BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +hostb + +tl RR latency +ns1b ./tcp_rr -4 --nolog -C 5201 -P 5202 +sleep 2 +hout LAT tcp_rr --nolog -c -H __ADDR4__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +ns2b ./tcp_rr -4 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT tcp_rr --nolog -c -H __ADDR4__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl CRR latency +ns1b ./tcp_crr -4 --nolog -C 5201 -P 5202 +sleep 2 +hout LAT tcp_crr --nolog -c -H __ADDR4__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +ns2b ./tcp_crr -4 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT tcp_crr --nolog -c -H __ADDR4__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tr TCP/IPv6 to host +hostb (iperf3 -s1J -p 5211 | jq -rM ".end.sum_received.bits_per_second" >t1) & +hostb iperf3 -s1J -p 5212 | jq -rM ".end.sum_received.bits_per_second" >t2 +ns1b iperf3 -c fd00::2 -p 5211 __OPTS__ & iperf3 -c fd00::2 -p 5212 __OPTS__ +sleep 10 +hostb +hout BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +hostb (iperf3 -s1J -p 5213 | jq -rM ".end.sum_received.bits_per_second" >t1) & +hostb iperf3 -s1J -p 5214 | jq -rM ".end.sum_received.bits_per_second" >t2 +ns2b iperf3 -c __GW6__%__IFNAME__ -p 5213 __OPTS__ & iperf3 -c __GW6__%__IFNAME__ -p 5214 __OPTS__ +sleep 10 +hostb +hout BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +ns1b +ns2b + +tl RR latency +hostb tcp_rr -6 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./tcp_rr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb tcp_rr -6 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./tcp_rr --nolog -c -H __GW6__%__IFNAME__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl CRR latency +hostb tcp_crr -6 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./tcp_crr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb tcp_crr -6 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./tcp_crr --nolog -c -H __GW6__%__IFNAME__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl TCP/IPv4 to host +hostb (iperf3 -s1J -p 5211 | jq -rM ".end.sum_received.bits_per_second" >t1) & +hostb iperf3 -s1J -p 5212 | jq -rM ".end.sum_received.bits_per_second" >t2 +ns1b iperf3 -c 10.0.2.2 -p 5211 __OPTS__ & iperf3 -c 10.0.2.2 -p 5212 __OPTS__ +sleep 10 +hostb +hout BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +hostb (iperf3 -s1J -p 5213 | jq -rM ".end.sum_received.bits_per_second" >t1) & +hostb iperf3 -s1J -p 5214 | jq -rM ".end.sum_received.bits_per_second" >t2 +ns2b iperf3 -c __GW4__ -p 5213 __OPTS__ & iperf3 -c __GW4__ -p 5214 __OPTS__ +sleep 10 +hostb +hout BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +ns1b +ns2b + +tl RR latency +hostb tcp_rr -4 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./tcp_rr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb tcp_rr -4 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./tcp_rr --nolog -c -H __GW4__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl CRR latency +hostb tcp_crr -4 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./tcp_crr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb tcp_crr -4 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./tcp_crr --nolog -c -H __GW4__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +sleep 5 + + +tr UDP/IPv6 to ns +#ns1b iperf3 -s1J -p 5201 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +#hostb iperf3 -u -c __ADDR6__ -p 5201 -t5 -b 35G +#sleep 10 +#ns1out BW cat t1 +#bw __BW__ 0.0 0.0 +bw - +ns2b iperf3 -s1J -p 5204 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +hostb iperf3 -u -c __ADDR6__ -p 5204 -t5 -b 35G +sleep 10 +ns2out BW cat t1 +bw __BW__ 0.0 0.0 + +tl RR latency +#ns1b ./udp_rr -6 --nolog -C 5201 -P 5202 +#sleep 2 +#hout LAT udp_rr --nolog -c -H __ADDR6__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +#lat __LAT__ 100000 100000 +lat - +ns2b ./udp_rr -6 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT udp_rr --nolog -c -H __ADDR6__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl UDP/IPv4 to ns +ns1b iperf3 -s1J -p 5201 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +hostb iperf3 -u -c __ADDR4__ -p 5201 -t5 -b 35G +sleep 10 +ns1out BW cat t1 +bw __BW__ 0.0 0.0 +ns2b iperf3 -s1J -p 5204 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +hostb iperf3 -u -c __ADDR4__ -p 5204 -t5 -b 35G +sleep 10 +ns2out BW cat t1 +bw __BW__ 0.0 0.0 + +tl RR latency +ns1b ./udp_rr -6 --nolog -C 5201 -P 5202 +sleep 2 +hout LAT udp_rr --nolog -c -H __ADDR4__ -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +ns2b ./udp_rr -6 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT udp_rr --nolog -c -H __ADDR4__ -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tr UDP/IPv6 to host +hostb iperf3 -s1J -p 5211 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +ns1b iperf3 -u -c fd00::2 -p 5211 -t5 -b 35G +sleep 10 +hout BW cat t1 +bw __BW__ 0.0 0.0 +hostb iperf3 -s1J -p 5214 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +ns2b iperf3 -u -c __GW6__%__IFNAME__ -p 5214 -t5 -b 35G +sleep 10 +hout BW cat t1 +bw __BW__ 0.0 0.0 + +tl RR latency +hostb udp_rr -6 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./udp_rr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb udp_rr -6 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./udp_rr --nolog -c -H __GW6__%__IFNAME__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl UDP/IPv4 to host +hostb iperf3 -s1J -p 5211 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +ns1b iperf3 -u -c 10.0.2.2 -p 5211 -t5 -b 35G +sleep 10 +hout BW cat t1 +bw __BW__ 0.0 0.0 +hostb iperf3 -s1J -p 5214 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +ns2b iperf3 -u -c __GW4__ -p 5214 -t5 -b 35G +sleep 10 +hout BW cat t1 +bw __BW__ 0.0 0.0 + +tl RR latency +hostb udp_rr -6 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./udp_rr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb udp_rr -6 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./udp_rr --nolog -c -H __GW4__ -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + + +ns1 exit +ns1 podman run --rm --net=slirp4netns:allow_host_loopback=true,enable_ipv6=true -p 5201-5202:5201-5202/tcp -p 5201-5202:5201-5202/udp -ti alpine sh +ns1 apk add iperf3 jq bc +ns1 wget lameexcu.se/tcp_rr; chmod 755 tcp_rr +ns1 wget lameexcu.se/tcp_crr; chmod 755 tcp_crr +ns1 wget lameexcu.se/udp_rr; chmod 755 udp_rr +info +info +info loopback (lo) connections +th mode rootlesskit pasta + + +tr TCP/IPv6 to ns +ns1b (iperf3 -s1J -p 5201 | jq -rM ".end.sum_received.bits_per_second" >t1) & +ns1b iperf3 -s1J -p 5202 | jq -rM ".end.sum_received.bits_per_second" >t2 +hostb iperf3 -c ::1 -p 5201 -t5 -l 1M -Z & iperf3 -c ::1 -p 5202 -t5 -l 1M -Z +sleep 10 +ns1b +ns1out BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +ns2b (iperf3 -s1J -p 5203 | jq -rM ".end.sum_received.bits_per_second" >t1) & +ns2b iperf3 -s1J -p 5204 | jq -rM ".end.sum_received.bits_per_second" >t2 +hostb iperf3 -c ::1 -p 5203 -t5 -l 1M -Z & iperf3 -c ::1 -p 5204 -t5 -l 1M -Z +sleep 10 +ns2b +ns2out BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +hostb + +tl RR latency +ns1b ./tcp_rr -6 --nolog -C 5201 -P 5202 +sleep 2 +hout LAT tcp_rr --nolog -c -H ::1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +ns2b ./tcp_rr -6 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT tcp_rr --nolog -c -H ::1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl CRR latency +ns1b ./tcp_crr -6 --nolog -C 5201 -P 5202 +sleep 2 +hout LAT tcp_crr --nolog -c -H ::1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +ns2b ./tcp_crr -6 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT tcp_crr --nolog -c -H ::1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl TCP/IPv4 to ns +ns1b (iperf3 -s1J -p 5201 | jq -rM ".end.sum_received.bits_per_second" >t1) & +ns1b iperf3 -s1J -p 5202 | jq -rM ".end.sum_received.bits_per_second" >t2 +hostb iperf3 -c 127.0.0.1 -p 5201 __OPTS__ & iperf3 -c 127.0.0.1 -p 5202 __OPTS__ +sleep 10 +ns1b +ns1out BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +ns2b (iperf3 -s1J -p 5203 | jq -rM ".end.sum_received.bits_per_second" >t1) & +ns2b iperf3 -s1J -p 5204 | jq -rM ".end.sum_received.bits_per_second" >t2 +hostb iperf3 -c 127.0.0.1 -p 5203 __OPTS__ & iperf3 -c 127.0.0.1 -p 5204 __OPTS__ +sleep 10 +ns2b +ns2out BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +hostb + +tl RR latency +ns1b ./tcp_rr -4 --nolog -C 5201 -P 5202 +sleep 2 +hout LAT tcp_rr --nolog -c -H 127.0.0.1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +ns2b ./tcp_rr -4 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT tcp_rr --nolog -c -H 127.0.0.1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl CRR latency +ns1b ./tcp_crr -4 --nolog -C 5201 -P 5202 +sleep 2 +hout LAT tcp_crr --nolog -c -H 127.0.0.1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +ns2b ./tcp_crr -4 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT tcp_crr --nolog -c -H 127.0.0.1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tr TCP/IPv6 to host +hostb (iperf3 -s1J -p 5211 | jq -rM ".end.sum_received.bits_per_second" >t1) & +hostb iperf3 -s1J -p 5212 | jq -rM ".end.sum_received.bits_per_second" >t2 +ns1b iperf3 -c fd00::2 -p 5211 __OPTS__ & iperf3 -c fd00::2 -p 5212 __OPTS__ +sleep 10 +hostb +hout BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +hostb (iperf3 -s1J -p 5213 | jq -rM ".end.sum_received.bits_per_second" >t1) & +hostb iperf3 -s1J -p 5214 | jq -rM ".end.sum_received.bits_per_second" >t2 +ns2b iperf3 -c ::1 -p 5213 __OPTS__ & iperf3 -c ::1 -p 5214 __OPTS__ +sleep 10 +hostb +hout BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +ns1b +ns2b + +tl RR latency +hostb tcp_rr -6 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./tcp_rr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb tcp_rr -6 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./tcp_rr --nolog -c -H ::1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl CRR latency +hostb tcp_crr -6 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./tcp_crr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb tcp_crr -6 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./tcp_crr --nolog -c -H ::1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl TCP/IPv4 to host +hostb (iperf3 -s1J -p 5211 | jq -rM ".end.sum_received.bits_per_second" >t1) & +hostb iperf3 -s1J -p 5212 | jq -rM ".end.sum_received.bits_per_second" >t2 +ns1b iperf3 -c 10.0.2.2 -p 5211 __OPTS__ & iperf3 -c 10.0.2.2 -p 5212 __OPTS__ +sleep 10 +hostb +hout BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +hostb (iperf3 -s1J -p 5213 | jq -rM ".end.sum_received.bits_per_second" >t1) & +hostb iperf3 -s1J -p 5214 | jq -rM ".end.sum_received.bits_per_second" >t2 +ns2b iperf3 -c 127.0.0.1 -p 5213 __OPTS__ & iperf3 -c 127.0.0.1 -p 5214 __OPTS__ +sleep 10 +hostb +hout BW echo "$(cat t1) + $(cat t2)" | bc -l +bw __BW__ 0.0 0.0 +ns1b +ns2b + +tl RR latency +hostb tcp_rr -4 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./tcp_rr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb tcp_rr -4 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./tcp_rr --nolog -c -H 127.0.0.1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl CRR latency +hostb tcp_crr -4 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./tcp_crr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb tcp_crr -4 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./tcp_crr --nolog -c -H 127.0.0.1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +sleep 5 + + +tr UDP/IPv6 to ns +ns1b iperf3 -s1J -p 5201 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +hostb iperf3 -u -c ::1 -p 5201 -t5 -b 35G +sleep 10 +ns1out BW cat t1 +bw __BW__ 0.0 0.0 +ns2b iperf3 -s1J -p 5204 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +hostb iperf3 -u -c ::1 -p 5204 -t5 -b 35G +sleep 10 +ns2out BW cat t1 +bw __BW__ 0.0 0.0 + +tl RR latency +ns1b ./udp_rr -6 --nolog -C 5201 -P 5202 +sleep 2 +hout LAT udp_rr --nolog -c -H ::1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +ns2b ./udp_rr -6 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT udp_rr --nolog -c -H ::1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl UDP/IPv4 to ns +ns1b iperf3 -s1J -p 5201 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +hostb iperf3 -u -c 127.0.0.1 -p 5201 -t5 -b 35G +sleep 10 +ns1out BW cat t1 +bw __BW__ 0.0 0.0 +ns2b iperf3 -s1J -p 5204 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +hostb iperf3 -u -c 127.0.0.1 -p 5204 -t5 -b 35G +sleep 10 +ns2out BW cat t1 +bw __BW__ 0.0 0.0 + +tl RR latency +ns1b ./udp_rr -6 --nolog -C 5201 -P 5202 +sleep 2 +hout LAT udp_rr --nolog -c -H 127.0.0.1 -C 5201 -P 5202 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +ns2b ./udp_rr -6 --nolog -C 5203 -P 5204 +sleep 2 +hout LAT udp_rr --nolog -c -H 127.0.0.1 -C 5203 -P 5204 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tr UDP/IPv6 to host +hostb iperf3 -s1J -p 5211 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +ns1b iperf3 -u -c fd00::2 -p 5211 -t5 -b 35G +sleep 10 +hout BW cat t1 +bw __BW__ 0.0 0.0 +hostb iperf3 -s1J -p 5214 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +ns2b iperf3 -u -c ::1 -p 5214 -t5 -b 35G +sleep 10 +hout BW cat t1 +bw __BW__ 0.0 0.0 + +tl RR latency +hostb udp_rr -6 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./udp_rr --nolog -c -H fd00::2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb udp_rr -6 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./udp_rr --nolog -c -H ::1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + +tl UDP/IPv4 to host +hostb iperf3 -s1J -p 5211 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +ns1b iperf3 -u -c 10.0.2.2 -p 5211 -t5 -b 35G +sleep 10 +hout BW cat t1 +bw __BW__ 0.0 0.0 +hostb iperf3 -s1J -p 5214 | jq -rM ".intervals[0].sum.bits_per_second" >t1 +ns2b iperf3 -u -c 127.0.0.1 -p 5214 -t5 -b 35G +sleep 10 +hout BW cat t1 +bw __BW__ 0.0 0.0 + +tl RR latency +hostb udp_rr -6 --nolog -C 5211 -P 5212 +sleep 2 +ns1out LAT ./udp_rr --nolog -c -H 10.0.2.2 -C 5211 -P 5212 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 +hostb udp_rr -6 --nolog -C 5213 -P 5214 +sleep 2 +ns2out LAT ./udp_rr --nolog -c -H 127.0.0.1 -C 5213 -P 5214 -l 5 | sed -n 's/^throughput=\(.*\)/\1/p' +lat __LAT__ 100000 100000 + + +nl +nl +say Thanks for watching! +sleep 15 diff --git a/test/lib/layout b/test/lib/layout index 7802dac..2d6b197 100644 --- a/test/lib/layout +++ b/test/lib/layout @@ -207,7 +207,6 @@ layout_two_guests() { layout_demo_pasta() { sleep 3 - tmux kill-pane -a -t 0 cmd_write 0 cd ${BASEPATH} cmd_write 0 clear sleep 1 @@ -244,7 +243,6 @@ layout_demo_pasta() { layout_demo_passt() { sleep 3 - tmux kill-pane -a -t 0 cmd_write 0 cd ${BASEPATH} cmd_write 0 clear sleep 1 @@ -276,3 +274,39 @@ layout_demo_passt() { sleep 1 } + +# layout_demo_podman() - Four panes for pasta demo with Podman +layout_demo_podman() { + sleep 3 + + cmd_write 0 cd ${BASEPATH} + cmd_write 0 clear + sleep 1 + cmd_write 0 clear + + tmux split-window -v -l '65%' -t passt_test + tmux split-window -h -t passt_test + tmux split-window -h -l '42%' -t passt_test:1.0 + + PANE_HOST=0 + PANE_INFO=1 + PANE_NS1=2 + PANE_NS2=3 + + get_info_cols + + tmux pipe-pane -O -t ${PANE_NS1} "cat >> ${LOGDIR}/pane_ns1.log" + tmux select-pane -t ${PANE_NS1} -T "Podman with slirp4netns" + + tmux pipe-pane -O -t ${PANE_NS2} "cat >> ${LOGDIR}/pane_ns2.log" + tmux select-pane -t ${PANE_NS2} -T "Podman with pasta" + + tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done' + tmux send-keys -t ${PANE_INFO} -N 100 C-m + tmux select-pane -t ${PANE_INFO} -T "" + + tmux pipe-pane -O -t ${PANE_HOST} "cat >> ${LOGDIR}/pane_host.log" + tmux select-pane -t ${PANE_HOST} -T "host" + + sleep 1 +} diff --git a/test/lib/setup b/test/lib/setup index df21655..b076eff 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -327,12 +327,31 @@ teardown_demo_passt() { pane_wait GUEST pane_wait HOST pane_wait PASST + + tmux kill-pane -a -t 0 + tmux send-keys -t 0 "C-c" } -# teardown_demo_pasta() - Exit namespace from remaining pane +# teardown_demo_pasta() - Exit perf and namespace from remaining pane teardown_demo_pasta() { + tmux send-keys -t ${PANE_NS} "q" + pane_wait NS tmux send-keys -t ${PANE_NS} "C-d" pane_wait NS + + tmux kill-pane -a -t 0 + tmux send-keys -t 0 "C-c" +} + +# teardown_demo_podman() - Exit namespaces +teardown_demo_podman() { + tmux send-keys -t ${PANE_NS1} "C-d" + tmux send-keys -t ${PANE_NS2} "C-d" + pane_wait NS1 + pane_wait NS2 + + tmux kill-pane -a -t 0 + tmux send-keys -t 0 "C-c" } # setup() - Run setup_*() functions diff --git a/test/lib/term b/test/lib/term index cc6349f..e8a1d38 100755 --- a/test/lib/term +++ b/test/lib/term @@ -176,6 +176,15 @@ pane_highlight() { sleep 3 } +# pane_resize() - Resize a pane given its name +# $1: Pane name +# $2: Direction: U, D, L, or R +# $3: Adjustment in lines or columns +pane_resize() { + __pane_number=$(eval echo \$PANE_${1}) + tmux resize-pane -${2} -t ${__pane_number} ${3} +} + # pane_run() - Issue a command in given pane name # $1: Pane name # $@: Command to issue @@ -201,6 +210,7 @@ pane_wait() { case ${__l} in '$ ' | '# ' | '# # ' | *"$ " | *"# ") return ;; *" #[m " | *" #[m [K" | *"]# ["*) return ;; + *' $ [6n' | *' # [6n' ) return ;; esac do sleep 0.1 || sleep 1; done } diff --git a/test/lib/test b/test/lib/test index 9f6f6e4..2854191 100755 --- a/test/lib/test +++ b/test/lib/test @@ -218,12 +218,32 @@ test_one_line() { pane_run NS "${__arg}" pane_wait NS ;; + "ns1") + pane_run NS1 "${__arg}" + pane_wait NS1 + ;; + "ns2") + pane_run NS2 "${__arg}" + pane_wait NS2 + ;; "nsb") pane_run NS "${__arg}" ;; + "ns1b") + pane_run NS1 "${__arg}" + ;; + "ns2b") + pane_run NS2 "${__arg}" + ;; "nsw") pane_wait NS ;; + "ns1w") + pane_wait NS1 + ;; + "ns2w") + pane_wait NS2 + ;; "nstools") pane_run NS 'which '"${__arg}"' >/dev/null || echo skip' pane_wait NS @@ -259,6 +279,18 @@ test_one_line() { pane_wait NS TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "$(pane_parse NS)")" ;; + "ns1out") + __varname="${__arg%% *}" + pane_run NS1 "${__arg#* }" + pane_wait NS1 + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "$(pane_parse NS1)")" + ;; + "ns2out") + __varname="${__arg%% *}" + pane_run NS2 "${__arg#* }" + pane_wait NS2 + TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__varname}__" "$(pane_parse NS2)")" + ;; "check") info_check "${__arg}" __nok=0 @@ -326,6 +358,9 @@ test_one_line() { "killp") pane_kill "${__arg}" ;; + "resize") + pane_resize ${__arg} + ;; *) __def_body="$(eval printf \"\$TEST_ONE_DEF_$__cmd\")" if [ -n "${__def_body}" ]; then diff --git a/test/run b/test/run index dadd983..c91122d 100755 --- a/test/run +++ b/test/run @@ -128,6 +128,14 @@ demo() { MODE=pasta test demo video_stop 0 + teardown demo_pasta + + layout_demo_podman + video_grab demo_podman + MODE=podman + test demo + video_stop 0 + teardown_demo_podman return 0 } -- cgit v1.2.3