forked from alex8866/kubernetes-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskydns_test.go
More file actions
58 lines (55 loc) · 2.6 KB
/
skydns_test.go
File metadata and controls
58 lines (55 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"os/exec"
"testing"
"strings"
. "github.com/smartystreets/goconvey/convey"
)
func TestKubeDNS(t *testing.T) {
Convey("Subject: Checking DNS are working", t, func() {
Convey("Subject: Checking whether kube-dns rc is existed", func() {
Convey("When run kubectl get --namespace=kube-system rc kube-dns-v11", func() {
output, err := exec.Command("kubectl", "get", "--namespace=kube-system", "rc", "kube-dns-v11").Output()
Convey("etcd, kube2sky, skydns and healthz should be in the output", func() {
So(string(output), ShouldContainSubstring, "etcd")
So(string(output), ShouldContainSubstring, "kube2sky")
So(string(output), ShouldContainSubstring, "skydns")
So(string(output), ShouldContainSubstring, "healthz")
So(err, ShouldBeNil)
})
})
})
Convey("Subject: Checking whether all pods are running ", func() {
Convey("When run kubectl get --all-namespaces pod", func() {
output, err := exec.Command("kubectl", "get", "--namespace=kube-system", "-l", "k8s-app=kube-dns", "pod").Output()
Convey("kube-dns-v11-xxxxx and 4/4 should be in the output", func() {
So(string(output), ShouldContainSubstring, "kube-dns-v11")
So(string(output), ShouldContainSubstring, "Running")
So(string(output), ShouldContainSubstring, "4/4")
So(err, ShouldBeNil)
})
})
})
Convey("Subject: Checking whether kube-dns svc is existed", func() {
Convey("When run kubectl get --namespace=kube-system svc kube-dns", func() {
output, err := exec.Command("kubectl", "get", "--namespace=kube-system", "svc", "kube-dns").Output()
Convey("kube-dns should be in the output", func() {
So(string(output), ShouldContainSubstring, "kube-dns")
So(err, ShouldBeNil)
})
})
Convey("When run kubectl exec --namespace=kube-system -it kube-dns-v11-xxxxx -c skydns nslookup kube-dns.kube-system.svc.cluster.local 127.0.0.1", func() {
output, err := exec.Command("kubectl", "get", "--namespace=kube-system", "-l", "k8s-app=kube-dns", "pod").Output()
n := strings.Index(string(output), "kube-dns-v11")
l := strings.Count("kube-dns-v11-xxxx", "")
podname := string(output)[n:n+l]
output, err = exec.Command("kubectl", "exec", "--namespace=kube-system", podname, "-c", "skydns", "nslookup", "kube-dns.kube-system.svc.cluster.local", "127.0.0.1").Output()
Convey("kube-dns and its IP 10.254.0.10 should be in the output", func() {
So(string(output), ShouldContainSubstring, "kube-dns")
So(string(output), ShouldContainSubstring, "10.254.0.10")
So(err, ShouldBeNil)
})
})
})
})
}