Skip to content

Commit

Permalink
Add Weaviate module tests with Weaviate modules
Browse files Browse the repository at this point in the history
  • Loading branch information
antas-marcin committed Mar 24, 2024
1 parent e4c533a commit 18f9523
Showing 1 changed file with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,59 @@
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();
Config config = new Config("http", weaviate.getHttpHostAddress());
config.setGRPCHost(weaviate.getGrpcHostAddress());
WeaviateClient client = new WeaviateClient(config);
Result<Meta> 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<String> enableModules = Arrays.asList(
"backup-filesystem",
"text2vec-openai",
"text2vec-cohere",
"text2vec-huggingface",
"generative-openai"
);
Map<String, String> 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> 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());
});
}
}
}

0 comments on commit 18f9523

Please sign in to comment.