Skip to content

Commit 0e304e5

Browse files
author
Per Goncalves da Silva
committed
externalize ||zation
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 21aa561 commit 0e304e5

File tree

2 files changed

+94
-77
lines changed

2 files changed

+94
-77
lines changed

Diff for: .github/workflows/e2e-tests.yml

+60-24
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,97 @@ on:
99
workflow_dispatch:
1010
merge_group:
1111
jobs:
12+
13+
# Build the OLM image and save it as an artifact
1214
build:
1315
runs-on: ubuntu-latest
1416
outputs:
1517
sha: ${{ steps.vars.outputs.sha }}
1618
steps:
19+
# checkout code and setup go
1720
- uses: actions/checkout@v4
1821
- uses: actions/setup-go@v5
1922
with:
2023
go-version-file: "go.mod"
21-
check-latest: true
22-
cache-dependency-path: "**/*.sum"
23-
- name: Build
24-
run: make e2e-local-build
25-
- name: Output Variables
26-
id: vars
27-
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
28-
- name: Save docker image
24+
# build binaries and image for e2e test (includes experimental features)
25+
- name: Build controller image
26+
run: make e2e-build
27+
- name: Save image
2928
run: docker save quay.io/operator-framework/olm:local -o olm-image.tar
3029
- name: Upload Docker image as artifact
3130
uses: actions/upload-artifact@v4
3231
with:
3332
name: olm-image.tar
3433
path: olm-image.tar
35-
e2e:
34+
35+
# Run e2e tests in parallel jobs
36+
# Take olm image from the previous stage
37+
run-e2e:
3638
needs: build
3739
strategy:
3840
fail-fast: false
3941
matrix:
40-
parallel-id: [0, 1, 2, 3, flake]
42+
parallel-id: [0, 1, 2, 3, flakes]
4143
runs-on: ubuntu-latest
4244
env:
45+
# absolute path to test artifacts directory
4346
ARTIFACT_DIR: ${{ github.workspace }}/artifacts
47+
E2E_TEST_CHUNK: ${{ matrix.parallel-id }}
48+
E2E_NODES: 2
49+
E2E_KUBECONFIG_ROOT: $${{ github.workspace }}/kubeconfigs
4450
steps:
51+
# checkout code and setup go
4552
- uses: actions/checkout@v4
4653
- uses: actions/setup-go@v5
4754
with:
4855
go-version-file: "go.mod"
49-
check-latest: true
50-
cache-dependency-path: "**/*.sum"
51-
- name: Download Docker image from artifacts
56+
57+
# load the olm image
58+
- name: Load OLM Docker image
5259
uses: actions/download-artifact@v4
5360
with:
5461
name: olm-image.tar
5562
path: .
56-
- name: Load Docker image
63+
- run: docker load < olm-image.tar
64+
65+
# set e2e environment variables
66+
- run: echo "GINKGO_E2E_OPTS=-output-dir ${ARTIFACT_DIR} -junit-report junit_e2e.xml -nodes ${E2E_NODES}" >> $GITHUB_ENV
67+
- run: echo "E2E_OPTS=-output-dir -test-data-dir=./testdata -gather-artifacts-script-path=./collect-ci-artifacts.sh -kubeconfig-root=${E2E_KUBECONFIG_ROOT}" >> $GITHUB_ENV
68+
69+
# run e2e tests
70+
# create artifacts directory
71+
- run: mkdir -p ${ARTIFACT_DIR}
72+
73+
# deploy test clusters
74+
- name: Deploy test cluster(s)
5775
run: |
58-
docker load < olm-image.tar
59-
- run: mkdir -p '${{ env.ARTIFACT_DIR }}'
76+
mkdir -p ${E2E_KUBECONFIG_ROOT}
77+
for i in $(seq 1 ${E2E_NODES}); do
78+
export KUBECONFIG=${E2E_KUBECONFIG_ROOT}/kubeconfig-${i}
79+
export KIND_CLUSTER_NAME=kind-olmv0-${i}
80+
export KIND_CREATE_OPTS="--kubeconfig=${KUBECONFIG}"
81+
export HELM_INSTALL_OPTS="--kubeconfig ${KUBECONFIG}"
82+
make kind-create deploy
83+
done
84+
85+
# run non-flakes if matrix-id is not 'flakes'
6086
- name: Run e2e tests
61-
if: ${{ matrix.parallel-id != 'flake' }}
62-
run: make e2e-local E2E_TEST_CHUNK=${{ matrix.parallel-id }} E2E_TEST_NUM_CHUNKS=${{ strategy.job-total }} E2E_NODES=2 ARTIFACT_DIR='${{ env.ARTIFACT_DIR }}' SKIP='\[FLAKE\]'
63-
- name: Run e2e tests for flakes
64-
if: ${{ matrix.parallel-id == 'flake' }}
65-
run: make e2e-local E2E_NODES=2 ARTIFACT_DIR='${{ env.ARTIFACT_DIR }}' TEST='\[FLAKE\]'
66-
- name: Archive Test Artifacts # test results, failed or not, are always uploaded.
87+
if: ${{ matrix.parallel-id != 'flakes' }}
88+
run: |
89+
# subtract 1 from total jobs to account for the flakes job
90+
export E2E_TEST_NUM_CHUNKS=$(( ${{ strategy.job-total }} - 1 ))
91+
export GINKGO_E2E_OPTS="${GINKGO_E2E_OPTS} -focus $(go run ./test/e2e/split/... -chunks $E2E_TEST_NUM_CHUNKS -print-chunk $E2E_TEST_CHUNK ./test/e2e) -skip '\[FLAKE\]'"
92+
make e2e
93+
94+
# run e2e tests for flakes if matrix-id is 'flakes'
95+
- name: Run flaky e2e tests
96+
if: ${{ matrix.parallel-id == 'flakes' }}
97+
run: |
98+
export GINKGO_E2E_OPTS="-focus '\[FLAKE\]'"
99+
make e2e
100+
101+
# archive test results
102+
- name: Archive Test Artifacts
67103
if: ${{ always() }}
68104
uses: actions/upload-artifact@v4
69105
with:
@@ -74,12 +110,12 @@ jobs:
74110
e2e-tests:
75111
if: ${{ always() }}
76112
runs-on: ubuntu-latest
77-
needs: e2e
113+
needs: run-e2e
78114
steps:
79115
- run: |
80116
echo "Matrix result: ${{ needs.e2e.result }}"
81117
- name: check individual matrix results
82118
if: ${{ needs.e2e.result == 'failure' }}
83119
run: |
84120
echo 'Failure: at least one e2e matrix job has failed'
85-
exit 1
121+
exit 1

Diff for: Makefile

+34-53
Original file line numberDiff line numberDiff line change
@@ -129,61 +129,42 @@ deploy-local:
129129
e2e.namespace:
130130
@printf "e2e-tests-$(shell date +%s)-$$RANDOM" > e2e.namespace
131131

132-
E2E_NODES ?= 1
133-
E2E_FLAKE_ATTEMPTS ?= 1
134-
E2E_TIMEOUT ?= 90m
135-
E2E_TEST_CHUNK ?= all
136-
E2E_TEST_NUM_CHUNKS ?= 4
137-
ifneq (all,$(E2E_TEST_CHUNK))
138-
TEST := $(shell go run ./test/e2e/split/... -chunks $(E2E_TEST_NUM_CHUNKS) -print-chunk $(E2E_TEST_CHUNK) ./test/e2e)
139-
endif
140-
E2E_OPTS ?= $(if $(E2E_SEED),-seed '$(E2E_SEED)') $(if $(SKIP), -skip '$(SKIP)') $(if $(TEST),-focus '$(TEST)') $(if $(ARTIFACT_DIR), -output-dir $(ARTIFACT_DIR) -junit-report junit_e2e.xml) -flake-attempts $(E2E_FLAKE_ATTEMPTS) -nodes $(E2E_NODES) -timeout $(E2E_TIMEOUT) -v -randomize-suites -race -trace --show-node-events
141-
E2E_INSTALL_NS ?= operator-lifecycle-manager
142-
E2E_CATALOG_NS ?= $(E2E_INSTALL_NS)
143-
E2E_TEST_NS ?= operators
144-
E2E_KUBECONFIG_ROOT := $(or $(E2E_KUBECONFIG_ROOT), $(shell mktemp -d))
145-
146132
.PHONY: e2e
133+
GINKGO_E2E_OPTS += -timeout 90m -v -randomize-suites -race -trace --show-node-events
134+
E2E_OPTS += -namespace=operators -olmNamespace=operator-lifecycle-manager -catalogNamespace=operator-lifecycle-manager -dummyImage=bitnami/nginx:latest
147135
e2e:
148-
$(GINKGO) $(E2E_OPTS) $(or $(run), ./test/e2e) $< -- -namespace=$(E2E_TEST_NS) -olmNamespace=$(E2E_INSTALL_NS) -catalogNamespace=$(E2E_CATALOG_NS) -dummyImage=bitnami/nginx:latest $(or $(extra_args), -kubeconfig=${KUBECONFIG})
149-
150-
.PHONY: e2e-local
151-
e2e-local: extra_args=-test-data-dir=./testdata -gather-artifacts-script-path=./collect-ci-artifacts.sh -kubeconfig-root=$(E2E_KUBECONFIG_ROOT)
152-
e2e-local: e2e-local-deploy
153-
e2e-local: e2e
154-
155-
.PHONY: e2e-local-deploy
156-
e2e-local-deploy:
157-
@echo "Deploying OLM to local kind clusters in parallel, output might be interleaved"
158-
@for i in $$(seq 1 $(E2E_NODES)); do \
159-
( \
160-
E2E_KUBECONFIG=$(E2E_KUBECONFIG_ROOT)/kubeconfig-$$i; \
161-
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)-$$i; \
162-
$(KIND) create cluster --name $(KIND_CLUSTER_NAME)-$$i --image $(KIND_CLUSTER_IMAGE) --kubeconfig=$$E2E_KUBECONFIG; \
163-
$(KIND) load docker-image quay.io/operator-framework/olm:local --name $(KIND_CLUSTER_NAME)-$$i; \
164-
$(HELM) install olm deploy/chart \
165-
--kubeconfig=$$E2E_KUBECONFIG \
166-
--set debug=true \
167-
--set olm.image.ref=quay.io/operator-framework/olm:local \
168-
--set olm.image.pullPolicy=IfNotPresent \
169-
--set catalog.image.ref=quay.io/operator-framework/olm:local \
170-
--set catalog.image.pullPolicy=IfNotPresent \
171-
--set package.image.ref=quay.io/operator-framework/olm:local \
172-
--set package.image.pullPolicy=IfNotPresent \
173-
--wait; \
174-
sleep 1; \
175-
) & \
176-
done; \
177-
wait
178-
179-
180-
# set go env and other vars, ensure that the dockerfile exists, and then build wait, cpb, and other command binaries and finally the kind image archive
181-
.PHONY: e2e-local-build
182-
e2e-local-build: BUILD_TAGS="json1 e2e experimental_metrics"
183-
e2e-local-build: export GOOS=linux
184-
e2e-local-build: export GOARCH=386
185-
e2e-local-build: build_cmd=build
186-
e2e-local-build: e2e.Dockerfile bin/wait bin/cpb $(CMDS)
136+
$(GINKGO) $(GINKGO_E2E_OPTS) ./test/e2e -- $(E2E_OPTS)
137+
138+
.PHONY: kind-clean
139+
kind-clean:
140+
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME) || true
141+
142+
.PHONY: kind-create
143+
kind-create:
144+
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --image $(KIND_CLUSTER_IMAGE) $(KIND_CREATE_OPTS)
145+
$(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME)
146+
147+
.PHONY: deploy
148+
OLM_IMAGE := quay.io/operator-framework/olm:local
149+
deploy:
150+
$(KIND) load docker-image $(OLM_IMAGE) --name $(KIND_CLUSTER_NAME); \
151+
$(HELM) install olm deploy/chart \
152+
--set debug=true \
153+
--set olm.image.ref=$(OLM_IMAGE) \
154+
--set olm.image.pullPolicy=IfNotPresent \
155+
--set catalog.image.ref=$(OLM_IMAGE) \
156+
--set catalog.image.pullPolicy=IfNotPresent \
157+
--set package.image.ref=$(OLM_IMAGE) \
158+
--set package.image.pullPolicy=IfNotPresent \
159+
$(HELM_INSTALL_OPTS) \
160+
--wait;
161+
162+
.PHONY: e2e-build
163+
e2e-build: BUILD_TAGS="json1 e2e experimental_metrics"
164+
e2e-build: export GOOS=linux
165+
e2e-build: export GOARCH=amd64
166+
e2e-build: build_cmd=build
167+
e2e-build: e2e.Dockerfile bin/wait bin/cpb $(CMDS)
187168
docker build -t quay.io/operator-framework/olm:local -f $< bin
188169

189170
vendor:

0 commit comments

Comments
 (0)