diff --git a/tests/scripts/run-tests-gcp-vm.sh b/tests/scripts/run-tests-gcp-vm.sh index 7f35e26c0b..4c9a8478e3 100644 --- a/tests/scripts/run-tests-gcp-vm.sh +++ b/tests/scripts/run-tests-gcp-vm.sh @@ -31,15 +31,15 @@ if [ "${STOP_LONGEVITY}" = "true" ]; then printf "\n## Error Logs\n\n" >> $results ## ngf error logs - ngfErrText=$(gcloud logging read --project=${GKE_PROJECT} 'resource.labels.cluster_name='"${RESOURCE_NAME}"' AND resource.type=k8s_container AND resource.labels.container_name=nginx-gateway AND severity=ERROR AND SEARCH("error")' --format "value(textPayload)") - ngfErrJSON=$(gcloud logging read --project=${GKE_PROJECT} 'resource.labels.cluster_name='"${RESOURCE_NAME}"' AND resource.type=k8s_container AND resource.labels.container_name=nginx-gateway AND severity=ERROR AND SEARCH("error")' --format "value(jsonPayload)") + ngfErrText=$(gcloud logging read --project=${GKE_PROJECT} 'resource.labels.cluster_name='"${RESOURCE_NAME}"' AND resource.type=k8s_container AND resource.labels.container_name=nginx-gateway AND labels."k8s-pod/app_kubernetes_io/instance"=ngf-longevity AND severity=ERROR AND SEARCH("error")' --format "value(textPayload)") + ngfErrJSON=$(gcloud logging read --project=${GKE_PROJECT} 'resource.labels.cluster_name='"${RESOURCE_NAME}"' AND resource.type=k8s_container AND resource.labels.container_name=nginx-gateway AND labels."k8s-pod/app_kubernetes_io/instance"=ngf-longevity AND severity=ERROR AND SEARCH("error")' --format "value(jsonPayload)") printf "### nginx-gateway\n$ngfErrText\n$ngfErrJSON\n\n" >> $results ## nginx error logs - ngxErr=$(gcloud logging read --project=${GKE_PROJECT} 'resource.labels.cluster_name='"${RESOURCE_NAME}"' AND resource.type=k8s_container AND resource.labels.container_name=nginx AND severity=ERROR AND SEARCH("`[warn]`") OR SEARCH("`[error]`") OR SEARCH("`[emerg]`")' --format "value(textPayload)") + ngxErr=$(gcloud logging read --project=${GKE_PROJECT} 'resource.labels.cluster_name='"${RESOURCE_NAME}"' AND resource.type=k8s_container AND resource.labels.container_name=nginx AND labels."k8s-pod/app_kubernetes_io/instance"=ngf-longevity AND severity=ERROR AND SEARCH("`[warn]`") OR SEARCH("`[error]`") OR SEARCH("`[emerg]`")' --format "value(textPayload)") printf "### nginx\n$ngxErr\n\n" >> $results ## nginx non-200 responses (also filter out 499 since wrk cancels connections) - ngxNon200=$(gcloud logging read --project=${GKE_PROJECT} 'resource.labels.cluster_name='"${RESOURCE_NAME}"' AND resource.type=k8s_container AND resource.labels.container_name=nginx AND "GET" "HTTP/1.1" -"200" -"499" -"client prematurely closed connection"' --format "value(textPayload)") + ngxNon200=$(gcloud logging read --project=${GKE_PROJECT} 'resource.labels.cluster_name='"${RESOURCE_NAME}"' AND resource.type=k8s_container AND resource.labels.container_name=nginx AND labels."k8s-pod/app_kubernetes_io/instance"=ngf-longevity AND "GET" "HTTP/1.1" -"200" -"499" -"client prematurely closed connection"' --format "value(textPayload)") printf "$ngxNon200\n\n" >> $results fi diff --git a/tests/suite/scripts/longevity-wrk.sh b/tests/suite/scripts/longevity-wrk.sh index 20cf551d50..58312a1e1c 100755 --- a/tests/suite/scripts/longevity-wrk.sh +++ b/tests/suite/scripts/longevity-wrk.sh @@ -1,6 +1,6 @@ #!/bin/bash -SVC_IP=$(kubectl -n nginx-gateway get svc ngf-test-nginx-gateway-fabric -o jsonpath='{.status.loadBalancer.ingress[0].ip}') +SVC_IP=$(kubectl -n nginx-gateway get svc ngf-longevity-nginx-gateway-fabric -o jsonpath='{.status.loadBalancer.ingress[0].ip}') echo "${SVC_IP} cafe.example.com" | sudo tee -a /etc/hosts diff --git a/tests/suite/system_suite_test.go b/tests/suite/system_suite_test.go index a46b08d8ba..ecfc60c3ef 100644 --- a/tests/suite/system_suite_test.go +++ b/tests/suite/system_suite_test.go @@ -79,6 +79,7 @@ const ( ) type setupConfig struct { + releaseName string chartPath string gwAPIVersion string deploy bool @@ -140,7 +141,7 @@ func setup(cfg setupConfig, extraInstallArgs ...string) { } installCfg := framework.InstallationConfig{ - ReleaseName: releaseName, + ReleaseName: cfg.releaseName, Namespace: ngfNamespace, ChartPath: cfg.chartPath, ServiceType: *serviceType, @@ -180,13 +181,13 @@ func setup(cfg setupConfig, extraInstallArgs ...string) { Expect(err).ToNot(HaveOccurred()) } -func teardown() { +func teardown(relName string) { if portFwdPort != 0 { portForwardStopCh <- struct{}{} } cfg := framework.InstallationConfig{ - ReleaseName: releaseName, + ReleaseName: relName, Namespace: ngfNamespace, } @@ -221,6 +222,7 @@ var _ = BeforeSuite(func() { localChartPath = filepath.Join(basepath, "deploy/helm-chart") cfg := setupConfig{ + releaseName: releaseName, chartPath: localChartPath, gwAPIVersion: *gatewayAPIVersion, deploy: true, @@ -236,6 +238,12 @@ var _ = BeforeSuite(func() { cfg.deploy = false } + // use a different release name for longevity to allow us to filter on a specific label when collecting + // logs from GKE + if strings.Contains(labelFilter, "longevity") { + cfg.releaseName = "ngf-longevity" + } + setup(cfg) }) @@ -246,7 +254,12 @@ var _ = AfterSuite(func() { labelFilter := GinkgoLabelFilter() if !strings.Contains(labelFilter, "longevity-setup") { - teardown() + relName := releaseName + if strings.Contains(labelFilter, "longevity-teardown") { + relName = "ngf-longevity" + } + + teardown(relName) } }) diff --git a/tests/suite/upgrade_test.go b/tests/suite/upgrade_test.go index 401b8d9a91..0e5983401f 100644 --- a/tests/suite/upgrade_test.go +++ b/tests/suite/upgrade_test.go @@ -49,7 +49,7 @@ var _ = Describe("Upgrade testing", Label("nfr", "upgrade"), func() { BeforeEach(func() { // this test is unique in that it needs to install the previous version of NGF, // so we need to uninstall the version installed at the suite level, then install the custom version - teardown() + teardown(releaseName) cfg := setupConfig{ chartPath: "oci://ghcr.io/nginxinc/charts/nginx-gateway-fabric",