@@ -127,9 +127,6 @@ func runRecoveryTest(teaURL, coffeeURL, ngfPodName, containerName string, files
127
127
Should (Succeed ())
128
128
}
129
129
130
- // TEMP: Add sleep to see if it resolves falures
131
- time .Sleep (30 * time .Second )
132
-
133
130
Eventually (
134
131
func () error {
135
132
return checkForWorkingTraffic (teaURL , coffeeURL )
@@ -159,7 +156,7 @@ func runRecoveryTest(teaURL, coffeeURL, ngfPodName, containerName string, files
159
156
WithPolling (500 * time .Millisecond ).
160
157
Should (Succeed ())
161
158
162
- checkContainerLogsForErrors (ngfPodName )
159
+ checkContainerLogsForErrors (ngfPodName , containerName == nginxContainerName )
163
160
}
164
161
165
162
func restartContainer (ngfPodName , containerName string ) {
@@ -261,15 +258,17 @@ func expectRequestToFail(appURL, address string) error {
261
258
// Since this function retrieves all the logs from both containers and the NGF pod may be shared between tests,
262
259
// the logs retrieved may contain log messages from previous tests, thus any errors in the logs from previous tests
263
260
// may cause an interference with this test and cause this test to fail.
264
- func checkContainerLogsForErrors (ngfPodName string ) {
265
- logs , err := resourceManager .GetPodLogs (
261
+ // Additionally, when the NGINX process is killed, some errors are expected in the NGF logs while we wait for the
262
+ // NGINX container to be restarted.
263
+ func checkContainerLogsForErrors (ngfPodName string , checkNginxLogsOnly bool ) {
264
+ nginxLogs , err := resourceManager .GetPodLogs (
266
265
ngfNamespace ,
267
266
ngfPodName ,
268
267
& core.PodLogOptions {Container : nginxContainerName },
269
268
)
270
269
Expect (err ).ToNot (HaveOccurred ())
271
270
272
- for _ , line := range strings .Split (logs , "\n " ) {
271
+ for _ , line := range strings .Split (nginxLogs , "\n " ) {
273
272
Expect (line ).ToNot (ContainSubstring ("[crit]" ), line )
274
273
Expect (line ).ToNot (ContainSubstring ("[alert]" ), line )
275
274
Expect (line ).ToNot (ContainSubstring ("[emerg]" ), line )
@@ -282,18 +281,20 @@ func checkContainerLogsForErrors(ngfPodName string) {
282
281
}
283
282
}
284
283
285
- logs , err = resourceManager .GetPodLogs (
286
- ngfNamespace ,
287
- ngfPodName ,
288
- & core.PodLogOptions {Container : ngfContainerName },
289
- )
290
- Expect (err ).ToNot (HaveOccurred ())
284
+ if ! checkNginxLogsOnly {
285
+ ngfLogs , err := resourceManager .GetPodLogs (
286
+ ngfNamespace ,
287
+ ngfPodName ,
288
+ & core.PodLogOptions {Container : ngfContainerName },
289
+ )
290
+ Expect (err ).ToNot (HaveOccurred ())
291
291
292
- for _ , line := range strings .Split (logs , "\n " ) {
293
- if * plusEnabled && strings .Contains (line , "\" level\" :\" error\" " ) {
294
- Expect (line ).To (ContainSubstring ("Usage reporting must be enabled when using NGINX Plus" ), line )
295
- } else {
296
- Expect (line ).ToNot (ContainSubstring ("\" level\" :\" error\" " ), line )
292
+ for _ , line := range strings .Split (ngfLogs , "\n " ) {
293
+ if * plusEnabled && strings .Contains (line , "\" level\" :\" error\" " ) {
294
+ Expect (line ).To (ContainSubstring ("Usage reporting must be enabled when using NGINX Plus" ), line )
295
+ } else {
296
+ Expect (line ).ToNot (ContainSubstring ("\" level\" :\" error\" " ), line )
297
+ }
297
298
}
298
299
}
299
300
}
0 commit comments