-
Notifications
You must be signed in to change notification settings - Fork 1
test: add integration tests with real Consul instance #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add comprehensive integration test suite that runs against a real Consul instance via Docker Compose. This validates the full election lifecycle including session management, leader failover, and tag promotion. Changes: - Add configs/integration/docker-compose.yaml with minimal Consul setup - Add internal/ballot/ballot_integration_test.go with 6 integration tests - Update CI workflow to run integration tests with Consul service container - Add Makefile with test targets (test, test-integration, etc.) - Fix releaseSession() to always clear local state even if Destroy fails Integration tests cover: - Full election cycle (session, lock, tag promotion) - Leader failover when session is destroyed - Tag promotion/demotion - Health check failure triggers demotion - Multiple instances competing for leadership - Session renewal over time 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
==========================================
- Coverage 78.34% 78.25% -0.10%
==========================================
Files 4 4
Lines 471 469 -2
==========================================
- Hits 369 367 -2
Misses 82 82
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a comprehensive integration test suite that validates the full election lifecycle against a real Consul instance, including session management, leader failover, and tag promotion. The changes also include a bug fix to ensure releaseSession() clears local state even if the Consul session destroy operation fails.
- Integration tests with 6 test cases covering election cycles, failover, health checks, and multi-instance scenarios
- Bug fix to
releaseSession()to always clear local state, preventing stale session references - CI automation with GitHub Actions integration job using Consul service container
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
internal/ballot/ballot_integration_test.go |
Adds 6 comprehensive integration tests with //go:build integration tag to validate election behavior against real Consul |
internal/ballot/ballot.go |
Fixes releaseSession() to clear local session state before destroying session, preventing stale references |
configs/integration/docker-compose.yaml |
Provides minimal Consul dev-mode setup with health checks for local integration testing |
Makefile |
Adds convenience targets for running unit tests, integration tests, and managing Docker Compose lifecycle |
.github/workflows/ci.yml |
Adds integration job with Consul service container to run integration tests in CI |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add defer ballot.releaseSession() to all integration tests for proper session cleanup - Simplify TestIntegration_TagPromotion to test promotion only (not the incomplete demotion scenario) - Fix Makefile test-integration target to run cleanup even on test failure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use setupViper consistently for both ballots in LeaderFailover test - Add clarifying comments explaining that Ballot copies config at creation time, so viper resets don't affect already-created instances 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Changes
configs/integration/docker-compose.yaml- Minimal Consul setup for testsinternal/ballot/ballot_integration_test.go- 6 integration tests with//go:build integrationtag.github/workflows/ci.yml- Addedintegrationjob with Consul serviceMakefile- Test targets (test,test-integration,integration-up,integration-down)internal/ballot/ballot.go- FixreleaseSession()to always clear local stateIntegration Tests
TestIntegration_FullElectionCycleTestIntegration_LeaderFailoverTestIntegration_TagPromotionTestIntegration_HealthCheckFailureTestIntegration_MultipleInstancesTestIntegration_SessionRenewalTest plan
go test ./...)make test-integration)🤖 Generated with Claude Code