Internal - Refactor Agent Integration Tests to Remove Backend Dependency#491
Internal - Refactor Agent Integration Tests to Remove Backend Dependency#491cleverchuk wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors agent integration tests to remove the live SolarWinds backend dependency. A new in-process testing/feature-tests module uses OTel's AgentInstrumentationExtension plus a TestSettingsReader (injected via a new TestAgentListener) to assert agent behavior locally. Old backend-driven smoke tests, the Lambda smoke test, and the corresponding k6 scenarios / CI workflow are deleted; Spring MVC instrumentation gets co-located handler-name tests.
Changes:
- Adds
testing/feature-testswith 7 in-process feature test classes; replacesTestSamplershort-circuit with real-sampler-plus-TestSettingsReadersetup via a newTestAgentListener. - Adds
HandlerNameInstrumentationTestin bothspring-webmvc-3.1andspring-webmvc-6javaagent submodules and enables profiler/strict-context flags in the instrumentation test convention. - Removes redundant smoke tests, the entire
LambdaTest/SmokeTestV2flows, related k6 functions, thelambda-test.ymlworkflow, and thecleanListedDependenciestest finalizer.
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| testing/feature-tests/build.gradle.kts | New module Gradle script; depends on shadowJar and Java 17 |
| testing/feature-tests/src/test/.../ContextPropagationTest.java | Asserts W3C+sw tracestate injection |
| testing/feature-tests/src/test/.../SdkTracingTest.java | Manual SDK span / stacktrace / service.name asserts (two tests near-duplicate) |
| testing/feature-tests/src/test/.../TriggerTraceTest.java | Asserts X-Trace-Options attributes on root span |
| testing/feature-tests/src/test/.../TransactionNamingTest.java | Asserts SDK transaction-name attribute |
| testing/feature-tests/src/test/.../TransactionFilteringTest.java | URL-based filter via SettingsManager.initialize; tearDown does not reset config |
| testing/feature-tests/src/test/.../MetricsGenerationTest.java | Seven near-identical per-metric tests |
| testing/feature-tests/src/test/.../ProfilingSpanProcessorTest.java | Uses Thread.sleep; strict equality assertion on profile span count |
| testing/agent-test-extension/.../TestAutoConfigurationCustomizer.java | customize() no longer uses its parameter; duplicates listener setup |
| testing/agent-test-extension/.../TestAgentListener.java | Waits for AgentState.READY then installs test settings |
| testing/agent-test-extension/.../TestSampler.java | Deleted |
| testing/agent-test-extension/build.gradle.kts | Adds compileOnly deps for new listener |
| instrumentation/spring-webmvc/spring-webmvc-3.1/javaagent/... | New handler-name test + tests built against Spring 5.3.30 (not 3.1) |
| instrumentation/spring-webmvc/spring-webmvc-6/javaagent/... | New handler-name test (mirrors v3.1 version) |
| buildSrc/.../solarwinds.instrumentation-conventions.gradle.kts | Adds strict-context, profiler, and stacktrace JVM args globally |
| build.gradle.kts | Removes Test→cleanListedDependencies finalizer |
| settings.gradle.kts | Registers testing:feature-tests |
| smoke-tests/src/test/java/com/solarwinds/SmokeTest.java | Removes tests that moved in-process |
| smoke-tests/src/test/java/com/solarwinds/SmokeTestV2.java | Removes redundant tests |
| smoke-tests/src/test/java/com/solarwinds/LambdaTest.java | Deleted |
| smoke-tests/k6/basic.js | Removes large k6 verification helpers; tightens load options |
| .github/workflows/lambda-test.yml | Workflow deleted |
Comments suppressed due to low confidence (3)
testing/feature-tests/src/test/java/com/solarwinds/opentelemetry/instrumentation/feature/test/ProfilingSpanProcessorTest.java:63
- The
.as(...)description "sw.profile.spans attribute should be set 1" reads awkwardly. Consider rewording to e.g. "sw.profile.spans attribute should equal 1" so the failure message is clearer.
assertThat(profileSpans).as("sw.profile.spans attribute should be set 1").isEqualTo(1);
testing/feature-tests/src/test/java/com/solarwinds/opentelemetry/instrumentation/feature/test/MetricsGenerationTest.java:93
verifyTokenbucketExhaustionCountMetricIsReportedasserts that thetrace.service.tokenbucket_exhaustion_countmetric is reported after a single successful span. Token-bucket exhaustion typically only happens when the sampler is rate-limited; with the always-sample settings used in this suite (rate = 1,000,000) this metric may or may not be emitted at all, making the test fragile. Please verify this metric is unconditionally emitted on every span flush; otherwise the test will become intermittently failing.
@Test
void verifyTokenbucketExhaustionCountMetricIsReported() {
Tracer tracer = GlobalOpenTelemetry.get().getTracer("test");
Span span =
tracer.spanBuilder("GET /petclinic/api/pettypes").setSpanKind(SpanKind.SERVER).startSpan();
span.end();
testing.waitForTraces(1);
await()
.atMost(5, TimeUnit.SECONDS)
.untilAsserted(
() -> {
List<MetricData> metrics = testing.metrics();
assertThat(metrics)
.as("trace.service.tokenbucket_exhaustion_count metric should be reported")
.anyMatch(m -> m.getName().equals("trace.service.tokenbucket_exhaustion_count"));
});
}
testing/agent-test-extension/src/main/java/com/solarwinds/opentelemetry/extensions/TestSampler.java:1
TestSamplerwas the only consumer of theSolarwindsSamplersubclass extension point used by the test extension. With it deleted, sampling now goes through the realSolarwindsSampler. Please confirm there are no other tests or wiring referencingTestSampler(e.g. in resources/META-INF service files) that should also be cleaned up.
Summary
Replaces the existing smoke/e2e integration test suite with a new
feature-testsmodule (testing/feature-tests) that uses the OTelAgentInstrumentationExtensionto test agent behavior in-process. The old tests required a live SolarWinds backend, a k6 load driver, and sometimes a cloud environment just to assert correctness of agent internals. The new tests are self-contained: they run with the real agent loaded but intercept spans and metrics locally, removing all external dependencies from the core feature verification loop. Smoke tests whose coverage is now redundant are removed, and the Lambda CI workflow is also removed for the same reason. Some tests with external dependencies remain unchanged.What Changed and Why
Replacing backend-dependent tests with in-process feature tests
The previous approach validated agent behavior by sending traffic through a full stack (k6 → app → SolarWinds backend) and then asserting on JSON result files. This made tests slow, and fragile. The new
feature-testsmodule usesAgentInstrumentationExtension— the standard OTel test harness — which intercepts spans, metrics, and context directly in the test JVM. This lets each test assert on the exact OTel data structures the agent produces, without any network calls.Seven feature areas are covered:
ContextPropagationTesttraceparentand SolarWindssw=tracestateheader injectionSdkTracingTestTriggerTraceTestX-Trace-Optionstrigger-trace header stamps the expected attributes on the root spanTransactionNamingTestTransactionFilteringTestMetricsGenerationTestProfilingSpanProcessorTestSampling setup: real sampler path instead of a bypass
The test extension previously installed a
TestSamplerthat short-circuited sampling entirely, bypassing settings. The replacement usesTestUtils.initSettingsReader()to inject aTestSettingsReaderwith always-sample settings (rate = 1_000_000, flags(true, false, true, true, false)) directly into the production sampler. A newTestAgentListener(ordered last viaorder = Integer.MAX_VALUE) waits forAgentState.READYbefore injecting these settings, so the real startup sequence runs to completion before the test configuration is applied.Co-located Spring MVC instrumentation tests
New
HandlerNameInstrumentationTestclasses are added inside thespring-webmvc-3.1andspring-webmvc-6javaagent submodules, keeping instrumentation-level tests alongside the instrumentation code they cover.Cleanup
SmokeTestcases whose coverage moved tofeature-tests(transaction filtering, JDBC, trigger trace, context propagation, transaction naming, metrics, profiling, SDK tracing) are deleted outright. What remains inSmokeTestare tests that are genuinely environment-specific and can't run in-process: proxy usage, log export to the backend, OTel metric export, and cloud metadata checks.SmokeTestV2,LambdaTest, and the corresponding k6 scenarios are deleted in full — they either duplicated the new tests or validated backend connectivity rather than agent correctness. Thelambda-test.ymlCI workflow and the top-level build reference to the removed module are also deleted.Test services data