Skip to content

Add docker related unit tests in new projects#825

Merged
rujche merged 25 commits intomainfrom
rujche/main/add-unit-test-about-docker-in-new-projects
Mar 12, 2026
Merged

Add docker related unit tests in new projects#825
rujche merged 25 commits intomainfrom
rujche/main/add-unit-test-about-docker-in-new-projects

Conversation

@rujche
Copy link
Contributor

@rujche rujche commented Feb 26, 2026

@rujche rujche self-assigned this Feb 26, 2026
@rujche rujche marked this pull request as ready for review February 26, 2026 07:08
@rujche rujche requested a review from a team as a code owner February 26, 2026 07:08
@rujche rujche requested a review from Copilot February 26, 2026 08:04
Copy link

Copilot AI left a comment

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 adds comprehensive Docker-related unit tests for Azure Spring Cloud services using both Testcontainers and Docker Compose approaches. The PR introduces integration tests for Azure Cosmos DB, Storage Blob, Storage Queue, Service Bus, and Event Hubs across multiple API patterns (client libraries, spring-messaging, and spring-cloud-stream-binders). According to the PR description, this work depends on spring-cloud-azure 7.1.0 which is not yet released.

Changes:

  • Added Testcontainers integration tests for 7 service/API combinations
  • Added Docker Compose integration tests for 5 service/API combinations
  • Removed <name> elements from existing testcontainers POM files
  • Updated root pom.xml to include all new test modules
  • Added README documentation for testcontainers samples

Reviewed changes

Copilot reviewed 38 out of 42 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
spring-cloud-azure-testcontainers/storage-queue/src/test/java/StorageQueueTestcontainersTest.java Storage Queue testcontainer integration test
spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java Storage Blob testcontainer integration test
spring-cloud-azure-testcontainers/cosmos/src/test/java/CosmosTestcontainersTest.java Cosmos DB testcontainer integration test
spring-cloud-azure-testcontainers/service-bus/spring-messaging/src/test/java/ServiceBusTestContainerTest.java Service Bus spring-messaging testcontainer integration test
spring-cloud-azure-testcontainers/service-bus/spring-cloud-stream-binders/src/test/java/ServiceBusTestContainerTest.java Service Bus stream binder testcontainer integration test
spring-cloud-azure-testcontainers/event-hubs/client/src/test/java/EventHubsTestContainerTest.java Event Hubs client testcontainer integration test
spring-cloud-azure-testcontainers/event-hubs/spring-cloud-stream-binders/src/test/java/EventHubsTestContainerTest.java Event Hubs stream binder testcontainer integration test
spring-cloud-azure-docker-compose/storage-queue/src/test/java/StorageQueueDockerComposeTest.java Storage Queue docker-compose integration test
spring-cloud-azure-docker-compose/storage-blob/src/test/java/AzureBlobResourceDockerComposeTest.java Storage Blob docker-compose integration test
spring-cloud-azure-docker-compose/service-bus/spring-messaging/src/test/java/ServiceBusDockerComposeTest.java Service Bus spring-messaging docker-compose test
spring-cloud-azure-docker-compose/service-bus/spring-cloud-stream-binders/src/test/java/ServiceBusDockerComposeTest.java Service Bus stream binder docker-compose test
spring-cloud-azure-docker-compose/event-hubs/client/src/test/java/EventHubsDockerComposeTest.java Event Hubs client docker-compose test
spring-cloud-azure-docker-compose/event-hubs/spring-cloud-stream-binders/src/test/java/EventHubsDockerComposeTest.java Event Hubs stream binder docker-compose test
spring-cloud-azure-testcontainers/README.md Documentation for testcontainers samples
Multiple pom.xml files Build configurations with dependencies for all test modules
Multiple Config.json files Service Bus and Event Hubs emulator configuration
Multiple *-compose.yaml files Docker Compose service definitions
pom.xml Root POM updated to include all new modules

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 42 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (7)

spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:37

  • Inconsistent test method visibility: The test method uses package-private visibility (no modifier), while other similar test files in this PR use public visibility (e.g., CosmosTestcontainersTest.java line 69). For consistency across the codebase, test methods should use the same visibility modifier. Either make this method public to match CosmosTestcontainersTest, or update the other tests to use package-private visibility following JUnit 5 conventions.
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:37
  • Inconsistent test method name: The test method name "test" is too generic and doesn't describe what is being tested. Other test files in this PR use more descriptive names like "queueClientShouldSendAndReceiveMessage", "connectionDetailsShouldBeProvidedByFactory", etc. Rename this method to something more descriptive like "blobResourceShouldWriteAndReadContent" to follow the naming conventions in the codebase.
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:25
  • Inconsistent class name: The class name "AzureBlobResourceTestContainerTest" doesn't match the file name "StorageBlobTestcontainersTest.java". The class name should match the file name. Additionally, "TestContainer" should be "Testcontainers" (one word) to match the naming pattern used in other test files like StorageQueueTestcontainersTest, CosmosTestcontainersTest, etc. Rename the class to "StorageBlobTestcontainersTest".
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:23
  • Inconsistent test annotation: The test uses @SpringJUnitConfig which is different from the pattern used in StorageQueueTestcontainersTest which uses @SpringBootTest with @ExtendWith(SpringExtension.class). While @SpringJUnitConfig is valid, the inconsistency in test setup across similar storage tests may cause confusion. For consistency, consider using @SpringBootTest with @ExtendWith(SpringExtension.class) as in the storage queue test, unless there's a specific reason for the difference.
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:31
  • The Azurite command is invalid and will cause the container to fail at startup. The command "azurite --skipApiVersionCheck && azurite -l /data --blobHost 0.0.0.0 --queueHost 0.0.0.0 --tableHost 0.0.0.0" starts Azurite twice in sequence using shell chaining (&&), which is incorrect. The container should use a single Azurite command. Based on the pattern in other tests, this should be either "azurite-blob --blobHost 0.0.0.0 --skipApiVersionCheck" for blob-only, or "azurite -l /data --blobHost 0.0.0.0 --queueHost 0.0.0.0 --tableHost 0.0.0.0 --skipApiVersionCheck" for all services.
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:1
  • Missing copyright header. The file should start with the Microsoft copyright and license notice, as seen in other test files in this PR. Add the following at the top of the file:
    // Copyright (c) Microsoft Corporation. All rights reserved.
    // Licensed under the MIT License.
    spring-cloud-azure-testcontainers/cosmos/pom.xml:21
  • Unused property: The property 'version.spring.boot' is defined with value '3.4.0' but is never used in this POM file. The parent already defines Spring Boot version 4.0.3, so this property serves no purpose. Remove this unused property to avoid confusion.

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

@rujche rujche requested a review from Copilot February 26, 2026 09:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 42 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (5)

spring-cloud-azure-testcontainers/cosmos/pom.xml:22

  • The property version.spring.boot is set to 3.4.0 but the project inherits from spring-boot-starter-parent 4.0.3, and the property doesn’t appear to be used anywhere in this POM. Removing the unused property (or aligning it with the parent if it’s meant to be used) will avoid confusion.
    spring-cloud-azure-testcontainers/storage-queue/pom.xml:22
  • This module now pins Spring Cloud Azure to 7.1.0. Per the PR description, 7.1.0 isn’t released yet, so Maven resolution (and CI) will fail until that artifact is published. Consider keeping 7.0.0 for now (or using an explicit snapshot/repository if you truly need unreleased bits) and updating to 7.1.0 once it’s available.
    spring-cloud-azure-testcontainers/cosmos/pom.xml:22
  • This module now depends on Spring Cloud Azure 7.1.0. If that version is not yet released, Maven/CI will fail resolving spring-cloud-azure-dependencies. Consider keeping the released version until 7.1.0 is available (or explicitly configuring snapshot repos if using pre-release artifacts).
    spring-cloud-azure-testcontainers/storage-blob/pom.xml:22
  • This module now pins Spring Cloud Azure to 7.1.0. If 7.1.0 isn’t published yet (as noted in the PR description), builds will fail due to an unresolvable dependency. Prefer sticking to the currently released version (e.g., 7.0.0) until 7.1.0 is available, or explicitly use a snapshot + repository if required.
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:31
  • The azurite container command includes shell syntax ("&&") and starts azurite twice. Testcontainers passes the command directly to the container entrypoint, so this will not be interpreted by a shell and is likely to fail container startup. Use a single azurite command/args (e.g., set host bindings and --skipApiVersionCheck) rather than chaining commands.

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 42 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (7)

spring-cloud-azure-testcontainers/cosmos/pom.xml:22

  • version.spring.cloud.azure is set to 7.1.0, but the PR description notes 7.1.0 isn't released yet. Merging with this version will break builds until the dependency is available. Consider staying on 7.0.0 (or another resolvable version) and bumping after 7.1.0 is released.
    spring-cloud-azure-testcontainers/storage-queue/pom.xml:23
  • version.spring.cloud.azure is set to 7.1.0, but the PR description indicates 7.1.0 is not released yet. As-is, this will fail dependency resolution in CI until that version is available. Consider keeping these modules on the repo’s current Spring Cloud Azure version (7.0.0) or using a -SNAPSHOT/version property that is available in your build until 7.1.0 is released.
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:31
  • GenericContainer.withCommand(...) does not run through a shell, so chaining commands with && (and passing the whole command as a single string) will not behave as intended and will likely prevent Azurite from starting. Pass the command as separate arguments (single Azurite invocation) or explicitly run a shell entrypoint if you truly need command chaining.
    spring-cloud-azure-testcontainers/storage-blob/pom.xml:23
  • The tests in this module import org.springframework.boot.testcontainers.service.connection.ServiceConnection, but this POM doesn't declare spring-boot-testcontainers (unlike the other testcontainers sample modules in this PR). Add spring-boot-testcontainers (test scope) or switch to spring-boot-starter-test + spring-boot-testcontainers to ensure the @ServiceConnection API is available at compile/runtime without relying on transitive dependencies.
    spring-cloud-azure-testcontainers/storage-queue/pom.xml:23
  • The tests in this module use Spring Boot Testcontainers @ServiceConnection, but this POM doesn't declare spring-boot-testcontainers (and it also only brings in junit-jupiter-api, which may lead to tests not running if the Jupiter engine isn't present). Consider aligning with the other modules here by using spring-boot-starter-test + spring-boot-testcontainers (test scope).
    spring-cloud-azure-testcontainers/cosmos/pom.xml:22
  • This module’s tests import Spring Boot’s @ServiceConnection, but the POM doesn’t include spring-boot-testcontainers (test scope). Without it, compilation can fail depending on transitive dependency resolution. Add spring-boot-testcontainers (or use spring-boot-starter-test + spring-boot-testcontainers like the other emulator-based modules in this PR).
    spring-cloud-azure-testcontainers/storage-blob/pom.xml:23
  • version.spring.cloud.azure is set to 7.1.0, but the PR description indicates 7.1.0 is not released yet. This will fail dependency resolution in CI until the artifact is published. Consider keeping this at 7.0.0 for now (or using an available snapshot) and updating once 7.1.0 is released.

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

…zureBlobResourceDockerComposeTest.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 42 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:31

  • GenericContainer.withCommand(...) does not run in a shell, so using '&&' here will not work (it will be passed as a literal arg and Azurite won’t start). Replace this with a single executable + arguments (e.g., run 'azurite' once with the needed flags), or use an explicit shell entrypoint if you truly need shell operators.
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:26
  • The file is named StorageBlobTestcontainersTest.java but the test class is AzureBlobResourceTestContainerTest. Even though it compiles (non-public class), this makes the test harder to find and is inconsistent with typical Java/test discovery conventions; consider renaming the class to match the filename (or vice versa).

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 42 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (2)

spring-cloud-azure-testcontainers/storage-queue/pom.xml:23

  • This module pins Spring Cloud Azure to 7.1.0 while most other samples in this repo are still on 7.0.0. Until the repo-wide version is bumped (and 7.1.0 is available in the configured repositories), this module will be hard to build in the reactor; consider aligning to the repo’s current version or centralizing the version in a parent property so all modules move together.
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:31
  • GenericContainer.withCommand(...) does not run through a shell, so passing a single string with spaces/"&&" will be treated as one argument and likely fail to start Azurite. Provide the command as separate arguments (single azurite invocation) instead of using shell operators.

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 42 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:31

  • GenericContainer.withCommand(...) does not run through a shell; passing a single string containing && will be treated as a literal command/args and will fail to start Azurite. Use a single Azurite invocation with proper arguments (e.g., command + args), or explicitly run a shell (/bin/sh -c ...) if you truly need chaining.
    spring-cloud-azure-testcontainers/storage-blob/src/test/java/StorageBlobTestcontainersTest.java:26
  • The class name AzureBlobResourceTestContainerTest does not match the filename StorageBlobTestcontainersTest.java, which makes the sample harder to discover/grep and inconsistent with the other test class naming in this PR. Consider renaming the class or the file so they match.

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

@rujche rujche marked this pull request as draft February 27, 2026 07:07
saragluna
saragluna previously approved these changes Mar 2, 2026
Copy link
Contributor

@saragluna saragluna left a comment

Choose a reason for hiding this comment

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

LGTM

@rujche rujche marked this pull request as ready for review March 12, 2026 01:30
@rujche rujche merged commit 46d2beb into main Mar 12, 2026
10 checks passed
@rujche rujche deleted the rujche/main/add-unit-test-about-docker-in-new-projects branch March 12, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants