Skip to content

Commit

Permalink
Use /usr/bin/env for scripts (#2315)
Browse files Browse the repository at this point in the history
`/usr/bin/env bash` is more flexible than `/bin/bash` when using different OSes.
This also fixes files and script with wrong permissions.
  • Loading branch information
lucacome authored Jul 31, 2024
1 parent f07197c commit f586309
Show file tree
Hide file tree
Showing 34 changed files with 32 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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`; \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/reconfig/scripts/create-resources-gw-last.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

num_namespaces=$1

Expand Down
2 changes: 1 addition & 1 deletion tests/reconfig/scripts/create-resources-routes-last.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

num_namespaces=$1

Expand Down
2 changes: 1 addition & 1 deletion tests/reconfig/scripts/delete-multiple.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

num_namespaces=$1

Expand Down
Empty file modified tests/results/dp-perf/1.2.0/1.2.0-plus.md
100755 → 100644
Empty file.
Empty file modified tests/results/dp-perf/1.2.0/1.2.0.md
100755 → 100644
Empty file.
Empty file modified tests/results/dp-perf/1.3.0/1.3.0-plus.md
100755 → 100644
Empty file.
Empty file modified tests/results/dp-perf/1.3.0/1.3.0.md
100755 → 100644
Empty file.
Empty file modified tests/results/dp-perf/edge/edge-oss.md
100755 → 100644
Empty file.
Empty file modified tests/results/dp-perf/edge/edge-plus.md
100755 → 100644
Empty file.
Empty file modified tests/results/ngf-upgrade/1.2.0/1.2.0-plus.md
100755 → 100644
Empty file.
Empty file modified tests/results/ngf-upgrade/1.2.0/1.2.0.md
100755 → 100644
Empty file.
Empty file modified tests/results/ngf-upgrade/1.3.0/1.3.0-plus.md
100755 → 100644
Empty file.
Empty file modified tests/results/ngf-upgrade/1.3.0/1.3.0.md
100755 → 100644
Empty file.
Empty file modified tests/results/ngf-upgrade/edge/edge-oss.md
100755 → 100644
Empty file.
Empty file modified tests/results/ngf-upgrade/edge/edge-plus.md
100755 → 100644
Empty file.
Empty file modified tests/results/scale/1.3.0/1.3.0-plus.md
100755 → 100644
Empty file.
Empty file modified tests/results/scale/1.3.0/1.3.0.md
100755 → 100644
Empty file.
Empty file modified tests/results/scale/edge/edge-oss.md
100755 → 100644
Empty file.
Empty file modified tests/results/scale/edge/edge-plus.md
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion tests/scripts/add-local-ip-auth-networks.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source scripts/vars.env

Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/check-pod-exit-code.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/cleanup-router.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source scripts/vars.env

Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/cleanup-vm.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source scripts/vars.env

Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/create-and-setup-gcp-vm.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/create-gke-cluster.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source scripts/vars.env

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/scripts/create-gke-router.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source scripts/vars.env

Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/delete-gke-cluster.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

source scripts/vars.env

Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/remote-scripts/run-nfr-tests.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/remote-scripts/run-tests.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
3 changes: 1 addition & 2 deletions tests/scripts/run-tests-gcp-vm.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/sync-files-to-vm.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/suite/scripts/longevity-wrk.sh
Original file line number Diff line number Diff line change
@@ -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}')

Expand Down

0 comments on commit f586309

Please sign in to comment.