feat(azure): reduce time/memory by running specific sub-services by NathanBaulch ยท Pull Request #3451 ยท testcontainers/testcontainers-go
Summary by CodeRabbit
Release Notes
-
New Features
- Added WithEnabledServices option to Azurite for selective Azure Storage service configuration (Blob, Queue, Table)
- Added examples demonstrating service-specific configurations
-
Documentation
- Updated Azurite documentation with WithEnabledServices usage details
Summary by CodeRabbit
-
New Features
- Added
WithEnabledServicesoption to selectively enable specific Azure Storage services (Blob, Queue, Table), reducing resource consumption and exposed ports.
- Added
-
Documentation
- Updated documentation for Azurite container configuration options.
Walkthrough
Run accepts Azurite-specific Options, validates enabled services, builds per-service entrypoint/flags, aggregates exposed ports and wait strategies, and starts the container via testcontainers.Run. Service-to-port resolution was centralized in servicePort; ServiceURL now uses it and per-service URL helpers delegate to ServiceURL.
Changes
| Cohort / File(s) | Change summary |
|---|---|
Core runtimemodules/azure/azurite/azurite.go |
Added servicePort(Service) (nat.Port, error); updated ServiceURL to use it and return via PortEndpoint; removed internal serviceURL helper; refactored Run() to apply Options, compute per-service entrypoint/CLI flags, aggregate WithCmd, WithExposedPorts, and WithWaitStrategy, then call testcontainers.Run. |
Options APImodules/azure/azurite/options.go |
Introduced exported Option type (func(*options) error) with Customize to satisfy testcontainers.ContainerCustomizer; added WithEnabledServices(...) with validation, duplicate check, and defaulting to Blob/Queue/Table; changed options.EnabledServices to []Service. |
Service typesmodules/azure/azurite/services.go |
Simplified to type Service string; exported BlobService, QueueService, TableService as Service constants; removed old alias types and internal constants. |
Tests & examplesmodules/azure/azurite/azurite_test.go, modules/azure/azurite/examples_test.go |
Added TestAzurite_enabledServices to verify enabling/disabling services and ServiceURL behavior; examples updated to call WithEnabledServices(...) for specific services. |
Docs / compile assertionsmodules/azure/eventhubs/options.go, modules/azure/servicebus/options.go, docs/modules/azure.md |
Updated comments and compile-time assertions to reference testcontainers.ContainerCustomizer; docs add WithEnabledServices subsection describing selective service enabling. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant Dev as Caller
participant Run as azurite.Run
participant Opts as Option funcs
participant Builder as module opts builder
participant TC as testcontainers.Run
participant Container as started container
Dev->>Run: Call Run(opts...)
Run->>Opts: Iterate & apply Option funcs (Customize)
Note right of Run #bfe1d6: validate enabled services\n(default blob,queue,table)
Run->>Builder: Build entrypoint/cmd, per-service flags, exposed ports, wait strategies
Builder-->>Run: module customizers (WithCmd, WithExposedPorts, WithWaitStrategy)
Run->>TC: Call testcontainers.Run(module customizers + remaining opts)
TC-->>Container: Return running container or error
Run->>Dev: Return container or wrapped error
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~25 minutes
Possibly related PRs
- chore(meilisearch|memcached|milvus|minio|mockserver|mssql): use Run function #3415 โ Similar refactor pattern: building moduleOpts and calling
testcontainers.Runinstead of constructingGenericContainerRequest. - chore(azurite): use Run function #3318 โ Directly related changes to
modules/azure/azurite/azurite.gorefactoring container construction and option processing. - chore(couchbase|etcd|firestore|mcpgateway|eventhubs|servicebus): apply consistent pattern for options #3447 โ Introduces
Option/WithEnabledServicesand moves early option processing in Azure modules; closely related.
Suggested labels
feature
Suggested reviewers
- mdelapenya
Poem
"I hopped into code with a twitchy nose,
Turned knobs for services that Azurite knows.
Ports aligned and commands in queue,
Containers wake โ a bright debut.
Hop, test, and run โ a rabbit's bravo ๐"
Pre-merge checks and finishing touches
โ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | โ ๏ธ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
โ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title Check | โ Passed | The PR title "feat(azure): reduce time/memory by running specific sub-services" directly and clearly summarizes the main objective of the changeset. The primary change is the introduction of the WithEnabledServices option that allows consumers to select which Azure Storage services (blob, queue, table) to run, rather than always running all three. This enables reduced startup time and memory usage when only specific services are needed. The title is concise, specific, and accurately captures this core improvement without extraneous details. |
| Description Check | โ Passed | The PR description is well-related to the changeset and provides meaningful context. It clearly explains what the PR does (exposing service selection via the options pattern), how it works (using specific entrypoints like azurite-blob or azurite-queue for individual services), and why it matters (faster startup, lower memory, fewer exposed ports). The description includes concrete details such as the 30% startup improvement observed by the author and acknowledges the limitation with azurite-table. The content aligns well with the actual code changes across multiple files, including the new WithEnabledServices option, refactored service URL methods, and updated documentation. |
โจ Finishing touches
- ๐ Generate docstrings
๐งช Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
๐ Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
๐ Files selected for processing (2)
docs/modules/azure.md(1 hunks)modules/azure/azurite/azurite_test.go(1 hunks)
๐ง Files skipped from review as they are similar to previous changes (2)
- modules/azure/azurite/azurite_test.go
- docs/modules/azure.md
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test (1.25.x, modules/azure) / test: modules/azure/1.25.x
- GitHub Check: test (1.24.x, modules/azure) / test: modules/azure/1.24.x
- GitHub Check: Analyze (go)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.