forked from alex8866/kubernetes-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcluster_test.go
More file actions
59 lines (56 loc) · 2.07 KB
/
cluster_test.go
File metadata and controls
59 lines (56 loc) · 2.07 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
59
package main
import (
"os/exec"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestKubeCluster(t *testing.T) {
Convey("Subject: Checking kube cluster are in health", t, func() {
Convey("Given kube cluster is configured by ansible", func() {
Convey("When run kubectl cluster-info", func() {
info, err := exec.Command("kubectl", "cluster-info").Output()
Convey("'Kubernetes master is running at' is showing", func() {
So(string(info), ShouldContainSubstring, "running")
So(string(info), ShouldContainSubstring, "443")
So(err, ShouldBeNil)
})
})
Convey("When run kubectl get serviceaccount", func() {
output, err := exec.Command("kubectl", "get", "serviceaccount").Output()
Convey("A default serviceAccount default should be listed there", func() {
So(string(output), ShouldContainSubstring, "default")
So(err, ShouldBeNil)
})
})
Convey("When run kubectl get secret", func() {
output, err := exec.Command("kubectl", "get", "secret").Output()
Convey("A default token should be listed there", func() {
So(string(output), ShouldContainSubstring, "default-token")
So(err, ShouldBeNil)
})
})
Convey("When run kubectl get namespace", func() {
output, err := exec.Command("kubectl", "get", "namespace").Output()
Convey("default and kube-system should be listed there", func() {
So(string(output), ShouldContainSubstring, "default")
So(string(output), ShouldContainSubstring, "kube-system")
So(err, ShouldBeNil)
})
})
Convey("When run kubectl get node", func() {
output, err := exec.Command("kubectl", "get", "node").Output()
Convey("At least one node should be ready", func() {
So(string(output), ShouldContainSubstring, "Ready")
So(err, ShouldBeNil)
})
})
Convey("When run kubectl get service", func() {
output, err := exec.Command("kubectl", "get", "service").Output()
Convey("A default service named kubernetes is there", func() {
So(string(output), ShouldContainSubstring, "kubernetes")
So(err, ShouldBeNil)
})
})
})
})
}