-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add integration test action #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
09f6e21
wip: initial implementation for replicated clusters
NickLarsenNZ d2a469c
refactor: Move architecture extraction into script
Techassi e4a4a98
chore: Install required tools (kuttl, stackablectl, beku)
Techassi 232007d
chore: Remove > which apparently slipped through
Techassi 6186e57
chore: Replace -O with -o
Techassi d9b044d
refactor: Move tool directory setup into own step
Techassi a24e371
chore: Install gettext-base package
Techassi 52dbeb6
feat: Run the integration test
Techassi 7f7d2a5
chore: Add sudo to apt command
Techassi 0e58ef2
fix: Use correct context variable
Techassi 8948f4f
chore: Make the comment a comment sigh...
Techassi 5d52eed
fix: Prefix parameter with --
Techassi adefdfa
fix: Remove superfluous quote
Techassi 0112487
fix: Apply chmod +x
Techassi 7ed716a
feat: Add start and end time outputs
Techassi c2145eb
feat: Use dynamic operator version based on branch
Techassi 646e95c
chore: chmod +x get_operator_version.sh
Techassi cd51be3
fix: Adjust quoting of shell commands
Techassi ec92400
fix: Pass ref name to get_operator_version script
Techassi e2e0bda
fix: Adjust outputs
Techassi 8a35ac7
fix: Add GH_TOKEN env var
Techassi 191b756
feat: Add instance selection
Techassi 406c84c
fix: Export env vars
Techassi 3cb80e3
feat: Properly append test parameters
Techassi c3e5406
fix: Use correct env var
Techassi 1272705
chore: Validate test parameters before cluster creation
Techassi 27470f5
chore: Add Kubernetes distribution tag
Techassi 21da5cb
chore: Rework test parameter validation
Techassi fab9859
chore: Add triggered-by tag
Techassi ec1809f
chore: Add README
Techassi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| uname -m | sed -e "s#x86_64#amd64#" | sed -e "s#aarch64#arm64#" |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/usr/bin/env bash | ||
| set -uo pipefail | ||
|
|
||
| if [ "$1" == "main" ]; then | ||
| echo "0.0.0-dev" | ||
| exit | ||
| fi | ||
|
|
||
| PR_NUMBER=$(gh pr view "$1" --json number --jq '.number') | ||
|
|
||
| if [ "$?" != "0" ]; then | ||
| echo "0.0.0-dev" | ||
| else | ||
| echo "0.0.0-pr$PR_NUMBER" | ||
| fi |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # `run-integration-test` | ||
|
|
||
| > Manifest: [run-integration-test/action.yml][run-integration-test] | ||
|
|
||
| This action runs an operator integration test. It does the following work: | ||
|
|
||
| 1. Create a test cluster on-the-fly using the requested Kubernetes version and distribution via | ||
| Replicated. | ||
| 2. Run the integration test based on the provided test parameters. | ||
| 3. Delete the cluster of the tests are done and send out a notification on failure. | ||
|
|
||
| ## Inputs and Outputs | ||
|
|
||
| > [!TIP] | ||
| > For descriptions of the inputs and outputs, see the complete [run-integration-test] action. | ||
|
|
||
| ### Inputs | ||
|
|
||
| - `test-platform`(required, eg: `kind-1.31.0-amd64`) | ||
| - `test-run` (required, `test-suite` or `test`) | ||
| - `test-parameter` (defaults to `smoke`) | ||
| - `replicated-api-token` (required) | ||
|
|
||
| ### Outputs | ||
|
|
||
| - `start-time` | ||
| - `end-time` | ||
|
|
||
| [run-integration-test]: ./action.yml | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,216 @@ | ||
| --- | ||
| name: Run Integration Test | ||
| description: | | ||
| This action runs Stackable Operator integration tests on various platforms and | ||
| Kubernetes distributions. | ||
| inputs: | ||
| test-platform: | ||
| description: | | ||
| The platform/distribution to run on (eg: `okd-4.15-amd64`) | ||
| required: true | ||
| test-run: | ||
| description: Type of test run | ||
| required: true | ||
| test-parameter: | ||
| description: Parameter to `--test-suite` or `--test` (ignored for `all`) | ||
| default: "" | ||
| replicated-api-token: | ||
| description: Replicated API token (only needed if running on replicated) | ||
| default: "" | ||
| outputs: | ||
| start-time: | ||
| description: The date and time this integration test was started. | ||
| value: ${{ steps.start-time.outputs.START_TIME }} | ||
| end-time: | ||
| description: The date and time this integration test finished. | ||
| value: ${{ steps.end-time.outputs.END_TIME }} | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Record Start Time | ||
| id: start-time | ||
| shell: bash | ||
| run: | | ||
| echo "START_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" | tee -a "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Extract Test and Instance Configuration | ||
| env: | ||
| TEST_PARAMETER: ${{ inputs.test-parameter }} | ||
| TEST_PLATFORM: ${{ inputs.test-platform }} | ||
| TEST_RUN: ${{ inputs.test-run }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| ##################################### | ||
| # Extract Kubernetes-related Values # | ||
| ##################################### | ||
|
|
||
| export KUBERNETES_DISTRIBUTION=$(echo "$TEST_PLATFORM" | cut -d - -f 1) | ||
| export KUBERNETES_VERSION=$(echo "$TEST_PLATFORM" | cut -d - -f 2) | ||
| export KUBERNETES_ARCHITECTURE=$(echo "$TEST_PLATFORM" | cut -d - -f 3) | ||
|
|
||
| echo "KUBERNETES_DISTRIBUTION=$KUBERNETES_DISTRIBUTION" | tee -a "$GITHUB_ENV" | ||
| echo "KUBERNETES_VERSION=$KUBERNETES_VERSION" | tee -a "$GITHUB_ENV" | ||
| echo "KUBERNETES_ARCHITECTURE=$KUBERNETES_ARCHITECTURE" | tee -a "$GITHUB_ENV" | ||
|
|
||
| ################################## | ||
| # Extract Instance Configuration # | ||
| ################################## | ||
|
|
||
| export INSTANCE_SIZE=$(yq '.instance-size' -e ./tests/infrastructure.yaml) | ||
| INSTANCE_TYPE=$(yq '.[env(KUBERNETES_DISTRIBUTION)].[env(KUBERNETES_ARCHITECTURE)].[env(INSTANCE_SIZE)]' -e "$GITHUB_ACTION_PATH/instances.yml") | ||
|
|
||
| echo "INSTANCE_TYPE=$INSTANCE_TYPE" | tee -a "$GITHUB_ENV" | ||
|
|
||
| ############################ | ||
| # Validate Test Parameters # | ||
| ############################ | ||
|
|
||
| if [ -z "$TEST_RUN" ]; then | ||
| echo "TEST_RUN must be defined and not empty" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$TEST_RUN" != "all" ]; then | ||
| if [ -z "$TEST_PARAMETER" ]; then | ||
| echo "TEST_PARAMETER must be defined and not empty" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$TEST_RUN" == "test-suite" ]; then | ||
| yq '.suites[] | select(.name == env(TEST_PARAMETER))' -e ./tests/test-definition.yaml | ||
| elif [ "$TEST_RUN" == "test" ]; then | ||
| yq '.tests[] | select(.name == env(TEST_PARAMETER))' -e ./tests/test-definition.yaml | ||
| fi | ||
| fi | ||
|
|
||
| echo "TEST_PARAMETER=$TEST_PARAMETER" | tee -a "$GITHUB_ENV" | ||
| echo "TEST_RUN=$TEST_RUN" | tee -a "$GITHUB_ENV" | ||
|
|
||
| - name: Prepare Replicated Cluster | ||
| if: env.KUBERNETES_DISTRIBUTION != 'ionos' | ||
| id: prepare-replicated-cluster | ||
| uses: replicatedhq/replicated-actions/create-cluster@v1 # todo, hash | ||
| with: | ||
| # See: https://github.com/replicatedhq/replicated-actions/tree/main/create-cluster#inputs | ||
| api-token: ${{ inputs.replicated-api-token }} | ||
| cluster-name: integration-test-${{ github.repository }}-${{ github.run_id }} | ||
| instance-type: ${{ env.INSTANCE_TYPE }} | ||
| kubernetes-distribution: ${{ env.KUBERNETES_DISTRIBUTION }} | ||
| kubernetes-version: ${{ env.KUBERNETES_VERSION }} | ||
| ttl: 4h # todo: allow this to be configurable | ||
| disk: 50 # todo: allow this to be configurable | ||
| nodes: 1 # todo: allow this to be configurable | ||
| tags: | | ||
| - key: node-architecture | ||
| value: ${{ env.KUBERNETES_ARCHITECTURE }} | ||
| - key: kubernetes-distribution | ||
| value: ${{ env.KUBERNETES_DISTRIBUTION }} | ||
| - key: triggered-by | ||
| value: ${{ github.triggering_actor }} | ||
|
|
||
| - name: Set Replicated kubeconfig | ||
| if: env.KUBERNETES_DISTRIBUTION != 'ionos' | ||
| env: | ||
| KUBECONFIG: ${{ steps.prepare-replicated-cluster.outputs.cluster-kubeconfig }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| mkdir ~/.kube | ||
| echo "$KUBECONFIG" > ~/.kube/config | ||
|
|
||
| - name: Extract Operator Name | ||
| env: | ||
| REPOSITORY: ${{ github.repository }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| OPERATOR_NAME=$(echo "$REPOSITORY" | cut -d / -f 2 | sed 's/-operator//g') | ||
| echo "OPERATOR_NAME=$OPERATOR_NAME" | tee -a "$GITHUB_ENV" | ||
|
|
||
| - name: Setup Tool Directory | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| TOOL_DIRECTORY="$HOME/.local/bin" | ||
| mkdir -p "$TOOL_DIRECTORY" | ||
|
|
||
| echo "$TOOL_DIRECTORY" | tee -a "$GITHUB_PATH" | ||
| echo "TOOL_DIRECTORY=$TOOL_DIRECTORY" | tee -a "$GITHUB_ENV" | ||
|
|
||
| # We don't need to install kubectl, kind or helm because it is already part of the installed | ||
| # tools of the runner image. | ||
| # See https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-kubernetes-tools.sh | ||
| - name: Install kubectl-kuttl | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| curl -L -o "$TOOL_DIRECTORY/kubectl-kuttl" https://github.com/kudobuilder/kuttl/releases/download/v0.19.0/kubectl-kuttl_0.19.0_linux_x86_64 | ||
| chmod +x "$TOOL_DIRECTORY/kubectl-kuttl" | ||
|
|
||
| # Python3 is already installed, if we ever need to specify the version, we can use the | ||
| # setup-python action. | ||
| # See https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-python.sh | ||
| - name: Install beku | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| pip install beku-stackabletech | ||
|
|
||
| # mikefarah/yq is already installed on the runner | ||
| # See https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-yq.sh | ||
|
|
||
| - name: Install stackablectl | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| curl -L -o "$TOOL_DIRECTORY/stackablectl" https://github.com/stackabletech/stackable-cockpit/releases/latest/download/stackablectl-x86_64-unknown-linux-gnu | ||
| chmod +x "$TOOL_DIRECTORY/stackablectl" | ||
|
|
||
| - name: Install apt packages | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| sudo apt update | ||
| sudo apt install -y \ | ||
| gettext-base | ||
|
|
||
| - name: Run Integration Test (${{ inputs.test-run }}=${{ inputs.test-parameter }}) | ||
| env: | ||
| REF_NAME: ${{ github.ref_name }} | ||
| GH_TOKEN: ${{ github.token }} | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| OPERATOR_VERSION=$("$GITHUB_ACTION_PATH/../.scripts/get_operator_version.sh" "$REF_NAME") | ||
| python ./scripts/run-tests --skip-tests --operator "$OPERATOR_NAME=$OPERATOR_VERSION" | ||
|
|
||
| if [ "$TEST_RUN" == "all" ]; then | ||
| python ./scripts/run-tests --skip-release --log-level debug | ||
| else | ||
| python ./scripts/run-tests --skip-release --log-level debug "--$TEST_RUN" "$TEST_PARAMETER" | ||
| fi | ||
|
|
||
| - name: Destroy Replicated Cluster | ||
| if: env.KUBERNETES_DISTRIBUTION != 'ionos' && always() | ||
| # If the creation of the cluster failed, we don't want to error and abort | ||
| continue-on-error: true | ||
| uses: replicatedhq/replicated-actions/remove-cluster@v1 # todo, hash | ||
| with: | ||
| # See: https://github.com/replicatedhq/replicated-actions/tree/main/remove-cluster#inputs | ||
| api-token: ${{ inputs.replicated-api-token }} | ||
| cluster-id: ${{ steps.prepare-replicated-cluster.outputs.cluster-id }} | ||
|
|
||
| - name: Record End Time | ||
| id: end-time | ||
| if: always() | ||
| shell: bash | ||
| run: | | ||
| echo "END_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" | tee -a "$GITHUB_OUTPUT" |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| eks: | ||
| arm64: | ||
| small: m7g.large | ||
| medium: m7g.2xlarge | ||
| large: m7g.4xlarge | ||
| amd64: | ||
| small: m6i.large | ||
| medium: m6i.2xlarge | ||
| large: m6i.4xlarge | ||
|
|
||
| gke: | ||
| arm64: | ||
| small: t2a-standard-2 | ||
| medium: t2a-standard-8 | ||
| large: t2a-standard-16 | ||
| amd64: | ||
| small: e2-standard-2 | ||
| medium: e2-standard-8 | ||
| large: e2-standard-16 | ||
|
|
||
| aks: | ||
| arm64: | ||
| small: Standard_D2ps_v5 | ||
| medium: Standard_D8ps_v5 | ||
| large: Standard_D16ps_v5 | ||
| amd64: | ||
| small: Standard_DS1_v2 | ||
| medium: Standard_DS3_v2 | ||
| large: Standard_DS5_v2 | ||
|
|
||
| kind: | ||
| amd64: | ||
| small: r1.small | ||
| medium: r1.medium | ||
| large: r1.large |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idea: we could also have
elapsed-time.See: https://stackoverflow.com/a/6948865