Skip to content

Conversation

@kacpersaw
Copy link
Contributor

Summary

Add integration tests that run against a real Kubernetes cluster using KinD (Kubernetes in Docker). This addresses #58.

Changes

New Files

  • integration_test.go - Integration tests with build tag //go:build integration
  • .github/workflows/integration.yaml - CI workflow for integration tests
  • scripts/kind-setup.sh - Helper script for local development

Test Coverage

Test Description
TestIntegration_PodEvents Pod creation and deletion events
TestIntegration_ReplicaSetEvents ReplicaSet event handling
TestIntegration_MultiNamespace Multi-namespace support
TestIntegration_LabelSelector Label selector filtering

CI Workflow

The new workflow runs in sequence:

  1. Lint - golangci-lint
  2. Unit tests - go test ./... -race
  3. Integration tests - Runs only after lint and unit tests pass, using KinD cluster
  • 10 minute timeout for the integration job
  • Runs on pushes to main and on all PRs

Local Development

# Create a KinD cluster
./scripts/kind-setup.sh create

# Run integration tests
go test -tags=integration -v ./...

# Clean up when done
./scripts/kind-setup.sh delete

Implementation Notes

  • Uses the existing fakeAgentAPI to mock the Coder server - this keeps tests fast and focused on validating real Kubernetes informer behavior
  • Tests create isolated namespaces with unique names and clean up after themselves
  • Pods use NodeSelector with non-existent labels to stay in Pending state (avoids needing to actually run containers)

Closes #58

@kacpersaw kacpersaw force-pushed the kacpersaw/kind-integration-tests branch from 65a45d7 to f58945d Compare December 9, 2025 09:47
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.
The integration tests were using quartz.NewMock(t) which creates a mock
clock that doesn't advance automatically. This caused timeouts when
waiting for log source registration because the timers in the log
queuer never fired.

Changes:
- Remove mock clock usage from all integration tests
- Use real clock (nil) which is the default
- Reduce logDebounce to 5s for faster test execution
- Increase informer sync wait to 1s for reliability
The tests now use waitForLogContaining which continuously collects
logs until finding the expected message, rather than expecting
specific messages in the first batch of logs received.

This fixes flaky tests caused by Kubernetes scheduling events
arriving before pod lifecycle events.
@kacpersaw kacpersaw force-pushed the kacpersaw/kind-integration-tests branch from 3aef12d to 7630eda Compare December 11, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add integration testing using KinD

1 participant