Skip to content

Conversation

@thrawn01
Copy link
Contributor

Purpose

This PR consolidates the config/ package into daemon/ and adds comprehensive shutdown behavior tests. The config package functionality is more appropriately located in daemon since it directly populates daemon.Config and handles application startup concerns.

Implementation

  • Config Package Consolidation: Moved all YAML config types (File, Logging, QueueStorage, PartitionStorage, Queue, Partition) and ApplyConfigFile() function from config/ to daemon/config.go. Updated cmd/querator/server.go to import only daemon instead of config. Deleted the config/ package entirely.

  • Shutdown Behavior Tests: Added service/shutdown_test.go with four test scenarios:

    • ProduceThenShutdown: Verifies items produced before shutdown survive restart (BadgerDB, PostgreSQL only)
    • LeaseThenShutdown: Verifies leased items persist in storage after restart
    • PartialCompleteThenShutdown: Verifies completed items are removed while uncompleted items remain
    • ShutdownDuringActiveRequests: Verifies graceful handling of in-flight requests during shutdown (all backends)
  • Test Design: Tests use StorageItemsList for persistence verification to avoid lifecycle loop timing dependencies. Persistence tests are correctly skipped for InMemory backend since it doesn't persist data across restarts.

- Move YAML config types (File, Logging, QueueStorage, etc.) to daemon/config.go
- Move ApplyConfigFile() and helper functions to daemon package
- Update cmd/querator/server.go to use daemon.File and daemon.ApplyConfigFile
- Move config tests to daemon/config_test.go
- Delete config/ package entirely
- Add service/shutdown_test.go with comprehensive shutdown tests
- Test ProduceThenShutdown: verify items persist across restart (BadgerDB, PostgreSQL)
- Test LeaseThenShutdown: verify leased items persist in storage after restart
- Test PartialCompleteThenShutdown: verify completed items removed, uncompleted remain
- Test ShutdownDuringActiveRequests: verify graceful handling of in-flight requests
- Skip persistence tests for InMemory backend (not persistent)
- Use StorageItemsList for persistence verification (avoids lifecycle loop timing)
- Remove InMemory backend from shutdown tests since all tests require persistence
- Add deferred cleanup to ensure daemon is shut down even if test fails early
- Prevents port 2319 from being left in use causing subsequent tests to fail
- Use fresh context with timeout for deferred cleanup instead of canceled context
- Prevents goroutine leaks when shutdown is called with already-canceled context
@thrawn01 thrawn01 merged commit 2f5cb51 into main Dec 12, 2025
1 check passed
@thrawn01 thrawn01 self-assigned this Dec 12, 2025
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.

2 participants