Skip to content

Commit 1476fe0

Browse files
authored
Use custom NGF Debian image for tests (#2260)
Problem: We're using a specific version of debian to create the VM. This image is deprecated. We also install all the dependencies needed every time we create the VM. Solution: Create a custom image with all of our dependencies and specify the image-family as a parameter so we can always use the latest version.
1 parent 57ab5e9 commit 1476fe0

File tree

7 files changed

+11
-26
lines changed

7 files changed

+11
-26
lines changed

.github/workflows/nfr.yml

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ jobs:
101101
echo "GKE_PROJECT=${{ secrets.GCP_PROJECT_ID }}" >> vars.env
102102
echo "GKE_SVC_ACCOUNT=${{ secrets.GCP_SERVICE_ACCOUNT }}" >> vars.env
103103
echo "GKE_NODES_SERVICE_ACCOUNT=${{ secrets.GKE_NODES_SERVICE_ACCOUNT }}" >> vars.env
104-
echo "IMAGE=projects/debian-cloud/global/images/debian-11-bullseye-v20240213" >> vars.env
105104
echo "NETWORK_TAGS=nfr-tests-${{ github.run_id }}-${{ matrix.type }}" >> vars.env
106105
echo "NGF_REPO=nginxinc" >> vars.env
107106
echo "NGF_BRANCH=${{ github.ref_name }}" >> vars.env

tests/scripts/create-and-setup-gcp-vm.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ gcloud compute firewall-rules create ${RESOURCE_NAME} \
1414
--source-ranges=${SOURCE_IP_RANGE} \
1515
--target-tags=${NETWORK_TAGS}
1616

17-
gcloud compute instances create ${RESOURCE_NAME} --project=${GKE_PROJECT} --zone=${GKE_CLUSTER_ZONE} --machine-type=e2-medium \
17+
gcloud compute instances create ${RESOURCE_NAME} --project=${GKE_PROJECT} --zone=${GKE_CLUSTER_ZONE} --machine-type=n2-standard-2 \
1818
--network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=default --maintenance-policy=MIGRATE \
1919
--provisioning-model=STANDARD --service-account=${GKE_SVC_ACCOUNT} \
2020
--scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append,https://www.googleapis.com/auth/cloud-platform \
21-
--tags=${NETWORK_TAGS} --create-disk=auto-delete=yes,boot=yes,device-name=${RESOURCE_NAME},image=${IMAGE},mode=rw,size=10 --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=goog-ec-src=vm_add-gcloud --reservation-affinity=any
21+
--tags=${NETWORK_TAGS} --create-disk=auto-delete=yes,boot=yes,device-name=${RESOURCE_NAME},image-family=projects/${GKE_PROJECT}/global/images/ngf-debian,mode=rw,size=20 --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=goog-ec-src=vm_add-gcloud --reservation-affinity=any
2222

2323
# Add VM IP to GKE master control node access, if required
2424
if [ "${ADD_VM_IP_AUTH_NETWORKS}" = "true" ]; then
@@ -44,5 +44,5 @@ for ((i=1; i<=MAX_RETRIES; i++)); do
4444
done
4545

4646
gcloud compute scp --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} ${SCRIPT_DIR}/vars.env username@${RESOURCE_NAME}:~
47-
48-
gcloud compute ssh --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} username@${RESOURCE_NAME} --command="bash -s" < ${SCRIPT_DIR}/remote-scripts/install-deps.sh
47+
gcloud compute ssh --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} username@${RESOURCE_NAME} \
48+
--command="git clone https://github.com/${NGF_REPO}/nginx-gateway-fabric.git && cd nginx-gateway-fabric/tests && git checkout ${NGF_BRANCH} && gcloud container clusters get-credentials ${GKE_CLUSTER_NAME} --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} --quiet"

tests/scripts/remote-scripts/install-deps.sh

-15
This file was deleted.

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

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ set -e
44

55
source ~/vars.env
66

7-
echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile && . $HOME/.profile
8-
97
if [ "$START_LONGEVITY" == "true" ]; then
108
GINKGO_LABEL="longevity-setup"
119
elif [ "$STOP_LONGEVITY" == "true" ]; then

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

-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ set -e
44

55
source ~/vars.env
66

7-
echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile && . $HOME/.profile
8-
97
cd nginx-gateway-fabric/tests && make test 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}

tests/scripts/run-tests-gcp-vm.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ gcloud compute scp --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} ${SCRIPT_
1414
gcloud compute ssh --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} username@${RESOURCE_NAME} \
1515
--command="export START_LONGEVITY=${START_LONGEVITY} &&\
1616
export STOP_LONGEVITY=${STOP_LONGEVITY} &&\
17-
bash -s" < ${SCRIPT_DIR}/remote-scripts/${SCRIPT}
17+
source /etc/profile &&\
18+
bash -s" < ${SCRIPT_DIR}/remote-scripts/${SCRIPT}; retcode=$?
19+
20+
if [ $retcode -ne 0 ]; then
21+
echo "Error running tests on VM"
22+
exit 1
23+
fi
1824

1925
if [ "${NFR}" = "true" ]; then
2026
gcloud compute scp --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} --recurse username@${RESOURCE_NAME}:~/nginx-gateway-fabric/tests/results .

tests/scripts/vars.env-example

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ GKE_CLUSTER_REGION=<region where GKE cluster is deployed>
1010
GKE_PROJECT=<GCP project>
1111
GKE_SVC_ACCOUNT=<service account with k8s admin permissions>
1212
GKE_NODES_SERVICE_ACCOUNT=<service account for the GKE nodes to assume>
13-
IMAGE=projects/debian-cloud/global/images/debian-11-bullseye-v20240213
1413
NETWORK_TAGS=<network tags>
1514
NGF_REPO=nginxinc
1615
NGF_BRANCH=main

0 commit comments

Comments
 (0)