@@ -20,6 +20,7 @@ import (
20
20
"io/ioutil"
21
21
"net"
22
22
"os"
23
+ "os/exec"
23
24
"time"
24
25
25
26
"k8s.io/api/core/v1"
@@ -108,6 +109,60 @@ var _ = Describe("kube-controllers FV tests", func() {
108
109
Expect (* info .Spec .DatastoreReady ).To (BeTrue ())
109
110
})
110
111
112
+ Context ("Healthcheck FV tests" , func () {
113
+ It ("should pass health check" , func () {
114
+ // wait for a health check cycle to pass
115
+ Eventually (func () []byte {
116
+ cmd := exec .Command ("docker" , "exec" , policyController .Name , "/usr/bin/check-status" , "-r" )
117
+ stdoutStderr , _ := cmd .CombinedOutput ()
118
+
119
+ return stdoutStderr
120
+ }, 20 * time .Second , 500 * time .Millisecond ).ShouldNot (ContainSubstring ("initialized to false" ))
121
+ Eventually (func () []byte {
122
+ cmd := exec .Command ("docker" , "exec" , policyController .Name , "/usr/bin/check-status" , "-r" )
123
+ stdoutStderr , _ := cmd .CombinedOutput ()
124
+
125
+ return stdoutStderr
126
+ }, 20 * time .Second , 500 * time .Millisecond ).ShouldNot (ContainSubstring ("Error" ))
127
+ })
128
+
129
+ It ("should fail health check if apiserver is not running" , func () {
130
+ // wait for a health check cycle to pass
131
+ Eventually (func () []byte {
132
+ cmd := exec .Command ("docker" , "exec" , policyController .Name , "/usr/bin/check-status" , "-r" )
133
+ stdoutStderr , _ := cmd .CombinedOutput ()
134
+
135
+ return stdoutStderr
136
+ }, 20 * time .Second , 500 * time .Millisecond ).ShouldNot (ContainSubstring ("initialized to false" ))
137
+
138
+ apiserver .Stop ()
139
+ Eventually (func () []byte {
140
+ cmd := exec .Command ("docker" , "exec" , policyController .Name , "/usr/bin/check-status" , "-r" )
141
+ stdoutStderr , _ := cmd .CombinedOutput ()
142
+
143
+ return stdoutStderr
144
+ }, 20 * time .Second , 500 * time .Millisecond ).Should (ContainSubstring ("Error reaching apiserver" ))
145
+ })
146
+
147
+ It ("should fail health check if etcd not running" , func () {
148
+ // wait for a health check cycle to pass
149
+ Eventually (func () []byte {
150
+ cmd := exec .Command ("docker" , "exec" , policyController .Name , "/usr/bin/check-status" , "-r" )
151
+ stdoutStderr , _ := cmd .CombinedOutput ()
152
+
153
+ return stdoutStderr
154
+ }, 20 * time .Second , 500 * time .Millisecond ).ShouldNot (ContainSubstring ("initialized to false" ))
155
+
156
+ etcd .Stop ()
157
+ Eventually (func () []byte {
158
+ cmd := exec .Command ("docker" , "exec" , policyController .Name , "/usr/bin/check-status" , "-r" )
159
+ stdoutStderr , _ := cmd .CombinedOutput ()
160
+
161
+ return stdoutStderr
162
+ }, 20 * time .Second , 500 * time .Millisecond ).Should (ContainSubstring ("Error verifying datastore" ))
163
+ })
164
+ })
165
+
111
166
Context ("Node FV tests" , func () {
112
167
It ("should be removed in response to a k8s node delete [Release]" , func () {
113
168
kn := & v1.Node {
0 commit comments