Skip to content

Commit 70c70e9

Browse files
committed
Skip checking gateway container logs for errors
1 parent 6168233 commit 70c70e9

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

tests/suite/graceful_recovery_test.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ func runRecoveryTest(teaURL, coffeeURL, ngfPodName, containerName string, files
127127
Should(Succeed())
128128
}
129129

130-
// TEMP: Add sleep to see if it resolves falures
131-
time.Sleep(30 * time.Second)
132-
133130
Eventually(
134131
func() error {
135132
return checkForWorkingTraffic(teaURL, coffeeURL)
@@ -159,7 +156,7 @@ func runRecoveryTest(teaURL, coffeeURL, ngfPodName, containerName string, files
159156
WithPolling(500 * time.Millisecond).
160157
Should(Succeed())
161158

162-
checkContainerLogsForErrors(ngfPodName)
159+
checkContainerLogsForErrors(ngfPodName, containerName == nginxContainerName)
163160
}
164161

165162
func restartContainer(ngfPodName, containerName string) {
@@ -261,15 +258,17 @@ func expectRequestToFail(appURL, address string) error {
261258
// Since this function retrieves all the logs from both containers and the NGF pod may be shared between tests,
262259
// the logs retrieved may contain log messages from previous tests, thus any errors in the logs from previous tests
263260
// 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(
266265
ngfNamespace,
267266
ngfPodName,
268267
&core.PodLogOptions{Container: nginxContainerName},
269268
)
270269
Expect(err).ToNot(HaveOccurred())
271270

272-
for _, line := range strings.Split(logs, "\n") {
271+
for _, line := range strings.Split(nginxLogs, "\n") {
273272
Expect(line).ToNot(ContainSubstring("[crit]"), line)
274273
Expect(line).ToNot(ContainSubstring("[alert]"), line)
275274
Expect(line).ToNot(ContainSubstring("[emerg]"), line)
@@ -282,18 +281,20 @@ func checkContainerLogsForErrors(ngfPodName string) {
282281
}
283282
}
284283

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())
291291

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+
}
297298
}
298299
}
299300
}

0 commit comments

Comments
 (0)