From b86fc67adf16a9135f9cd93f41a7a6a0af825573 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 22 Jun 2017 11:45:18 +0000 Subject: [PATCH] Extend test to include a network policy --- test/840_weave_kube_3_test.sh | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/test/840_weave_kube_3_test.sh b/test/840_weave_kube_3_test.sh index 5abe537e..9b98dec1 100755 --- a/test/840_weave_kube_3_test.sh +++ b/test/840_weave_kube_3_test.sh @@ -70,6 +70,30 @@ assert "run_on $HOST1 ps aux | grep -c '[d]efunct'" "0" assert "run_on $HOST2 ps aux | grep -c '[d]efunct'" "0" assert "run_on $HOST3 ps aux | grep -c '[d]efunct'" "0" +# Set up a simple network policy so all our test pods can talk to each other +run_on $HOST1 "$KUBECTL annotate ns default net.beta.kubernetes.io/network-policy='{\"ingress\":{\"isolation\":\"DefaultDeny\"}}'" +run_on $HOST1 "$KUBECTL apply -f -" </dev/null") if [ -n podIP ] ; then - status=$($SSH $HOST1 "curl -s -S http://$podIP:8080/status") + status=$($SSH $HOST1 "$KUBECTL exec $podName -- curl -s -S http://127.0.0.1:8080/status") if [ $status = "pass" ] ; then return 0 fi @@ -108,7 +133,6 @@ check_all_pods_communicate() { assert_raises 'wait_for_x check_all_pods_communicate pods' # Check that a pod can contact the outside world -podName=$($SSH $HOST1 "$KUBECTL get pods -l run=nettest -o go-template='{{(index .items 0).metadata.name}}'") assert_raises "$SSH $HOST1 $KUBECTL exec $podName -- $PING 8.8.8.8" tear_down_kubeadm