Skip to content

Commit f4cd649

Browse files
author
Ian Campbell
committed
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 <[email protected]>
1 parent d796098 commit f4cd649

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

test/cases/000_smoke/test.exp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,13 @@ sshcmd "status" "kubectl get -o wide nodes ; echo ; kubectl --namespace=kube-sys
197197

198198
sshcmd "apply app.yaml" "kubectl apply -f /root/app.yaml"
199199

200+
await_sshcmd_output "await alpine pod ready" \
201+
{kubectl get pods --selector=name=alpine -o jsonpath='{.items[*].status.phase}' ; echo} \
202+
"Running"
200203
await_sshcmd_output "await nginx pod ready" \
201204
{kubectl get pods --selector=name=nginx -o jsonpath='{.items[*].status.phase}' ; echo} \
202205
"Running"
203-
puts "SUCCESS application pod ready"
206+
puts "SUCCESS application pods ready"
204207

205208
sshcmd "status" "kubectl get -o wide nodes ; echo ; kubectl --namespace=kube-system get -o wide pods ; echo ; kubectl --namespace=default get -o wide pods"
206209

@@ -213,6 +216,25 @@ if [string match "Welcome to nginx!" $curl] {
213216
}
214217
puts "SUCCESS nginx responded well"
215218

219+
send_sshcmd {kubectl exec $(kubectl get pods -l name==alpine -o=jsonpath='{.items[*].metadata.name}') -- wget -q -O - http://nginx/}
220+
expect -i $ssh_sid -timeout 10 \
221+
"Welcome to nginx!" {
222+
puts "SUCCESS intra-pod networking ok"
223+
} $ssh_prompt {
224+
puts "FAIL intra-pod networking (returned to prompt)"
225+
kill ssh_sid lk_sid
226+
exit 1
227+
} timeout {
228+
puts "FAIL intra-pod networking (timeout)"
229+
kill ssh_sid lk_sid
230+
exit 1
231+
} eof {
232+
puts "FAIL intra-pod networking (eof)"
233+
kill ssh_sid lk_sid
234+
exit 1
235+
}
236+
await_ssh_prompt "intra-pod networking"
237+
216238
kill ssh_sid
217239

218240
puts "RUN poweroff -f"

test/cases/000_smoke/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,24 @@ files:
4747
nodePort: 30002
4848
selector:
4949
name: nginx
50+
---
51+
apiVersion: extensions/v1beta1
52+
kind: Deployment
53+
metadata:
54+
name: alpine
55+
labels:
56+
name: alpine
57+
namespace: default
58+
spec:
59+
replicas: 1
60+
template:
61+
metadata:
62+
labels:
63+
name: alpine
64+
spec:
65+
containers:
66+
- name: alpine
67+
image: alpine:3.7
68+
command: ["/bin/sh", "-c", "while : ; do sleep 1h ; done"]
69+
nodeSelector:
70+
beta.kubernetes.io/os: linux

0 commit comments

Comments
 (0)