Skip to content

Commit

Permalink
Filter by special release name
Browse files Browse the repository at this point in the history
  • Loading branch information
sjberman committed Mar 11, 2024
1 parent 116dc20 commit 9fdb2b7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
8 changes: 4 additions & 4 deletions tests/scripts/run-tests-gcp-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/suite/scripts/longevity-wrk.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down
21 changes: 17 additions & 4 deletions tests/suite/system_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const (
)

type setupConfig struct {
releaseName string
chartPath string
gwAPIVersion string
deploy bool
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -221,6 +222,7 @@ var _ = BeforeSuite(func() {
localChartPath = filepath.Join(basepath, "deploy/helm-chart")

cfg := setupConfig{
releaseName: releaseName,
chartPath: localChartPath,
gwAPIVersion: *gatewayAPIVersion,
deploy: true,
Expand All @@ -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)
})

Expand All @@ -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)
}
})

Expand Down
2 changes: 1 addition & 1 deletion tests/suite/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9fdb2b7

Please sign in to comment.