Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Qdrant module #8353

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ body:
- PostgreSQL
- Presto
- Pulsar
- Qdrant
- QuestDB
- RabbitMQ
- Redpanda
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 @@ -46,6 +46,7 @@ body:
- PostgreSQL
- Presto
- Pulsar
- Qdrant
- QuestDB
- RabbitMQ
- Redpanda
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 @@ -44,6 +44,7 @@ body:
- Oracle XE
- OrientDB
- PostgreSQL
- Qdrant
- QuestDB
- Presto
- Pulsar
Expand Down
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ updates:
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "gradle"
directory: "/modules/qdrant"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "gradle"
directory: "/modules/questdb"
schedule:
Expand Down
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@
- changed-files:
- any-glob-to-any-file:
- modules/pulsar/**/*
"modules/qdrant":
- changed-files:
- any-glob-to-any-file:
- modules/qdrant/**/*
"modules/questdb":
- 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 @@ -202,6 +202,9 @@ labels:
- name: modules/pulsar
color: '#006b75'

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

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

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

Testcontainers module for [Qdrant](https://registry.hub.docker.com/r/qdrant/qdrant)

## Qdrant's usage examples

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

<!--codeinclude-->
[Default QDrant container](../../modules/qdrant/src/test/java/org/testcontainers/qdrant/QdrantContainerTest.java) inside_block:qdrantContainer
<!--/codeinclude-->

## Adding this module to your project dependencies

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

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

=== "Maven"
```xml
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>qdrant</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 @@ -88,6 +88,7 @@ nav:
- modules/mockserver.md
- modules/nginx.md
- modules/pulsar.md
- modules/qdrant.md
- modules/rabbitmq.md
- modules/redpanda.md
- modules/solace.md
Expand Down
12 changes: 12 additions & 0 deletions modules/qdrant/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
description = "Testcontainers :: Qdrant"

dependencies {
api project(':testcontainers')

testImplementation 'org.assertj:assertj-core:3.25.1'
testImplementation 'io.qdrant:client:1.7.1'
testImplementation platform('io.grpc:grpc-bom:1.61.1')
testImplementation 'io.grpc:grpc-stub'
testImplementation 'io.grpc:grpc-protobuf'
testImplementation 'io.grpc:grpc-netty-shaded'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.testcontainers.qdrant;

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;

/**
* Testcontainers implementation for Qdrant.
* <p>
* Supported image: {@code qdrant/qdrant}
* <p>
* Exposed ports:
* <ul>
* <li>HTTP: 6333</li>
* <li>Grpc: 6334</li>
* </ul>
*/
public class QdrantContainer extends GenericContainer<QdrantContainer> {

private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("qdrant/qdrant");

public QdrantContainer(String image) {
this(DockerImageName.parse(image));
}

public QdrantContainer(DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);
withExposedPorts(6333, 6334);
waitingFor(Wait.forHttp("/readyz").forPort(6333));
}

public String getHttpHostAddress() {
return getHost() + ":" + getMappedPort(6333);
}
eddumelendez marked this conversation as resolved.
Show resolved Hide resolved

public String getGrpcHostAddress() {
return getHost() + ":" + getMappedPort(6334);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.testcontainers.qdrant;

import io.grpc.Grpc;
import io.grpc.InsecureChannelCredentials;
import io.qdrant.client.QdrantGrpcClient;
import io.qdrant.client.grpc.QdrantOuterClass;
import org.junit.Test;

import java.util.concurrent.ExecutionException;

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

public class QdrantContainerTest {

@Test
public void test() throws ExecutionException, InterruptedException {
try (
// qdrantContainer {
QdrantContainer qdrant = new QdrantContainer("qdrant/qdrant:v1.7.4")
// }
) {
qdrant.start();

QdrantGrpcClient client = QdrantGrpcClient
.newBuilder(
Grpc.newChannelBuilder(qdrant.getGrpcHostAddress(), InsecureChannelCredentials.create()).build()
)
.build();
QdrantOuterClass.HealthCheckReply healthCheckReply = client
.qdrant()
.healthCheck(QdrantOuterClass.HealthCheckRequest.getDefaultInstance())
.get();
assertThat(healthCheckReply.getVersion()).isEqualTo("1.7.4");
}
}
}
16 changes: 16 additions & 0 deletions modules/qdrant/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>