Skip to content

Commit

Permalink
Add Qdrant module (#8353)
Browse files Browse the repository at this point in the history
Co-authored-by: Anush <anushshetty90@gmail.com>
  • Loading branch information
eddumelendez and Anush008 committed Feb 21, 2024
1 parent 0c9833b commit 2c987ee
Show file tree
Hide file tree
Showing 12 changed files with 146 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 @@ -47,6 +47,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 @@ -47,6 +47,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 @@ -45,6 +45,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 @@ -240,6 +240,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 @@ -152,6 +152,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 @@ -205,6 +205,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 @@ -89,6 +89,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,36 @@
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 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>

0 comments on commit 2c987ee

Please sign in to comment.