-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f45bb44
commit 2c5244d
Showing
12 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ body: | |
- ActiveMQ | ||
- Azure | ||
- Cassandra | ||
- ChromaDB | ||
- Clickhouse | ||
- CockroachDB | ||
- Consul | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ body: | |
- ActiveMQ | ||
- Azure | ||
- Cassandra | ||
- ChromaDB | ||
- Clickhouse | ||
- CockroachDB | ||
- Consul | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ body: | |
- ActiveMQ | ||
- Azure | ||
- Cassandra | ||
- ChromaDB | ||
- Clickhouse | ||
- CockroachDB | ||
- CrateDB | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} |
34 changes: 34 additions & 0 deletions
34
modules/chromadb/src/main/java/org/testcontainers/chromadb/ChromaDBContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
modules/chromadb/src/test/java/org/testcontainers/chromadb/ChromaDBContainerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |