From 8392f5f757fa61dfd28b8bb373bc6a0be1d808d0 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 13 Sep 2017 15:53:22 -0500 Subject: [PATCH] test: add test for network teardown on sandbox setup errors Signed-off-by: Dan Williams --- test/network.bats | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/network.bats b/test/network.bats index 67fbdfc8..ea3bb8f1 100644 --- a/test/network.bats +++ b/test/network.bats @@ -184,3 +184,22 @@ load helpers stop_crio } + +@test "Clean up network if pod sandbox fails" { + rm -f /var/lib/cni/networks/crionet_test_args/* + start_crio "" "" "" "prepare_plugin_test_args_network_conf" + + # make conmon non-executable to cause the sandbox setup to fail after + # networking has been configured + chmod 0644 /go/src/github.com/kubernetes-incubator/cri-o/conmon/conmon + run crioctl pod run --config "$TESTDATA"/sandbox_config.json + chmod 0755 /go/src/github.com/kubernetes-incubator/cri-o/conmon/conmon + + # ensure that the server cleaned up sandbox networking if the sandbox + # failed after network setup + rm -f /var/lib/cni/networks/crionet_test_args/last_reserved_ip + num_allocated=$(ls /var/lib/cni/networks/crionet_test_args | wc -l) + [[ "${num_allocated}" == "0" ]] + + stop_crio +}