From 4b9af378084fd6e4f73cfb945ffdec0314d65a06 Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Thu, 3 Apr 2025 14:58:07 +0200 Subject: [PATCH] migrating rest of the e2e tests --- test/actions.github.com/default-setup.test.sh | 4 +- .../dind-mode-setup.test.sh | 74 +++++++++++++++++++ .../single-namespace-setup.test.sh | 74 +++++++++++++++++++ 3 files changed, 149 insertions(+), 3 deletions(-) create mode 100755 test/actions.github.com/dind-mode-setup.test.sh create mode 100755 test/actions.github.com/single-namespace-setup.test.sh diff --git a/test/actions.github.com/default-setup.test.sh b/test/actions.github.com/default-setup.test.sh index 52ce6bc7..6eaeecaf 100755 --- a/test/actions.github.com/default-setup.test.sh +++ b/test/actions.github.com/default-setup.test.sh @@ -2,9 +2,7 @@ set -euo pipefail -DIR="$(dirname "${BASH_SOURCE[0]}")" - -DIR="$(realpath "${DIR}")" +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" ROOT_DIR="$(realpath "${DIR}/../..")" diff --git a/test/actions.github.com/dind-mode-setup.test.sh b/test/actions.github.com/dind-mode-setup.test.sh new file mode 100755 index 00000000..dd14ff1b --- /dev/null +++ b/test/actions.github.com/dind-mode-setup.test.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -euo pipefail + +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +SCALE_SET_NAME="default-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +WORKFLOW_FILE="arc-test-dind-workflow.yaml" +ARC_NAME="arc" +ARC_NAMESPACE="arc-systems" + +function install_arc() { + echo "Creating namespace ${ARC_NAMESPACE}" + kubectl create namespace "${SCALE_SET_NAMESPACE}" + + echo "Installing ARC" + helm install "${ARC_NAME}" \ + --namespace "${ARC_NAMESPACE}" \ + --create-namespace \ + --set image.repository="${IMAGE_NAME}" \ + --set image.tag="${IMAGE_TAG}" \ + ${ROOT_DIR}/charts/gha-runner-scale-set-controller \ + --debug + + if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then + NAMESPACE="${ARC_NAMESPACE}" log_arc + return 1 + fi +} + +function install_scale_set() { + echo "Installing scale set ${SCALE_SET_NAMESPACE}/${SCALE_SET_NAME}" + helm install "${SCALE_SET_NAME}" \ + --namespace "${SCALE_SET_NAMESPACE}" \ + --create-namespace \ + --set githubConfigUrl="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \ + --set githubConfigSecret.github_token="${GITHUB_TOKEN}" \ + --set containerMode.type="dind" \ + ${ROOT_DIR}/charts/gha-runner-scale-set \ + --version="${VERSION}" \ + --debug + + if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then + NAMESPACE="${ARC_NAMESPACE}" log_arc + return 1 + fi +} + +function main() { + local failed=() + + build_image + create_cluster + + install_arc + install_scale_set + + WORKFLOW_FILE="${WORKFLOW_FILE}" SCALE_SET_NAME="${SCALE_SET_NAME}" run_workflow || failed+=("run_workflow") + + INSTALLATION_NAME="${SCALE_SET_NAME}" NAMESPACE="${SCALE_SET_NAMESPACE}" cleanup_scale_set || failed+=("cleanup_scale_set") + + NAMESPACE="${ARC_NAMESPACE}" log_arc || failed+=("log_arc") + + delete_cluster + + print_results "${failed[@]}" +} + +main diff --git a/test/actions.github.com/single-namespace-setup.test.sh b/test/actions.github.com/single-namespace-setup.test.sh new file mode 100755 index 00000000..2e70375c --- /dev/null +++ b/test/actions.github.com/single-namespace-setup.test.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -euo pipefail + +DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" + +ROOT_DIR="$(realpath "${DIR}/../..")" + +source "${DIR}/helper.sh" + +SCALE_SET_NAME="default-$(date +'%M%S')$(((${RANDOM} + 100) % 100 + 1))" +SCALE_SET_NAMESPACE="arc-runners" +WORKFLOW_FILE="arc-test-workflow.yaml" +ARC_NAME="arc" +ARC_NAMESPACE="${SCALE_SET_NAMESPACE}" + +function install_arc() { + echo "Creating namespace ${ARC_NAMESPACE}" + kubectl create namespace "${SCALE_SET_NAMESPACE}" + + echo "Installing ARC" + helm install "${ARC_NAME}" \ + --namespace "${ARC_NAMESPACE}" \ + --create-namespace \ + --set image.repository="${IMAGE_NAME}" \ + --set image.tag="${IMAGE_TAG}" \ + --set flags.watchSingleNamespace="${ARC_NAMESPACE}" + ${ROOT_DIR}/charts/gha-runner-scale-set-controller \ + --debug + + if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then + NAMESPACE="${ARC_NAMESPACE}" log_arc + return 1 + fi +} + +function install_scale_set() { + echo "Installing scale set ${SCALE_SET_NAMESPACE}/${SCALE_SET_NAME}" + helm install "${SCALE_SET_NAME}" \ + --namespace "${SCALE_SET_NAMESPACE}" \ + --create-namespace \ + --set githubConfigUrl="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \ + --set githubConfigSecret.github_token="${GITHUB_TOKEN}" \ + ${ROOT_DIR}/charts/gha-runner-scale-set \ + --version="${VERSION}" \ + --debug + + if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then + NAMESPACE="${ARC_NAMESPACE}" log_arc + return 1 + fi +} + +function main() { + local failed=() + + build_image + create_cluster + + install_arc + install_scale_set + + WORKFLOW_FILE="${WORKFLOW_FILE}" SCALE_SET_NAME="${SCALE_SET_NAME}" run_workflow || failed+=("run_workflow") + + INSTALLATION_NAME="${SCALE_SET_NAME}" NAMESPACE="${SCALE_SET_NAMESPACE}" cleanup_scale_set || failed+=("cleanup_scale_set") + + NAMESPACE="${ARC_NAMESPACE}" log_arc || failed+=("log_arc") + + delete_cluster + + print_results "${failed[@]}" +} + +main