Skip to content

Commit f45bb44

Browse files
authored
Add Weaviate module (#8337)
1 parent 329e972 commit f45bb44

File tree

12 files changed

+131
-0
lines changed

12 files changed

+131
-0
lines changed

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ body:
5555
- ToxiProxy
5656
- Trino
5757
- Vault
58+
- Weaviate
5859
- YugabyteDB
5960
validations:
6061
required: true

.github/ISSUE_TEMPLATE/enhancement.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ body:
5555
- ToxiProxy
5656
- Trino
5757
- Vault
58+
- Weaviate
5859
- YugabyteDB
5960
validations:
6061
required: true

.github/ISSUE_TEMPLATE/feature.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ body:
5555
- ToxiProxy
5656
- Trino
5757
- Vault
58+
- Weaviate
5859
- YugabyteDB
5960
- New Module
6061
- type: textarea

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ updates:
302302
schedule:
303303
interval: "weekly"
304304
open-pull-requests-limit: 10
305+
- package-ecosystem: "gradle"
306+
directory: "/modules/weaviate"
307+
schedule:
308+
interval: "weekly"
309+
open-pull-requests-limit: 10
305310
- package-ecosystem: "gradle"
306311
directory: "/modules/yugabytedb"
307312
schedule:

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@
192192
- changed-files:
193193
- any-glob-to-any-file:
194194
- modules/vault/**/*
195+
"modules/weaviate":
196+
- changed-files:
197+
- any-glob-to-any-file:
198+
- modules/weaviate/**/*
195199
"modules/yugabytedb":
196200
- changed-files:
197201
- any-glob-to-any-file:

.github/settings.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ labels:
238238
- name: modules/vault
239239
color: '#006b75'
240240

241+
- name: modules/weaviate
242+
color: '#006b75'
243+
241244
- name: modules/yugabytedb
242245
color: '#006b75'
243246

docs/modules/weaviate.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Weaviate
2+
3+
Testcontainers module for [Weaviate](https://hub.docker.com/r/semitechnologies/weaviate)
4+
5+
## WeaviateContainer's usage examples
6+
7+
You can start a Weaviate container instance from any Java application by using:
8+
9+
<!--codeinclude-->
10+
[Default Weaviate container](../../modules/weaviate/src/test/java/org/testcontainers/weaviate/WeaviateContainerTest.java) inside_block:container
11+
<!--/codeinclude-->
12+
13+
## Adding this module to your project dependencies
14+
15+
Add the following dependency to your `pom.xml`/`build.gradle` file:
16+
17+
=== "Gradle"
18+
```groovy
19+
testImplementation "org.testcontainers:weaviate:{{latest_version}}"
20+
```
21+
22+
=== "Maven"
23+
```xml
24+
<dependency>
25+
<groupId>org.testcontainers</groupId>
26+
<artifactId>weaviate</artifactId>
27+
<version>{{latest_version}}</version>
28+
<scope>test</scope>
29+
</dependency>
30+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ nav:
9393
- modules/solr.md
9494
- modules/toxiproxy.md
9595
- modules/vault.md
96+
- modules/weaviate.md
9697
- modules/webdriver_containers.md
9798
- Test framework integration:
9899
- test_framework_integration/junit_4.md

modules/weaviate/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
description = "Testcontainers :: Weaviate"
2+
3+
dependencies {
4+
api project(':testcontainers')
5+
6+
testImplementation 'org.assertj:assertj-core:3.25.1'
7+
testImplementation 'io.weaviate:client:4.5.1'
8+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.testcontainers.weaviate;
2+
3+
import org.testcontainers.containers.GenericContainer;
4+
import org.testcontainers.utility.DockerImageName;
5+
6+
/**
7+
* Testcontainers implementation of Weaviate.
8+
* <p>
9+
* Supported image: {@code semitechnologies/weaviate}
10+
* <p>
11+
* Exposed ports:
12+
* <ul>
13+
* <li>HTTP: 8080</li>
14+
* <li>gRPC: 50051</li>
15+
* </ul>
16+
*/
17+
public class WeaviateContainer extends GenericContainer<WeaviateContainer> {
18+
19+
private static final String WEAVIATE_IMAGE = "semitechnologies/weaviate";
20+
21+
public WeaviateContainer(String dockerImageName) {
22+
this(DockerImageName.parse(dockerImageName));
23+
}
24+
25+
public WeaviateContainer(DockerImageName dockerImageName) {
26+
super(dockerImageName);
27+
dockerImageName.assertCompatibleWith(DockerImageName.parse(WEAVIATE_IMAGE));
28+
withExposedPorts(8080, 50051);
29+
withEnv("AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED", "true");
30+
withEnv("PERSISTENCE_DATA_PATH", "/var/lib/weaviate");
31+
}
32+
33+
public String getHttpHostAddress() {
34+
return getHost() + ":" + getMappedPort(8080);
35+
}
36+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.testcontainers.weaviate;
2+
3+
import io.weaviate.client.Config;
4+
import io.weaviate.client.WeaviateClient;
5+
import io.weaviate.client.base.Result;
6+
import io.weaviate.client.v1.misc.model.Meta;
7+
import org.junit.Test;
8+
9+
import static org.assertj.core.api.Assertions.assertThat;
10+
11+
public class WeaviateContainerTest {
12+
13+
@Test
14+
public void test() {
15+
try ( // container {
16+
WeaviateContainer weaviate = new WeaviateContainer("semitechnologies/weaviate:1.22.4")
17+
// }
18+
) {
19+
weaviate.start();
20+
WeaviateClient client = new WeaviateClient(new Config("http", weaviate.getHttpHostAddress()));
21+
Result<Meta> meta = client.misc().metaGetter().run();
22+
assertThat(meta.getResult().getVersion()).isEqualTo("1.22.4");
23+
}
24+
}
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<configuration>
2+
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<!-- encoders are assigned the type
5+
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
6+
<encoder>
7+
<pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
8+
</encoder>
9+
</appender>
10+
11+
<root level="INFO">
12+
<appender-ref ref="STDOUT"/>
13+
</root>
14+
15+
<logger name="org.testcontainers" level="INFO"/>
16+
</configuration>

0 commit comments

Comments
 (0)