Skip to content

Commit 181d35f

Browse files
authored
Updating run-capz-e2e.sh to run extra commands (#529)
Signed-off-by: Mark Rossett <marosset@microsoft.com>
1 parent 72920e9 commit 181d35f

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

capz/readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ az role assignment create \
116116
--scope "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>"
117117
```
118118

119+
## Running custom commands with `run-capz-e2e.sh`
120+
121+
`run-capz-e2e.sh` now accepts an optional command to execute after the cluster and supporting components are ready. When any arguments are provided, the script runs the command in the prepared environment and skips the built-in Windows e2e Ginkgo suite.
122+
123+
Example usage from a Prow job:
124+
125+
```bash
126+
./capz/run-capz-e2e.sh bash -c "cd ${GOPATH}/src/sigs.k8s.io/azuredisk-csi-driver && ./deploy/install-driver.sh master local,snapshot,enable-avset && make e2e-test"
127+
```
128+
129+
The script exits with the same status as the supplied command, so downstream automation can use the exit code to determine job success or failure.
130+
119131
## Hyper-V isolated containers support
120132

121133
Requires containerd v1.7+ deployed to the Windows nodes.

capz/run-capz-e2e.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ if [[ ! -d $AZURE_CLOUD_PROVIDER_ROOT ]]; then
2020
fi
2121

2222
main() {
23+
local -a post_command=("$@")
24+
2325
# defaults
2426
export KUBERNETES_VERSION="${KUBERNETES_VERSION:-"latest"}"
2527
export CONTROL_PLANE_MACHINE_COUNT="${AZURE_CONTROL_PLANE_MACHINE_COUNT:-"1"}"
@@ -65,6 +67,15 @@ main() {
6567
ensure_cloud_provider_taint_on_windows_nodes
6668
wait_for_windows_machinedeployment
6769
if [[ "${HYPERV}" == "true" ]]; then apply_hyperv_configuration; fi
70+
71+
if [[ ${#post_command[@]} -gt 0 ]]; then
72+
local exit_code
73+
log "post command detected; skipping default e2e tests"
74+
run_post_command "${post_command[@]}"
75+
exit_code=$?
76+
return ${exit_code}
77+
fi
78+
6879
run_e2e_test
6980
}
7081

@@ -458,6 +469,20 @@ apply_hyperv_configuration(){
458469
set +x
459470
}
460471

472+
run_post_command() {
473+
log "running user provided command: $*"
474+
set +o errexit
475+
"${@}"
476+
local exit_code=$?
477+
set -o errexit
478+
if [[ ${exit_code} -ne 0 ]]; then
479+
log "user provided command failed with exit code ${exit_code}"
480+
else
481+
log "user provided command completed successfully"
482+
fi
483+
return ${exit_code}
484+
}
485+
461486
run_e2e_test() {
462487
export SKIP_TEST="${SKIP_TEST:-"false"}"
463488
if [[ ! "$SKIP_TEST" == "true" ]]; then
@@ -685,4 +710,4 @@ EOF
685710
}
686711

687712
trap run_capz_e2e_cleanup EXIT
688-
main
713+
main "$@"

0 commit comments

Comments
 (0)