Skip to content

Commit f58945d

Browse files
committed
feat: add KinD integration tests
Add integration tests that run against a real Kubernetes cluster using KinD (Kubernetes in Docker). This addresses #58. Changes: - Add integration_test.go with tests for: - Pod events (create/delete) - ReplicaSet events - Multi-namespace support - Label selector filtering - Add .github/workflows/integration.yaml CI workflow that: - Runs lint and unit tests first - Then runs integration tests with KinD - 10 minute timeout - Add scripts/kind-setup.sh for local development - Update README.md with integration test documentation The integration tests use the existing fakeAgentAPI to mock the Coder server, focusing on validating real Kubernetes informer behavior.
1 parent 736495d commit f58945d

File tree

4 files changed

+752
-0
lines changed

4 files changed

+752
-0
lines changed

.github/workflows/integration.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: integration
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
actions: none
11+
checks: none
12+
contents: read
13+
deployments: none
14+
issues: none
15+
packages: none
16+
pull-requests: none
17+
repository-projects: none
18+
security-events: none
19+
statuses: none
20+
21+
# Cancel in-progress runs for pull requests when developers push
22+
# additional changes
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
26+
27+
jobs:
28+
unit-test:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Go
35+
uses: actions/setup-go@v5
36+
with:
37+
go-version: "~1.22"
38+
39+
- name: Test
40+
run: go test ./... -race
41+
42+
integration-test:
43+
needs: [unit-test]
44+
runs-on: ubuntu-latest
45+
timeout-minutes: 10
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
50+
- name: Setup Go
51+
uses: actions/setup-go@v5
52+
with:
53+
go-version: "~1.22"
54+
55+
- name: Create KinD cluster
56+
uses: helm/kind-action@v1
57+
with:
58+
cluster_name: integration-test
59+
60+
- name: Run integration tests
61+
run: go test -tags=integration -v -timeout=8m ./...

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,42 @@ Kubernetes provides an [informers](https://pkg.go.dev/k8s.io/client-go/informers
6464
6565
- [`SSL_CERT_FILE`](https://go.dev/src/crypto/x509/root_unix.go#L19): Specifies the path to an SSL certificate.
6666
- [`SSL_CERT_DIR`](https://go.dev/src/crypto/x509/root_unix.go#L25): Identifies which directory to check for SSL certificate files.
67+
68+
## Development
69+
70+
### Running Tests
71+
72+
Unit tests can be run with:
73+
74+
```console
75+
go test ./... -race
76+
```
77+
78+
### Integration Tests
79+
80+
Integration tests run against a real Kubernetes cluster using [KinD (Kubernetes in Docker)](https://kind.sigs.k8s.io/).
81+
82+
**Prerequisites:**
83+
- [Docker](https://docs.docker.com/get-docker/)
84+
- [KinD](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
85+
- [kubectl](https://kubernetes.io/docs/tasks/tools/)
86+
87+
**Setup and run:**
88+
89+
```console
90+
# Create a KinD cluster
91+
./scripts/kind-setup.sh create
92+
93+
# Run integration tests
94+
go test -tags=integration -v ./...
95+
96+
# Clean up when done
97+
./scripts/kind-setup.sh delete
98+
```
99+
100+
The integration tests validate:
101+
- Pod event streaming with real Kubernetes informers
102+
- ReplicaSet event handling
103+
- Multi-namespace support
104+
- Label selector filtering
105+

0 commit comments

Comments
 (0)