diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ca5eec7303..cbed6607f0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,9 @@ repos: - id: check-case-conflict - id: check-vcs-permalinks - id: check-json + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: check-symlinks - id: pretty-format-json args: [--autofix, --no-sort-keys, --no-ensure-ascii] - id: mixed-line-ending diff --git a/tests/Makefile b/tests/Makefile index 6876242697..16dcd67031 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -37,7 +37,7 @@ run-conformance-tests: ## Run conformance tests --restart=Never -- sh -c "go test -v . -tags conformance,experimental -args --gateway-class=$(GATEWAY_CLASS) \ --supported-features=$(SUPPORTED_FEATURES) --version=$(NGF_VERSION) \ --report-output=output.txt; cat output.txt" | tee output.txt - bash scripts/check-pod-exit-code.sh + ./scripts/check-pod-exit-code.sh sed -e '1,/CONFORMANCE PROFILE/d' output.txt > conformance-profile.yaml rm output.txt grpc_core_result=`yq '.profiles[0].core.result' conformance-profile.yaml`; \ @@ -77,27 +77,27 @@ setup-gcp-and-run-nfr-tests: create-gke-router create-and-setup-vm nfr-test ## C .PHONY: create-gke-cluster create-gke-cluster: ## Create a GKE cluster - bash scripts/create-gke-cluster.sh $(CI) + ./scripts/create-gke-cluster.sh $(CI) .PHONY: create-and-setup-vm create-and-setup-vm: ## Create and setup a GCP VM for tests - bash scripts/create-and-setup-gcp-vm.sh + ./scripts/create-and-setup-gcp-vm.sh .PHONY: create-gke-router create-gke-router: ## Create a GKE router to allow egress traffic from private nodes (allows for external image pulls) - bash scripts/create-gke-router.sh + ./scripts/create-gke-router.sh .PHONY: sync-files-to-vm sync-files-to-vm: ## Syncs your local NGF files with the NGF repo on the VM - bash scripts/sync-files-to-vm.sh + ./scripts/sync-files-to-vm.sh .PHONY: run-tests-on-vm run-tests-on-vm: ## Run the functional tests on a GCP VM - bash scripts/run-tests-gcp-vm.sh + ./scripts/run-tests-gcp-vm.sh .PHONY: nfr-test nfr-test: ## Run the NFR tests on a GCP VM - NFR=true CI=$(CI) bash scripts/run-tests-gcp-vm.sh + NFR=true CI=$(CI) ./scripts/run-tests-gcp-vm.sh .PHONY: start-longevity-test start-longevity-test: export START_LONGEVITY=true @@ -135,19 +135,19 @@ cleanup-gcp: cleanup-router cleanup-vm delete-gke-cluster ## Cleanup all GCP res .PHONY: cleanup-router cleanup-router: ## Delete the GKE router - bash scripts/cleanup-router.sh + ./scripts/cleanup-router.sh .PHONY: cleanup-vm cleanup-vm: ## Delete the test GCP VM and delete the firewall rule - bash scripts/cleanup-vm.sh + ./scripts/cleanup-vm.sh .PHONY: delete-gke-cluster delete-gke-cluster: ## Delete the GKE cluster - bash scripts/delete-gke-cluster.sh + ./scripts/delete-gke-cluster.sh .PHONY: add-local-ip-to-cluster add-local-ip-to-cluster: ## Add local IP to the GKE cluster master-authorized-networks - bash scripts/add-local-ip-auth-networks.sh + ./scripts/add-local-ip-auth-networks.sh HELM_PARAMETERS += --set nameOverride=nginx-gateway --set nginxGateway.kind=skip --set service.create=false diff --git a/tests/reconfig/scripts/create-resources-gw-last.sh b/tests/reconfig/scripts/create-resources-gw-last.sh old mode 100644 new mode 100755 index cf01af317c..8fe41f45d3 --- a/tests/reconfig/scripts/create-resources-gw-last.sh +++ b/tests/reconfig/scripts/create-resources-gw-last.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash num_namespaces=$1 diff --git a/tests/reconfig/scripts/create-resources-routes-last.sh b/tests/reconfig/scripts/create-resources-routes-last.sh old mode 100644 new mode 100755 index 88d819ec7e..c502c22d96 --- a/tests/reconfig/scripts/create-resources-routes-last.sh +++ b/tests/reconfig/scripts/create-resources-routes-last.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash num_namespaces=$1 diff --git a/tests/reconfig/scripts/delete-multiple.sh b/tests/reconfig/scripts/delete-multiple.sh index 19734932d1..8f479833b4 100755 --- a/tests/reconfig/scripts/delete-multiple.sh +++ b/tests/reconfig/scripts/delete-multiple.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash num_namespaces=$1 diff --git a/tests/results/dp-perf/1.2.0/1.2.0-plus.md b/tests/results/dp-perf/1.2.0/1.2.0-plus.md old mode 100755 new mode 100644 diff --git a/tests/results/dp-perf/1.2.0/1.2.0.md b/tests/results/dp-perf/1.2.0/1.2.0.md old mode 100755 new mode 100644 diff --git a/tests/results/dp-perf/1.3.0/1.3.0-plus.md b/tests/results/dp-perf/1.3.0/1.3.0-plus.md old mode 100755 new mode 100644 diff --git a/tests/results/dp-perf/1.3.0/1.3.0.md b/tests/results/dp-perf/1.3.0/1.3.0.md old mode 100755 new mode 100644 diff --git a/tests/results/dp-perf/edge/edge-oss.md b/tests/results/dp-perf/edge/edge-oss.md old mode 100755 new mode 100644 diff --git a/tests/results/dp-perf/edge/edge-plus.md b/tests/results/dp-perf/edge/edge-plus.md old mode 100755 new mode 100644 diff --git a/tests/results/ngf-upgrade/1.2.0/1.2.0-plus.md b/tests/results/ngf-upgrade/1.2.0/1.2.0-plus.md old mode 100755 new mode 100644 diff --git a/tests/results/ngf-upgrade/1.2.0/1.2.0.md b/tests/results/ngf-upgrade/1.2.0/1.2.0.md old mode 100755 new mode 100644 diff --git a/tests/results/ngf-upgrade/1.3.0/1.3.0-plus.md b/tests/results/ngf-upgrade/1.3.0/1.3.0-plus.md old mode 100755 new mode 100644 diff --git a/tests/results/ngf-upgrade/1.3.0/1.3.0.md b/tests/results/ngf-upgrade/1.3.0/1.3.0.md old mode 100755 new mode 100644 diff --git a/tests/results/ngf-upgrade/edge/edge-oss.md b/tests/results/ngf-upgrade/edge/edge-oss.md old mode 100755 new mode 100644 diff --git a/tests/results/ngf-upgrade/edge/edge-plus.md b/tests/results/ngf-upgrade/edge/edge-plus.md old mode 100755 new mode 100644 diff --git a/tests/results/scale/1.3.0/1.3.0-plus.md b/tests/results/scale/1.3.0/1.3.0-plus.md old mode 100755 new mode 100644 diff --git a/tests/results/scale/1.3.0/1.3.0.md b/tests/results/scale/1.3.0/1.3.0.md old mode 100755 new mode 100644 diff --git a/tests/results/scale/edge/edge-oss.md b/tests/results/scale/edge/edge-oss.md old mode 100755 new mode 100644 diff --git a/tests/results/scale/edge/edge-plus.md b/tests/results/scale/edge/edge-plus.md old mode 100755 new mode 100644 diff --git a/tests/scripts/add-local-ip-auth-networks.sh b/tests/scripts/add-local-ip-auth-networks.sh old mode 100644 new mode 100755 index 525260fe93..98466d1811 --- a/tests/scripts/add-local-ip-auth-networks.sh +++ b/tests/scripts/add-local-ip-auth-networks.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash source scripts/vars.env diff --git a/tests/scripts/check-pod-exit-code.sh b/tests/scripts/check-pod-exit-code.sh old mode 100644 new mode 100755 index be0ac5b541..a7455c7a56 --- a/tests/scripts/check-pod-exit-code.sh +++ b/tests/scripts/check-pod-exit-code.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash CODE=$(kubectl get pod conformance -o jsonpath='{.status.containerStatuses[].state.terminated.exitCode}') if [ $CODE -ne 0 ]; then diff --git a/tests/scripts/cleanup-router.sh b/tests/scripts/cleanup-router.sh index e564aaa0e2..7b95b642c8 100755 --- a/tests/scripts/cleanup-router.sh +++ b/tests/scripts/cleanup-router.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash source scripts/vars.env diff --git a/tests/scripts/cleanup-vm.sh b/tests/scripts/cleanup-vm.sh old mode 100644 new mode 100755 index f0265bc8db..6c7b4e6fda --- a/tests/scripts/cleanup-vm.sh +++ b/tests/scripts/cleanup-vm.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash source scripts/vars.env diff --git a/tests/scripts/create-and-setup-gcp-vm.sh b/tests/scripts/create-and-setup-gcp-vm.sh old mode 100644 new mode 100755 index a783c80f1a..2dc455a865 --- a/tests/scripts/create-and-setup-gcp-vm.sh +++ b/tests/scripts/create-and-setup-gcp-vm.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) diff --git a/tests/scripts/create-gke-cluster.sh b/tests/scripts/create-gke-cluster.sh old mode 100644 new mode 100755 index 55c4309141..21a8cf919c --- a/tests/scripts/create-gke-cluster.sh +++ b/tests/scripts/create-gke-cluster.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash source scripts/vars.env @@ -34,5 +34,5 @@ gcloud container clusters create ${GKE_CLUSTER_NAME} \ # Add current IP to GKE master control node access, if this script is not invoked during a CI run. if [ "${IS_CI}" = "false" ]; then SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - bash ${SCRIPT_DIR}/add-local-ip-auth-networks.sh + ./${SCRIPT_DIR}/add-local-ip-auth-networks.sh fi diff --git a/tests/scripts/create-gke-router.sh b/tests/scripts/create-gke-router.sh index 25bad4ce21..421fc74f8a 100755 --- a/tests/scripts/create-gke-router.sh +++ b/tests/scripts/create-gke-router.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash source scripts/vars.env diff --git a/tests/scripts/delete-gke-cluster.sh b/tests/scripts/delete-gke-cluster.sh old mode 100644 new mode 100755 index dedacbdb1d..0f390bbd8f --- a/tests/scripts/delete-gke-cluster.sh +++ b/tests/scripts/delete-gke-cluster.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash source scripts/vars.env diff --git a/tests/scripts/remote-scripts/run-nfr-tests.sh b/tests/scripts/remote-scripts/run-nfr-tests.sh old mode 100644 new mode 100755 index b93d2a9127..c61077cbf9 --- a/tests/scripts/remote-scripts/run-nfr-tests.sh +++ b/tests/scripts/remote-scripts/run-nfr-tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/tests/scripts/remote-scripts/run-tests.sh b/tests/scripts/remote-scripts/run-tests.sh old mode 100644 new mode 100755 index 96f68299a6..dad6dbc946 --- a/tests/scripts/remote-scripts/run-tests.sh +++ b/tests/scripts/remote-scripts/run-tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/tests/scripts/run-tests-gcp-vm.sh b/tests/scripts/run-tests-gcp-vm.sh old mode 100644 new mode 100755 index 97545a6076..9fa635b3a2 --- a/tests/scripts/run-tests-gcp-vm.sh +++ b/tests/scripts/run-tests-gcp-vm.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) @@ -14,7 +14,6 @@ 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}; retcode=$? if [ $retcode -ne 0 ]; then diff --git a/tests/scripts/sync-files-to-vm.sh b/tests/scripts/sync-files-to-vm.sh index c7862c2054..ceede7f461 100755 --- a/tests/scripts/sync-files-to-vm.sh +++ b/tests/scripts/sync-files-to-vm.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash source scripts/vars.env -NGF_DIR=$(dirname "$PWD") +NGF_DIR=$(dirname "$CUR") gcloud compute config-ssh --ssh-config-file ngf-gcp.ssh > /dev/null diff --git a/tests/suite/scripts/longevity-wrk.sh b/tests/suite/scripts/longevity-wrk.sh index 58312a1e1c..7d758c0976 100755 --- a/tests/suite/scripts/longevity-wrk.sh +++ b/tests/suite/scripts/longevity-wrk.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash SVC_IP=$(kubectl -n nginx-gateway get svc ngf-longevity-nginx-gateway-fabric -o jsonpath='{.status.loadBalancer.ingress[0].ip}')