Refactor OTEL test module-reload helper into shared utility#4941
Conversation
There was a problem hiding this comment.
Pull request overview
This PR consolidates duplicated OTEL module reload + env isolation logic used by the api-proxy’s OTEL-related unit tests into a shared helper, ensuring consistent handling of OTEL env keys across test suites.
Changes:
- Added a shared OTEL test utility (
otel-test-utils.js) with a single source of truth for OTEL-related env keys and a helper to loadotel.jswith env isolation. - Updated
otel.test.jsto use the shared loader instead of an inline implementation. - Updated
otel-fanout.test.jsto use the shared loader in both places where fresh module loads were previously duplicated.
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/test-helpers/otel-test-utils.js | Introduces shared env-key list and otel.js fresh-load helper for tests. |
| containers/api-proxy/otel.test.js | Replaces local OTEL module reload/env setup with the shared helper. |
| containers/api-proxy/otel-fanout.test.js | Removes duplicated loadOtelFresh implementations in favor of the shared helper. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
🔬 Smoke Test: Copilot PAT — PASS
Overall: PASS · Auth mode: PAT (COPILOT_GITHUB_TOKEN) PR: "Refactor OTEL test module-reload helper into shared utility" ·
|
Smoke Test: Copilot BYOK (Direct) — PASS ✅
Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY)
|
|
Merged PRs:
✅ GitHub PR query Overall: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🔭 Smoke Test: API Proxy OpenTelemetry Tracing
All 5 scenarios passed.
|
🔬 Smoke Test ResultsPR: Refactor OTEL test module-reload helper into shared utility
Overall: PARTIAL — MCP verified ✅; pre-step template variables were not substituted so HTTP and file tests could not be evaluated.
|
Chroot Version Comparison
Result: ❌ Not all versions match — Python and Node.js differ between host and chroot environments.
|
Smoke Test: GitHub Actions Services Connectivity
Overall: FAIL
|
Smoke Test Results
Overall Status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
|
Deduplicate Copilot bearer-prefix stripping in api-proxy
|
|
Refactor OTEL test module-reload helper into shared utility MCP connectivity: ✅ Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra Overall: FAIL
|
The OTEL module reload/env-isolation helper logic was duplicated across
otel.test.jsandotel-fanout.test.js, and the copies had already drifted (GH_AW_OTLP_ENDPOINTSexisted in only one). This change consolidates that behavior into one shared test utility to keep future env-key updates consistent.Shared OTEL test utility
containers/api-proxy/test-helpers/otel-test-utils.jsOTEL_ENV_KEYS(single source of truth for OTEL-related env vars)loadOtelModule(envOverrides)(save env → clear keys →jest.resetModules()→ requireotel→ restore env)otel.test.jscleanuploadOtelimplementation with a thin wrapper aroundloadOtelModule(...).otel-fanout.test.jscleanuploadOtelFreshimplementations with wrappers that callloadOtelModule(...).