Skip to content

Commit

Permalink
test: Test intra-pod networking is ok
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Ian Campbell committed Feb 7, 2018
1 parent d796098 commit f4cd649
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/cases/000_smoke/test.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand Down
21 changes: 21 additions & 0 deletions test/cases/000_smoke/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f4cd649

Please sign in to comment.