Skip to content

Commit

Permalink
Add Weaviate module (#8337)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez committed Feb 20, 2024
1 parent 329e972 commit f45bb44
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ body:
- ToxiProxy
- Trino
- Vault
- Weaviate
- YugabyteDB
validations:
required: true
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/enhancement.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ body:
- ToxiProxy
- Trino
- Vault
- Weaviate
- YugabyteDB
validations:
required: true
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ body:
- ToxiProxy
- Trino
- Vault
- Weaviate
- YugabyteDB
- New Module
- type: textarea
Expand Down
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ updates:
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "gradle"
directory: "/modules/weaviate"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "gradle"
directory: "/modules/yugabytedb"
schedule:
Expand Down
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@
- changed-files:
- any-glob-to-any-file:
- modules/vault/**/*
"modules/weaviate":
- changed-files:
- any-glob-to-any-file:
- modules/weaviate/**/*
"modules/yugabytedb":
- changed-files:
- any-glob-to-any-file:
Expand Down
3 changes: 3 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ labels:
- name: modules/vault
color: '#006b75'

- name: modules/weaviate
color: '#006b75'

- name: modules/yugabytedb
color: '#006b75'

Expand Down
30 changes: 30 additions & 0 deletions docs/modules/weaviate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Weaviate

Testcontainers module for [Weaviate](https://hub.docker.com/r/semitechnologies/weaviate)

## WeaviateContainer's usage examples

You can start a Weaviate container instance from any Java application by using:

<!--codeinclude-->
[Default Weaviate container](../../modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java) inside_block:container
<!--/codeinclude-->

## Adding this module to your project dependencies

Add the following dependency to your `pom.xml`/`build.gradle` file:

=== "Gradle"
```groovy
testImplementation "org.testcontainers:weaviate:{{latest_version}}"
```

=== "Maven"
```xml
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>weaviate</artifactId>
<version>{{latest_version}}</version>
<scope>test</scope>
</dependency>
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ nav:
- modules/solr.md
- modules/toxiproxy.md
- modules/vault.md
- modules/weaviate.md
- modules/webdriver_containers.md
- Test framework integration:
- test_framework_integration/junit_4.md
Expand Down
8 changes: 8 additions & 0 deletions modules/weaviate/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
description = "Testcontainers :: Weaviate"

dependencies {
api project(':testcontainers')

testImplementation 'org.assertj:assertj-core:3.25.1'
testImplementation 'io.weaviate:client:4.5.1'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.testcontainers.weaviate;

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.DockerImageName;

/**
* Testcontainers implementation of Weaviate.
* <p>
* Supported image: {@code semitechnologies/weaviate}
* <p>
* Exposed ports:
* <ul>
* <li>HTTP: 8080</li>
* <li>gRPC: 50051</li>
* </ul>
*/
public class WeaviateContainer extends GenericContainer<WeaviateContainer> {

private static final String WEAVIATE_IMAGE = "semitechnologies/weaviate";

public WeaviateContainer(String dockerImageName) {
this(DockerImageName.parse(dockerImageName));
}

public WeaviateContainer(DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DockerImageName.parse(WEAVIATE_IMAGE));
withExposedPorts(8080, 50051);
withEnv("AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED", "true");
withEnv("PERSISTENCE_DATA_PATH", "/var/lib/weaviate");
}

public String getHttpHostAddress() {
return getHost() + ":" + getMappedPort(8080);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.testcontainers.weaviate;

import io.weaviate.client.Config;
import io.weaviate.client.WeaviateClient;
import io.weaviate.client.base.Result;
import io.weaviate.client.v1.misc.model.Meta;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class WeaviateContainerTest {

@Test
public void test() {
try ( // container {
WeaviateContainer weaviate = new WeaviateContainer("semitechnologies/weaviate:1.22.4")
// }
) {
weaviate.start();
WeaviateClient client = new WeaviateClient(new Config("http", weaviate.getHttpHostAddress()));
Result<Meta> meta = client.misc().metaGetter().run();
assertThat(meta.getResult().getVersion()).isEqualTo("1.22.4");
}
}
}
16 changes: 16 additions & 0 deletions modules/weaviate/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>

<logger name="org.testcontainers" level="INFO"/>
</configuration>

0 comments on commit f45bb44

Please sign in to comment.