-
-
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
2c5244d
commit 0c9833b
Showing
13 changed files
with
205 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 |
---|---|---|
|
@@ -33,6 +33,7 @@ body: | |
- Kafka | ||
- LocalStack | ||
- MariaDB | ||
- Milvus | ||
- MinIO | ||
- MockServer | ||
- MongoDB | ||
|
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ body: | |
- Kafka | ||
- LocalStack | ||
- MariaDB | ||
- Milvus | ||
- MinIO | ||
- MockServer | ||
- MongoDB | ||
|
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ body: | |
- Kafka | ||
- LocalStack | ||
- MariaDB | ||
- Milvus | ||
- MinIO | ||
- MockServer | ||
- MongoDB | ||
|
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,36 @@ | ||
# Milvus | ||
|
||
Testcontainers module for [Milvus](https://hub.docker.com/r/milvusdb/milvus). | ||
|
||
## Milvus's usage examples | ||
|
||
You can start a Milvus container instance from any Java application by using: | ||
|
||
<!--codeinclude--> | ||
[Default config](../../modules/milvus/src/test/java/org/testcontainers/milvus/MilvusContainerTest.java) inside_block:milvusContainer | ||
<!--/codeinclude--> | ||
|
||
With external Etcd: | ||
|
||
<!--codeinclude--> | ||
[External Etcd](../../modules/milvus/src/test/java/org/testcontainers/milvus/MilvusContainerTest.java) inside_block:externalEtcd | ||
<!--/codeinclude--> | ||
|
||
## Adding this module to your project dependencies | ||
|
||
Add the following dependency to your `pom.xml`/`build.gradle` file: | ||
|
||
=== "Gradle" | ||
```groovy | ||
testImplementation "org.testcontainers:milvus:{{latest_version}}" | ||
``` | ||
|
||
=== "Maven" | ||
```xml | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>milvus</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 :: ActiveMQ" | ||
|
||
dependencies { | ||
api project(':testcontainers') | ||
|
||
testImplementation 'org.assertj:assertj-core:3.25.1' | ||
testImplementation 'io.milvus:milvus-sdk-java:2.3.4' | ||
} |
61 changes: 61 additions & 0 deletions
61
modules/milvus/src/main/java/org/testcontainers/milvus/MilvusContainer.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,61 @@ | ||
package org.testcontainers.milvus; | ||
|
||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.utility.DockerImageName; | ||
import org.testcontainers.utility.MountableFile; | ||
|
||
/** | ||
* Testcontainers implementation for Milvus. | ||
* <p> | ||
* Supported image: {@code milvusdb/milvus} | ||
* <p> | ||
* Exposed ports: | ||
* <ul> | ||
* <li>Management port: 9091</li> | ||
* <li>HTTP: 19530</li> | ||
* </ul> | ||
*/ | ||
public class MilvusContainer extends GenericContainer<MilvusContainer> { | ||
|
||
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("milvusdb/milvus"); | ||
|
||
private String etcdEndpoint; | ||
|
||
public MilvusContainer(String image) { | ||
this(DockerImageName.parse(image)); | ||
} | ||
|
||
public MilvusContainer(DockerImageName dockerImageName) { | ||
super(dockerImageName); | ||
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); | ||
withExposedPorts(9091, 19530); | ||
waitingFor(Wait.forHttp("/healthz").forPort(9091)); | ||
withCommand("milvus", "run", "standalone"); | ||
withCopyFileToContainer( | ||
MountableFile.forClasspathResource("testcontainers/embedEtcd.yaml"), | ||
"/milvus/configs/embedEtcd.yaml" | ||
); | ||
withEnv("COMMON_STORAGETYPE", "local"); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
if (this.etcdEndpoint == null) { | ||
withEnv("ETCD_USE_EMBED", "true"); | ||
withEnv("ETCD_DATA_DIR", "/var/lib/milvus/etcd"); | ||
withEnv("ETCD_CONFIG_PATH", "/milvus/configs/embedEtcd.yaml"); | ||
} else { | ||
withEnv("ETCD_ENDPOINTS", this.etcdEndpoint); | ||
} | ||
} | ||
|
||
public MilvusContainer withEtcdEndpoint(String etcdEndpoint) { | ||
this.etcdEndpoint = etcdEndpoint; | ||
return this; | ||
} | ||
|
||
public String getEndpoint() { | ||
return "http://" + getHost() + ":" + getMappedPort(19530); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
modules/milvus/src/main/resources/testcontainers/embedEtcd.yaml
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,2 @@ | ||
listen-client-urls: http://0.0.0.0:2379 | ||
advertise-client-urls: http://0.0.0.0:2379 |
66 changes: 66 additions & 0 deletions
66
modules/milvus/src/test/java/org/testcontainers/milvus/MilvusContainerTest.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,66 @@ | ||
package org.testcontainers.milvus; | ||
|
||
import io.milvus.client.MilvusServiceClient; | ||
import io.milvus.param.ConnectParam; | ||
import org.junit.Test; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.Network; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class MilvusContainerTest { | ||
|
||
@Test | ||
public void withDefaultConfig() { | ||
try ( | ||
// milvusContainer { | ||
MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:v2.3.9") | ||
// } | ||
) { | ||
milvus.start(); | ||
|
||
assertThat(milvus.getEnvMap()).doesNotContainKey("ETCD_ENDPOINTS"); | ||
assertMilvusVersion(milvus); | ||
} | ||
} | ||
|
||
@Test | ||
public void withExternalEtcd() { | ||
try ( | ||
// externalEtcd { | ||
Network network = Network.newNetwork(); | ||
GenericContainer<?> etcd = new GenericContainer<>("quay.io/coreos/etcd:v3.5.5") | ||
.withNetwork(network) | ||
.withNetworkAliases("etcd") | ||
.withCommand( | ||
"etcd", | ||
"-advertise-client-urls=http://127.0.0.1:2379", | ||
"-listen-client-urls=http://0.0.0.0:2379", | ||
"--data-dir=/etcd" | ||
) | ||
.withEnv("ETCD_AUTO_COMPACTION_MODE", "revision") | ||
.withEnv("ETCD_AUTO_COMPACTION_RETENTION", "1000") | ||
.withEnv("ETCD_QUOTA_BACKEND_BYTES", "4294967296") | ||
.withEnv("ETCD_SNAPSHOT_COUNT", "50000") | ||
.waitingFor(Wait.forLogMessage(".*ready to serve client requests.*", 1)); | ||
MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:v2.3.9") | ||
.withNetwork(network) | ||
.withEtcdEndpoint("etcd:2379") | ||
.dependsOn(etcd) | ||
// } | ||
) { | ||
milvus.start(); | ||
|
||
assertThat(milvus.getEnvMap()).doesNotContainKey("ETCD_USE_EMBED"); | ||
assertMilvusVersion(milvus); | ||
} | ||
} | ||
|
||
private static void assertMilvusVersion(MilvusContainer milvus) { | ||
MilvusServiceClient milvusClient = new MilvusServiceClient( | ||
ConnectParam.newBuilder().withUri(milvus.getEndpoint()).build() | ||
); | ||
assertThat(milvusClient.getVersion().getData().getVersion()).isEqualTo("v2.3.9"); | ||
} | ||
} |
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> |