Test Grid Autoscaling in Kubernetes #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Grid Autoscaling in Kubernetes | |
on: | |
workflow_call: | |
inputs: | |
release: | |
description: 'Test a new release process' | |
required: false | |
type: string | |
default: 'false' | |
push-results: | |
description: 'Publish the results to the repository' | |
required: false | |
type: boolean | |
default: false | |
iteration: | |
description: 'Test a specific iteration' | |
required: false | |
type: string | |
default: '20' | |
workflow_dispatch: | |
inputs: | |
publish-results: | |
description: 'Publish the results to the repository' | |
required: false | |
type: boolean | |
default: false | |
pr-results: | |
description: 'Create a PR with the results' | |
required: false | |
type: boolean | |
default: false | |
iteration: | |
description: 'Test a specific iteration' | |
required: false | |
type: string | |
default: '20' | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
RUN_ID: ${{ github.run_id }} | |
TEST_AUTOSCALING_ITERATIONS: ${{ github.event.inputs.iteration || '20' }} | |
jobs: | |
build-and-test: | |
name: Test K8s | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- k8s-version: 'v1.31.2' | |
test-strategy: test_k8s_autoscaling_job_count_strategy_default_in_chaos | |
cluster: 'minikube' | |
helm-version: 'v3.16.3' | |
docker-version: '27.3.1' | |
python-version: '3.13' | |
- k8s-version: 'v1.31.2' | |
test-strategy: test_k8s_autoscaling_job_count_strategy_default_with_node_max_sessions | |
cluster: 'minikube' | |
helm-version: 'v3.16.3' | |
docker-version: '27.3.1' | |
python-version: '3.13' | |
- k8s-version: 'v1.31.2' | |
test-strategy: test_k8s_autoscaling_job_count_strategy_default | |
cluster: 'minikube' | |
helm-version: 'v3.16.3' | |
docker-version: '27.3.1' | |
python-version: '3.13' | |
- k8s-version: 'v1.31.2' | |
test-strategy: test_k8s_autoscaling_deployment_count_in_chaos | |
cluster: 'minikube' | |
helm-version: 'v3.16.3' | |
docker-version: '27.3.1' | |
python-version: '3.13' | |
- k8s-version: 'v1.31.2' | |
test-strategy: test_k8s_autoscaling_deployment_count_with_node_max_sessions | |
cluster: 'minikube' | |
helm-version: 'v3.16.3' | |
docker-version: '27.3.1' | |
python-version: '3.13' | |
- k8s-version: 'v1.31.2' | |
test-strategy: test_k8s_autoscaling_deployment_count | |
cluster: 'minikube' | |
helm-version: 'v3.16.3' | |
docker-version: '27.3.1' | |
python-version: '3.13' | |
env: | |
CLUSTER: ${{ matrix.cluster }} | |
KUBERNETES_VERSION: ${{ matrix.k8s-version }} | |
HELM_VERSION: ${{ matrix.helm-version }} | |
DOCKER_VERSION: ${{ matrix.docker-version }} | |
steps: | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: false | |
large-packages: false | |
- name: Checkout code | |
uses: actions/checkout@main | |
- name: Set up containerd image store feature | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 10 | |
max_attempts: 3 | |
command: | | |
make setup_dev_env | |
- name: Output Docker info | |
run: docker info | |
- name: Set up Python | |
uses: actions/setup-python@main | |
with: | |
python-version: ${{ matrix.python-version }} | |
check-latest: true | |
- name: Get branch name (only for push to branch) | |
if: github.event_name == 'push' | |
run: echo "BRANCH=$(echo ${PUSH_BRANCH##*/})" >> $GITHUB_ENV | |
env: | |
PUSH_BRANCH: ${{ github.ref }} | |
- name: Get target branch name (only for PRs) | |
if: github.event_name == 'pull_request' | |
run: echo "BRANCH=$(echo ${TARGET_BRANCH##*/})" >> $GITHUB_ENV | |
env: | |
TARGET_BRANCH: ${{ github.head_ref }} | |
- name: Output branch name | |
run: echo ${BRANCH} | |
- name: Set Selenium base version | |
uses: ./.github/actions/get-latest-upstream | |
with: | |
release: ${{ inputs.release || false }} | |
gh_cli_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Sets build date | |
run: | | |
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV | |
echo "IMAGE_REGISTRY=artifactory/selenium" >> $GITHUB_ENV | |
echo "AUTHORS=${AUTHORS}" >> $GITHUB_ENV | |
env: | |
AUTHORS: ${{ vars.AUTHORS || 'SeleniumHQ' }} | |
- name: Setup Kubernetes cluster | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 10 | |
max_attempts: 3 | |
command: CLUSTER=${CLUSTER} SERVICE_MESH=${SERVICE_MESH} KUBERNETES_VERSION=${KUBERNETES_VERSION} NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make chart_cluster_setup | |
- name: Build Docker images | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 12 | |
max_attempts: 3 | |
retry_wait_seconds: 60 | |
command: NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build | |
- name: Build Helm charts | |
run: | | |
BUILD_DATE=${BUILD_DATE} make chart_build | |
echo "CHART_PACKAGE_PATH=$(cat /tmp/selenium_chart_version)" >> $GITHUB_ENV | |
echo "CHART_FILE_NAME=$(basename $(cat /tmp/selenium_chart_version))" >> $GITHUB_ENV | |
- name: Test Selenium Grid on Kubernetes with Autoscaling | |
uses: nick-invision/retry@master | |
with: | |
timeout_minutes: 30 | |
max_attempts: 3 | |
command: | | |
NAME=${IMAGE_REGISTRY} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} TEST_UPGRADE_CHART=false TEST_AUTOSCALING_ITERATIONS=${TEST_AUTOSCALING_ITERATIONS} \ | |
make ${{ matrix.test-strategy }} | |
- name: Rename results | |
run: mv ./tests/tests/autoscaling_results.md ./tests/tests/results_${{ matrix.test-strategy }}.md | |
- name: Upload results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: results_${{ matrix.test-strategy }} | |
path: ./tests/tests/results_${{ matrix.test-strategy }}.md | |
if-no-files-found: ignore | |
- name: Cleanup Kubernetes cluster | |
if: always() | |
run: CLUSTER=${CLUSTER} make chart_cluster_cleanup | |
- name: Clean up Docker | |
if: always() | |
run: docker system prune -af | |
publish-results: | |
name: Publish Results | |
if: (!failure() && !cancelled() && (github.event.inputs.publish-results == 'true')) | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@main | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Download results | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./.keda | |
pattern: 'results_*' | |
merge-multiple: 'true' | |
run-id: ${{ env.RUN_ID }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit files | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Selenium CI Bot" | |
git add .keda/. | |
git commit -m "[ci] Upload autoscaling in K8s test results [skip ci]" -a | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.SELENIUM_CI_TOKEN }} | |
branch: ${{ env.BRANCH_NAME }} | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
pr-results: | |
name: Create a PR with the results | |
if: (!failure() && !cancelled() && (github.event.inputs.pr-results == 'true')) | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@main | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Download results | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./.keda | |
pattern: 'results_*' | |
merge-multiple: 'true' | |
run-id: ${{ env.RUN_ID }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit configs | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Selenium CI Bot" | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@main | |
with: | |
token: ${{ secrets.SELENIUM_CI_TOKEN }} | |
commit-message: "[ci] Upload autoscaling in K8s test results" | |
title: "[ci] Upload autoscaling in K8s test results" | |
body: "This PR contains the results of the autoscaling tests in Kubernetes" | |
committer: 'Selenium CI Bot <[email protected]>' | |
author: 'Selenium CI Bot <[email protected]>' | |
branch: autoscaling-results | |
- name: Check outputs | |
if: ${{ steps.cpr.outputs.pull-request-number }} | |
run: | | |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | |
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |