Skip to content

Commit d796098

Browse files
author
Ian Campbell
committed
test: Add a basic Deployment+Service, check access from host.
Needs a top-level Makefile hook to add a new yml to the image. Signed-off-by: Ian Campbell <[email protected]>
1 parent 798d14d commit d796098

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ KUBE_BASENAME ?= kube-
1616
.PHONY: all master node
1717
all: master node
1818

19-
master: yml/kube.yml yml/$(KUBE_RUNTIME).yml yml/$(KUBE_RUNTIME)-master.yml yml/$(KUBE_NETWORK).yml
19+
master: yml/kube.yml yml/$(KUBE_RUNTIME).yml yml/$(KUBE_RUNTIME)-master.yml yml/$(KUBE_NETWORK).yml $(KUBE_EXTRA_YML)
2020
linuxkit $(LINUXKIT_ARGS) build $(LINUXKIT_BUILD_ARGS) -name $(KUBE_BASENAME)master $(KUBE_FORMAT_ARGS) $^
2121

22-
node: yml/kube.yml yml/$(KUBE_RUNTIME).yml yml/$(KUBE_NETWORK).yml
22+
node: yml/kube.yml yml/$(KUBE_RUNTIME).yml yml/$(KUBE_NETWORK).yml $(KUBE_EXTRA_YML)
2323
linuxkit $(LINUXKIT_ARGS) build $(LINUXKIT_BUILD_ARGS) -name $(KUBE_BASENAME)node $(KUBE_FORMAT_ARGS) $^
2424

2525
yml/weave.yml: kube-weave.yaml

test/cases/000_smoke/common.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export KUBE_RUNTIME=$runtime
2222
export KUBE_NETWORK=$network
2323
export LINUXKIT_BUILD_ARGS="--disable-content-trust"
2424
export KUBE_BASENAME="`pwd`/kube-"
25+
export KUBE_EXTRA_YML="`pwd`/../test.yml"
2526
make -C ${RT_PROJECT_ROOT}/../../ master
2627

2728
../test.exp ${RT_PROJECT_ROOT}/../../boot.sh ${RT_PROJECT_ROOT}/../../ssh_into_kubelet.sh

test/cases/000_smoke/test.exp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ proc kill args {
2424

2525
proc boot_linuxkit {} {
2626
global lk_sid bootexec
27-
spawn env {KUBE_RUN_ARGS=-publish 2222:22} KUBE_MEM=3584 KUBE_VCPUS=2 KUBE_DISK=8G KUBE_CLEAR_STATE=y KUBE_MASTER_UNTAINT=y $bootexec
27+
spawn env {KUBE_RUN_ARGS=-publish 2222:22 -publish 30002:30002} KUBE_MEM=3584 KUBE_VCPUS=2 KUBE_DISK=8G KUBE_CLEAR_STATE=y KUBE_MASTER_UNTAINT=y $bootexec
2828
set lk_sid $spawn_id
2929
puts "INFO lk ($lk_sid) is pid [exp_pid -i $lk_sid]"
3030
}
@@ -195,6 +195,24 @@ await_sshcmd_output "await etcd ready" \
195195

196196
sshcmd "status" "kubectl get -o wide nodes ; echo ; kubectl --namespace=kube-system get -o wide pods"
197197

198+
sshcmd "apply app.yaml" "kubectl apply -f /root/app.yaml"
199+
200+
await_sshcmd_output "await nginx pod ready" \
201+
{kubectl get pods --selector=name=nginx -o jsonpath='{.items[*].status.phase}' ; echo} \
202+
"Running"
203+
puts "SUCCESS application pod ready"
204+
205+
sshcmd "status" "kubectl get -o wide nodes ; echo ; kubectl --namespace=kube-system get -o wide pods ; echo ; kubectl --namespace=default get -o wide pods"
206+
207+
set curl [exec curl -sS http://localhost:30002]
208+
if [string match "Welcome to nginx!" $curl] {
209+
puts "FAIL nginx returned:"
210+
puts $curl
211+
kill ssh_sid lk_sid
212+
exit 1
213+
}
214+
puts "SUCCESS nginx responded well"
215+
198216
kill ssh_sid
199217

200218
puts "RUN poweroff -f"

test/cases/000_smoke/test.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
files:
2+
- path: containers/services/kubelet/lower/root/app.yaml
3+
contents: |
4+
apiVersion: extensions/v1beta1
5+
kind: Deployment
6+
metadata:
7+
name: nginx
8+
labels:
9+
name: nginx
10+
namespace: default
11+
spec:
12+
replicas: 1
13+
template:
14+
metadata:
15+
labels:
16+
name: nginx
17+
spec:
18+
containers:
19+
- name: nginx
20+
image: nginx:alpine
21+
ports:
22+
- name: www
23+
containerPort: 80
24+
volumeMounts:
25+
- mountPath: /tmp
26+
name: tmp-volume
27+
volumes:
28+
- name: tmp-volume
29+
emptyDir:
30+
medium: Memory
31+
nodeSelector:
32+
beta.kubernetes.io/os: linux
33+
---
34+
apiVersion: v1
35+
kind: Service
36+
metadata:
37+
name: nginx
38+
labels:
39+
name: nginx
40+
namespace: default
41+
spec:
42+
type: NodePort
43+
ports:
44+
# the port that this service should serve on
45+
- port: 80
46+
targetPort: 80
47+
nodePort: 30002
48+
selector:
49+
name: nginx

0 commit comments

Comments
 (0)