mirror of
https://passt.top/passt
synced 2025-05-28 04:17:20 +02:00
test: Add migration tests
PCAP=1 ./run migrate/bidirectional gives an overview of how the whole thing is working. Add 12 tests in total, checking basic functionality with and without flows in both directions, with and without sockets in half-closed states (both inbound and outbound), migration behaviour under traffic flood, under traffic flood with > 253 flows, and strict checking of sequences under flood with ramp patterns in both directions. These tests need preparation and teardown for each case, as we need to restore the source guest in its own context and pane before we can test again. Eventually, we could consider alternating source and target so that we don't need to restart from scratch every time, but that's beyond the scope of this initial test implementation. Trick: './run migrate/*' runs all the tests with preparation and teardown steps. Co-authored-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
89ecf2fd40
commit
a1e48a02ff
16 changed files with 871 additions and 14 deletions
|
@ -135,7 +135,7 @@ layout_two_guests() {
|
|||
get_info_cols
|
||||
|
||||
pane_watch_contexts ${PANE_GUEST_1} "guest #1 in namespace #1" qemu_1 guest_1
|
||||
pane_watch_contexts ${PANE_GUEST_2} "guest #2 in namespace #2" qemu_2 guest_2
|
||||
pane_watch_contexts ${PANE_GUEST_2} "guest #2 in namespace #1" qemu_2 guest_2
|
||||
|
||||
tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
|
||||
tmux send-keys -t ${PANE_INFO} -N 100 C-m
|
||||
|
@ -143,13 +143,66 @@ layout_two_guests() {
|
|||
|
||||
pane_watch_contexts ${PANE_HOST} host host
|
||||
pane_watch_contexts ${PANE_PASST_1} "passt #1 in namespace #1" pasta_1 passt_1
|
||||
pane_watch_contexts ${PANE_PASST_2} "passt #2 in namespace #2" pasta_2 passt_2
|
||||
pane_watch_contexts ${PANE_PASST_2} "passt #2 in namespace #1" pasta_1 passt_2
|
||||
|
||||
info_layout "two guests, two passt instances, in namespaces"
|
||||
|
||||
sleep 1
|
||||
}
|
||||
|
||||
# layout_migrate() - Two guest panes, two passt panes, two passt-repair panes,
|
||||
# plus host and log
|
||||
layout_migrate() {
|
||||
sleep 1
|
||||
|
||||
tmux kill-pane -a -t 0
|
||||
cmd_write 0 clear
|
||||
|
||||
tmux split-window -v -t passt_test
|
||||
tmux split-window -h -l '33%'
|
||||
tmux split-window -h -t passt_test:1.1
|
||||
|
||||
tmux split-window -h -l '35%' -t passt_test:1.0
|
||||
tmux split-window -v -t passt_test:1.0
|
||||
|
||||
tmux split-window -v -t passt_test:1.4
|
||||
tmux split-window -v -t passt_test:1.6
|
||||
|
||||
tmux split-window -v -t passt_test:1.3
|
||||
|
||||
PANE_GUEST_1=0
|
||||
PANE_GUEST_2=1
|
||||
PANE_INFO=2
|
||||
PANE_MON=3
|
||||
PANE_HOST=4
|
||||
PANE_PASST_REPAIR_1=5
|
||||
PANE_PASST_1=6
|
||||
PANE_PASST_REPAIR_2=7
|
||||
PANE_PASST_2=8
|
||||
|
||||
get_info_cols
|
||||
|
||||
pane_watch_contexts ${PANE_GUEST_1} "guest #1 in namespace #1" qemu_1 guest_1
|
||||
pane_watch_contexts ${PANE_GUEST_2} "guest #2 in namespace #2" qemu_2 guest_2
|
||||
|
||||
tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
|
||||
tmux send-keys -t ${PANE_INFO} -N 100 C-m
|
||||
tmux select-pane -t ${PANE_INFO} -T "test log"
|
||||
|
||||
pane_watch_contexts ${PANE_MON} "QEMU monitor" mon mon
|
||||
|
||||
pane_watch_contexts ${PANE_HOST} host host
|
||||
pane_watch_contexts ${PANE_PASST_REPAIR_1} "passt-repair #1 in namespace #1" repair_1 passt_repair_1
|
||||
pane_watch_contexts ${PANE_PASST_1} "passt #1 in namespace #1" pasta_1 passt_1
|
||||
|
||||
pane_watch_contexts ${PANE_PASST_REPAIR_2} "passt-repair #2 in namespace #2" repair_2 passt_repair_2
|
||||
pane_watch_contexts ${PANE_PASST_2} "passt #2 in namespace #2" pasta_2 passt_2
|
||||
|
||||
info_layout "two guests, two passt + passt-repair instances, in namespaces"
|
||||
|
||||
sleep 1
|
||||
}
|
||||
|
||||
# layout_demo_pasta() - Four panes for pasta demo
|
||||
layout_demo_pasta() {
|
||||
sleep 1
|
||||
|
|
138
test/lib/setup
138
test/lib/setup
|
@ -305,6 +305,117 @@ setup_two_guests() {
|
|||
context_setup_guest guest_2 ${GUEST_2_CID}
|
||||
}
|
||||
|
||||
# setup_migrate() - Set up two namespace, run qemu, passt/passt-repair in both
|
||||
setup_migrate() {
|
||||
context_setup_host host
|
||||
context_setup_host mon
|
||||
context_setup_host pasta_1
|
||||
context_setup_host pasta_2
|
||||
|
||||
layout_migrate
|
||||
|
||||
# Ports:
|
||||
#
|
||||
# guest #1 | guest #2 | ns #1 | host
|
||||
# --------- |-----------|-----------|------------
|
||||
# 10001 as server | | to guest | to ns #1
|
||||
# 10002 | | as server | to ns #1
|
||||
# 10003 | | to init | as server
|
||||
# 10004 | as server | to guest | to ns #1
|
||||
|
||||
__opts=
|
||||
[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_1.pcap"
|
||||
[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
|
||||
[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
|
||||
|
||||
__map_host4=192.0.2.1
|
||||
__map_host6=2001:db8:9a55::1
|
||||
__map_ns4=192.0.2.2
|
||||
__map_ns6=2001:db8:9a55::2
|
||||
|
||||
# Option 1: send stuff via spliced path in pasta
|
||||
# context_run_bg pasta_1 "./pasta ${__opts} -P ${STATESETUP}/pasta_1.pid -t 10001,10002 -T 10003 -u 10001,10002 -U 10003 --config-net ${NSTOOL} hold ${STATESETUP}/ns1.hold"
|
||||
# Option 2: send stuff via tap (--map-guest-addr) instead (useful to see capture of full migration)
|
||||
context_run_bg pasta_1 "./pasta ${__opts} -P ${STATESETUP}/pasta_1.pid -t 10001,10002,10004 -T 10003 -u 10001,10002,10004 -U 10003 --map-guest-addr ${__map_host4} --map-guest-addr ${__map_host6} --config-net ${NSTOOL} hold ${STATESETUP}/ns1.hold"
|
||||
context_setup_nstool passt_1 ${STATESETUP}/ns1.hold
|
||||
context_setup_nstool passt_repair_1 ${STATESETUP}/ns1.hold
|
||||
|
||||
context_setup_nstool passt_2 ${STATESETUP}/ns1.hold
|
||||
context_setup_nstool passt_repair_2 ${STATESETUP}/ns1.hold
|
||||
|
||||
context_setup_nstool qemu_1 ${STATESETUP}/ns1.hold
|
||||
context_setup_nstool qemu_2 ${STATESETUP}/ns1.hold
|
||||
|
||||
__ifname="$(context_run qemu_1 "ip -j link show | jq -rM '.[] | select(.link_type == \"ether\").ifname'")"
|
||||
|
||||
sleep 1
|
||||
|
||||
__opts="--vhost-user"
|
||||
[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_1.pcap"
|
||||
[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
|
||||
[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
|
||||
|
||||
context_run_bg passt_1 "./passt -s ${STATESETUP}/passt_1.socket -P ${STATESETUP}/passt_1.pid -f ${__opts} -t 10001 -u 10001"
|
||||
wait_for [ -f "${STATESETUP}/passt_1.pid" ]
|
||||
|
||||
context_run_bg passt_repair_1 "./passt-repair ${STATESETUP}/passt_1.socket.repair"
|
||||
|
||||
__opts="--vhost-user"
|
||||
[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_2.pcap"
|
||||
[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
|
||||
[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
|
||||
|
||||
context_run_bg passt_2 "./passt -s ${STATESETUP}/passt_2.socket -P ${STATESETUP}/passt_2.pid -f ${__opts} -t 10004 -u 10004"
|
||||
wait_for [ -f "${STATESETUP}/passt_2.pid" ]
|
||||
|
||||
context_run_bg passt_repair_2 "./passt-repair ${STATESETUP}/passt_2.socket.repair"
|
||||
|
||||
__vmem="512M" # Keep migration fast
|
||||
__qemu_netdev1=" \
|
||||
-chardev socket,id=c,path=${STATESETUP}/passt_1.socket \
|
||||
-netdev vhost-user,id=v,chardev=c \
|
||||
-device virtio-net,netdev=v \
|
||||
-object memory-backend-memfd,id=m,share=on,size=${__vmem} \
|
||||
-numa node,memdev=m"
|
||||
__qemu_netdev2=" \
|
||||
-chardev socket,id=c,path=${STATESETUP}/passt_2.socket \
|
||||
-netdev vhost-user,id=v,chardev=c \
|
||||
-device virtio-net,netdev=v \
|
||||
-object memory-backend-memfd,id=m,share=on,size=${__vmem} \
|
||||
-numa node,memdev=m"
|
||||
|
||||
GUEST_1_CID=94557
|
||||
context_run_bg qemu_1 'qemu-system-'"${QEMU_ARCH}" \
|
||||
' -M accel=kvm:tcg' \
|
||||
' -m '${__vmem}' -cpu host -smp '${VCPUS} \
|
||||
' -kernel '"${KERNEL}" \
|
||||
' -initrd '${INITRAMFS}' -nographic -serial stdio' \
|
||||
' -nodefaults' \
|
||||
' -append "console=ttyS0 mitigations=off apparmor=0" ' \
|
||||
" ${__qemu_netdev1}" \
|
||||
" -pidfile ${STATESETUP}/qemu_1.pid" \
|
||||
" -device vhost-vsock-pci,guest-cid=$GUEST_1_CID" \
|
||||
" -monitor unix:${STATESETUP}/qemu_1_mon.sock,server,nowait"
|
||||
|
||||
GUEST_2_CID=94558
|
||||
context_run_bg qemu_2 'qemu-system-'"${QEMU_ARCH}" \
|
||||
' -M accel=kvm:tcg' \
|
||||
' -m '${__vmem}' -cpu host -smp '${VCPUS} \
|
||||
' -kernel '"${KERNEL}" \
|
||||
' -initrd '${INITRAMFS}' -nographic -serial stdio' \
|
||||
' -nodefaults' \
|
||||
' -append "console=ttyS0 mitigations=off apparmor=0" ' \
|
||||
" ${__qemu_netdev2}" \
|
||||
" -pidfile ${STATESETUP}/qemu_2.pid" \
|
||||
" -device vhost-vsock-pci,guest-cid=$GUEST_2_CID" \
|
||||
" -monitor unix:${STATESETUP}/qemu_2_mon.sock,server,nowait" \
|
||||
" -incoming tcp:0:20005"
|
||||
|
||||
context_setup_guest guest_1 ${GUEST_1_CID}
|
||||
# Only available after migration:
|
||||
( context_setup_guest guest_2 ${GUEST_2_CID} & )
|
||||
}
|
||||
|
||||
# teardown_context_watch() - Remove contexts and stop panes watching them
|
||||
# $1: Pane number watching
|
||||
# $@: Context names
|
||||
|
@ -375,7 +486,8 @@ teardown_two_guests() {
|
|||
context_wait pasta_1
|
||||
context_wait pasta_2
|
||||
|
||||
rm -f "${STATESETUP}/passt__[12].pid" "${STATESETUP}/pasta_[12].pid"
|
||||
rm "${STATESETUP}/passt_1.pid" "${STATESETUP}/passt_2.pid"
|
||||
rm "${STATESETUP}/pasta_1.pid" "${STATESETUP}/pasta_2.pid"
|
||||
|
||||
teardown_context_watch ${PANE_HOST} host
|
||||
teardown_context_watch ${PANE_GUEST_1} qemu_1 guest_1
|
||||
|
@ -384,6 +496,30 @@ teardown_two_guests() {
|
|||
teardown_context_watch ${PANE_PASST_2} pasta_2 passt_2
|
||||
}
|
||||
|
||||
# teardown_migrate() - Exit namespaces, kill qemu processes, passt and pasta
|
||||
teardown_migrate() {
|
||||
${NSTOOL} exec ${STATESETUP}/ns1.hold -- kill $(cat "${STATESETUP}/qemu_1.pid")
|
||||
${NSTOOL} exec ${STATESETUP}/ns1.hold -- kill $(cat "${STATESETUP}/qemu_2.pid")
|
||||
context_wait qemu_1
|
||||
context_wait qemu_2
|
||||
|
||||
${NSTOOL} exec ${STATESETUP}/ns1.hold -- kill $(cat "${STATESETUP}/passt_2.pid")
|
||||
context_wait passt_1
|
||||
context_wait passt_2
|
||||
${NSTOOL} stop "${STATESETUP}/ns1.hold"
|
||||
context_wait pasta_1
|
||||
|
||||
rm -f "${STATESETUP}/passt_1.pid" "${STATESETUP}/passt_2.pid"
|
||||
rm -f "${STATESETUP}/pasta_1.pid" "${STATESETUP}/pasta_2.pid"
|
||||
|
||||
teardown_context_watch ${PANE_HOST} host
|
||||
|
||||
teardown_context_watch ${PANE_GUEST_1} qemu_1 guest_1
|
||||
teardown_context_watch ${PANE_GUEST_2} qemu_2 guest_2
|
||||
teardown_context_watch ${PANE_PASST_1} pasta_1 passt_1
|
||||
teardown_context_watch ${PANE_PASST_2} pasta_1 passt_2
|
||||
}
|
||||
|
||||
# teardown_demo_passt() - Exit namespace, kill qemu, passt and pasta
|
||||
teardown_demo_passt() {
|
||||
tmux send-keys -t ${PANE_GUEST} "C-c"
|
||||
|
|
|
@ -68,6 +68,45 @@ test_iperf3() {
|
|||
TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__var}__" "${__bw}" )"
|
||||
}
|
||||
|
||||
# test_iperf3m() - Ugly helper for iperf3 directive, guest migration variant
|
||||
# $1: Variable name: to put the measure bandwidth into
|
||||
# $2: Initial source/client context
|
||||
# $3: Second source/client context the guest is moving to
|
||||
# $4: Destination name or address for client
|
||||
# $5: Port number, ${i} is translated to process index
|
||||
# $6: Run time, in seconds
|
||||
# $7: Client options
|
||||
test_iperf3m() {
|
||||
__var="${1}"; shift
|
||||
__cctx="${1}"; shift
|
||||
__cctx2="${1}"; shift
|
||||
__dest="${1}"; shift
|
||||
__port="${1}"; shift
|
||||
__time="${1}"; shift
|
||||
|
||||
pane_or_context_run "${__cctx}" 'rm -f c.json'
|
||||
|
||||
# A 1s wait for connection on what's basically a local link
|
||||
# indicates something is pretty wrong
|
||||
__timeout=1000
|
||||
pane_or_context_run_bg "${__cctx}" \
|
||||
'iperf3 -J -c '${__dest}' -p '${__port} \
|
||||
' --connect-timeout '${__timeout} \
|
||||
' -t'${__time}' -i0 '"${@}"' > c.json' \
|
||||
|
||||
__jval=".end.sum_received.bits_per_second"
|
||||
|
||||
sleep $((${__time} + 3))
|
||||
|
||||
pane_or_context_output "${__cctx2}" \
|
||||
'cat c.json'
|
||||
|
||||
__bw=$(pane_or_context_output "${__cctx2}" \
|
||||
'cat c.json | jq -rMs "map('${__jval}') | add"')
|
||||
|
||||
TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__var}__" "${__bw}" )"
|
||||
}
|
||||
|
||||
test_one_line() {
|
||||
__line="${1}"
|
||||
|
||||
|
@ -177,6 +216,12 @@ test_one_line() {
|
|||
"guest2w")
|
||||
pane_or_context_wait guest_2 || TEST_ONE_nok=1
|
||||
;;
|
||||
"mon")
|
||||
pane_or_context_run mon "${__arg}" || TEST_ONE_nok=1
|
||||
;;
|
||||
"monb")
|
||||
pane_or_context_run_bg mon "${__arg}"
|
||||
;;
|
||||
"ns")
|
||||
pane_or_context_run ns "${__arg}" || TEST_ONE_nok=1
|
||||
;;
|
||||
|
@ -292,6 +337,9 @@ test_one_line() {
|
|||
"iperf3")
|
||||
test_iperf3 ${__arg}
|
||||
;;
|
||||
"iperf3m")
|
||||
test_iperf3m ${__arg}
|
||||
;;
|
||||
"set")
|
||||
TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg%% *}__" "${__arg#* }")"
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue