@@ -107,9 +107,11 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("functional", "gracefu
107
107
runRestartNodeTest (teaURL , coffeeURL , files , & ns , true )
108
108
})
109
109
110
- //It("recovers when node is restarted abruptly", func() {
111
- // runRestartNodeTest(teaURL, coffeeURL, files, &ns, false)
112
- //})
110
+ It ("recovers when node is restarted abruptly" , func () {
111
+ // FIXME(bjee19) remove Skip() when https://github.com/nginxinc/nginx-gateway-fabric/issues/1108 is completed.
112
+ Skip ("Test currently fails due to this issue: https://github.com/nginxinc/nginx-gateway-fabric/issues/1108" )
113
+ runRestartNodeTest (teaURL , coffeeURL , files , & ns , false )
114
+ })
113
115
})
114
116
115
117
func runRestartNodeTest (teaURL , coffeeURL string , files []string , ns * core.Namespace , drain bool ) {
@@ -146,27 +148,28 @@ func runRestartNodeTest(teaURL, coffeeURL string, files []string, ns *core.Names
146
148
}
147
149
}
148
150
149
- output , err := exec .Command (
151
+ containerOutput , err := exec .Command (
150
152
"docker" ,
151
153
"container" ,
152
154
"ls" ,
153
155
).CombinedOutput ()
154
156
if err != nil {
155
157
Expect (err ).ToNot (HaveOccurred ())
156
158
}
157
-
158
- fmt .Println (string (output ))
159
+ fmt .Println (string (containerOutput ))
159
160
160
161
var containerName string
161
- for _ , line := range strings .Split (string (output ), "\n " ) {
162
+ for _ , line := range strings .Split (string (containerOutput ), "\n " ) {
162
163
for _ , word := range strings .Split (line , " " ) {
164
+ // This is a potential weak spot in the code where we rely on the container which NGF
165
+ // is running on to contain "control-plane" in the name and for no other container to have that either.
166
+ // This is currently working in our test framework may break in the future.
163
167
if strings .Contains (word , "control-plane" ) {
164
168
containerName = strings .TrimSpace (word )
165
169
break
166
170
}
167
171
}
168
172
}
169
-
170
173
Expect (containerName ).ToNot (Equal ("" ))
171
174
172
175
// really jank - get the string that contains "control-plane"
@@ -182,9 +185,10 @@ func runRestartNodeTest(teaURL, coffeeURL string, files []string, ns *core.Names
182
185
Expect (err ).ToNot (HaveOccurred ())
183
186
}
184
187
188
+ // need to wait for docker container to restart and be running before polling for ready NGF Pods or else we will error
185
189
Eventually (
186
190
func () bool {
187
- output , err = exec .Command (
191
+ output , err : = exec .Command (
188
192
"docker" ,
189
193
"container" ,
190
194
"inspect" ,
@@ -212,42 +216,10 @@ func runRestartNodeTest(teaURL, coffeeURL string, files []string, ns *core.Names
212
216
ports := []string {fmt .Sprintf ("%d:80" , ngfHTTPForwardedPort ), fmt .Sprintf ("%d:443" , ngfHTTPSForwardedPort )}
213
217
portForwardStopCh = make (chan struct {})
214
218
err = framework .PortForward (ctlr .GetConfigOrDie (), ngfNamespace , ngfPodName , ports , portForwardStopCh )
215
- address = "127.0.0.1"
216
- portFwdPort = ngfHTTPForwardedPort
217
- portFwdHTTPSPort = ngfHTTPSForwardedPort
218
219
Expect (err ).ToNot (HaveOccurred ())
219
220
}
220
221
221
- Eventually (
222
- func () error {
223
- return checkForWorkingTraffic (teaURL , coffeeURL )
224
- }).
225
- WithTimeout (timeoutConfig .RequestTimeout ).
226
- WithPolling (500 * time .Millisecond ).
227
- Should (Succeed ())
228
-
229
- Expect (resourceManager .DeleteFromFiles (files , ns .Name )).To (Succeed ())
230
-
231
- Eventually (
232
- func () error {
233
- return checkForFailingTraffic (teaURL , coffeeURL )
234
- }).
235
- WithTimeout (timeoutConfig .RequestTimeout ).
236
- WithPolling (500 * time .Millisecond ).
237
- Should (Succeed ())
238
-
239
- Expect (resourceManager .ApplyFromFiles (files , ns .Name )).To (Succeed ())
240
- Expect (resourceManager .WaitForAppsToBeReadyWithPodCount (ns .Name , 2 )).To (Succeed ())
241
-
242
- Eventually (
243
- func () error {
244
- return checkForWorkingTraffic (teaURL , coffeeURL )
245
- }).
246
- WithTimeout (timeoutConfig .RequestTimeout ).
247
- WithPolling (500 * time .Millisecond ).
248
- Should (Succeed ())
249
-
250
- checkContainerLogsForErrors (ngfPodName )
222
+ checkNGFFunctionality (teaURL , coffeeURL , ngfPodName , files , ns )
251
223
}
252
224
253
225
func runRecoveryTest (teaURL , coffeeURL , ngfPodName , containerName string , files []string , ns * core.Namespace ) {
@@ -276,37 +248,7 @@ func runRecoveryTest(teaURL, coffeeURL, ngfPodName, containerName string, files
276
248
WithPolling (500 * time .Millisecond ).
277
249
Should (Succeed ())
278
250
}
279
-
280
- Eventually (
281
- func () error {
282
- return checkForWorkingTraffic (teaURL , coffeeURL )
283
- }).
284
- WithTimeout (timeoutConfig .RequestTimeout ).
285
- WithPolling (500 * time .Millisecond ).
286
- Should (Succeed ())
287
-
288
- Expect (resourceManager .DeleteFromFiles (files , ns .Name )).To (Succeed ())
289
-
290
- Eventually (
291
- func () error {
292
- return checkForFailingTraffic (teaURL , coffeeURL )
293
- }).
294
- WithTimeout (timeoutConfig .RequestTimeout ).
295
- WithPolling (500 * time .Millisecond ).
296
- Should (Succeed ())
297
-
298
- Expect (resourceManager .ApplyFromFiles (files , ns .Name )).To (Succeed ())
299
- Expect (resourceManager .WaitForAppsToBeReadyWithPodCount (ns .Name , 2 )).To (Succeed ())
300
-
301
- Eventually (
302
- func () error {
303
- return checkForWorkingTraffic (teaURL , coffeeURL )
304
- }).
305
- WithTimeout (timeoutConfig .RequestTimeout ).
306
- WithPolling (500 * time .Millisecond ).
307
- Should (Succeed ())
308
-
309
- checkContainerLogsForErrors (ngfPodName )
251
+ checkNGFFunctionality (teaURL , coffeeURL , ngfPodName , files , ns )
310
252
}
311
253
312
254
func restartContainer (ngfPodName , containerName string ) {
@@ -404,6 +346,39 @@ func expectRequestToFail(appURL, address string) error {
404
346
return nil
405
347
}
406
348
349
+ func checkNGFFunctionality (teaURL , coffeeURL , ngfPodName string , files []string , ns * core.Namespace ) {
350
+ Eventually (
351
+ func () error {
352
+ return checkForWorkingTraffic (teaURL , coffeeURL )
353
+ }).
354
+ WithTimeout (timeoutConfig .RequestTimeout ).
355
+ WithPolling (500 * time .Millisecond ).
356
+ Should (Succeed ())
357
+
358
+ Expect (resourceManager .DeleteFromFiles (files , ns .Name )).To (Succeed ())
359
+
360
+ Eventually (
361
+ func () error {
362
+ return checkForFailingTraffic (teaURL , coffeeURL )
363
+ }).
364
+ WithTimeout (timeoutConfig .RequestTimeout ).
365
+ WithPolling (500 * time .Millisecond ).
366
+ Should (Succeed ())
367
+
368
+ Expect (resourceManager .ApplyFromFiles (files , ns .Name )).To (Succeed ())
369
+ Expect (resourceManager .WaitForAppsToBeReadyWithPodCount (ns .Name , 2 )).To (Succeed ())
370
+
371
+ Eventually (
372
+ func () error {
373
+ return checkForWorkingTraffic (teaURL , coffeeURL )
374
+ }).
375
+ WithTimeout (timeoutConfig .RequestTimeout ).
376
+ WithPolling (500 * time .Millisecond ).
377
+ Should (Succeed ())
378
+
379
+ checkContainerLogsForErrors (ngfPodName )
380
+ }
381
+
407
382
// checkContainerLogsForErrors checks both nginx and ngf container's logs for any possible errors.
408
383
// Since this function retrieves all the logs from both containers and the NGF pod may be shared between tests,
409
384
// the logs retrieved may contain log messages from previous tests, thus any errors in the logs from previous tests
0 commit comments