From 0f84ca040dde2b025e09f36a1267b1f8e0bf5986 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Tue, 23 Jul 2024 19:57:56 -0700 Subject: [PATCH] Avoid cloning the repo/downloading dependencies Problem: The VM clones the repo every time it's created and downloads the go dependencies. This is time consuming. Solution: Clone the repo in the base image and run `go mod download` so that most of the dependencies are already present. When the VM starts and the repo is nginxinc it will just do a git fetch on the repo to sync it. --- .github/workflows/nfr.yml | 1 - tests/scripts/create-and-setup-gcp-vm.sh | 16 +++++++++++++++- tests/scripts/create-gke-cluster.sh | 3 ++- tests/scripts/vars.env-example | 2 +- tests/suite/upgrade_test.go | 2 +- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nfr.yml b/.github/workflows/nfr.yml index 8c078f5ab4..7ad7eff852 100644 --- a/.github/workflows/nfr.yml +++ b/.github/workflows/nfr.yml @@ -102,7 +102,6 @@ jobs: echo "GKE_SVC_ACCOUNT=${{ secrets.GCP_SERVICE_ACCOUNT }}" >> vars.env echo "GKE_NODES_SERVICE_ACCOUNT=${{ secrets.GKE_NODES_SERVICE_ACCOUNT }}" >> 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 echo "SOURCE_IP_RANGE=$(curl -sS -4 icanhazip.com)/32" >> vars.env echo "ADD_VM_IP_AUTH_NETWORKS=true" >> vars.env diff --git a/tests/scripts/create-and-setup-gcp-vm.sh b/tests/scripts/create-and-setup-gcp-vm.sh index 00a9aecec2..a783c80f1a 100644 --- a/tests/scripts/create-and-setup-gcp-vm.sh +++ b/tests/scripts/create-and-setup-gcp-vm.sh @@ -44,5 +44,19 @@ 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}:~ + +if [ -n "${NGF_REPO}" ] && [ "${NGF_REPO}" != "nginxinc" ]; then + gcloud compute ssh --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} username@${RESOURCE_NAME} \ + --command="bash -i < GKE_SVC_ACCOUNT= GKE_NODES_SERVICE_ACCOUNT= NETWORK_TAGS= -NGF_REPO=nginxinc +NGF_REPO= NGF_BRANCH=main GINKGO_LABEL= GINKGO_FLAGS= diff --git a/tests/suite/upgrade_test.go b/tests/suite/upgrade_test.go index c16248719a..6539fffd96 100644 --- a/tests/suite/upgrade_test.go +++ b/tests/suite/upgrade_test.go @@ -257,7 +257,7 @@ var _ = Describe("Upgrade testing", Label("nfr", "upgrade"), func() { Expect(framework.WriteMetricsResults(resultsFile, res.metrics)).To(Succeed()) - link := fmt.Sprintf("\n\n![%[1]v.png](%[1]v.png)\n", res.scheme) + link := fmt.Sprintf("\n\n![%[1]v-oss.png](%[1]v-oss.png)\n", res.scheme) if *plusEnabled { link = fmt.Sprintf("\n\n![%[1]v-plus.png](%[1]v-plus.png)\n", res.scheme) }