Use network-tester image in Kubernetes test
This commit is contained in:
1 parent
aa84c4788a
commit
348a926af4
1 file changed
+26
-11
@@ -18,6 +18,7 @@ NUM_HOSTS=$(howmany $HOSTS)
|
|||||||
SUCCESS="$(( $NUM_HOSTS * ($NUM_HOSTS-1) )) established"
|
SUCCESS="$(( $NUM_HOSTS * ($NUM_HOSTS-1) )) established"
|
||||||
KUBECTL="sudo kubectl --kubeconfig /etc/kubernetes/admin.conf"
|
KUBECTL="sudo kubectl --kubeconfig /etc/kubernetes/admin.conf"
|
||||||
KUBE_PORT=6443
|
KUBE_PORT=6443
|
||||||
|
IMAGE=weaveworks/network-tester:latest
|
||||||
|
|
||||||
tear_down_kubeadm
|
tear_down_kubeadm
|
||||||
|
|
||||||
@@ -64,21 +65,35 @@ assert "run_on $HOST2 ps aux | grep -c '[d]efunct'" "0"
|
|||||||
assert "run_on $HOST3 ps aux | grep -c '[d]efunct'" "0"
|
assert "run_on $HOST3 ps aux | grep -c '[d]efunct'" "0"
|
||||||
|
|
||||||
# See if we can get some pods running that connect to the network
|
# See if we can get some pods running that connect to the network
|
||||||
run_on $HOST1 "$KUBECTL run hello --image=weaveworks/hello-world --replicas=3"
|
run_on $HOST1 "$KUBECTL run --image-pull-policy=Never nettest --image=$IMAGE --replicas=3 -- -peers=3 -dns-name=nettest.default.svc.cluster.local."
|
||||||
|
# Create a headless service so they can be found in Kubernetes DNS
|
||||||
|
run_on $HOST1 "$KUBECTL create -f -" <<EOF
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: nettest
|
||||||
|
spec:
|
||||||
|
clusterIP: None
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 8080
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
run: nettest
|
||||||
|
EOF
|
||||||
|
|
||||||
wait_for_pods() {
|
check_all_pods_communicate() {
|
||||||
for i in $(seq 1 45); do
|
podIP=$($SSH $HOST1 "$KUBECTL get pods -l run=nettest -o go-template='{{(index .items 0).status.podIP}}' 2>/dev/null")
|
||||||
if run_on $HOST1 "$KUBECTL get pods | grep 'hello.*Running'" ; then
|
if [ -n podIP ] ; then
|
||||||
return
|
status=$($SSH $HOST1 "curl -s -S http://$podIP:8080/status")
|
||||||
|
if [ $status = "pass" ] ; then
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
echo "Waiting for pods"
|
fi
|
||||||
sleep 1
|
return 1
|
||||||
done
|
|
||||||
echo "Timed out waiting for pods" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_raises wait_for_pods
|
assert_raises 'wait_for_x check_all_pods_communicate pods'
|
||||||
|
|
||||||
tear_down_kubeadm
|
tear_down_kubeadm
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user