Skip to content

Commit

Permalink
Use custom NGF Debian image for tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lucacome committed Jul 18, 2024
1 parent 4813408 commit b74f425
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 25 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/nfr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ jobs:
echo "GKE_PROJECT=${{ secrets.GCP_PROJECT_ID }}" >> vars.env
echo "GKE_SVC_ACCOUNT=${{ secrets.GCP_SERVICE_ACCOUNT }}" >> vars.env
echo "GKE_NODES_SERVICE_ACCOUNT=${{ secrets.GKE_NODES_SERVICE_ACCOUNT }}" >> vars.env
echo "IMAGE=projects/debian-cloud/global/images/debian-11-bullseye-v20240213" >> vars.env
echo "NETWORK_TAGS=nfr-tests-${{ github.run_id }}-${{ matrix.type }}" >> vars.env
echo "NGF_REPO=nginxinc" >> vars.env
echo "NGF_BRANCH=${{ github.ref_name }}" >> vars.env
Expand Down Expand Up @@ -134,7 +133,7 @@ jobs:
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
name: results-${{ matrix.type }}
path: tests/results/
path: tests/results/**/*-${{ matrix.type }}.*

- name: Cleanup
working-directory: ./tests
Expand Down
6 changes: 3 additions & 3 deletions tests/scripts/create-and-setup-gcp-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gcloud compute instances create ${RESOURCE_NAME} --project=${GKE_PROJECT} --zone
--network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=default --maintenance-policy=MIGRATE \
--provisioning-model=STANDARD --service-account=${GKE_SVC_ACCOUNT} \
--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 \
--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
--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

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

gcloud compute scp --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} ${SCRIPT_DIR}/vars.env username@${RESOURCE_NAME}:~

gcloud compute ssh --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} username@${RESOURCE_NAME} --command="bash -s" < ${SCRIPT_DIR}/remote-scripts/install-deps.sh
gcloud compute ssh --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} username@${RESOURCE_NAME} \
--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"
15 changes: 0 additions & 15 deletions tests/scripts/remote-scripts/install-deps.sh

This file was deleted.

2 changes: 0 additions & 2 deletions tests/scripts/remote-scripts/run-nfr-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ set -e

source ~/vars.env

echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile && . $HOME/.profile

if [ "$START_LONGEVITY" == "true" ]; then
GINKGO_LABEL="longevity-setup"
elif [ "$STOP_LONGEVITY" == "true" ]; then
Expand Down
2 changes: 0 additions & 2 deletions tests/scripts/remote-scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ set -e

source ~/vars.env

echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile && . $HOME/.profile

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}
1 change: 1 addition & 0 deletions tests/scripts/run-tests-gcp-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gcloud compute scp --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} ${SCRIPT_
gcloud compute ssh --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} username@${RESOURCE_NAME} \
--command="export START_LONGEVITY=${START_LONGEVITY} &&\
export STOP_LONGEVITY=${STOP_LONGEVITY} &&\
source /etc/profile &&\
bash -s" < ${SCRIPT_DIR}/remote-scripts/${SCRIPT}

if [ "${NFR}" = "true" ]; then
Expand Down
1 change: 0 additions & 1 deletion tests/scripts/vars.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ GKE_CLUSTER_REGION=<region where GKE cluster is deployed>
GKE_PROJECT=<GCP project>
GKE_SVC_ACCOUNT=<service account with k8s admin permissions>
GKE_NODES_SERVICE_ACCOUNT=<service account for the GKE nodes to assume>
IMAGE=projects/debian-cloud/global/images/debian-11-bullseye-v20240213
NETWORK_TAGS=<network tags>
NGF_REPO=nginxinc
NGF_BRANCH=main
Expand Down

0 comments on commit b74f425

Please sign in to comment.