Skip to content

Commit 2d6a56f

Browse files
authored
Adds Integration Tests for ToolHive Operator (#2107)
* adds integration tests for operator Signed-off-by: ChrisJBurns <[email protected]> * fix linting issues Signed-off-by: ChrisJBurns <[email protected]> --------- Signed-off-by: ChrisJBurns <[email protected]>
1 parent fef14a8 commit 2d6a56f

File tree

5 files changed

+508
-3
lines changed

5 files changed

+508
-3
lines changed

.github/workflows/operator-ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,27 @@ jobs:
3232
- name: Run tests
3333
run: task operator-test
3434

35+
operator-tests-integration:
36+
name: Operator Tests Integration
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
40+
41+
- name: Set up Go
42+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
43+
with:
44+
go-version-file: 'go.mod'
45+
cache: true
46+
47+
- name: Install Task
48+
uses: arduino/setup-task@v2
49+
with:
50+
version: 3.44.1
51+
repo-token: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Run tests
54+
run: task operator-test-integration
55+
3556
build-operator:
3657
name: Build Operator
3758
runs-on: ubuntu-latest

Taskfile.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ tasks:
5252
- go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
5353
# we have to use ldflags to avoid the LC_DYSYMTAB linker error.
5454
# https://github.com/stacklok/toolhive/issues/1687
55-
- go test -ldflags=-extldflags=-Wl,-w -v -json -race $(go list ./... | grep -v '/test/e2e') | gotestfmt -hide "all"
55+
- go test -ldflags=-extldflags=-Wl,-w -v -json -race $(go list ./... | grep -v '/test/e2e' | grep -v '/cmd/thv-operator/test-integration') | gotestfmt -hide "all"
5656

5757
test-windows:
5858
desc: Run unit tests (excluding e2e tests) on Windows with race detection
@@ -83,7 +83,7 @@ tasks:
8383
- go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
8484
# we have to use ldflags to avoid the LC_DYSYMTAB linker error.
8585
# https://github.com/stacklok/toolhive/issues/1687
86-
- go test -ldflags=-extldflags=-Wl,-w -json -race -coverprofile=coverage/coverage.out $(go list ./... | grep -v '/test/e2e') | gotestfmt
86+
- go test -ldflags=-extldflags=-Wl,-w -json -race -coverprofile=coverage/coverage.out $(go list ./... | grep -v '/test/e2e' | grep -v '/cmd/thv-operator/test-integration') | gotestfmt
8787
- go tool cover -func=coverage/coverage.out
8888
- echo "Generating HTML coverage report in coverage/coverage.html"
8989
- go tool cover -html=coverage/coverage.out -o coverage/coverage.html

cmd/thv-operator/Taskfile.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,14 @@ tasks:
196196
desc: Run tests for the operator
197197
cmds:
198198
- go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
199-
- KUBEBUILDER_ASSETS="$(shell setup-envtest use 1.28.0 -p path)" go test ./cmd/thv-operator/... -coverprofile cover.out
199+
- KUBEBUILDER_ASSETS="$($(go env GOPATH)/bin/setup-envtest use 1.31.0 -p path)" go test ./cmd/thv-operator/... -coverprofile cover.out
200+
201+
operator-test-integration:
202+
desc: Run integration tests for the operator using envtest
203+
cmds:
204+
- go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
205+
- go install github.com/onsi/ginkgo/v2/ginkgo@latest
206+
- KUBEBUILDER_ASSETS="$($(go env GOPATH)/bin/setup-envtest use 1.31.0 -p path)" $(go env GOPATH)/bin/ginkgo -v ./cmd/thv-operator/test-integration
200207

201208
operator-e2e-test-ginkgo:
202209
desc: Run E2E tests for the operator with Ginkgo

0 commit comments

Comments
 (0)