From 18f9523b05f6e8ce73235856f412fbf47e6196a2 Mon Sep 17 00:00:00 2001 From: Marcin Antas Date: Sun, 24 Mar 2024 11:48:12 +0100 Subject: [PATCH 1/2] Add Weaviate module tests with Weaviate modules --- .../weaviate/WeaviateContainerTest.java | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java b/modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java index 9aa8fe19f61..f08d637bd66 100644 --- a/modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java +++ b/modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java @@ -4,16 +4,20 @@ import io.weaviate.client.WeaviateClient; import io.weaviate.client.base.Result; import io.weaviate.client.v1.misc.model.Meta; -import org.junit.Test; - +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; +import org.assertj.core.api.InstanceOfAssertFactories; +import org.junit.Test; public class WeaviateContainerTest { @Test - public void test() { + public void testWeaviate() { try ( // container { - WeaviateContainer weaviate = new WeaviateContainer("semitechnologies/weaviate:1.24.1") + WeaviateContainer weaviate = new WeaviateContainer("semitechnologies/weaviate:1.24.5") // } ) { weaviate.start(); @@ -21,7 +25,38 @@ public void test() { config.setGRPCHost(weaviate.getGrpcHostAddress()); WeaviateClient client = new WeaviateClient(config); Result meta = client.misc().metaGetter().run(); - assertThat(meta.getResult().getVersion()).isEqualTo("1.24.1"); + assertThat(meta.getResult().getVersion()).isEqualTo("1.24.5"); + } + } + + @Test + public void testWeaviateWithModules() { + List enableModules = Arrays.asList( + "backup-filesystem", + "text2vec-openai", + "text2vec-cohere", + "text2vec-huggingface", + "generative-openai" + ); + Map env = new HashMap<>(); + env.put("ENABLE_MODULES", String.join(",", enableModules)); + env.put("BACKUP_FILESYSTEM_PATH", "/tmp/backups"); + try (WeaviateContainer weaviate = new WeaviateContainer("semitechnologies/weaviate:1.24.5").withEnv(env)) { + weaviate.start(); + Config config = new Config("http", weaviate.getHttpHostAddress()); + config.setGRPCHost(weaviate.getGrpcHostAddress()); + WeaviateClient client = new WeaviateClient(config); + Result meta = client.misc().metaGetter().run(); + assertThat(meta.getResult().getVersion()).isEqualTo("1.24.5"); + Object modules = meta.getResult().getModules(); + assertThat(modules) + .isNotNull() + .asInstanceOf(InstanceOfAssertFactories.map(String.class, Object.class)) + .extracting(Map::keySet) + .satisfies(keys -> { + assertThat(keys.size()).isEqualTo(enableModules.size()); + keys.forEach(key -> assertThat(enableModules.contains(key)).isTrue()); + }); } } } From d4579c7ab0245124453dac75e05bfaf0407f5296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Mon, 25 Mar 2024 16:41:35 -0600 Subject: [PATCH 2/2] Fix format --- .../org/testcontainers/weaviate/WeaviateContainerTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java b/modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java index f08d637bd66..4acaa3b98fd 100644 --- a/modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java +++ b/modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java @@ -4,13 +4,15 @@ import io.weaviate.client.WeaviateClient; import io.weaviate.client.base.Result; import io.weaviate.client.v1.misc.model.Meta; +import org.assertj.core.api.InstanceOfAssertFactories; +import org.junit.Test; + import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; + import static org.assertj.core.api.Assertions.assertThat; -import org.assertj.core.api.InstanceOfAssertFactories; -import org.junit.Test; public class WeaviateContainerTest {