Skip to content

Commit e1116fb

Browse files
authored
Avoid cloning the repo/downloading dependencies (#2280)
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.
1 parent 536ab0f commit e1116fb

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

.github/workflows/nfr.yml

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ jobs:
102102
echo "GKE_SVC_ACCOUNT=${{ secrets.GCP_SERVICE_ACCOUNT }}" >> vars.env
103103
echo "GKE_NODES_SERVICE_ACCOUNT=${{ secrets.GKE_NODES_SERVICE_ACCOUNT }}" >> vars.env
104104
echo "NETWORK_TAGS=nfr-tests-${{ github.run_id }}-${{ matrix.type }}" >> vars.env
105-
echo "NGF_REPO=nginxinc" >> vars.env
106105
echo "NGF_BRANCH=${{ github.ref_name }}" >> vars.env
107106
echo "SOURCE_IP_RANGE=$(curl -sS -4 icanhazip.com)/32" >> vars.env
108107
echo "ADD_VM_IP_AUTH_NETWORKS=true" >> vars.env

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,19 @@ 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+
if [ -n "${NGF_REPO}" ] && [ "${NGF_REPO}" != "nginxinc" ]; then
49+
gcloud compute ssh --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} username@${RESOURCE_NAME} \
50+
--command="bash -i <<EOF
51+
rm -rf nginx-gateway-fabric
52+
git clone https://github.com/${NGF_REPO}/nginx-gateway-fabric.git
53+
EOF" -- -t
54+
fi
55+
4756
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"
57+
--command="bash -i <<EOF
58+
cd nginx-gateway-fabric/tests
59+
git fetch -pP --all
60+
git checkout ${NGF_BRANCH}
61+
gcloud container clusters get-credentials ${GKE_CLUSTER_NAME} --zone ${GKE_CLUSTER_ZONE} --project=${GKE_PROJECT} --quiet
62+
EOF" -- -t

tests/scripts/create-gke-cluster.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ gcloud container clusters create ${GKE_CLUSTER_NAME} \
2828
--monitoring=SYSTEM,POD,DEPLOYMENT \
2929
--logging=SYSTEM,WORKLOAD \
3030
--machine-type ${GKE_MACHINE_TYPE} \
31-
--num-nodes ${GKE_NUM_NODES}
31+
--num-nodes ${GKE_NUM_NODES} \
32+
--no-enable-insecure-kubelet-readonly-port
3233

3334
# Add current IP to GKE master control node access, if this script is not invoked during a CI run.
3435
if [ "${IS_CI}" = "false" ]; then

tests/scripts/vars.env-example

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ 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>
1313
NETWORK_TAGS=<network tags>
14-
NGF_REPO=nginxinc
14+
NGF_REPO=<optional repo, by default nginxinc>
1515
NGF_BRANCH=main
1616
GINKGO_LABEL=<optional label to filter the tests, e.g. "performance">
1717
GINKGO_FLAGS=<optional flags to pass to the go test command>

tests/suite/upgrade_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ var _ = Describe("Upgrade testing", Label("nfr", "upgrade"), func() {
257257

258258
Expect(framework.WriteMetricsResults(resultsFile, res.metrics)).To(Succeed())
259259

260-
link := fmt.Sprintf("\n\n![%[1]v.png](%[1]v.png)\n", res.scheme)
260+
link := fmt.Sprintf("\n\n![%[1]v-oss.png](%[1]v-oss.png)\n", res.scheme)
261261
if *plusEnabled {
262262
link = fmt.Sprintf("\n\n![%[1]v-plus.png](%[1]v-plus.png)\n", res.scheme)
263263
}

0 commit comments

Comments
 (0)