From 791d9aecfcf6a56cae6908f85351820ed85453f4 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 25 May 2018 10:29:40 +0000 Subject: [PATCH] Extend k8s test to cover namespaceSelector and >10 Namespaces --- test/840_weave_kube_3_test.sh | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/test/840_weave_kube_3_test.sh b/test/840_weave_kube_3_test.sh index 63d305bf..f9a345cd 100755 --- a/test/840_weave_kube_3_test.sh +++ b/test/840_weave_kube_3_test.sh @@ -225,12 +225,39 @@ run_on $HOST1 "$KUBECTL delete netpol allow-nettest-deny" # nettest-deny should still not be able to reach nettest pods assert_raises "! $SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null" -# allow access for all +# Create many namespaces to stress namespaceSelector +for n in 1 2 3 4 5 6 7 8 9 10; do + run_on $HOST1 "$KUBECTL create namespace namespace${n}" +done + +# allow access from any namespace run_on $HOST1 "$KUBECTL apply -f -" </dev/null" + +# host should still not be able to reach pods via service virtual IP or NodePort +# because host is not in a namespace +assert_raises "! $SSH $HOST1 curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null" +assert_raises "! $SSH $HOST1 curl -s -S -f -m 2 http://$HOST2:31138/status >/dev/null" + +# allow access from anywhere +run_on $HOST1 "$KUBECTL apply -f -" </dev/null" - # Virtual IP and NodePort should now work assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null" assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$HOST2:31138/status >/dev/null"