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 ChromaDB module #8336

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -17,6 +17,7 @@ body:
- ActiveMQ
- Azure
- Cassandra
- ChromaDB
- Clickhouse
- CockroachDB
- Consul
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 @@ -17,6 +17,7 @@ body:
- ActiveMQ
- Azure
- Cassandra
- ChromaDB
- Clickhouse
- CockroachDB
- Consul
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 @@ -17,6 +17,7 @@ body:
- ActiveMQ
- Azure
- Cassandra
- ChromaDB
- Clickhouse
- CockroachDB
- CrateDB
Expand Down
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ updates:
ignore:
- dependency-name: "io.dropwizard.metrics:metrics-core"
update-types: [ "version-update:semver-major" ]
- package-ecosystem: "gradle"
directory: "/modules/chromadb"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "gradle"
directory: "/modules/clickhouse"
schedule:
Expand Down
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
- changed-files:
- any-glob-to-any-file:
- modules/cassandra/**/*
"modules/chromadb":
- changed-files:
- any-glob-to-any-file:
- modules/chromadb/**/*
"modules/clickhouse":
- 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 @@ -115,6 +115,9 @@ labels:
- name: modules/cassandra
color: '#006b75'

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

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

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

Testcontainers module for [ChromaDB](https://registry.hub.docker.com/r/chromadb/chroma)

## ChromaDB's usage examples

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

<!--codeinclude-->
[Default ChromaDB container](../../modules/chromadb/src/test/java/org/testcontainers/chromadb/ChromaDBContainerTest.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:chromadb:{{latest_version}}"
```

=== "Maven"
```xml
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>chromadb</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 @@ -75,6 +75,7 @@ nav:
- modules/databases/yugabytedb.md
- modules/activemq.md
- modules/azure.md
- modules/chromadb.md
- modules/consul.md
- modules/docker_compose.md
- modules/elasticsearch.md
Expand Down
8 changes: 8 additions & 0 deletions modules/chromadb/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
description = "Testcontainers :: ChromaDB"

dependencies {
api project(':testcontainers')

testImplementation 'org.assertj:assertj-core:3.25.1'
testImplementation 'io.rest-assured:rest-assured:5.4.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.testcontainers.chromadb;

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

/**
* Testcontainers implementation of ChromaDB.
* <p>
* Supported images: {@code chromadb/chroma}, {@code ghcr.io/chroma-core/chroma}
* <p>
* Exposed ports: 8000
*/
public class ChromaDBContainer extends GenericContainer<ChromaDBContainer> {

private static final DockerImageName DEFAULT_DOCKER_IMAGE = DockerImageName.parse("chromadb/chroma");

private static final DockerImageName GHCR_DOCKER_IMAGE = DockerImageName.parse("ghcr.io/chroma-core/chroma");

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

public ChromaDBContainer(DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DEFAULT_DOCKER_IMAGE, GHCR_DOCKER_IMAGE);
withExposedPorts(8000);
waitingFor(Wait.forHttp("/api/v1/heartbeat"));
}

public String getEndpoint() {
return "http://" + getHost() + ":" + getFirstMappedPort();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.testcontainers.chromadb;

import io.restassured.http.ContentType;
import org.junit.Test;

import static io.restassured.RestAssured.given;

public class ChromaDBContainerTest {

@Test
public void test() {
try ( // container {
ChromaDBContainer chroma = new ChromaDBContainer("chromadb/chroma:0.4.22")
// }
) {
chroma.start();

given()
.baseUri(chroma.getEndpoint())
.when()
.body("{\"name\": \"test\"}")
.contentType(ContentType.JSON)
.post("/api/v1/databases")
.then()
.statusCode(200);

given().baseUri(chroma.getEndpoint()).when().get("/api/v1/databases/test").then().statusCode(200);
}
}
}
16 changes: 16 additions & 0 deletions modules/chromadb/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>