-
-
Notifications
You must be signed in to change notification settings - Fork 250
Closed
Labels
triageInvestigation requiredInvestigation required
Description
Expected Behaviour
If I use .withReuse with LocalstackContainer then testcontainer reuse the current stopped or running localstack container.
Actual Behaviour
A new container are create for each executions
Steps to Reproduce
const container1 = await new LocalstackContainer('localstack/localstack:4.8')
.withExposedPorts({ container: 4566, host: 4566 })
.withAutoRemove(false)
.withReuse()
.start()
await container1.stop();
const container2 = await new LocalstackContainer('localstack/localstack:4.8')
.withExposedPorts({ container: 4566, host: 4566 })
.withAutoRemove(false)
.withReuse()
.start()
expect(container1.getId()).toBe(container2.getId()); // Ids not equalsActually I looked the root cause and I think I found why. It's because Localstack module set an env var before create the container :
this.withEnvironment({
LAMBDA_DOCKER_FLAGS: `${this.environment["LAMBDA_DOCKER_FLAGS"] ?? ""} -l ${LABEL_TESTCONTAINERS_SESSION_ID}=${reaper.sessionId}`,
});Unfortunately this env var is not consistent and the reuse strategy use labels to choose if container could be reuse or not.
I haven't one solution to fix this because I don't known if this env var is necessary to run localstack. If it's required then it could be great to add a note in the doc for this point or maybe you will propose a technical solution to fix this.
Metadata
Metadata
Assignees
Labels
triageInvestigation requiredInvestigation required