|
6 | 6 | "fmt"
|
7 | 7 | "net/http"
|
8 | 8 | "os/exec"
|
| 9 | + "slices" |
9 | 10 | "strings"
|
10 | 11 | "time"
|
11 | 12 |
|
@@ -318,9 +319,16 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
|
318 | 319 | setUpPortForward(nginxPodName, ns.Name)
|
319 | 320 |
|
320 | 321 | checkNGFFunctionality(teaURL, coffeeURL, "", files, ns)
|
321 |
| - // if errorLogs := getUnexpectedNginxErrorLogs(ngfPodName, ns.Name); errorLogs != "" { |
322 |
| - // Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs)) |
323 |
| - //} |
| 322 | + |
| 323 | + checkNGFContainerLogsForErrors(ngfPodName) |
| 324 | + |
| 325 | + nginxPodNames, err = framework.GetReadyNginxPodNames(k8sClient, ns.Name, timeoutConfig.GetTimeout) |
| 326 | + Expect(err).ToNot(HaveOccurred()) |
| 327 | + Expect(nginxPodNames).To(HaveLen(1)) |
| 328 | + |
| 329 | + if errorLogs := getUnexpectedNginxErrorLogs(nginxPodNames[0], ns.Name); errorLogs != "" { |
| 330 | + Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs)) |
| 331 | + } |
324 | 332 | }
|
325 | 333 |
|
326 | 334 | runRestartNodeWithDrainingTest := func(teaURL, coffeeURL string, files []string, ns *core.Namespace) {
|
@@ -433,9 +441,20 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
|
433 | 441 | setUpPortForward(nginxPodNames[0], ns.Name)
|
434 | 442 |
|
435 | 443 | checkNGFFunctionality(teaURL, coffeeURL, nginxContainerName, files, &ns)
|
436 |
| - // if errorLogs := getUnexpectedNginxErrorLogs(nginxPodName, ns.Name); errorLogs != "" { |
437 |
| - // Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs)) |
438 |
| - //} |
| 444 | + |
| 445 | + ngfPodNames, err := framework.GetReadyNGFPodNames(k8sClient, ngfNamespace, releaseName, timeoutConfig.GetTimeout) |
| 446 | + Expect(err).ToNot(HaveOccurred()) |
| 447 | + Expect(ngfPodNames).To(HaveLen(1)) |
| 448 | + |
| 449 | + nginxPodNames, err = framework.GetReadyNginxPodNames(k8sClient, ns.Name, timeoutConfig.GetTimeout) |
| 450 | + Expect(err).ToNot(HaveOccurred()) |
| 451 | + Expect(nginxPodNames).To(HaveLen(1)) |
| 452 | + |
| 453 | + checkNGFContainerLogsForErrors(ngfPodNames[0]) |
| 454 | + |
| 455 | + if errorLogs := getUnexpectedNginxErrorLogs(nginxPodNames[0], ns.Name); errorLogs != "" { |
| 456 | + Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs)) |
| 457 | + } |
439 | 458 | })
|
440 | 459 |
|
441 | 460 | It("recovers when NGF Pod is restarted", func() {
|
@@ -489,6 +508,16 @@ var _ = Describe("Graceful Recovery test", Ordered, Label("graceful-recovery"),
|
489 | 508 | Should(Succeed())
|
490 | 509 |
|
491 | 510 | checkNGFFunctionality(teaURL, coffeeURL, "", files, &ns)
|
| 511 | + |
| 512 | + checkNGFContainerLogsForErrors(newNGFPodName) |
| 513 | + |
| 514 | + nginxPodNames, err := framework.GetReadyNginxPodNames(k8sClient, ns.Name, timeoutConfig.GetTimeout) |
| 515 | + Expect(err).ToNot(HaveOccurred()) |
| 516 | + Expect(nginxPodNames).To(HaveLen(1)) |
| 517 | + |
| 518 | + if errorLogs := getUnexpectedNginxErrorLogs(nginxPodNames[0], ns.Name); errorLogs != "" { |
| 519 | + Skip(fmt.Sprintf("NGINX has unexpected error logs: \n%s", errorLogs)) |
| 520 | + } |
492 | 521 | })
|
493 | 522 |
|
494 | 523 | It("recovers when drained node is restarted", func() {
|
@@ -593,30 +622,30 @@ func getNginxErrorLogs(nginxPodName, namespace string) string {
|
593 | 622 | return errorLogs
|
594 | 623 | }
|
595 | 624 |
|
596 |
| -// func getUnexpectedNginxErrorLogs(nginxPodName, namespace string) string { |
597 |
| -// expectedErrStrings := []string{ |
598 |
| -// "connect() failed (111: Connection refused)", |
599 |
| -// "could not be resolved (host not found) during usage report", |
600 |
| -// "server returned 429", |
601 |
| -// // FIXME(salonichf5) remove this error message check |
602 |
| -// // when https://github.com/nginx/nginx-gateway-fabric/issues/2090 is completed. |
603 |
| -// "no live upstreams while connecting to upstream", |
604 |
| -// } |
605 |
| -// |
606 |
| -// unexpectedErrors := "" |
607 |
| -// |
608 |
| -// errorLogs := getNginxErrorLogs(nginxPodName, namespace) |
609 |
| -// |
610 |
| -// for _, line := range strings.Split(errorLogs, "\n") { |
611 |
| -// if !slices.ContainsFunc(expectedErrStrings, func(s string) bool { |
612 |
| -// return strings.Contains(line, s) |
613 |
| -// }) { |
614 |
| -// unexpectedErrors += line |
615 |
| -// } |
616 |
| -// } |
617 |
| -// |
618 |
| -// return unexpectedErrors |
619 |
| -//} |
| 625 | +func getUnexpectedNginxErrorLogs(nginxPodName, namespace string) string { |
| 626 | + expectedErrStrings := []string{ |
| 627 | + "connect() failed (111: Connection refused)", |
| 628 | + "could not be resolved (host not found) during usage report", |
| 629 | + "server returned 429", |
| 630 | + // FIXME(salonichf5) remove this error message check |
| 631 | + // when https://github.com/nginx/nginx-gateway-fabric/issues/2090 is completed. |
| 632 | + "no live upstreams while connecting to upstream", |
| 633 | + } |
| 634 | + |
| 635 | + unexpectedErrors := "" |
| 636 | + |
| 637 | + errorLogs := getNginxErrorLogs(nginxPodName, namespace) |
| 638 | + |
| 639 | + for _, line := range strings.Split(errorLogs, "\n") { |
| 640 | + if !slices.ContainsFunc(expectedErrStrings, func(s string) bool { |
| 641 | + return strings.Contains(line, s) |
| 642 | + }) { |
| 643 | + unexpectedErrors += line |
| 644 | + } |
| 645 | + } |
| 646 | + |
| 647 | + return unexpectedErrors |
| 648 | +} |
620 | 649 |
|
621 | 650 | // checkNGFContainerLogsForErrors checks NGF container's logs for any possible errors.
|
622 | 651 | func checkNGFContainerLogsForErrors(ngfPodName string) {
|
|
0 commit comments