Thanks to visit codestin.com
Credit goes to github.com

Skip to content

.withReuse(true) is broken out of the box because of randomly assigned network alias #2801

@aaronjwhiteside

Description

@aaronjwhiteside

On line:

https://github.com/testcontainers/testcontainers-java/blob/master/core/src/main/java/org/testcontainers/containers/GenericContainer.java#L136-L139

A random network alias is assigned during field initialization time, this ALWAYS prevents the computed hash from matching, unless one calls container.getNetworkAliases().clear() before adding their own network alias with .withNetworkAliases("some static value").

I propose that the default behaviour to allocate a random network alias be changed to happen lazily and when no other explictly specified network alias is set.

And also perhaps print a warning/error when no explict network alias is defined and .withReuse(true) is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions