Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions capz/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ az role assignment create \
--scope "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Storage/storageAccounts/<storage-account-name>"
```

## Running custom commands with `run-capz-e2e.sh`

`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.

Example usage from a Prow job:

```bash
./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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better/possible to separate the new added test cases into different file? but I do not have much context on the added test so just a rough idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?
into a different markdown file?

```

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.

## Hyper-V isolated containers support

Requires containerd v1.7+ deployed to the Windows nodes.
Expand Down
27 changes: 26 additions & 1 deletion capz/run-capz-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ if [[ ! -d $AZURE_CLOUD_PROVIDER_ROOT ]]; then
fi

main() {
local -a post_command=("$@")

# defaults
export KUBERNETES_VERSION="${KUBERNETES_VERSION:-"latest"}"
export CONTROL_PLANE_MACHINE_COUNT="${AZURE_CONTROL_PLANE_MACHINE_COUNT:-"1"}"
Expand Down Expand Up @@ -65,6 +67,15 @@ main() {
ensure_cloud_provider_taint_on_windows_nodes
wait_for_windows_machinedeployment
if [[ "${HYPERV}" == "true" ]]; then apply_hyperv_configuration; fi

if [[ ${#post_command[@]} -gt 0 ]]; then
local exit_code
log "post command detected; skipping default e2e tests"
run_post_command "${post_command[@]}"
exit_code=$?
return ${exit_code}
fi

run_e2e_test
}

Expand Down Expand Up @@ -458,6 +469,20 @@ apply_hyperv_configuration(){
set +x
}

run_post_command() {
log "running user provided command: $*"
set +o errexit
"${@}"
local exit_code=$?
set -o errexit
if [[ ${exit_code} -ne 0 ]]; then
log "user provided command failed with exit code ${exit_code}"
else
log "user provided command completed successfully"
fi
return ${exit_code}
}

run_e2e_test() {
export SKIP_TEST="${SKIP_TEST:-"false"}"
if [[ ! "$SKIP_TEST" == "true" ]]; then
Expand Down Expand Up @@ -681,4 +706,4 @@ EOF
}

trap run_capz_e2e_cleanup EXIT
main
main "$@"
Loading