Skip to content

Move most of the remaining tests to Test Containers as well#1785

Open
siri-varma wants to merge 19 commits into
dapr:masterfrom
siri-varma:users/svegiraju/finish-testcontainers-migration
Open

Move most of the remaining tests to Test Containers as well#1785
siri-varma wants to merge 19 commits into
dapr:masterfrom
siri-varma:users/svegiraju/finish-testcontainers-migration

Conversation

@siri-varma

@siri-varma siri-varma commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description

Finishes migrating the sdk-tests integration tests off the legacy dapr run CLI harness and onto Testcontainers (BaseContainerIT / DaprContainer), and strips the now-unused legacy setup from the build CI job. This removes the slow, flaky host-daprd path that was driving the build sb:3.5.x job toward its timeout.

What changed

Test migration (last legacy ITs → Testcontainers)

  • Migrated the remaining CLI-based ITs: ActorReminderRecoveryIT, ActorReminderFailoverIT, WaitForSidecarIT, BindingIT (now Testcontainers Kafka + in-code bindings), and ActorSdkResiliencyIT (moved off ToxiProxyRun; still @Disabled).
  • Added reusable mechanics to BaseContainerIT: startAppAndAttach (app subprocess + pinned-port daprd), restartApp / restartSidecar, waitForActorsReady, and newToxiproxy (Testcontainers ToxiProxy for network-fault injection — replaces the host-installed binary; same toxics, now hermetic and version-pinned).
  • Centralized shared backing services in SharedTestInfra: one Docker Network + JVM-singleton Redis / Zipkin / Mongo / Kafka.

Actor IT flakiness fix — shared control plane (DNS-alias collision)

  • Root cause: every actor IT attaches daprd to the JVM-wide shared Network. The builder used withReusablePlacement(true); with Testcontainers reuse disabled (as on CI), DaprContainer.configure() auto-creates a placement and scheduler per daprd instance — each claiming the placement / scheduler network alias and never stopped (no stop() override). Multiple containers answering one alias make Docker DNS round-robin daprd to an arbitrary/empty control plane, so multi-sidecar failover (ActorReminderFailoverIT) and post-restart reminder recovery (ActorReminderRecoveryIT) hit a placement that never saw the actor-host registrations → did not find address for actor / reminders not resumed.
  • Fix: JVM-singleton placement() / scheduler() in SharedTestInfra on the shared network, wired into every daprd via withPlacementContainer / withSchedulerContainer. Exactly one container answers each alias, so DNS resolves deterministically; this also removes the per-daprd control-plane container leak.

CI cleanup

  • Dropped Dapr CLI + dapr init, host Kafka, and host ToxiProxy setup from the build job.
  • Removed the dead dapr run harness, binding YAMLs, and local-test.yml.

Issue reference

Closes #1522

Test results

  • Actor package: greenActorReminderRecoveryIT (4/4) and ActorReminderFailoverIT (1/1), which failed deterministically before the fix, now pass both in isolation and in the full suite.
  • tracing.http.TracingIT: fixed. Its Spring @Bean app eagerly called the legacy OpenTelemetry.createOpenTelemetry(SERVICE_NAME) overload, which probes a fixed 127.0.0.1:9411 for Zipkin readiness. After this migration Zipkin runs as a Testcontainer on a random mapped host port, so the probe threw ConnectException, the app subprocess crashed before binding its port, and startAppAndAttach reported "connection refused". Switched the bean to the explicit-endpoint overload that skips the probe (the app exports no spans the test asserts on — the validated calllocal/tracing-http-it/sleep span is emitted by the sidecar over the container network). Passes in isolation.
  • Full sdk-tests suite (local): 7 → 1 error. All four actor errors resolved by the control-plane fix; TracingIT.http resolved by the bean fix above.
  • 1 remaining local failure (spring.messaging.DaprSpringMessagingIT) is a topic-subscription readiness timeout. It reproduces even in isolation and is independent of this PR — it is a standalone @SpringBootTest that manages its own container and touches none of the code changed here. It appears environment-sensitive on a local macOS Docker host (uses host.testcontainers.internal); CI on this PR is the arbiter for whether it affects the target environment. Tracked as follow-up, not introduced here.

Checklist

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

siri-varma added 14 commits July 9, 2026 17:08
…acy CI

Migrates the last 7 sdk-tests ITs off the dapr-run CLI harness onto
BaseContainerIT/DaprContainer so the build job can drop the Dapr CLI,
dapr init/uninstall, host Kafka, and host ToxiProxy setup. Covers the
app-restart, sidecar-restart, multi-sidecar failover, ToxiProxy, and
Kafka mechanics, plus CI and dead-code cleanup. Addresses dapr#1522.

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
…eck invariant, reminder client, explicit YAML cleanup

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
… type name

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
…ecar helper)

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
…cement/scheduler)

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Every migrated actor IT attaches daprd to the JVM-wide shared Network.
The builder previously used withReusablePlacement(true); with
Testcontainers reuse disabled (as on CI), DaprContainer.configure()
auto-creates a placement + scheduler per daprd instance -- each claiming
the "placement"/"scheduler" network alias and never stopped (no stop()
override). Multiple containers answering one alias make Docker DNS
round-robin daprd to an arbitrary/empty control plane, so multi-sidecar
failover (ActorReminderFailoverIT) and post-restart reminder recovery
(ActorReminderRecoveryIT) hit a placement that never saw the actor-host
registrations -> "did not find address for actor" / reminder not resumed.

Introduce JVM-singleton placement()/scheduler() in SharedTestInfra on the
shared network and wire every daprd to them via withPlacementContainer/
withSchedulerContainer. Exactly one container answers each alias, so DNS
resolves deterministically; this also eliminates the per-daprd
control-plane container leak.

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
@siri-varma siri-varma requested review from a team as code owners July 10, 2026 04:39
These were working documents for the Testcontainers migration and are not
part of the shipped SDK; dropping them from the PR.

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
The http tracing test app's Spring @bean OpenTelemetryConfig.initOpenTelemetry()
called the legacy io.dapr.it.tracing.OpenTelemetry.createOpenTelemetry(SERVICE_NAME)
overload, which runs waitForZipkin() -> NetworkUtils.waitForSocket(127.0.0.1, 9411).
After the Testcontainers migration Zipkin runs on a random mapped host port, not a
fixed 9411, so that probe threw ConnectException, bean creation failed, the app
subprocess never bound its port, and startAppAndAttach reported connection refused.

Switch to the two-arg createOpenTelemetry(SERVICE_NAME, url) overload that skips
the probe. The app exports no spans the test asserts on -- the validated
calllocal/tracing-http-it/sleep span is emitted by the Dapr sidecar, which exports
to Zipkin over the container network -- so the app only needs to boot.

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
@siri-varma siri-varma changed the title Make Integration Tests Faster Move most of the remaining tests to Test Containers as well Jul 10, 2026
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
…g config

The prior "Optimize docs" commit switched the job to javadoc:aggregate,
but that goal does not apply the pom's <reporting> configuration --
additionalDependencies (spring-data-commons/keyvalue) and
excludePackageNames -- so aggregate Javadoc fails to resolve spring-data
symbols (TypeInformation, PropertyPath) and the build errors out.

Revert the step to site-deploy, which runs Javadoc as a site report so
that config applies. The actual speedup is unchanged: <inherited>false>
on the aggregate report (in the same "Optimize docs" commit) stops the
report re-executing once per reactor module -- the source of the ~32 min
runtime -- so it now runs a single aggregate pass.

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Comment thread pom.xml
<!-- Aggregate is a root-only report. Without inherited=false the site
lifecycle re-runs it at every reactor module, multiplying a full-source
Javadoc pass ~10x. Keep it pinned to the aggregator module. -->
<inherited>false</inherited>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javier-aliaga / @cicoyle Please double check this change.

We are able to save 30 mins because of this change. It was taking 32 mins before now just takes 4 mins

@siri-varma

Copy link
Copy Markdown
Contributor Author

@javier-aliaga need one review on this pr please

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.06%. Comparing base (26b2327) to head (c7fdb76).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1785      +/-   ##
============================================
+ Coverage     77.02%   77.06%   +0.04%     
  Complexity     2324     2324              
============================================
  Files           245      245              
  Lines          7198     7198              
  Branches        760      760              
============================================
+ Hits           5544     5547       +3     
+ Misses         1288     1285       -3     
  Partials        366      366              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the migration of sdk-tests integration tests from the legacy dapr run CLI harness to a Testcontainers-based harness (BaseContainerIT / DaprContainer), while also removing now-unused legacy CI setup to reduce build flakiness/timeouts.

Changes:

  • Migrated remaining CLI-harness integration tests and app fixtures to Testcontainers, removing DaprRun/BaseIT/@DaprRunConfig and introducing container-native equivalents (app subprocess + sidecar container).
  • Introduced JVM-singleton shared test infrastructure (SharedTestInfra) for backing services and a single shared Dapr placement/scheduler to prevent Docker network-alias DNS collisions across multiple sidecars.
  • Simplified CI by removing Dapr CLI/runtime init and host-managed Kafka/ToxiProxy setup; added Maven caching for docs validation and prevented repeated aggregate Javadoc generation across reactor modules.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sdk-tests/src/test/java/io/dapr/it/tracing/http/Service.java Removes legacy @DaprRunConfig usage for the tracing HTTP test service.
sdk-tests/src/test/java/io/dapr/it/tracing/http/OpenTelemetryConfig.java Avoids startup-blocking Zipkin readiness probe by switching to the explicit-endpoint OpenTelemetry factory overload.
sdk-tests/src/test/java/io/dapr/it/tracing/grpc/Service.java Removes legacy @DaprRunConfig usage for the tracing gRPC test service.
sdk-tests/src/test/java/io/dapr/it/ToxiProxyRun.java Deletes legacy host-binary ToxiProxy runner in favor of Testcontainers ToxiProxy.
sdk-tests/src/test/java/io/dapr/it/resiliency/WaitForSidecarIT.java Migrates waitForSidecar resiliency test to Testcontainers + ToxiProxyContainer.
sdk-tests/src/test/java/io/dapr/it/methodinvoke/http/MethodInvokeService.java Removes legacy @DaprRunConfig usage for method-invoke HTTP service.
sdk-tests/src/test/java/io/dapr/it/methodinvoke/grpc/MethodInvokeService.java Removes legacy @DaprRunConfig usage for method-invoke gRPC service.
sdk-tests/src/test/java/io/dapr/it/DaprRunConfig.java Deletes legacy annotation configuration used by the CLI harness.
sdk-tests/src/test/java/io/dapr/it/DaprRun.java Deletes legacy dapr run CLI harness implementation.
sdk-tests/src/test/java/io/dapr/it/containers/SharedTestInfra.java Adds shared Docker network + singleton Redis/Zipkin/Mongo/Kafka plus singleton placement/scheduler containers.
sdk-tests/src/test/java/io/dapr/it/containers/BaseContainerIT.java Adds helpers for app+sidecar lifecycle, shared control plane wiring, sidecar/app restart helpers, ToxiProxy helper, and Kafka/HTTP binding component helpers.
sdk-tests/src/test/java/io/dapr/it/binding/http/BindingIT.java Migrates binding integration tests to Testcontainers and in-code component creation (Kafka + HTTP binding).
sdk-tests/src/test/java/io/dapr/it/BaseIT.java Deletes legacy base test harness used by CLI-based ITs.
sdk-tests/src/test/java/io/dapr/it/actors/services/springboot/StatefulActorService.java Removes legacy @DaprRunConfig usage for actor service fixture.
sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorService.java Removes legacy @DaprRunConfig usage for actor service fixture.
sdk-tests/src/test/java/io/dapr/it/actors/ActorTimerRecoveryIT.java Migrates timer recovery test to BaseContainerIT + app subprocess attach model.
sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java Migrates actor state test to BaseContainerIT + app subprocess attach model.
sdk-tests/src/test/java/io/dapr/it/actors/ActorSdkResiliencyIT.java Replaces host ToxiProxy usage with Testcontainers ToxiProxy and migrates to container harness (still disabled).
sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderRecoveryIT.java Migrates reminder recovery test to container harness and uses restartSidecar helper.
sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderFailoverIT.java Migrates multi-sidecar failover test to shared placement/scheduler model to avoid alias collisions.
sdk-tests/pom.xml Adds testcontainers-kafka test dependency.
sdk-tests/deploy/local-test.yml Removes legacy local docker-compose harness no longer needed.
sdk-tests/components/kafka_bindings.yaml Removes legacy YAML component config (now created in code).
sdk-tests/components/http_binding.yaml Removes legacy YAML component config (now created in code).
pom.xml Prevents aggregate Javadoc report from running in every reactor module (<inherited>false</inherited>).
.github/workflows/validate-docs.yml Enables Maven cache for docs validation workflow.
.github/workflows/build.yml Removes legacy Dapr CLI/runtime init and host Kafka/ToxiProxy setup from CI build job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize CI/CD build times - Integration tests timing

2 participants