mirror of
https://github.com/actions/actions-runner-controller.git
synced 2026-03-28 09:39:18 +08:00
Introduce experimental chart release (#4373)
This commit is contained in:
89
test/actions.github.com/anonymous-proxy-setup-v2.test.sh
Executable file
89
test/actions.github.com/anonymous-proxy-setup-v2.test.sh
Executable file
@@ -0,0 +1,89 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="anonymous-proxy-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-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 controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \
|
||||
--debug
|
||||
|
||||
if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then
|
||||
NAMESPACE="${ARC_NAMESPACE}" log_arc
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function install_squid() {
|
||||
echo "Starting squid-proxy"
|
||||
kubectl apply -f "${DIR}/anonymous-proxy-setup.squid.yaml"
|
||||
}
|
||||
|
||||
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 controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
--set proxy.https.url="http://squid.default.svc.cluster.local:3128" \
|
||||
--set "proxy.noProxy[0]=10.96.0.1:443" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental"
|
||||
|
||||
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_squid
|
||||
|
||||
install_scale_set || {
|
||||
echo "Scale set installation failed"
|
||||
NAMESPACE="${ARC_NAMESPACE}" log_arc
|
||||
delete_cluster
|
||||
exit 1
|
||||
}
|
||||
|
||||
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
|
||||
@@ -8,6 +8,8 @@ ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="anonymous-proxy-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-workflow.yaml"
|
||||
|
||||
104
test/actions.github.com/auth-proxy-setup-v2.test.sh
Executable file
104
test/actions.github.com/auth-proxy-setup-v2.test.sh
Executable file
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")"
|
||||
|
||||
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="arc-systems"
|
||||
|
||||
function install_arc() {
|
||||
install_openebs || {
|
||||
echo "OpenEBS installation failed"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "Creating namespace ${ARC_NAMESPACE}"
|
||||
kubectl create namespace "${SCALE_SET_NAMESPACE}"
|
||||
|
||||
echo "Installing ARC"
|
||||
helm install "${ARC_NAME}" \
|
||||
--namespace "${ARC_NAMESPACE}" \
|
||||
--create-namespace \
|
||||
--set controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \
|
||||
--debug
|
||||
|
||||
if ! NAME="${ARC_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_arc; then
|
||||
NAMESPACE="${ARC_NAMESPACE}" log_arc
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function install_squid() {
|
||||
echo "Starting squid-proxy"
|
||||
kubectl apply -f "${DIR}/auth-proxy-setup.squid.yaml"
|
||||
|
||||
echo "Creating scale set namespace"
|
||||
kubectl create namespace "${SCALE_SET_NAMESPACE}" || true
|
||||
|
||||
echo "Creating squid proxy secret"
|
||||
kubectl create secret generic proxy-auth \
|
||||
--namespace=arc-runners \
|
||||
--from-literal=username=github \
|
||||
--from-literal=password='actions'
|
||||
}
|
||||
|
||||
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 controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
--set proxy.https.url="http://squid.default.svc.cluster.local:3128" \
|
||||
--set proxy.https.credentialSecretRef="proxy-auth" \
|
||||
--set "proxy.noProxy[0]=10.96.0.1:443" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental" \
|
||||
--version="${VERSION}"
|
||||
|
||||
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_squid
|
||||
|
||||
install_scale_set || {
|
||||
echo "Scale set installation failed"
|
||||
NAMESPACE="${ARC_NAMESPACE}" log_arc
|
||||
delete_cluster
|
||||
exit 1
|
||||
}
|
||||
|
||||
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
|
||||
@@ -8,6 +8,8 @@ ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="default-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-workflow.yaml"
|
||||
|
||||
76
test/actions.github.com/default-setup-v2.test.sh
Executable file
76
test/actions.github.com/default-setup-v2.test.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")" || exit 1
|
||||
export VERSION
|
||||
|
||||
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="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 controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \
|
||||
--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 controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental" \
|
||||
--version="${VERSION}"
|
||||
|
||||
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
|
||||
@@ -8,6 +8,8 @@ ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="default-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-workflow.yaml"
|
||||
|
||||
76
test/actions.github.com/dind-mode-setup-v2.test.sh
Executable file
76
test/actions.github.com/dind-mode-setup-v2.test.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")"
|
||||
|
||||
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 controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \
|
||||
--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 controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
--set runner.mode="dind" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental" \
|
||||
--version="${VERSION}"
|
||||
|
||||
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
|
||||
@@ -8,6 +8,8 @@ ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="default-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-dind-workflow.yaml"
|
||||
|
||||
@@ -9,15 +9,83 @@ ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
export TARGET_ORG="${TARGET_ORG:-actions-runner-controller}"
|
||||
export TARGET_REPO="${TARGET_REPO:-arc_e2e_test_dummy}"
|
||||
export IMAGE_NAME="${IMAGE_NAME:-arc-test-image}"
|
||||
export VERSION="${VERSION:-$(yq .version <"${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")}"
|
||||
export IMAGE_TAG="${VERSION}"
|
||||
export IMAGE="${IMAGE_NAME}:${IMAGE_TAG}"
|
||||
|
||||
# Trims a single pair of matching surrounding quotes from the provided string.
|
||||
# Examples:
|
||||
# trim_quotes '"1.2.3"' -> 1.2.3
|
||||
# trim_quotes "'v1'" -> v1
|
||||
function trim_quotes() {
|
||||
local s
|
||||
s="$*"
|
||||
|
||||
if [[ ${#s} -ge 2 ]]; then
|
||||
local first last
|
||||
first="${s:0:1}"
|
||||
last="${s: -1}"
|
||||
if [[ ( "${first}" == '"' && "${last}" == '"' ) || ( "${first}" == "'" && "${last}" == "'" ) ]]; then
|
||||
s="${s:1:${#s}-2}"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf '%s\n' "${s}"
|
||||
}
|
||||
|
||||
# Tests decide which chart version to use. Helper provides extraction utilities.
|
||||
function chart_version() {
|
||||
local chart_yaml="$1"
|
||||
if [[ -z "${chart_yaml}" ]] || [[ ! -f "${chart_yaml}" ]]; then
|
||||
echo "Chart.yaml not found: ${chart_yaml}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local version
|
||||
version=""
|
||||
|
||||
if command -v yq >/dev/null 2>&1; then
|
||||
# Prefer yq v4+ syntax, but accept older variants.
|
||||
version="$(yq -r '.version' "${chart_yaml}" 2>/dev/null || true)"
|
||||
if [[ -z "${version}" ]] || [[ "${version}" == "null" ]]; then
|
||||
version="$(yq '.version' <"${chart_yaml}" 2>/dev/null || true)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Fallback for environments without yq.
|
||||
if [[ -z "${version}" ]] || [[ "${version}" == "null" ]]; then
|
||||
version="$(awk -F: 'tolower($1)=="version" {sub(/^[[:space:]]+/,"",$2); print $2; exit}' "${chart_yaml}" 2>/dev/null || true)"
|
||||
fi
|
||||
|
||||
version="$(trim_quotes "${version}" | tr -d "[:space:]")"
|
||||
if [[ -z "${version}" ]]; then
|
||||
echo "Failed to extract version from ${chart_yaml} via yq" >&2
|
||||
return 1
|
||||
fi
|
||||
printf '%s\n' "${version}"
|
||||
return 0
|
||||
}
|
||||
|
||||
function ensure_version_set() {
|
||||
if [[ -z "${VERSION:-}" ]]; then
|
||||
echo 'VERSION is not set. Set it in the test, e.g. export VERSION="$(chart_version path/to/Chart.yaml)".' >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Defensive: if a tool produced quoted output, normalize it before using in tags/args.
|
||||
export VERSION="$(printf '%s' "${VERSION}" | tr -d "\"'[:space:]")"
|
||||
if [[ -z "${VERSION}" ]]; then
|
||||
echo "VERSION resolved to an empty value" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
export IMAGE_TAG="${IMAGE_TAG:-${VERSION}}"
|
||||
export IMAGE="${IMAGE:-${IMAGE_NAME}:${IMAGE_TAG}}"
|
||||
}
|
||||
|
||||
export PLATFORMS="linux/amd64"
|
||||
COMMIT_SHA="$(git rev-parse HEAD)"
|
||||
export COMMIT_SHA
|
||||
|
||||
function build_image() {
|
||||
ensure_version_set || return 1
|
||||
echo "Building ARC image ${IMAGE}"
|
||||
|
||||
cd "${ROOT_DIR}" || exit 1
|
||||
@@ -34,6 +102,7 @@ function build_image() {
|
||||
}
|
||||
|
||||
function create_cluster() {
|
||||
ensure_version_set || return 1
|
||||
echo "Deleting minikube cluster if exists"
|
||||
minikube delete || true
|
||||
|
||||
@@ -60,29 +129,29 @@ function delete_cluster() {
|
||||
|
||||
function log_arc() {
|
||||
echo "ARC logs"
|
||||
kubectl logs -n "${NAMESPACE}" -l app.kubernetes.io/name=gha-rs-controller
|
||||
kubectl logs -n "${NAMESPACE}" -l "app.kubernetes.io/part-of=gha-rs-controller,app.kubernetes.io/component=controller-manager"
|
||||
}
|
||||
|
||||
function wait_for_arc() {
|
||||
echo "Waiting for ARC to be ready"
|
||||
local count=0
|
||||
while true; do
|
||||
POD_NAME=$(kubectl get pods -n "${NAMESPACE}" -l app.kubernetes.io/name=gha-rs-controller -o name)
|
||||
POD_NAME=$(kubectl get pods -n "${NAMESPACE}" -l "app.kubernetes.io/part-of=gha-rs-controller,app.kubernetes.io/component=controller-manager" -o name 2>/dev/null || true)
|
||||
if [ -n "$POD_NAME" ]; then
|
||||
echo "Pod found: $POD_NAME"
|
||||
break
|
||||
fi
|
||||
if [ "$count" -ge 60 ]; then
|
||||
echo "Timeout waiting for controller pod with label app.kubernetes.io/name=gha-rs-controller"
|
||||
echo "Timeout waiting for controller pod with labels app.kubernetes.io/part-of=gha-rs-controller,app.kubernetes.io/component=controller-manager"
|
||||
return 1
|
||||
fi
|
||||
sleep 1
|
||||
count=$((count + 1))
|
||||
done
|
||||
|
||||
kubectl wait --timeout=30s --for=condition=ready pod -n "${NAMESPACE}" -l app.kubernetes.io/name=gha-rs-controller
|
||||
kubectl get pod -n "${NAMESPACE}"
|
||||
kubectl describe deployment "${NAME}" -n "${NAMESPACE}"
|
||||
kubectl wait --timeout=60s --for=condition=ready pod -n "${NAMESPACE}" -l "app.kubernetes.io/part-of=gha-rs-controller,app.kubernetes.io/component=controller-manager"
|
||||
kubectl get pod -n "${NAMESPACE}" -l "app.kubernetes.io/part-of=gha-rs-controller,app.kubernetes.io/component=controller-manager"
|
||||
kubectl describe deployment -n "${NAMESPACE}" -l "app.kubernetes.io/part-of=gha-rs-controller,app.kubernetes.io/component=controller-manager"
|
||||
}
|
||||
|
||||
function wait_for_scale_set() {
|
||||
@@ -129,14 +198,62 @@ function print_results() {
|
||||
}
|
||||
|
||||
function run_workflow() {
|
||||
echo "Checking if the workflow file exists"
|
||||
gh workflow view -R "${TARGET_ORG}/${TARGET_REPO}" "${WORKFLOW_FILE}" || return 1
|
||||
local repo
|
||||
repo="${TARGET_ORG}/${TARGET_REPO}"
|
||||
|
||||
# Pick a ref for workflow dispatch. Default to the repo's default branch.
|
||||
if [[ -z "${WORKFLOW_REF:-}" ]]; then
|
||||
WORKFLOW_REF="$(gh repo view -R "${repo}" --json defaultBranchRef --jq '.defaultBranchRef.name' 2>/dev/null || true)"
|
||||
WORKFLOW_REF="${WORKFLOW_REF:-main}"
|
||||
fi
|
||||
|
||||
local workflow_query
|
||||
workflow_query="${WORKFLOW_FILE}"
|
||||
|
||||
local workflow_id
|
||||
if [[ "${workflow_query}" =~ ^[0-9]+$ ]]; then
|
||||
workflow_id="${workflow_query}"
|
||||
else
|
||||
local q_escaped
|
||||
q_escaped="${workflow_query//\"/\\\"}"
|
||||
workflow_id="$(gh workflow list -R "${repo}" --limit 200 --json id,name,path --jq ".[] | select((.path | endswith(\"${q_escaped}\")) or (.name == \"${q_escaped}\")) | .id" 2>/dev/null | head -n1)"
|
||||
|
||||
if [[ -z "${workflow_id}" ]]; then
|
||||
# Common mismatch: .yml vs .yaml
|
||||
if [[ "${workflow_query}" == *.yaml ]]; then
|
||||
q_escaped="${workflow_query%.yaml}.yml"
|
||||
elif [[ "${workflow_query}" == *.yml ]]; then
|
||||
q_escaped="${workflow_query%.yml}.yaml"
|
||||
else
|
||||
q_escaped=""
|
||||
fi
|
||||
|
||||
if [[ -n "${q_escaped}" ]]; then
|
||||
local q2_escaped
|
||||
q2_escaped="${q_escaped//\"/\\\"}"
|
||||
workflow_id="$(gh workflow list -R "${repo}" --limit 200 --json id,name,path --jq ".[] | select((.path | endswith(\"${q2_escaped}\")) or (.name == \"${q2_escaped}\")) | .id" 2>/dev/null | head -n1)"
|
||||
if [[ -n "${workflow_id}" ]]; then
|
||||
WORKFLOW_FILE="${q_escaped}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "${workflow_id}" ]]; then
|
||||
echo "Workflow not found in ${repo}: ${WORKFLOW_FILE}" >&2
|
||||
echo "Available workflows in ${repo}:" >&2
|
||||
gh workflow list -R "${repo}" --limit 50 || true
|
||||
echo "Hint: set TARGET_ORG/TARGET_REPO to a repo that contains the workflow on its default branch, or set WORKFLOW_FILE to a valid workflow name/id/filename." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Resolved workflow id: ${workflow_id} (ref: ${WORKFLOW_REF})"
|
||||
|
||||
local queue_time
|
||||
queue_time="$(date -u +%FT%TZ)"
|
||||
|
||||
echo "Running workflow ${WORKFLOW_FILE}"
|
||||
gh workflow run -R "${TARGET_ORG}/${TARGET_REPO}" "${WORKFLOW_FILE}" --ref main -f arc_name="${SCALE_SET_NAME}" || return 1
|
||||
gh workflow run -R "${repo}" "${workflow_id}" --ref "${WORKFLOW_REF}" -f arc_name="${SCALE_SET_NAME}" || return 1
|
||||
|
||||
echo "Waiting for run to start"
|
||||
local count=0
|
||||
@@ -146,7 +263,7 @@ function run_workflow() {
|
||||
echo "Timeout waiting for run to start"
|
||||
return 1
|
||||
fi
|
||||
run_id=$(gh run list -R "${TARGET_ORG}/${TARGET_REPO}" --workflow "${WORKFLOW_FILE}" --created ">${queue_time}" --json "name,databaseId" --jq ".[] | select(.name | contains(\"${SCALE_SET_NAME}\")) | .databaseId")
|
||||
run_id=$(gh run list -R "${repo}" --workflow "${workflow_id}" --created ">${queue_time}" --json "name,databaseId" --jq ".[] | select(.name | contains(\"${SCALE_SET_NAME}\")) | .databaseId")
|
||||
echo "Run ID: ${run_id}"
|
||||
if [ -n "$run_id" ]; then
|
||||
echo "Run found!"
|
||||
@@ -159,10 +276,10 @@ function run_workflow() {
|
||||
done
|
||||
|
||||
echo "Waiting for run to complete"
|
||||
local code
|
||||
code=$(gh run watch "${run_id}" -R "${TARGET_ORG}/${TARGET_REPO}" --exit-status &>/dev/null)
|
||||
if [[ "${code}" -ne 0 ]]; then
|
||||
echo "Run failed with exit code ${code}"
|
||||
gh run watch "${run_id}" -R "${repo}" --exit-status &>/dev/null
|
||||
local status=$?
|
||||
if [[ "${status}" -ne 0 ]]; then
|
||||
echo "Run failed with exit code ${status}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
96
test/actions.github.com/init-with-min-runners-v2.test.sh
Executable file
96
test/actions.github.com/init-with-min-runners-v2.test.sh
Executable file
@@ -0,0 +1,96 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh" || {
|
||||
echo "Failed to source helper.sh"
|
||||
exit 1
|
||||
}
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="init-min-runners-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-workflow.yaml"
|
||||
ARC_NAME="arc"
|
||||
ARC_NAMESPACE="arc-systems"
|
||||
|
||||
function install_arc() {
|
||||
echo "Installing ARC"
|
||||
helm install arc \
|
||||
--namespace "arc-systems" \
|
||||
--create-namespace \
|
||||
--set controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
--set controller.manager.config.updateStrategy="eventual" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \
|
||||
--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 controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
--set scaleset.minRunners=5 \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental"
|
||||
|
||||
if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then
|
||||
NAMESPACE="${ARC_NAMESPACE}" log_arc
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function assert_5_runners() {
|
||||
echo "[*] Asserting 5 runners are created"
|
||||
local count=0
|
||||
while true; do
|
||||
pod_count=$(kubectl get pods -n arc-runners --no-headers | wc -l)
|
||||
|
||||
if [[ "${pod_count}" = 5 ]]; then
|
||||
echo "[*] Found 5 runners as expected"
|
||||
break
|
||||
fi
|
||||
|
||||
if [[ "$count" -ge 30 ]]; then
|
||||
echo "Timeout waiting for 5 pods to be created"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
count=$((count + 1))
|
||||
done
|
||||
}
|
||||
|
||||
function main() {
|
||||
local failed=()
|
||||
|
||||
build_image
|
||||
create_cluster
|
||||
|
||||
install_arc
|
||||
install_scale_set
|
||||
|
||||
assert_5_runners || failed+=("assert_5_runners")
|
||||
|
||||
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
|
||||
@@ -11,6 +11,8 @@ source "${DIR}/helper.sh" || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="init-min-runners-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-workflow.yaml"
|
||||
|
||||
83
test/actions.github.com/kubernetes-mode-setup-v2.test.sh
Executable file
83
test/actions.github.com/kubernetes-mode-setup-v2.test.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="kubernetes-mode-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-kubernetes-workflow.yaml"
|
||||
ARC_NAME="arc"
|
||||
ARC_NAMESPACE="arc-systems"
|
||||
|
||||
function install_arc() {
|
||||
install_openebs || {
|
||||
echo "OpenEBS installation failed"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "Creating namespace ${ARC_NAMESPACE}"
|
||||
kubectl create namespace "${SCALE_SET_NAMESPACE}"
|
||||
|
||||
echo "Installing ARC"
|
||||
helm install "${ARC_NAME}" \
|
||||
--namespace "${ARC_NAMESPACE}" \
|
||||
--create-namespace \
|
||||
--set controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \
|
||||
--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 controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
--set runner.mode="kubernetes" \
|
||||
--set runner.kubernetesMode.workVolumeClaim.accessModes={"ReadWriteOnce"} \
|
||||
--set runner.kubernetesMode.workVolumeClaim.storageClassName="openebs-hostpath" \
|
||||
--set runner.kubernetesMode.workVolumeClaim.resources.requests.storage="1Gi" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental"
|
||||
|
||||
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
|
||||
@@ -8,6 +8,8 @@ ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="kubernetes-mode-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-kubernetes-workflow.yaml"
|
||||
|
||||
150
test/actions.github.com/self-signed-ca-setup-v2.test.sh
Executable file
150
test/actions.github.com/self-signed-ca-setup-v2.test.sh
Executable file
@@ -0,0 +1,150 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh" || {
|
||||
echo "Failed to source helper.sh"
|
||||
exit 1
|
||||
}
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")"
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
LOCAL_CERT_PATH="${TEMP_DIR}/mitmproxy-ca-cert.crt"
|
||||
MITM_CERT_PATH="/root/.mitmproxy/mitmproxy-ca-cert.pem"
|
||||
|
||||
trap 'rm -rf "$TEMP_DIR"' EXIT
|
||||
|
||||
SCALE_SET_NAME="self-signed-crt-$(date '+%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-workflow.yaml"
|
||||
ARC_NAME="arc"
|
||||
ARC_NAMESPACE="arc-systems"
|
||||
|
||||
MITMPROXY_NAMESPACE="mitmproxy"
|
||||
MITMPROXY_POD_NAME="mitmproxy"
|
||||
|
||||
function install_arc() {
|
||||
echo "Installing ARC"
|
||||
helm install "${ARC_NAME}" \
|
||||
--namespace "${ARC_NAMESPACE}" \
|
||||
--create-namespace \
|
||||
--set controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \
|
||||
--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 "Creating namespace ${SCALE_SET_NAMESPACE}"
|
||||
kubectl create namespace "${SCALE_SET_NAMESPACE}"
|
||||
|
||||
echo "Installing ca-cert config map"
|
||||
kubectl -n "${SCALE_SET_NAMESPACE}" create configmap ca-cert \
|
||||
--from-file=mitmproxy-ca-cert.crt="${LOCAL_CERT_PATH}"
|
||||
|
||||
echo "Installing scale set ${SCALE_SET_NAME}/${SCALE_SET_NAMESPACE}"
|
||||
helm install "${SCALE_SET_NAME}" \
|
||||
--namespace "${SCALE_SET_NAMESPACE}" \
|
||||
--create-namespace \
|
||||
--set controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
--set proxy.https.url="http://mitmproxy.mitmproxy.svc.cluster.local:8080" \
|
||||
--set "proxy.noProxy[0]=10.96.0.1:443" \
|
||||
--set "githubServerTLS.certificateFrom.configMapKeyRef.name=ca-cert" \
|
||||
--set "githubServerTLS.certificateFrom.configMapKeyRef.key=mitmproxy-ca-cert.crt" \
|
||||
--set "githubServerTLS.runnerMountPath=/usr/local/share/ca-certificates/" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental"
|
||||
|
||||
if ! NAME="${SCALE_SET_NAME}" NAMESPACE="${ARC_NAMESPACE}" wait_for_scale_set; then
|
||||
NAMESPACE="${ARC_NAMESPACE}" log_arc
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function wait_for_mitmproxy_ready() {
|
||||
echo "Waiting for mitmproxy pod to be ready"
|
||||
|
||||
# Wait for pod to be running
|
||||
if ! kubectl wait --for=condition=ready pod -n "${MITMPROXY_NAMESPACE}" "${MITMPROXY_POD_NAME}" --timeout=60s; then
|
||||
echo "Timeout waiting for mitmproxy pod"
|
||||
kubectl get pods -n "${MITMPROXY_NAMESPACE}" || true
|
||||
kubectl describe pod -n "${MITMPROXY_NAMESPACE}" "${MITMPROXY_POD_NAME}" || true
|
||||
kubectl logs -n "${MITMPROXY_NAMESPACE}" "${MITMPROXY_POD_NAME}" || true
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Mitmproxy pod is ready, trying to copy the certitficate..."
|
||||
|
||||
# Verify certificate exists
|
||||
retry 15 1 kubectl exec -n "${MITMPROXY_NAMESPACE}" "${MITMPROXY_POD_NAME}" -- test -f "${MITM_CERT_PATH}"
|
||||
|
||||
echo "Getting mitmproxy CA certificate from pod"
|
||||
if ! kubectl exec -n "${MITMPROXY_NAMESPACE}" "${MITMPROXY_POD_NAME}" -- cat "${MITM_CERT_PATH}" >"${LOCAL_CERT_PATH}"; then
|
||||
echo "Failed to get mitmproxy CA certificate from pod"
|
||||
return 1
|
||||
fi
|
||||
echo "Mitmproxy certificate generated successfully and stored to ${LOCAL_CERT_PATH}"
|
||||
return 0
|
||||
}
|
||||
|
||||
function run_mitmproxy() {
|
||||
echo "Deploying mitmproxy to Kubernetes"
|
||||
|
||||
# Create namespace
|
||||
kubectl create namespace "${MITMPROXY_NAMESPACE}" || true
|
||||
|
||||
# Create mitmproxy pod and service
|
||||
kubectl apply -f "${DIR}/self-signed-ca-setup.mitm.yaml"
|
||||
|
||||
if ! wait_for_mitmproxy_ready; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Mitmproxy is ready"
|
||||
}
|
||||
|
||||
function main() {
|
||||
local failed=()
|
||||
|
||||
build_image
|
||||
create_cluster
|
||||
install_arc
|
||||
run_mitmproxy || {
|
||||
echo "Failed to run mitmproxy"
|
||||
echo "ARC logs:"
|
||||
NAMESPACE="${ARC_NAMESPACE}" log_arc
|
||||
echo "Deleting cluster..."
|
||||
delete_cluster
|
||||
exit 1
|
||||
}
|
||||
install_scale_set || {
|
||||
echo "Failed to run mitmproxy"
|
||||
echo "ARC logs:"
|
||||
NAMESPACE="${ARC_NAMESPACE}" log_arc
|
||||
echo "Deleting cluster..."
|
||||
delete_cluster
|
||||
exit 1
|
||||
}
|
||||
|
||||
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
|
||||
@@ -11,6 +11,8 @@ source "${DIR}/helper.sh" || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")"
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
LOCAL_CERT_PATH="${TEMP_DIR}/mitmproxy-ca-cert.crt"
|
||||
MITM_CERT_PATH="/root/.mitmproxy/mitmproxy-ca-cert.pem"
|
||||
|
||||
76
test/actions.github.com/single-namespace-setup-v2.test.sh
Executable file
76
test/actions.github.com/single-namespace-setup-v2.test.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")"
|
||||
|
||||
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 controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
--set controller.manager.config.watchSingleNamespace="${ARC_NAMESPACE}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \
|
||||
--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 controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental" \
|
||||
--version="${VERSION}"
|
||||
|
||||
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
|
||||
@@ -8,6 +8,8 @@ ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh"
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="default-$(date +'%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-workflow.yaml"
|
||||
|
||||
151
test/actions.github.com/update-strategy-v2.test.sh
Executable file
151
test/actions.github.com/update-strategy-v2.test.sh
Executable file
@@ -0,0 +1,151 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
|
||||
ROOT_DIR="$(realpath "${DIR}/../..")"
|
||||
|
||||
source "${DIR}/helper.sh" || {
|
||||
echo "Failed to source helper.sh"
|
||||
exit 1
|
||||
}
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="update-strategy-$(date '+%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-sleepy-matrix.yaml"
|
||||
ARC_NAME="arc"
|
||||
ARC_NAMESPACE="arc-systems"
|
||||
|
||||
function install_arc() {
|
||||
echo "Installing ARC"
|
||||
|
||||
helm install "${ARC_NAME}" \
|
||||
--namespace "${ARC_NAMESPACE}" \
|
||||
--create-namespace \
|
||||
--set controller.manager.container.image="${IMAGE_NAME}:${IMAGE_TAG}" \
|
||||
--set controller.manager.config.updateStrategy="eventual" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-controller-experimental" \
|
||||
--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_NAME}/${SCALE_SET_NAMESPACE}"
|
||||
helm install "${SCALE_SET_NAME}" \
|
||||
--namespace "${SCALE_SET_NAMESPACE}" \
|
||||
--create-namespace \
|
||||
--set controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental" \
|
||||
--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 upgrade_scale_set() {
|
||||
echo "Upgrading scale set ${SCALE_SET_NAME}/${SCALE_SET_NAMESPACE}"
|
||||
helm upgrade "${SCALE_SET_NAME}" \
|
||||
--namespace "${SCALE_SET_NAMESPACE}" \
|
||||
--set controllerServiceAccount.name="${ARC_NAME}-gha-rs-controller" \
|
||||
--set controllerServiceAccount.namespace="${ARC_NAMESPACE}" \
|
||||
--set auth.url="https://github.com/${TARGET_ORG}/${TARGET_REPO}" \
|
||||
--set auth.githubToken="${GITHUB_TOKEN}" \
|
||||
--set runner.container.image="ghcr.io/actions/actions-runner:latest" \
|
||||
--set runner.container.command={"/home/runner/run.sh"} \
|
||||
--set runner.env[0].name="TEST" \
|
||||
--set runner.env[0].value="E2E TESTS" \
|
||||
"${ROOT_DIR}/charts/gha-runner-scale-set-experimental" \
|
||||
--version="${VERSION}" \
|
||||
--debug
|
||||
|
||||
}
|
||||
|
||||
function assert_listener_deleted() {
|
||||
local count=0
|
||||
while true; do
|
||||
LISTENER_COUNT="$(kubectl get pods -l actions.github.com/scale-set-name="${SCALE_SET_NAME}" -n "${ARC_NAMESPACE}" --field-selector=status.phase=Running -o=jsonpath='{.items}' | jq 'length')"
|
||||
RUNNERS_COUNT="$(kubectl get pods -l app.kubernetes.io/component=runner -n "${SCALE_SET_NAMESPACE}" --field-selector=status.phase=Running -o=jsonpath='{.items}' | jq 'length')"
|
||||
RESOURCES="$(kubectl get pods -A)"
|
||||
|
||||
if [ "${LISTENER_COUNT}" -eq 0 ]; then
|
||||
echo "Listener has been deleted"
|
||||
echo "${RESOURCES}"
|
||||
return 0
|
||||
fi
|
||||
if [ "${count}" -ge 60 ]; then
|
||||
echo "Timeout waiting for listener to be deleted"
|
||||
echo "${RESOURCES}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Waiting for listener to be deleted"
|
||||
echo "Listener count: ${LISTENER_COUNT} target: 0 | Runners count: ${RUNNERS_COUNT} target: 3"
|
||||
|
||||
sleep 1
|
||||
count=$((count + 1))
|
||||
done
|
||||
}
|
||||
|
||||
function assert_listener_recreated() {
|
||||
count=0
|
||||
while true; do
|
||||
LISTENER_COUNT="$(kubectl get pods -l actions.github.com/scale-set-name="${SCALE_SET_NAME}" -n "${ARC_NAMESPACE}" --field-selector=status.phase=Running -o=jsonpath='{.items}' | jq 'length')"
|
||||
RUNNERS_COUNT="$(kubectl get pods -l app.kubernetes.io/component=runner -n "${SCALE_SET_NAMESPACE}" --field-selector=status.phase=Running -o=jsonpath='{.items}' | jq 'length')"
|
||||
RESOURCES="$(kubectl get pods -A)"
|
||||
|
||||
if [ "${LISTENER_COUNT}" -eq 1 ]; then
|
||||
echo "Listener is up!"
|
||||
echo "${RESOURCES}"
|
||||
return 0
|
||||
fi
|
||||
if [ "${count}" -ge 120 ]; then
|
||||
echo "Timeout waiting for listener to be recreated"
|
||||
echo "${RESOURCES}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Waiting for listener to be recreated"
|
||||
echo "Listener count: ${LISTENER_COUNT} target: 1 | Runners count: ${RUNNERS_COUNT} target: 0"
|
||||
|
||||
sleep 1
|
||||
count=$((count + 1))
|
||||
done
|
||||
}
|
||||
|
||||
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")
|
||||
|
||||
upgrade_scale_set || failed+=("upgrade_scale_set")
|
||||
assert_listener_deleted || failed+=("assert_listener_deleted")
|
||||
assert_listener_recreated || failed+=("assert_listener_recreated")
|
||||
|
||||
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
|
||||
@@ -11,6 +11,8 @@ source "${DIR}/helper.sh" || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
export VERSION="$(chart_version "${ROOT_DIR}/charts/gha-runner-scale-set-controller/Chart.yaml")"
|
||||
|
||||
SCALE_SET_NAME="update-strategy-$(date '+%M%S')$(((RANDOM + 100) % 100 + 1))"
|
||||
SCALE_SET_NAMESPACE="arc-runners"
|
||||
WORKFLOW_FILE="arc-test-sleepy-matrix.yaml"
|
||||
|
||||
Reference in New Issue
Block a user