Skip to content

Commit

Permalink
[chore] refactor ghwf functional tests go dependency caching (signalf…
Browse files Browse the repository at this point in the history
…x#1632)

* refactor ghwf functional tests go dependency caching

* Update Makefile

Co-authored-by: Antoine Toulme <atoulme@splunk.com>

* update functional test args to match previous behavior

* remove god mod tidy

* Temp test to verify env is clean enough

* Add fix where eks upgrade tests don't always cleanup the test env before running

* patch

---------

Co-authored-by: Antoine Toulme <atoulme@splunk.com>
  • Loading branch information
jvoravong and atoulme authored Jan 27, 2025
1 parent 43cef31 commit 2a6d764
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 109 deletions.
133 changes: 29 additions & 104 deletions .github/workflows/functional_test_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
default: false

env:
GO_VERSION: 1.22.10
# Make sure to exit early if cache segment download times out after 2 minutes.
# We limit cache download as a whole to 5 minutes.
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
Expand Down Expand Up @@ -48,17 +49,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ~1.22.5
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Create kind cluster
uses: helm/kind-action@v1.12.0
with:
Expand All @@ -80,8 +72,7 @@ jobs:
env:
K8S_VERSION: ${{ matrix.k8s-version }}
run: |
cd functional_tests
TEARDOWN_BEFORE_SETUP=true UPDATE_EXPECTED_RESULTS=${{ env.UPLOAD_UPDATED_EXPECTED_RESULTS }} go test -v -tags ${{ matrix.test-job }}
TEARDOWN_BEFORE_SETUP=true UPDATE_EXPECTED_RESULTS=${{ env.UPLOAD_UPDATED_EXPECTED_RESULTS }} TAGS=${{ matrix.test-job }} make functionaltest
- name: Collect Kubernetes Cluster debug info on failure
if: always() && (steps.run-functional-tests.outcome == 'failure' || env.UPLOAD_KUBERNETES_DEBUG_INFO == 'true')
id: collect-debug-info
Expand Down Expand Up @@ -119,17 +110,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ~1.21.8
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -149,8 +131,8 @@ jobs:
env:
HOST_ENDPOINT: 0.0.0.0
run: |
cd functional_tests
TEARDOWN_BEFORE_SETUP=true go test -v -tags functional
TEARDOWN_BEFORE_SETUP=true TAGS=functional make functionaltest
eks-upgrade-test:
name: Test helm upgrade in EKS - credentials needed
needs: kubernetes-test
Expand Down Expand Up @@ -182,17 +164,8 @@ jobs:
run: cd base && git checkout HEAD^
- uses: actions/setup-go@v5
with:
go-version: ~1.21.8
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -210,6 +183,7 @@ jobs:
cd base && make cert-manager
- name: Deploy previous version of the chart
run: |
helm list | grep -q "^sock$" && echo "Found previous 'sock' release. Deleting..." && helm delete sock
cd base && helm install sock helm-charts/splunk-otel-collector --set cloudProvider=aws --set distribution=eks --set splunkObservability.realm=us0 --set splunkObservability.accessToken=xxxxx
- name: Update dependencies
run: |
Expand All @@ -221,8 +195,7 @@ jobs:
env:
HOST_ENDPOINT: 0.0.0.0
run: |
cd functional_tests
go test -v -tags functional
TAGS=functional make functionaltest
eks-upgrade-from-release-test:
name: Test helm upgrade from release in EKS - credentials needed
Expand All @@ -245,17 +218,8 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: ~1.21.8
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -273,6 +237,7 @@ jobs:
cd base && make cert-manager
- name: Deploy previous version of the chart
run: |
helm list | grep -q "^sock$" && echo "Found previous 'sock' release. Deleting..." && helm delete sock
cd base && helm install sock helm-charts/splunk-otel-collector --set cloudProvider=aws --set distribution=eks --set splunkObservability.realm=us0 --set splunkObservability.accessToken=xxxxx --set operator.enabled=true --set environment=dev
- name: Update dependencies
run: |
Expand All @@ -284,8 +249,8 @@ jobs:
env:
HOST_ENDPOINT: 0.0.0.0
run: |
cd functional_tests
go test -v -tags functional
TAGS=functional make functionaltest
gke-autopilot-test:
name: Test helm install in GKE/Autopilot - credentials needed
needs: kubernetes-test
Expand All @@ -300,17 +265,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ~1.21.8
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- uses: 'google-github-actions/auth@v2.1.7'
with:
project_id: ${{ secrets.GKE_PROJECT }}
Expand All @@ -330,8 +286,7 @@ jobs:
env:
HOST_ENDPOINT: 0.0.0.0
run: |
cd functional_tests
TEARDOWN_BEFORE_SETUP=true go test -v -tags functional
TEARDOWN_BEFORE_SETUP=true TAGS=functional make functionaltest
gke-autopilot-upgrade-test:
name: Test helm upgrade in GKE/Autopilot - credentials needed
Expand Down Expand Up @@ -363,17 +318,8 @@ jobs:
run: cd base && git checkout HEAD^
- uses: actions/setup-go@v5
with:
go-version: ~1.21.8
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- uses: 'google-github-actions/auth@v2.1.7'
with:
project_id: ${{ secrets.GKE_PROJECT }}
Expand All @@ -398,8 +344,7 @@ jobs:
env:
HOST_ENDPOINT: 0.0.0.0
run: |
cd functional_tests
go test -v -tags functional
TAGS=functional make functionaltest
aks-windows-test:
name: Test helm install in AKS - credentials needed
Expand All @@ -415,17 +360,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ~1.21.8
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Set up kubelogin for non-interactive login
uses: azure/use-kubelogin@v1.2
with:
Expand All @@ -446,8 +382,7 @@ jobs:
env:
HOST_ENDPOINT: 0.0.0.0
run: |
cd functional_tests
TEARDOWN_BEFORE_SETUP=true go test -v -tags functional
TEARDOWN_BEFORE_SETUP=true TAGS=functional make functionaltest
gce-autopilot-test:
name: Test helm install in GCE (kops) - credentials needed
Expand All @@ -463,17 +398,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ~1.21.8
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@v4
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Update dependencies
run: |
make dep-update
Expand All @@ -486,5 +412,4 @@ jobs:
HOST_ENDPOINT: 0.0.0.0
KUBECONFIG: /tmp/kubeconfig
run: |
cd functional_tests
TEARDOWN_BEFORE_SETUP=true go test -v -tags functional
TEARDOWN_BEFORE_SETUP=true TAGS=functional make functionaltest
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ unittest: ## Run unittests on the Helm chart
@echo "Running unit tests on helm chart..."
cd helm-charts/splunk-otel-collector && helm unittest --strict -f "../../test/unittests/*.yaml" . || exit 1

# Example Usage:
# make functionaltest
# make functionaltest SKIP_SETUP=true SKIP_TEARDOWN=true SKIP_TESTS=true TEARDOWN_BEFORE_SETUP=true TAGS="functional" UPDATE_EXPECTED_RESULTS=true KUBE_TEST_ENV="kind" KUBECONFIG="/path/to/kubeconfig"
.PHONY: functionaltest
functionaltest: ## Run functional tests for this Helm chart with optional tags and environment variables
@echo "Running functional tests for this helm chart..."
cd functional_tests && go test -v $(if $(TAGS),-tags $(TAGS)) || exit 1

##@ Changelog
# Tasks related to changelog management

Expand Down
17 changes: 12 additions & 5 deletions functional_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ kind load docker-image ghcr.io/signalfx/splunk-otel-java/splunk-otel-java:v1.30.
## Config switches

When running tests you can use the following env vars to help with local development:
- `SKIP_SETUP`: skip setting up the chart and apps. Useful if they are already deployed.
- `SKIP_TEARDOWN`: skip deleting the chart and apps as part of cleanup. Useful to keep around for local development.
- `SKIP_TESTS`: skip running tests, just set up and tear down the cluster.
- `TEARDOWN_BEFORE_SETUP`: delete all the deployments made by these tests before setting up.
- `UPDATE_EXPECTED_RESULTS`: run golden.WriteMetrics() methods to generate new golden files for expected test results
- `KUBECONFIG`: Path to the kubeconfig file for the test cluster.
- `KUBE_TEST_ENV`: Set the type of cluster (e.g., `kind`, `eks`, `gce`).
- `SKIP_SETUP`: Skip setting up the chart/apps (useful if already deployed).
- `SKIP_TEARDOWN`: Skip cleanup (useful to keep apps for local dev).
- `SKIP_TESTS`: Skip tests; only set up and tear down the cluster.
- `TEARDOWN_BEFORE_SETUP`: Clean up deployments before setting up.
- `TAGS`: Specify which tests to run (e.g., `TAGS="functional"`).
- `UPDATE_EXPECTED_RESULTS`: Generate new golden files for test results.

## Run

From the root repository directory run `make functionaltest`.

0 comments on commit 2a6d764

Please sign in to comment.