Skip to content

Commit 2d703e5

Browse files
feat(run-integration-test): Integrate interu tool into action (#29)
* refactor: Adjust run-integration-test action * Update run-integration-test/action.yml Co-authored-by: Nick <[email protected]> * docs: Simplify strategy list * docs: Update platform section * chore: Apply suggestion Co-authored-by: Nick <[email protected]> * temp: Output available paths in $PATH * chore: Tool directory is already present in $PATH * refactor: Install tools before creating cluster * Revert "temp: Output available paths in $PATH" This reverts commit 7db8e66. * chore: Save tools to /usr/local/bin * chore: Apply suggestions Co-authored-by: Nick <[email protected]> * feat: Add support to specify tool versions * chore: Adjust env var * feat: Add new tags to Replicated cluster --------- Co-authored-by: Nick <[email protected]>
1 parent 11dd70c commit 2d703e5

File tree

2 files changed

+100
-166
lines changed

2 files changed

+100
-166
lines changed

run-integration-test/README.md

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,10 @@
55
This action runs an operator integration test. It does the following work:
66

77
1. Create a test cluster on-the-fly using the requested Kubernetes version, distribution and node
8-
architecture via Replicated. See [Test Platform Triple](#test-platform-triple) for more details.
8+
architecture via Replicated.
99
2. Run the integration test based on the provided test parameters.
1010
3. Delete the cluster of the tests are done and send out a notification on failure.
1111

12-
## Test Platform Triple
13-
14-
The [`test-platform`](#inputs) input expects a test platform triple to select the appropriate node
15-
architecture and Kubernetes distribution & version. The triple format is
16-
`<DISTRIBUTION>-<VERSION>-<ARCHITECTURE>`, eg. `kind-1.31.2-amd64` or `gke-1.31-arm64`.
17-
18-
Each distribution supports different instance types
19-
based on the cloud vendor machine names. This mapping is done via the `instances.yml` file. Based
20-
on this file, the following distributions are supported: `eks`, `gke`, `aks`, `kind`, `k3s`, `rke2`.
21-
There is no mapping for `oke` yet.
22-
23-
Supported Kubernetes version can be inspected on the official Replicated documentation
24-
[page][supported-clusters]. Supported architectures are `amd64` and `arm64`.
25-
2612
## Integration Test Configuration File
2713

2814
Each downstream repository needs a configuration file. This allows customization of various
@@ -52,22 +38,29 @@ runners:
5238
nodes: 3
5339
```
5440
41+
The platform is specified using a platform pair, which consists of the name of the Kubernetes
42+
distribution and version, eg. `rke2-1.31.2`. Each distribution supports different instance types
43+
based on the cloud vendor machine names. This mapping is done via the `instances.yml` file. Based
44+
on this file, the following distributions are supported: `eks`, `gke`, `aks`, `kind`, `k3s`, `rke2`.
45+
There is no mapping for `oke` yet.
46+
47+
Supported Kubernetes version can be inspected on the official Replicated documentation
48+
[page][supported-clusters]. Supported architectures are `amd64` and `arm64`.
49+
5550
### Profiles
5651

5752
Profiles allow for a variety of pre-configured runners and strategies. A profile can be chosen when
5853
calling interu. For example, the `schedule` profile could be used in CI on the `schedule` event.
5954

6055
The following strategies are currently available:
6156

62-
- `weighted`.
63-
- `use-runner`.
64-
65-
- The `weighted` strategy allows defining two or more `weights`. Each `weight` defines how often the
57+
- `weighted`: allows defining two or more `weights`. Each `weight` defines how often the
6658
runner specified is used when this profile is used. It should be noted that the weights *don't*
6759
need to add up to 100, but it is recommended to more easily gauge the probability.
68-
- The `use-runner` strategy just uses the specified `runner`.
60+
- `use-runner`: uses the specified `runner`.
6961

70-
Each profile can additionally specify test `options`, like `parallelism`, `test-run` and `test-parameter`.
62+
Each profile can additionally specify test `options`, like `parallelism`, `test-run` and
63+
`test-parameter`.
7164

7265
```yaml
7366
profiles:
@@ -99,10 +92,12 @@ profiles:
9992

10093
### Inputs
10194

102-
- `test-platform`(required, eg: `kind-1.31.2-amd64`)
103-
- `test-run` (required, `test-suite` or `test`)
104-
- `test-parameter` (defaults to `smoke`)
95+
- `test-profile` (required)
10596
- `replicated-api-token` (required)
97+
- `interu-version` (optional)
98+
- `beku-version` (optional)
99+
- `kuttl-version` (optional)
100+
- `stackablectl-version` (optional)
106101

107102
> [!NOTE]
108103
> `test-parameter` maps to a specific test *name*, not to a single test with all dimensions resolved.

run-integration-test/action.yml

Lines changed: 81 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@ description: |
44
This action runs Stackable Operator integration tests on various platforms and
55
Kubernetes distributions.
66
inputs:
7-
test-platform:
8-
description: |
9-
The platform/distribution to run on (eg: `okd-4.15-amd64`)
10-
required: true
11-
test-run:
12-
description: Type of test run
13-
required: true
14-
test-parameter:
15-
description: Parameter to `--test-suite` or `--test` (ignored for `all`)
16-
default: ""
7+
test-profile:
8+
description: Test profile to run
179
replicated-api-token:
1810
description: Replicated API token (only needed if running on replicated)
1911
default: ""
12+
interu-version:
13+
description: Version of interu
14+
default: 0.1.0
15+
beku-version:
16+
description: Version of beku
17+
default: 0.0.8
18+
kuttl-version:
19+
description: Version of kubectl-kuttl
20+
default: 0.19.0
21+
stackablectl-version:
22+
description: Version of stackablectl
23+
default: 24.11.2
2024
outputs:
2125
start-time:
2226
description: The date and time this integration test was started.
@@ -29,168 +33,61 @@ runs:
2933
steps:
3034
- name: Extract Test and Instance Configuration
3135
env:
32-
TEST_PARAMETER: ${{ inputs.test-parameter }}
33-
TEST_PLATFORM: ${{ inputs.test-platform }}
34-
TEST_RUN: ${{ inputs.test-run }}
36+
INTERU_VERSION: ${{ inputs.interu-version }}
37+
TEST_PROFILE: ${{ inputs.test-profile }}
3538
GITHUB_DEBUG: ${{ runner.debug }}
3639
shell: bash
3740
run: |
3841
set -euo pipefail
3942
[ -n "$GITHUB_DEBUG" ] && set -x
4043
41-
# Create and enter Python virtual env
42-
python -m venv .venv
43-
. .venv/bin/activate
44-
45-
# Install proper yq
46-
pip install yq==3.4.3
47-
yq --version
48-
49-
#####################################
50-
# Extract Kubernetes-related Values #
51-
#####################################
52-
53-
KUBERNETES_DISTRIBUTION=$(echo "$TEST_PLATFORM" | cut -d - -f 1)
54-
KUBERNETES_VERSION=$(echo "$TEST_PLATFORM" | cut -d - -f 2)
55-
KUBERNETES_ARCHITECTURE=$(echo "$TEST_PLATFORM" | cut -d - -f 3)
56-
57-
echo "KUBERNETES_DISTRIBUTION=$KUBERNETES_DISTRIBUTION" | tee -a "$GITHUB_ENV"
58-
echo "KUBERNETES_VERSION=$KUBERNETES_VERSION" | tee -a "$GITHUB_ENV"
59-
echo "KUBERNETES_ARCHITECTURE=$KUBERNETES_ARCHITECTURE" | tee -a "$GITHUB_ENV"
60-
61-
##################################
62-
# Extract Instance Configuration #
63-
##################################
64-
65-
INSTANCE_SIZE=$(yq -er '."instance-size"' ./tests/infrastructure.yaml)
66-
INSTANCE_TYPE=$(yq -er \
67-
--arg kubernetes_distribution "$KUBERNETES_DISTRIBUTION" \
68-
--arg kubernetes_architecture "$KUBERNETES_ARCHITECTURE" \
69-
--arg instance_size "$INSTANCE_SIZE" \
70-
'.[$kubernetes_distribution][$kubernetes_architecture][$instance_size]' \
71-
"$GITHUB_ACTION_PATH/instances.yml"
72-
)
73-
74-
# Optional config options
75-
CLUSTER_TTL=$(yq -er '."cluster-ttl" // "4h"' ./tests/infrastructure.yaml)
76-
INSTANCE_NODES=$(yq -er '.nodes // 1' ./tests/infrastructure.yaml)
77-
INSTANCE_DISK=$(yq -er '.disk // 50' ./tests/infrastructure.yaml)
78-
TEST_PARALLELISM=$(yq -er '.parallelism // 2' ./tests/infrastructure.yaml)
79-
80-
echo "INSTANCE_TYPE=$INSTANCE_TYPE" | tee -a "$GITHUB_ENV"
81-
echo "CLUSTER_TTL=$CLUSTER_TTL" | tee -a "$GITHUB_ENV"
82-
echo "INSTANCE_NODES=$INSTANCE_NODES" | tee -a "$GITHUB_ENV"
83-
echo "INSTANCE_DISK=$INSTANCE_DISK" | tee -a "$GITHUB_ENV"
84-
echo "TEST_PARALLELISM=$TEST_PARALLELISM" | tee -a "$GITHUB_ENV"
85-
86-
############################
87-
# Validate Test Parameters #
88-
############################
89-
90-
if [ -z "$TEST_RUN" ]; then
91-
echo "TEST_RUN must be defined and not empty"
92-
exit 1
93-
fi
44+
# Download interu
45+
curl -fsSL -o /tmp/interu "https://github.com/stackabletech/actions/releases/download/interu-$INTERU_VERSION/interu-x86_64-unknown-linux-gnu"
46+
sudo install -m 755 -t /usr/local/bin /tmp/interu
9447
95-
if [ "$TEST_RUN" != "all" ]; then
96-
if [ -z "$TEST_PARAMETER" ]; then
97-
echo "TEST_PARAMETER must be defined and not empty"
98-
exit 1
99-
fi
100-
101-
if [ "$TEST_RUN" == "test-suite" ]; then
102-
yq -er --arg test_parameter "$TEST_PARAMETER" '.suites[] | select(.name == $test_parameter)' ./tests/test-definition.yaml
103-
elif [ "$TEST_RUN" == "test" ]; then
104-
yq -er --arg test_parameter "$TEST_PARAMETER" '.tests[] | select(.name == $test_parameter)' ./tests/test-definition.yaml
105-
fi
106-
fi
48+
# Run interu to expand parameters into GITHUB_ENV
49+
interu --instances "$GITHUB_ACTION_PATH/instances.yml" --check-test-definitions "$TEST_PROFILE" --output "$GITHUB_ENV"
10750
108-
echo "TEST_PARAMETER=$TEST_PARAMETER" | tee -a "$GITHUB_ENV"
109-
echo "TEST_RUN=$TEST_RUN" | tee -a "$GITHUB_ENV"
110-
111-
- name: Prepare Replicated Cluster
112-
if: env.KUBERNETES_DISTRIBUTION != 'ionos'
113-
id: prepare-replicated-cluster
114-
uses: replicatedhq/replicated-actions/create-cluster@77121785951d05387334b773644c356885191f14 # v1.16.2
115-
with:
116-
# See: https://github.com/replicatedhq/replicated-actions/tree/main/create-cluster#inputs
117-
api-token: ${{ inputs.replicated-api-token }}
118-
cluster-name: integration-test-${{ github.repository }}-${{ github.run_id }}
119-
instance-type: ${{ env.INSTANCE_TYPE }}
120-
kubernetes-distribution: ${{ env.KUBERNETES_DISTRIBUTION }}
121-
kubernetes-version: ${{ env.KUBERNETES_VERSION }}
122-
ttl: ${{ env.CLUSTER_TTL }}
123-
disk: ${{ env.INSTANCE_DISK }}
124-
nodes: ${{ env.INSTANCE_NODES }}
125-
tags: |
126-
- key: node-architecture
127-
value: ${{ env.KUBERNETES_ARCHITECTURE }}
128-
- key: kubernetes-distribution
129-
value: ${{ env.KUBERNETES_DISTRIBUTION }}
130-
- key: triggered-by
131-
value: ${{ github.triggering_actor }}
132-
133-
- name: Set Replicated kubeconfig
134-
if: env.KUBERNETES_DISTRIBUTION != 'ionos'
135-
env:
136-
KUBECONFIG: ${{ steps.prepare-replicated-cluster.outputs.cluster-kubeconfig }}
137-
shell: bash
138-
run: |
139-
set -euo pipefail
140-
mkdir ~/.kube
141-
echo "$KUBECONFIG" > ~/.kube/config
142-
143-
- name: Extract Operator Name
144-
env:
145-
REPOSITORY: ${{ github.repository }}
146-
shell: bash
147-
run: |
148-
set -euo pipefail
149-
150-
OPERATOR_NAME=$(echo "$REPOSITORY" | cut -d / -f 2 | sed 's/-operator//g')
151-
echo "OPERATOR_NAME=$OPERATOR_NAME" | tee -a "$GITHUB_ENV"
152-
153-
- name: Setup Tool Directory
154-
shell: bash
155-
run: |
156-
set -euo pipefail
157-
158-
TOOL_DIRECTORY="$HOME/.local/bin"
159-
mkdir -p "$TOOL_DIRECTORY"
160-
161-
echo "$TOOL_DIRECTORY" | tee -a "$GITHUB_PATH"
162-
echo "TOOL_DIRECTORY=$TOOL_DIRECTORY" | tee -a "$GITHUB_ENV"
51+
# Install all tools BEFORE creating the cluster, because if some of the tools fail to download
52+
# and are therefore not available, there is no need to create the cluster or run the tests,
53+
# because the tests can never run in the first place.
16354

16455
# We don't need to install kubectl, kind or helm because it is already part of the installed
16556
# tools of the runner image.
16657
# See https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-kubernetes-tools.sh
16758
- name: Install kubectl-kuttl
59+
env:
60+
KUTTL_VERSION: ${{ inputs.kuttl-version }}
16861
shell: bash
16962
run: |
17063
set -euo pipefail
17164
172-
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
173-
chmod +x "$TOOL_DIRECTORY/kubectl-kuttl"
65+
curl -fsSL -o /tmp/kubectl-kuttl "https://github.com/kudobuilder/kuttl/releases/download/v$KUTTL_VERSION/kubectl-kuttl_${KUTTL_VERSION}_linux_x86_64"
66+
sudo install -m 755 -t /usr/local/bin /tmp/kubectl-kuttl
17467
17568
# Python3 is already installed, if we ever need to specify the version, we can use the
17669
# setup-python action.
17770
# See https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-python.sh
17871
- name: Install beku
72+
env:
73+
BEKU_VERSION: ${{ inputs.beku-version }}
17974
shell: bash
18075
run: |
18176
set -euo pipefail
182-
pip install beku-stackabletech
77+
pip install "beku-stackabletech==$BEKU_VERSION"
18378
18479
# mikefarah/yq is already installed on the runner
18580
# See https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-yq.sh
18681

18782
- name: Install stackablectl
83+
env:
84+
STACKABLECTL_VERSION: ${{ inputs.stackablectl-version }}
18885
shell: bash
18986
run: |
19087
set -euo pipefail
19188
192-
curl -L -o "$TOOL_DIRECTORY/stackablectl" https://github.com/stackabletech/stackable-cockpit/releases/latest/download/stackablectl-x86_64-unknown-linux-gnu
193-
chmod +x "$TOOL_DIRECTORY/stackablectl"
89+
curl -fsSL -o /tmp/stackablectl "https://github.com/stackabletech/stackable-cockpit/releases/download/stackablectl-$STACKABLECTL_VERSION/stackablectl-x86_64-unknown-linux-gnu"
90+
sudo install -m 755 -t /usr/local/bin /tmp/stackablectl
19491
19592
- name: Install apt packages
19693
shell: bash
@@ -201,13 +98,55 @@ runs:
20198
sudo apt install -y \
20299
gettext-base
203100
101+
- name: Prepare Replicated Cluster
102+
if: env.KUBERNETES_DISTRIBUTION != 'ionos'
103+
id: prepare-replicated-cluster
104+
uses: replicatedhq/replicated-actions/create-cluster@77121785951d05387334b773644c356885191f14 # v1.16.2
105+
with:
106+
# See: https://github.com/replicatedhq/replicated-actions/tree/main/create-cluster#inputs
107+
api-token: ${{ inputs.replicated-api-token }}
108+
cluster-name: integration-test-${{ github.repository }}-${{ github.run_id }}
109+
kubernetes-distribution: ${{ env.INTERU_KUBERNETES_DISTRIBUTION }}
110+
kubernetes-version: ${{ env.INTERU_KUBERNETES_VERSION }}
111+
ttl: ${{ env.INTERU_CLUSTER_TTL }}
112+
node-groups: ${{ env.INTERU_NODE_GROUPS }}
113+
tags: |
114+
- key: kubernetes-distribution
115+
value: ${{ env.INTERU_KUBERNETES_DISTRIBUTION }}
116+
- key: triggered-by
117+
value: ${{ github.triggering_actor }}
118+
- key: test-set
119+
value: ${{ env.INTERU_TEST_RUN }}=${{ env.INTERU_TEST_PARAMETER }}
120+
- key: test-parallelism
121+
value: "${{ env.INTERU_TEST_PARALLELISM }}"
122+
123+
- name: Set Replicated kubeconfig
124+
if: env.INTERU_KUBERNETES_DISTRIBUTION != 'ionos'
125+
env:
126+
KUBECONFIG: ${{ steps.prepare-replicated-cluster.outputs.cluster-kubeconfig }}
127+
shell: bash
128+
run: |
129+
set -euo pipefail
130+
mkdir ~/.kube
131+
echo "$KUBECONFIG" > ~/.kube/config
132+
133+
- name: Extract Operator Name
134+
env:
135+
REPOSITORY: ${{ github.repository }}
136+
shell: bash
137+
run: |
138+
set -euo pipefail
139+
140+
OPERATOR_NAME=$(echo "$REPOSITORY" | cut -d / -f 2 | sed 's/-operator//g')
141+
echo "OPERATOR_NAME=$OPERATOR_NAME" | tee -a "$GITHUB_ENV"
142+
204143
- name: Record Test Start Time
205144
id: start-time
206145
shell: bash
207146
run: |
208147
echo "START_TIME=$(date +'%Y-%m-%dT%H:%M:%S')" | tee -a "$GITHUB_OUTPUT"
209148
210-
- name: Run Integration Test (${{ inputs.test-run }}=${{ inputs.test-parameter }})
149+
- name: Run Integration Test (${{ env.INTERU_TEST_RUN }}=${{ env.INTERU_TEST_PARAMETER }}/${{ env.INTERU_TEST_PARALLELISM }})
211150
env:
212151
REF_NAME: ${{ github.ref_name }}
213152
GH_TOKEN: ${{ github.token }}
@@ -218,10 +157,10 @@ runs:
218157
OPERATOR_VERSION=$("$GITHUB_ACTION_PATH/../.scripts/get_operator_version.sh" "$REF_NAME")
219158
python ./scripts/run-tests --skip-tests --operator "$OPERATOR_NAME=$OPERATOR_VERSION"
220159
221-
if [ "$TEST_RUN" == "all" ]; then
222-
python ./scripts/run-tests --skip-release --log-level debug --parallel "$TEST_PARALLELISM"
160+
if [ "$INTERU_TEST_RUN" == "all" ]; then
161+
python ./scripts/run-tests --skip-release --log-level debug --parallel "$INTERU_TEST_PARALLELISM"
223162
else
224-
python ./scripts/run-tests --skip-release --log-level debug "--$TEST_RUN" "$TEST_PARAMETER" --parallel "$TEST_PARALLELISM"
163+
python ./scripts/run-tests --skip-release --log-level debug "--$INTERU_TEST_RUN" "$INTERU_TEST_PARAMETER" --parallel "$INTERU_TEST_PARALLELISM"
225164
fi
226165
227166
- name: Record Test End Time

0 commit comments

Comments
 (0)