Skip to content

Commit 60e1e34

Browse files
committed
test: use random container name
1 parent 7c6b972 commit 60e1e34

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/it/java/io/weaviate/containers/Weaviate.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ public class Weaviate extends WeaviateContainer {
2828
private volatile SharedClient clientInstance;
2929
private final String containerName;
3030

31+
/**
32+
* By default, testcontainer's name is only available after calling
33+
* {@link #start}.
34+
* We need to know each container's name in advance to run a cluster
35+
* of several nodes, in which case we alse set the name manually.
36+
*
37+
* @see Builder#build()
38+
*/
39+
@Override
40+
public String getContainerName() {
41+
return containerName != null
42+
? containerName
43+
: super.getContainerName();
44+
}
45+
3146
/**
3247
* Create a new instance of WeaviateClient connected to this container if none
3348
* exist. Get an existing client otherwise.
@@ -230,7 +245,7 @@ public Weaviate build() {
230245
}
231246

232247
environment.forEach((name, value) -> c.withEnv(name, value));
233-
c.withCreateContainerCmdModifier(cmd -> cmd.withName(containerName).withHostName(containerName));
248+
c.withCreateContainerCmdModifier(cmd -> cmd.withHostName(containerName));
234249
return c;
235250
}
236251
}

0 commit comments

Comments
 (0)