@@ -51,19 +51,23 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
51
51
52
52
checkForWorkingTraffic := func (teaURL , coffeeURL string ) error {
53
53
if err := expectRequestToSucceed (teaURL , address , "URI: /tea" ); err != nil {
54
+ fmt .Println ("checkForWorkingTraffic failed for teaURL:" , teaURL , "with error:" , err )
54
55
return err
55
56
}
56
57
if err := expectRequestToSucceed (coffeeURL , address , "URI: /coffee" ); err != nil {
58
+ fmt .Println ("checkForWorkingTraffic failed for coffeeURL:" , coffeeURL , "with error:" , err )
57
59
return err
58
60
}
59
61
return nil
60
62
}
61
63
62
64
checkForFailingTraffic := func (teaURL , coffeeURL string ) error {
63
65
if err := expectRequestToFail (teaURL , address ); err != nil {
66
+ fmt .Println ("checkForFailingTraffic failed for teaURL:" , teaURL , "with error:" , err )
64
67
return err
65
68
}
66
69
if err := expectRequestToFail (coffeeURL , address ); err != nil {
70
+ fmt .Println ("checkForFailingTraffic failed for coffeeURL:" , coffeeURL , "with error:" , err )
67
71
return err
68
72
}
69
73
return nil
@@ -89,7 +93,10 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
89
93
}
90
94
91
95
checkContainerRestart := func (podName , containerName , namespace string , currentRestartCount int ) error {
96
+ fmt .Println ("Checking if container restart count has incremented..." )
92
97
restartCount , err := getContainerRestartCount (podName , namespace , containerName )
98
+ fmt .Println ("Current restart count for container:" , restartCount )
99
+ fmt .Println ("error:" , err )
93
100
if err != nil {
94
101
return err
95
102
}
@@ -157,9 +164,12 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
157
164
}
158
165
159
166
restartNginxContainer := func (nginxPodName , namespace , containerName string ) {
167
+ fmt .Println ("restarting NGINX container in Pod:" , nginxPodName )
160
168
jobScript := "PID=$(pgrep -f \" nginx-agent\" ) && kill -9 $PID"
161
169
162
170
restartCount , err := getContainerRestartCount (nginxPodName , namespace , containerName )
171
+ fmt .Println ("Current restart count for NGINX container:" , restartCount )
172
+ fmt .Println ("error:" , err )
163
173
Expect (err ).ToNot (HaveOccurred ())
164
174
165
175
cleanUpPortForward ()
@@ -235,17 +245,22 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
235
245
236
246
runRestartNodeTest := func (teaURL , coffeeURL string , files []string , ns * core.Namespace , drain bool ) {
237
247
nodeNames , err := getNodeNames ()
248
+ fmt .Println ("Node names:" , nodeNames )
238
249
Expect (err ).ToNot (HaveOccurred ())
239
250
Expect (nodeNames ).To (HaveLen (1 ))
240
251
241
252
kindNodeName := nodeNames [0 ]
253
+ fmt .Println ("Kind node name:" , kindNodeName )
242
254
243
255
Expect (clusterName ).ToNot (BeNil (), "clusterName variable not set" )
256
+ fmt .Println ("Cluster name:" , * clusterName )
244
257
Expect (* clusterName ).ToNot (BeEmpty ())
245
258
containerName := * clusterName + "-control-plane"
259
+ fmt .Println ("Container name:" , containerName )
246
260
247
261
cleanUpPortForward ()
248
262
263
+ fmt .Println ("drain:" , drain )
249
264
if drain {
250
265
output , err := exec .Command (
251
266
"kubectl" ,
@@ -255,15 +270,20 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
255
270
"--delete-emptydir-data" ,
256
271
).CombinedOutput ()
257
272
273
+ fmt .Println ("Output of kubectl drain command:" , string (output ))
274
+ fmt .Println ("Error of kubectl drain command:" , err )
275
+
258
276
Expect (err ).ToNot (HaveOccurred (), string (output ))
259
277
260
278
output , err = exec .Command ("kubectl" , "delete" , "node" , kindNodeName ).CombinedOutput ()
261
279
Expect (err ).ToNot (HaveOccurred (), string (output ))
262
280
}
263
281
264
- _ , err = exec .Command ("docker" , "restart" , containerName ).CombinedOutput ()
282
+ restart , err : = exec .Command ("docker" , "restart" , containerName ).CombinedOutput ()
265
283
Expect (err ).ToNot (HaveOccurred ())
266
284
285
+ fmt .Println ("docker restart output:" , string (restart ))
286
+ fmt .Println ("docker restart error:" , err )
267
287
// need to wait for docker container to restart and be running before polling for ready NGF Pods or else we will error
268
288
Eventually (
269
289
func () bool {
@@ -274,6 +294,8 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
274
294
"{{.State.Running}}" ,
275
295
containerName ,
276
296
).CombinedOutput ()
297
+ fmt .Println ("docker inspect output:" , string (output ))
298
+ fmt .Println ("docker inspect error:" , err )
277
299
return strings .TrimSpace (string (output )) == "true" && err == nil
278
300
}).
279
301
WithTimeout (timeoutConfig .CreateTimeout ).
@@ -290,6 +312,8 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
290
312
releaseName ,
291
313
timeoutConfig .GetStatusTimeout ,
292
314
)
315
+ fmt .Println ("NGF Pod names:" , podNames )
316
+ fmt .Println ("NGF Pod error:" , err )
293
317
return len (podNames ) == 1 && err == nil
294
318
}).
295
319
WithTimeout (timeoutConfig .CreateTimeout * 2 ).
@@ -298,6 +322,9 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
298
322
Should (BeTrue ())
299
323
newNGFPodName := podNames [0 ]
300
324
325
+ fmt .Print ("New NGF Pod name:" , newNGFPodName )
326
+ fmt .Print ("Active NGF Pod name:" , activeNGFPodName )
327
+
301
328
// expected behavior is when node is drained, new pods will be created. when the node is
302
329
// abruptly restarted, new pods are not created.
303
330
if drain {
@@ -328,6 +355,8 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
328
355
329
356
setUpPortForward (activeNginxPodName , ns .Name )
330
357
358
+ fmt .Println ("Active Nginx Pod name:" , activeNginxPodName )
359
+
331
360
// sets activeNginxPodName to new pod
332
361
checkNGFFunctionality (teaURL , coffeeURL , files , ns )
333
362
@@ -522,6 +551,7 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
522
551
523
552
func expectRequestToSucceed (appURL , address string , responseBodyMessage string ) error {
524
553
status , body , err := framework .Get (appURL , address , timeoutConfig .RequestTimeout , nil , nil )
554
+ fmt .Println ("expectRequestToSucceed" , "HTTP status:" , status , "Response body:" , body )
525
555
526
556
if status != http .StatusOK {
527
557
return errors .New ("http status was not 200" )
@@ -536,6 +566,7 @@ func expectRequestToSucceed(appURL, address string, responseBodyMessage string)
536
566
537
567
func expectRequestToFail (appURL , address string ) error {
538
568
status , body , err := framework .Get (appURL , address , timeoutConfig .RequestTimeout , nil , nil )
569
+ fmt .Println ("expectRequestToFail" , "HTTP status:" , status , "Response body:" , body )
539
570
if status != 0 {
540
571
return errors .New ("expected http status to be 0" )
541
572
}
0 commit comments