Skip to content

feat(core): DockerCompose.stop now stops only services that it starts (does not stop the other services) - #620

Merged
alexanderankin merged 1 commit into
testcontainers:mainfrom
aksel:stop-services
Jun 27, 2024
Merged

feat(core): DockerCompose.stop now stops only services that it starts (does not stop the other services)#620
alexanderankin merged 1 commit into
testcontainers:mainfrom
aksel:stop-services

Conversation

@aksel

@akselaksel commented Jun 27, 2024

Copy link
Copy Markdown
Contributor

The command would otherwise stop/down all services, not just the services the instance itself started.

Useful for e.g. one fixture per service, and you want different scopes for the services.

…esent.
The command would otherwise stop/down all services, not just the services the instance itself started.
Useful for e.g. one fixture per service, and you want different scopes for the services.
@aksel

Copy link
Copy Markdown
ContributorAuthor

Apologies if my PR breaks any conventions or contribution guidelines. I was a bit confused by the docs, as they seemed to be targeted towards contributing features, which I don't think this is.

Let me know if I should close, resubmit, or change anything

Thanks! 😄

@alexanderankinalexanderankin changed the title DockerCompose.stop: Append self.services to stop/down command when present.feat(core): DockerCompose.stop: Append self.services to stop/down command when present.Jun 27, 2024
@aksel

aksel commented Jun 27, 2024

Copy link
Copy Markdown
ContributorAuthor

My specific use case is this:

importpytestfromtestcontainers.composeimportDockerCompose@pytest.fixture(scope="session")asyncdefaws() ->DockerCompose:
withDockerCompose(
".",
compose_file_name="docker-compose.yaml",
pull=True,
build=True,
services=["aws"],
# Wait for localstack to be healthywait=True,
) ascompose:
yieldcompose@pytest.fixture(scope="module")asyncdefdb(aws) ->DockerCompose:
withDockerCompose(
".",
compose_file_name="docker-compose.yaml",
pull=True,
build=True,
# Only start the DBservices=["db"],
# Wait for the DB to be healthywait=True,
) ascompose:
yieldcompose

Starting up aws takes a while, maybe around 20 seconds, but it can be session scoped and only done once. Until now, both have been session scoped. But now I want to get a clean DB in between modules (or packages, more likely). Nicer isolation and all that. But I couldn't figure out a way to stop onlydb, while keeping aws running. At first glance, seemed like an oversight, so I thought I might as well submit a PR with the two-line change.

@codecov

codecovBot commented Jun 27, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@27f2a6b). Learn more about missing BASE report.

Additional details and impacted files
@@ Coverage Diff @@## main #620 +/- ##
=======================================
Coverage ? 80.29% =======================================
Files ? 11 Lines ? 604 Branches ? 86 =======================================
Hits ? 485 Misses ? 92 Partials ? 27 

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

@alexanderankinalexanderankin changed the title feat(core): DockerCompose.stop: Append self.services to stop/down command when present.feat(core): DockerCompose.stop now stops only services that it starts (does not stop the other services)Jun 27, 2024
@alexanderankin
alexanderankin merged commit e711800 into testcontainers:mainJun 27, 2024
@aksel
aksel deleted the stop-services branch June 27, 2024 15:33
alexanderankin pushed a commit that referenced this pull request Jun 28, 2024
🤖 I have created a release *beep* *boop*
---
##
[4.7.0](testcontainers-v4.6.0...testcontainers-v4.7.0)
(2024-06-28)
### Features
* **core:** Added Generic module
([#612](#612))
([e575b28](e575b28))
* **core:** allow custom dockerfile path for image build and bypassing
build cache
([#615](#615))
([ead0f79](ead0f79)),
closes
[#610](#610)
* **core:** DockerCompose.stop now stops only services that it starts
(does not stop the other services)
([#620](#620))
([e711800](e711800))
### Bug Fixes
* **ollama:** Add support for ollama module
([#618](#618))
([5442d05](5442d05))
* **cosmosdb:** Add support for the CosmosDB Emulator
([#579](#579))
([8045a80](8045a80))
* improve ollama docs, s/ollama_dir/ollama_home/g
([#619](#619))
([27f2a6b](27f2a6b))
* **kafka:** Add Kraft to Kafka containers
([#611](#611))
([762d2a2](762d2a2))
### Documentation
* **contributing:** add contribution and new-container guide
([#460](#460))
([3519f4b](3519f4b))
---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for freeto 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.

2 participants

@aksel@alexanderankin