Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement]: Expose the compose recreate options #1276

Closed
rach-id opened this issue Jun 3, 2023 · 1 comment · Fixed by #2511
Closed

[Enhancement]: Expose the compose recreate options #1276

rach-id opened this issue Jun 3, 2023 · 1 comment · Fixed by #2511
Assignees
Labels
enhancement New feature or request

Comments

@rach-id
Copy link

rach-id commented Jun 3, 2023

Proposal

Currently, the implementation uses by default the "diverged" recreate strategy for docker-compose setups, and doesn't provide a way to override that:

Recreate: api.RecreateDiverged,
RecreateDependencies: api.RecreateDiverged,

Does it make sense to also provide these as options?

The issue I am facing is when trying to start the compose setup incrementally, i.e. start a container, run some tests, start another container that uses the first one as a dependency and run some other tests. This gives me the following errors:

  • if I specify the container dependencies as part of RunServices (deps), it fails with The container name "..." is already in use by container
  • If I dont, I get the no such service: ... error

So, I guess if we have the Recreate and RecreateDependencies options exposed, that would help with this, and also allow for more flexible testing setups.

@mdelapenya
Copy link
Member

mdelapenya commented Aug 30, 2023

Hey @sweexordious thanks for opening this issue. I'm currently triaging the repo, focusing on compose stuff.

I think you could achieve it if we exposed the stackUpOptionFunc and stackUpOptions types:

import tccompose "github.com/testcontainers/testcontainers-go/modules/compose"
...

	recreateForceFn := func() tccompose.StackUpOption {
		// At this moment, the types are not exported: 
		// return tccompose.stackUpOptionFunc(func(o *tccompose.stackUpOptions) {
		return tccompose.StackUpOptionFunc(func(o *tccompose.StackUpOptions) {
			o.Recreate = api.RecreateForce
			o.RecreateDependencies = api.RecreateForce
		})
	}

Then you would be able to define your own recreation strategy.

I only need to think about the implications of exposing the type, as this module was added long time ago and I'm not that familiar with it as I'd like to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants