Skip to content

Commit 51a02ed

Browse files
Extract functional test steps into reusable composite action
All kind-based functional test jobs now delegate to .github/actions/functional-test, which owns: Go setup, kind cluster creation, TLS cert fix, dep-update, optional test image build, make functionaltest, and debug artifact upload. Callers pass k8s-version, suite, go-version (or go-version-file), and optional flags for image override, debug info, and golden file updates.
1 parent 638aa1d commit 51a02ed

4 files changed

Lines changed: 137 additions & 126 deletions

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Run Functional Tests
2+
description: >
3+
Sets up a kind cluster, installs dependencies, and runs a functional test
4+
suite. Optionally overrides the collector image and uploads debug artifacts.
5+
6+
inputs:
7+
k8s-version:
8+
description: 'Kubernetes version for the kind cluster (e.g. v1.34.3)'
9+
required: true
10+
suite:
11+
description: 'Test suite to run (passed as SUITE= to make functionaltest)'
12+
required: true
13+
go-version:
14+
description: 'Go version to install'
15+
required: false
16+
default: ''
17+
go-version-file:
18+
description: 'Path to go.mod to determine Go version (used when go-version is not set)'
19+
required: false
20+
default: ''
21+
build-test-images:
22+
description: 'Whether to build and load test images into kind'
23+
required: false
24+
default: 'true'
25+
update-expected-results:
26+
description: 'Whether to update golden file expected test results'
27+
required: false
28+
default: 'false'
29+
kubernetes-debug-info:
30+
description: 'Whether to collect and upload k8s debug info'
31+
required: false
32+
default: 'false'
33+
artifact-suffix:
34+
description: 'Suffix for the k8s debug info artifact name'
35+
required: false
36+
default: ''
37+
otelcol-image-repo:
38+
description: 'Override for the collector image repository'
39+
required: false
40+
default: ''
41+
otelcol-image-tag:
42+
description: 'Override for the collector image tag'
43+
required: false
44+
default: ''
45+
46+
runs:
47+
using: composite
48+
steps:
49+
- name: Set up Go
50+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
51+
with:
52+
go-version: ${{ inputs.go-version != '' && inputs.go-version || '' }}
53+
go-version-file: ${{ inputs.go-version-file != '' && inputs.go-version-file || '' }}
54+
cache-dependency-path: '**/go.sum'
55+
56+
- name: Create kind cluster
57+
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
58+
with:
59+
node_image: kindest/node:${{ inputs.k8s-version }}
60+
kubectl_version: ${{ inputs.k8s-version }}
61+
cluster_name: kind
62+
config: ./.github/workflows/configs/kind-config.yaml
63+
64+
- name: Fix kubelet TLS server certificates
65+
shell: bash
66+
run: |
67+
kubectl get csr -o=jsonpath='{range.items[?(@.spec.signerName=="kubernetes.io/kubelet-serving")]}{.metadata.name}{" "}{end}' | xargs kubectl certificate approve
68+
69+
- name: Update dependencies
70+
shell: bash
71+
run: make dep-update
72+
73+
- name: Build and load test images into kind
74+
if: inputs.build-test-images == 'true'
75+
shell: bash
76+
run: make kind-build-test-images
77+
78+
- name: Run functional tests
79+
id: run-functional-tests
80+
shell: bash
81+
env:
82+
KUBECONFIG: /tmp/kube-config-splunk-otel-collector-chart-functional-testing
83+
KUBE_TEST_ENV: kind
84+
K8S_VERSION: ${{ inputs.k8s-version }}
85+
OTELCOL_IMAGE_REPO: ${{ inputs.otelcol-image-repo }}
86+
OTELCOL_IMAGE_TAG: ${{ inputs.otelcol-image-tag }}
87+
run: |
88+
TEARDOWN_BEFORE_SETUP=true \
89+
UPDATE_EXPECTED_RESULTS=${{ inputs.update-expected-results }} \
90+
SUITE=${{ inputs.suite }} \
91+
make functionaltest
92+
93+
- name: Collect Kubernetes Cluster debug info
94+
if: always() && (steps.run-functional-tests.outcome == 'failure' || inputs.kubernetes-debug-info == 'true')
95+
shell: bash
96+
run: |
97+
cd tools
98+
./splunk_kubernetes_debug_info.sh
99+
100+
- name: Upload Kubernetes Cluster debug info
101+
if: always() && (steps.run-functional-tests.outcome == 'failure' || inputs.kubernetes-debug-info == 'true')
102+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
103+
with:
104+
name: k8s-debug-info${{ inputs.artifact-suffix != '' && format('-{0}', inputs.artifact-suffix) || '' }}
105+
path: tools/splunk_kubernetes_debug_info_*
106+
retention-days: 5
107+
108+
- name: Upload updated expected results
109+
if: always() && inputs.update-expected-results == 'true'
110+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
111+
with:
112+
name: updated_expected_results${{ inputs.artifact-suffix != '' && format('-{0}', inputs.artifact-suffix) || '' }}
113+
path: ./functional_tests/**/*.yaml
114+
retention-days: 5
Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Dev Image Tests
22

33
on:
4-
schedule:
5-
- cron: "0 6 * * *"
64
workflow_dispatch:
75
inputs:
86
collector_image:
@@ -42,62 +40,25 @@ jobs:
4240
name: K8s ${{ matrix.k8s-kind-version }} / ${{ matrix.test-job }}
4341
runs-on: ubuntu-latest
4442
needs: get-test-matrix
45-
env:
46-
KUBECONFIG: /tmp/kube-config-splunk-otel-collector-chart-functional-testing
47-
KUBE_TEST_ENV: kind
48-
KUBERNETES_DEBUG_INFO: ${{ github.event.inputs.KUBERNETES_DEBUG_INFO || 'false' }}
4943
strategy:
5044
fail-fast: false
5145
matrix: ${{ fromJSON(needs.get-test-matrix.outputs.matrix) }}
5246
steps:
5347
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
54-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
55-
with:
56-
go-version: ${{ env.GO_VERSION }}
57-
cache-dependency-path: '**/go.sum'
5848

59-
- name: Set collector image overrides
49+
- name: Parse collector image input
50+
id: parse-image
6051
run: |
6152
IMAGE="${{ github.event.inputs.collector_image || 'quay.io/signalfx/splunk-otel-collector-dev:latest' }}"
62-
echo "OTELCOL_IMAGE_REPO=${IMAGE%:*}" >> "$GITHUB_ENV"
63-
echo "OTELCOL_IMAGE_TAG=${IMAGE##*:}" >> "$GITHUB_ENV"
53+
echo "repo=${IMAGE%:*}" >> "$GITHUB_OUTPUT"
54+
echo "tag=${IMAGE##*:}" >> "$GITHUB_OUTPUT"
6455
65-
- name: Create kind cluster
66-
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
56+
- uses: ./.github/actions/functional-test
6757
with:
68-
node_image: kindest/node:${{ matrix.k8s-kind-version }}
69-
kubectl_version: ${{ matrix.k8s-kind-version }}
70-
cluster_name: kind
71-
config: ./.github/workflows/configs/kind-config.yaml
72-
73-
- name: Fix kubelet TLS server certificates
74-
run: |
75-
kubectl get csr -o=jsonpath='{range.items[?(@.spec.signerName=="kubernetes.io/kubelet-serving")]}{.metadata.name}{" "}{end}' | xargs kubectl certificate approve
76-
77-
- name: Update dependencies
78-
run: make dep-update
79-
80-
- name: Build and load test images into kind
81-
run: make kind-build-test-images
82-
83-
- name: Run functional tests
84-
id: run-functional-tests
85-
env:
86-
K8S_VERSION: ${{ matrix.k8s-kind-version }}
87-
run: |
88-
TEARDOWN_BEFORE_SETUP=true SUITE=${{ matrix.test-job }} make functionaltest
89-
90-
- name: Collect Kubernetes Cluster debug info on failure
91-
if: always() && (steps.run-functional-tests.outcome == 'failure' || env.KUBERNETES_DEBUG_INFO == 'true')
92-
id: collect-debug-info
93-
run: |
94-
cd tools
95-
./splunk_kubernetes_debug_info.sh
96-
97-
- name: Upload Kubernetes Cluster debug info
98-
if: always() && (steps.run-functional-tests.outcome == 'failure' || env.KUBERNETES_DEBUG_INFO == 'true')
99-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
100-
with:
101-
name: k8s-debug-info-${{ matrix.test-job }}-${{ matrix.k8s-kind-version }}
102-
path: tools/splunk_kubernetes_debug_info_*
103-
retention-days: 5
58+
k8s-version: ${{ matrix.k8s-kind-version }}
59+
suite: ${{ matrix.test-job }}
60+
go-version: ${{ env.GO_VERSION }}
61+
kubernetes-debug-info: ${{ github.event.inputs.KUBERNETES_DEBUG_INFO || 'false' }}
62+
artifact-suffix: ${{ matrix.test-job }}-${{ matrix.k8s-kind-version }}
63+
otelcol-image-repo: ${{ steps.parse-image.outputs.repo }}
64+
otelcol-image-tag: ${{ steps.parse-image.outputs.tag }}

.github/workflows/functional_test_v2.yaml

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -61,53 +61,14 @@ jobs:
6161
continue-on-error: ${{ contains(github.event.pull_request.labels.*.name, 'Ignore Tests') }}
6262
steps:
6363
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
64-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
64+
- uses: ./.github/actions/functional-test
6565
with:
66+
k8s-version: ${{ matrix.k8s-kind-version }}
67+
suite: ${{ matrix.test-job }}
6668
go-version: ${{ env.GO_VERSION }}
67-
cache-dependency-path: '**/go.sum'
68-
- name: Create kind cluster
69-
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
70-
with:
71-
node_image: kindest/node:${{ matrix.k8s-kind-version }}
72-
kubectl_version: ${{ matrix.k8s-kind-version }}
73-
cluster_name: kind
74-
config: ./.github/workflows/configs/kind-config.yaml
75-
- name: Fix kubelet TLS server certificates
76-
run: |
77-
kubectl get csr -o=jsonpath='{range.items[?(@.spec.signerName=="kubernetes.io/kubelet-serving")]}{.metadata.name}{" "}{end}' | xargs kubectl certificate approve
78-
- name: Update dependencies
79-
run: |
80-
make dep-update
81-
- name: Build and load test images into kind
82-
run: |
83-
make kind-build-test-images
84-
- name: run functional tests
85-
id: run-functional-tests
86-
env:
87-
K8S_VERSION: ${{ matrix.k8s-kind-version }}
88-
run: |
89-
TEARDOWN_BEFORE_SETUP=true UPDATE_EXPECTED_RESULTS=${{ env.UPDATE_EXPECTED_RESULTS }} SUITE=${{ matrix.test-job }} make functionaltest
90-
- name: Collect Kubernetes Cluster debug info on failure
91-
if: always() && (steps.run-functional-tests.outcome == 'failure' || env.KUBERNETES_DEBUG_INFO == 'true')
92-
id: collect-debug-info
93-
run: |
94-
echo "Functional tests failed. Collecting debug info for current state of the Kubernetes cluster..."
95-
cd tools
96-
./splunk_kubernetes_debug_info.sh
97-
- name: Upload Kubernetes Cluster debug info
98-
if: always() && (steps.run-functional-tests.outcome == 'failure' || env.KUBERNETES_DEBUG_INFO == 'true')
99-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
100-
with:
101-
name: k8s-debug-info-${{ matrix.test-job }}-${{ matrix.k8s-kind-version }}
102-
path: tools/splunk_kubernetes_debug_info_*
103-
retention-days: 5
104-
- name: Upload updated files artifact
105-
if: always() && env.UPDATE_EXPECTED_RESULTS == 'true'
106-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
107-
with:
108-
name: updated_expected_results-${{ matrix.test-job }}-${{ matrix.k8s-kind-version }}
109-
path: ./functional_tests/**/*.yaml
110-
retention-days: 5
69+
update-expected-results: ${{ env.UPDATE_EXPECTED_RESULTS }}
70+
kubernetes-debug-info: ${{ env.KUBERNETES_DEBUG_INFO }}
71+
artifact-suffix: ${{ matrix.test-job }}-${{ matrix.k8s-kind-version }}
11172

11273
eks-test:
11374
name: Test helm install in EKS - credentials needed

.github/workflows/instrumentation_cr_test.yaml

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,10 @@ jobs:
1515
continue-on-error: ${{ contains(github.event.pull_request.labels.*.name, 'Ignore Tests') }}
1616
steps:
1717
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
18-
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
18+
- uses: ./.github/actions/functional-test
1919
with:
20+
k8s-version: v1.34.3
21+
suite: instrumentation_cr
2022
go-version-file: functional_tests/go.mod
21-
cache-dependency-path: functional_tests/go.sum
22-
- name: Create kind cluster
23-
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
24-
with:
25-
node_image: kindest/node:v1.34.3
26-
kubectl_version: v1.34.3
27-
cluster_name: kind
28-
config: ./.github/workflows/configs/kind-config.yaml
29-
- name: Fix kubelet TLS server certificates
30-
run: |
31-
kubectl get csr -o=jsonpath='{range.items[?(@.spec.signerName=="kubernetes.io/kubelet-serving")]}{.metadata.name}{" "}{end}' | xargs kubectl certificate approve
32-
- name: Update Helm dependencies
33-
run: make dep-update
34-
- name: Run instrumentation CR e2e tests
35-
id: run-e2e
36-
run: make functionaltest SUITE=instrumentation_cr
37-
- name: Collect Kubernetes Cluster debug info on failure
38-
if: always() && steps.run-e2e.outcome == 'failure'
39-
run: |
40-
echo "Instrumentation CR tests failed. Collecting debug info..."
41-
cd tools
42-
./splunk_kubernetes_debug_info.sh
43-
- name: Upload Kubernetes Cluster debug info
44-
if: always() && steps.run-e2e.outcome == 'failure'
45-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
46-
with:
47-
name: k8s-debug-info-instrumentation-cr
48-
path: tools/splunk_kubernetes_debug_info_*
49-
retention-days: 5
23+
build-test-images: 'false'
24+
artifact-suffix: instrumentation-cr

0 commit comments

Comments
 (0)