Repository navigation
chore: add environment variable override support for component tests - #4427
Conversation
Summary by CodeRabbit
WalkthroughThe changes replace a static constant for the base endpoint URL with a function that retrieves the value at runtime, allowing for dynamic configuration via an environment variable. Related utility functions are updated to use the new function, ensuring endpoint resolution is now environment-dependent rather than hardcoded. Changes
Sequence Diagram(s)sequenceDiagram
participant Env as Environment
participant Config as config.ts
participant Utils as utils.ts
participant Destination as Destination
Destination->>Utils: buildRequestConfig(destination)
Utils->>Config: getBaseEndpoint()
Config->>Env: Check RUDDER_TEST_API_ENDPOINT
alt Env variable set
Env-->>Config: Return env variable value
else Env variable not set
Config-->>Utils: Return default endpoint
end
Utils-->>Destination: Return request config with resolved endpoint
Suggested reviewers
Suggestions for improvement: ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
Allure Test reports for this run are available at:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4427 +/- ##
===========================================
- Coverage 91.14% 91.14% -0.01%
===========================================
Files 638 638
Lines 33478 33475 -3
Branches 7902 7903 +1
===========================================
- Hits 30513 30510 -3
Misses 2696 2696
Partials 269 269 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Add comprehensive documentation for envOverrides usage in component tests - Include examples for API endpoint override, debug mode, and feature flags - Provide best practices for dynamic vs static environment variable usage - Document common environment variables and implementation details - Guide developers on proper usage to ensure test compatibility
05c78cf to
b083195
Compare
|
Allure Test reports for this run are available at:
|
…mework - Move envUtils.ts to test/integrations/ directory alongside testUtils.ts - Integrate EnvManager into component.test.ts execution flow - Add environment variable handling with proper cleanup in finally blocks - Update rudder_test destination to support dynamic RUDDER_TEST_API_ENDPOINT override - Use runtime function evaluation instead of module load time for proper test isolation - Add working example test case in rudder_test processor data.ts - Update main README with comprehensive environment variable override documentation - Follow component test patterns by using data.ts files only Environment variable overrides now work seamlessly in component tests with: - Automatic snapshot and restore of environment variables - Per-test isolation with proper cleanup - Real working example demonstrates API endpoint override functionality - Dynamic evaluation ensures environment changes take effect during test execution
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/v0/destinations/rudder_test/utils.ts (1)
29-30: Function call implementation looks good with minor performance consideration.The implementation correctly calls
getBaseEndpoint()to enable runtime environment variable configuration. Note that this reads the environment variable on every function call, which is acceptable for the testing use case and aligns with the requirement for per-test environment variable overrides.Consider caching the environment variable value if
buildRequestConfigbecomes a performance bottleneck in high-volume scenarios, though this is likely unnecessary for the current testing use case.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
README.mdis excluded by!**/*.mdtest/integrations/component.test.tsis excluded by!**/test/**test/integrations/destinations/rudder_test/processor/data.tsis excluded by!**/test/**test/integrations/envUtils.tsis excluded by!**/test/**test/integrations/testTypes.tsis excluded by!**/test/**test/integrations/utils/envUtils.README.mdis excluded by!**/*.md,!**/test/**
📒 Files selected for processing (2)
src/v0/destinations/rudder_test/config.ts(1 hunks)src/v0/destinations/rudder_test/utils.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
src/v0/destinations/rudder_test/config.ts (1)
1-4: LGTM! Clean implementation of runtime environment variable override.The conversion from a static constant to a runtime function perfectly aligns with the PR objective of enabling environment variable overrides for component tests. The implementation is clean, well-documented, and maintains backward compatibility with the fallback URL.
src/v0/destinations/rudder_test/utils.ts (1)
2-2: Correct import update for the new function-based approach.The import change properly reflects the transition from a static constant to a dynamic function.
The documentation has been integrated into the main README.md file, so the separate documentation file is no longer needed.
|
Allure Test reports for this run are available at:
|
|



What are the changes introduced in this PR?
This PR adds environment variable override support for component tests, enabling per-test environment configuration without affecting other tests. The implementation follows component test patterns and integrates seamlessly into the existing test framework.
What is the related Linear task?
Part of INT-3615 - Breaking down large PR #4422 into smaller, manageable pieces.
Please explain the objectives of your changes below
This is the first of several smaller PRs to replace the large PR #4422. The objective is to provide a solid foundation for environment variable testing by:
Core Infrastructure
Features
Usage
Add directly to test cases in your files:
Real Working Example
Documentation
Any changes to existing capabilities/behavior?
No breaking changes. All existing functionality remains unchanged:
List any new dependencies added
No new dependencies added. Uses existing Node.js environment variable APIs.
Developer Notes
The feature is immediately usable and demonstrates real-world scenarios for testing different configurations without affecting other tests.