feat: significantly improve test suite architecture and maintainabili… #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor and Modularize Test Suite: Utilities, Configuration, Metrics, and Documentation
Description
This PR significantly refactors the test suite for the Turbonomic Companion Operator to improve maintainability, modularity, and test reliability. The changes are backward-compatible and do not break existing tests.
Key Improvements
1. Modularization and Code Organization
test_utils.go
,metrics_test_utils.go
,test_constants.go
), reducing duplication and improving clarity.test_config.go
, supporting environment-based overrides and validation.turboSA
, timeouts, intervals) are now defined in a single location and referenced throughout the test suite.2. Configuration Management
3. Metrics Testing
metrics_test_utils.go
to provide reusable helpers for asserting and snapshotting Prometheus metrics.4. Test Suite Robustness
5. Documentation
README_TEST_SUITE.md
with detailed documentation on test architecture, configuration, usage patterns, and migration guidance for existing tests.6. Technical Debt Resolution
go vet
and linter checks.make test
), and code coverage for the controller package is reported at 46.2%.Files Added or Modified
internal/controller/suite_test.go
(refactored, now uses utilities and config)internal/controller/workload_resources_mutator.go
(constant deduplication)internal/controller/test_utils.go
(new, general test helpers)internal/controller/metrics_test_utils.go
(new, metrics helpers)internal/controller/test_config.go
(new, configuration management)internal/controller/test_constants.go
(new, shared constants)internal/controller/README_TEST_SUITE.md
(new, documentation)Impact
Migration
Existing tests can be gradually migrated to use the new utilities and configuration patterns. The documentation provides a migration guide and best practices.
This PR is ready for review. All tests pass, the codebase is more maintainable, and the test suite is now easier to extend and configure.