From f4cd64922c204754a9d9565c7fbc03ea6c0a5dd3 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 7 Feb 2018 13:08:37 +0000 Subject: [PATCH] test: Test intra-pod networking is ok Add an alpine pod and use it to fetch from the nginx, which ensures that network traffic as well as DNS and such are working. Signed-off-by: Ian Campbell --- test/cases/000_smoke/test.exp | 24 +++++++++++++++++++++++- test/cases/000_smoke/test.yml | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/test/cases/000_smoke/test.exp b/test/cases/000_smoke/test.exp index aa3a450..144ad8e 100755 --- a/test/cases/000_smoke/test.exp +++ b/test/cases/000_smoke/test.exp @@ -197,10 +197,13 @@ sshcmd "status" "kubectl get -o wide nodes ; echo ; kubectl --namespace=kube-sys sshcmd "apply app.yaml" "kubectl apply -f /root/app.yaml" +await_sshcmd_output "await alpine pod ready" \ + {kubectl get pods --selector=name=alpine -o jsonpath='{.items[*].status.phase}' ; echo} \ + "Running" await_sshcmd_output "await nginx pod ready" \ {kubectl get pods --selector=name=nginx -o jsonpath='{.items[*].status.phase}' ; echo} \ "Running" -puts "SUCCESS application pod ready" +puts "SUCCESS application pods ready" sshcmd "status" "kubectl get -o wide nodes ; echo ; kubectl --namespace=kube-system get -o wide pods ; echo ; kubectl --namespace=default get -o wide pods" @@ -213,6 +216,25 @@ if [string match "Welcome to nginx!" $curl] { } puts "SUCCESS nginx responded well" +send_sshcmd {kubectl exec $(kubectl get pods -l name==alpine -o=jsonpath='{.items[*].metadata.name}') -- wget -q -O - http://nginx/} +expect -i $ssh_sid -timeout 10 \ + "Welcome to nginx!" { + puts "SUCCESS intra-pod networking ok" + } $ssh_prompt { + puts "FAIL intra-pod networking (returned to prompt)" + kill ssh_sid lk_sid + exit 1 + } timeout { + puts "FAIL intra-pod networking (timeout)" + kill ssh_sid lk_sid + exit 1 + } eof { + puts "FAIL intra-pod networking (eof)" + kill ssh_sid lk_sid + exit 1 + } +await_ssh_prompt "intra-pod networking" + kill ssh_sid puts "RUN poweroff -f" diff --git a/test/cases/000_smoke/test.yml b/test/cases/000_smoke/test.yml index 3b81221..12b64e9 100644 --- a/test/cases/000_smoke/test.yml +++ b/test/cases/000_smoke/test.yml @@ -47,3 +47,24 @@ files: nodePort: 30002 selector: name: nginx + --- + apiVersion: extensions/v1beta1 + kind: Deployment + metadata: + name: alpine + labels: + name: alpine + namespace: default + spec: + replicas: 1 + template: + metadata: + labels: + name: alpine + spec: + containers: + - name: alpine + image: alpine:3.7 + command: ["/bin/sh", "-c", "while : ; do sleep 1h ; done"] + nodeSelector: + beta.kubernetes.io/os: linux