test: consolidate qyl MCP and collector coverage - #367
Conversation
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
Risk: Low — changes are confined to test code and primarily refactor/expand assertions for existing behaviors.
This PR consolidates and tightens test coverage across the qyl MCP and collector test suites, focusing assertions on observable behavior and improving isolation for process-wide telemetry listeners.
Changes:
- Refactors MCP tests (credential redaction, scope injection, collector helper, error formatting) into more focused theory-driven coverage.
- Consolidates
WithQylTelemetrywrapping tests and keeps emission tests centered on emitted activities/tags. - Tightens GenAI metric selection to avoid cross-test interference when a process-wide
MeterListenercaptures multiple measurements.
Blockers
- None found.
Important issues
- None found.
Minor / optional
- None found.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/qyl.mcp.tests/Tools/SummaryCredentialRedactorTests.cs | Splits redaction coverage into targeted theories for credential patterns, runner token literals, and non-credential passthrough. |
| tests/qyl.mcp.tests/Tools/CollectorHelperTests.cs | Adds baseline success-path assertion; expands cancellation/timeout formatting and prefix behavior coverage. |
| tests/qyl.mcp.tests/Scoping/QylScopeInjectorTests.cs | Refactors to concise tests verifying null passthrough, in-place mutation, caller precedence, and case-insensitive behavior. |
| tests/qyl.mcp.tests/Formatting/ErrorFormatterTests.cs | Expands coverage for HTTP status categorization, transport-specific hints, cancellation vs timeout, and message leakage rules. |
| tests/qyl.collector.tests/Telemetry/GenAiMetricsTests.cs | Narrows duration-metric selection to include key tags, improving isolation under shared metric capture. |
| tests/qyl.collector.tests/Instrumentation/WithQylTelemetryWrapTests.cs | New consolidated tests for wrapping semantics and sensitive-data flag propagation. |
| tests/qyl.collector.tests/Instrumentation/WithQylTelemetryEmissionTests.cs | Keeps emission assertions focused on activities and required tags; reduces coupling to fake response details. |
| tests/qyl.collector.tests/Instrumentation/GenAiInstrumentationTests.cs | Removed in favor of consolidated WithQylTelemetryWrapTests. |
| tests/qyl.collector.tests/Instrumentation/ChatClientToolInstrumentationTests.cs | Removed in favor of consolidated WithQylTelemetryWrapTests. |
| tests/qyl.collector.tests/Ingestion/OtlpConstantsTests.cs | Refactors into parameterized expectations for OTLP path mapping and token-auth bypass defaults. |
Triage Bot report
Threads marked |
1 similar comment
Triage Bot report
Threads marked |
Drop 438 lines of brittle markdown-cosmetic assertions and per-file StubHttpMessageHandler boilerplate. Tests now pin the contract — URL routing, POST payload shape, error-message mapping — via the shared FakeHttpMessageHandler from ANcpLua.Agents.Testing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Triage Bot report
Threads marked |
1 similar comment
Triage Bot report
Threads marked |
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
22 source-generator snapshot tests each repeated the same 25-40 line
Preamble (using directives + Qyl.Instrumentation marker + all attribute
declarations) before its test-specific meter code. Pull the shared
boilerplate into MeterTestSources.{Preamble,InMyAppNamespace} and a
RunAndGetMeter() helper.
Per-test source code now shows only what's unique to that test —
the meter declaration and the instruments under test — instead of
drowning the eye in identical attribute prologues. The two outlier
tests (Private_Nested_Observable, Global_Namespace_Meter_Class) keep
their custom sources verbatim because they stub System.Diagnostics.Metrics
or live outside MyApp.
MeterEmitterTests.cs: 1420 -> 588 lines.
New MeterTestSources.cs: 100 lines.
Net: -732 lines, 21 tests preserved, identical generator coverage.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
…n facts 6 [Fact] methods + 2 [Theory] methods (with 2 rows each) all followed the same shape: POST a JSON body, expect 400, assert error-string fragments. Collapse into one TheoryData<string, string[]> with 10 rows. Same coverage, but a new bound-check case fits on one new line instead of 20. 967 -> 840 lines, all 79 functional tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Same pattern as the metrics consolidation: three functional endpoint test files each had 2-3 isolated rejection facts (POST/GET with different invalid payloads, all expecting 400 + an error-string fragment). Collapse each cluster into one [Theory] with InlineData rows. - ObserveSubscriptionEndpointsTests: 3 facts -> 1 Theory(3) (-45 lines) - SchemaPromotionEndpointsTests: 2 facts -> 1 Theory(2) (-17 lines) - McpMetricsEndpointsTests: 2 facts -> 1 Theory(2) (-14 lines) All 79 functional tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
AL0025 fires as a warning under default Test config but escalates to error under Release because Directory.Build.props enables TreatWarningsAsErrors. The configure lambdas in HappyPathConfigurations and RejectionCases don't capture anything, so qualify them as static. Fixes the docker-e2e Release Compile target that broke on the previous otel.extensions consolidation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
1. e2e-docker.yml: grant `actions: write` so docker/build-push-action can actually export to GHA cache (type=gha silently no-ops without that scope, defeating the cache speedup we just landed). 2. e2e-docker.yml: include core/specs/** in the path filter — TypeSpec changes can ripple into generated outputs that the E2E images compile against, but with the old filter a pure spec PR wouldn't trigger this gate. 3. MetricsToolsTests: align the NotFound theory row's stubbed error body with the metric name the test queries (request_count, not missing_metric). The output formatter happened to interpolate the real name so the assertion still passed, but the inline data was confusing to read. 4. QylOpenTelemetryServiceCollectionExtensionsTests: re-add the explicit `using System.Diagnostics.Metrics;` for human readers. The Common.targets injects it as a global using, so the build was already green — but file-level reviewers (and Copilot) can't see the global and read the file as broken. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
@coderabbitai autofix |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Summary
Verification