Skip to content

Commit 7d4e20c

Browse files
authored
Fix NFR upgrade tests with NGINX Plus (#2967)
Problem: When first deploying NGF edge version in the upgrade tests, NGINX Plus was not properly enabled. Also, once deployed, the upgraded version did not use the proper usage endpoint. Solution: Ensure that the upgrade tests deploy the edge version of the NGINX Plus image, and set the proper usage endpoint once upgraded.
1 parent 8ac863e commit 7d4e20c

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

tests/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ stop-longevity-test: nfr-test ## Stop the longevity test and collects results
130130
--ngf-image-repo=$(PREFIX) --nginx-image-repo=$(NGINX_PREFIX) --nginx-plus-image-repo=$(NGINX_PLUS_PREFIX) \
131131
--pull-policy=$(PULL_POLICY) --service-type=$(GW_SERVICE_TYPE) \
132132
--is-gke-internal-lb=$(GW_SVC_GKE_INTERNAL) --plus-enabled=$(PLUS_ENABLED) \
133-
--plus-license-file-name=$(PLUS_LICENSE_FILE) --plus-usage-endpoint=$(PLUS_USAGE_ENDPOINT)
133+
--plus-license-file-name=$(PLUS_LICENSE_FILE) --plus-usage-endpoint=$(PLUS_USAGE_ENDPOINT) \
134+
--gke-project=$(GKE_PROJECT)
134135

135136
.PHONY: test
136137
test: build-crossplane-image ## Runs the functional tests on your kind k8s cluster

tests/framework/ngf.go

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
148148

149149
args = append(args, setImageArgs(cfg)...)
150150
args = append(args, setTelemetryArgs(cfg)...)
151+
args = append(args, setPlusUsageEndpointArg(cfg)...)
151152
fullArgs := append(args, extraArgs...) //nolint:gocritic
152153

153154
GinkgoWriter.Printf("Upgrading NGF with command: helm %v\n", strings.Join(fullArgs, " "))

tests/scripts/remote-scripts/run-nfr-tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ elif [ "${STOP_LONGEVITY}" == "true" ]; then
1010
GINKGO_LABEL="longevity-teardown"
1111
fi
1212

13-
cd nginx-gateway-fabric/tests && make .vm-nfr-test CI=${CI} TAG="${TAG}" PREFIX="${PREFIX}" NGINX_PREFIX="${NGINX_PREFIX}" NGINX_PLUS_PREFIX="${NGINX_PLUS_PREFIX}" PLUS_ENABLED="${PLUS_ENABLED}" GINKGO_LABEL=${GINKGO_LABEL} GINKGO_FLAGS="${GINKGO_FLAGS}" PULL_POLICY=Always GW_SERVICE_TYPE=LoadBalancer GW_SVC_GKE_INTERNAL=true NGF_VERSION="${NGF_VERSION}" PLUS_USAGE_ENDPOINT="${PLUS_USAGE_ENDPOINT}"
13+
cd nginx-gateway-fabric/tests && make .vm-nfr-test CI=${CI} TAG="${TAG}" PREFIX="${PREFIX}" NGINX_PREFIX="${NGINX_PREFIX}" NGINX_PLUS_PREFIX="${NGINX_PLUS_PREFIX}" PLUS_ENABLED="${PLUS_ENABLED}" GINKGO_LABEL=${GINKGO_LABEL} GINKGO_FLAGS="${GINKGO_FLAGS}" PULL_POLICY=Always GW_SERVICE_TYPE=LoadBalancer GW_SVC_GKE_INTERNAL=true NGF_VERSION="${NGF_VERSION}" PLUS_USAGE_ENDPOINT="${PLUS_USAGE_ENDPOINT}" GKE_PROJECT="${GKE_PROJECT}"
1414

1515
if [ "${START_LONGEVITY}" == "true" ]; then
1616
suite/scripts/longevity-wrk.sh

tests/scripts/vars.env-example

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ GINKGO_FLAGS=<optional flags to pass to the go test command>
1818
SOURCE_IP_RANGE=<IPs that should be allowed SSH to the VM, e.g. 1.2.3.4/32 or $(curl -sS -4 icanhazip.com)/32>
1919
ADD_VM_IP_AUTH_NETWORKS=<if set to true, the script will add the VM IP to the list of the GKE cluster master authorized networks>
2020
PLUS_ENABLED=<enable nginx plus>
21+
PLUS_USAGE_ENDPOINT=<endpoint for reporting NGINX Plus usage>
2122
NGF_VERSION=<version of NGF being tested. Defaults to value of TAG if not set>
2223
GKE_MACHINE_TYPE=<the node type for the gke cluster, defaults to e2-medium>
2324
GKE_NUM_NODES=<the number of nodes in the gke cluster, defaults to 3>

tests/suite/system_suite_test.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var (
6464
plusLicenseFileName = flag.String("plus-license-file-name", "", "File name containing the NGINX Plus JWT")
6565
plusUsageEndpoint = flag.String("plus-usage-endpoint", "", "Endpoint for reporting NGINX Plus usage")
6666
clusterName = flag.String("cluster-name", "kind", "Cluster name")
67+
gkeProject = flag.String("gke-project", "", "GKE Project name")
6768
)
6869

6970
var (
@@ -84,6 +85,8 @@ var (
8485
logs string
8586
)
8687

88+
var formatNginxPlusEdgeImagePath = "us-docker.pkg.dev/%s/nginx-gateway-fabric/nginx-plus"
89+
8790
const (
8891
releaseName = "ngf-test"
8992
ngfNamespace = "nginx-gateway"
@@ -206,18 +209,24 @@ func createNGFInstallConfig(cfg setupConfig, extraInstallArgs ...string) framewo
206209
Telemetry: cfg.telemetry,
207210
}
208211

212+
switch {
209213
// if we aren't installing from the public charts, then set the custom images
210-
if !strings.HasPrefix(cfg.chartPath, "oci://") {
214+
case !strings.HasPrefix(cfg.chartPath, "oci://"):
211215
installCfg.NgfImageRepository = *ngfImageRepository
212216
installCfg.NginxImageRepository = *nginxImageRepository
213217
if *plusEnabled && cfg.nfr {
214218
installCfg.NginxImageRepository = *nginxPlusImageRepository
215219
}
216220
installCfg.ImageTag = *imageTag
217221
installCfg.ImagePullPolicy = *imagePullPolicy
218-
} else if version == "edge" {
222+
case version == "edge":
219223
chartVersion = "0.0.0-edge"
220224
installCfg.ChartVersion = chartVersion
225+
if *plusEnabled && cfg.nfr {
226+
installCfg.NginxImageRepository = fmt.Sprintf(formatNginxPlusEdgeImagePath, *gkeProject)
227+
}
228+
case *plusEnabled && cfg.nfr:
229+
installCfg.NginxImageRepository = fmt.Sprintf(formatNginxPlusEdgeImagePath, *gkeProject)
221230
}
222231

223232
output, err := framework.InstallGatewayAPI(cfg.gwAPIVersion)

tests/suite/upgrade_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ var _ = Describe("Upgrade testing", Label("nfr", "upgrade"), func() {
101101
ServiceType: *serviceType,
102102
IsGKEInternalLB: *isGKEInternalLB,
103103
Plus: *plusEnabled,
104+
PlusUsageEndpoint: *plusUsageEndpoint,
104105
}
105106

106107
type metricsResults struct {

0 commit comments

Comments
 (0)