File tree Expand file tree Collapse file tree 3 files changed +35
-7
lines changed
src/it/java/io/weaviate/containers Expand file tree Collapse file tree 3 files changed +35
-7
lines changed Original file line number Diff line number Diff line change 264264 @see: https://www.oracle.com/corporate/features/understanding-java-9-modules.html
265265 -->
266266 --add-opens=java.base/java.lang=ALL-UNNAMED
267- </argLine >
267+ </argLine >
268+ <properties >
269+ <property >
270+ <name >listener</name >
271+ <value >io.weaviate.containers.TestListener</value >
272+ </property >
273+ </properties >
268274 </configuration >
269275 </plugin >
270276 <plugin >
Original file line number Diff line number Diff line change @@ -18,9 +18,27 @@ public class Container {
1818 public static final Contextionary CONTEXTIONARY = Contextionary .createDefault ();
1919
2020 static {
21+ startAll ();
22+ }
23+
24+ /** Start all shared Testcontainers. */
25+ // TODO: start lazily?
26+ static void startAll () {
2127 WEAVIATE .start ();
2228 }
2329
30+ /**
31+ * Stop all shared Testcontainers created in {@link #startAll}.
32+ * <p>
33+ * Testcontainer's Ryuk will reap any dangling containers after the tests
34+ * finish. However, since {@link Weaviate} instances also hold a
35+ * {@link WeaviateClient}, we want to stop them proactively to
36+ * close client connections.
37+ */
38+ static void stopAll () {
39+ WEAVIATE .stop ();
40+ }
41+
2442 public static Group compose (Weaviate weaviate , GenericContainer <?>... containers ) {
2543 return new Group (weaviate , containers );
2644 }
Original file line number Diff line number Diff line change 1010import io .weaviate .client6 .WeaviateClient ;
1111
1212public class Weaviate extends WeaviateContainer {
13- private static WeaviateClient CLIENT ;
13+ private static WeaviateClient clientInstance ;
1414
1515 public static final String VERSION = "1.29.0" ;
1616 public static final String DOCKER_IMAGE = "semitechnologies/weaviate" ;
1717
18+ /**
19+ * Get a client for the current Weaviate container.
20+ * As we aren't running tests in parallel at the moment,
21+ * this is not made thread-safe.
22+ */
1823 public WeaviateClient getClient () {
19- if (CLIENT == null ) {
24+ if (clientInstance == null ) {
2025 var config = new Config ("http" , getHttpHostAddress (), getGrpcHostAddress ());
21- CLIENT = new WeaviateClient (config );
22- System .out .println ("create Weaviate client -- ONCE" );
26+ clientInstance = new WeaviateClient (config );
2327 }
24- return CLIENT ;
28+ return clientInstance ;
2529 }
2630
2731 public static Weaviate createDefault () {
@@ -104,7 +108,7 @@ public void stop() {
104108 // not shut down properly.
105109 super .stop ();
106110 try {
107- CLIENT .close ();
111+ clientInstance .close ();
108112 } catch (IOException e ) {
109113 // TODO: log error
110114 }
You can’t perform that action at this time.
0 commit comments