Skip to content

Commit

Permalink
Use v2.4.15 for testing
Browse files Browse the repository at this point in the history
Signed-off-by: yhmo <[email protected]>
  • Loading branch information
yhmo committed Nov 11, 2024
1 parent fe20897 commit e0135b9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 46 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:

standalone:
container_name: milvus-javasdk-test-standalone
image: milvusdb/milvus:v2.4.11
image: milvusdb/milvus:v2.4.15
command: ["milvus", "run", "standalone"]
environment:
ETCD_ENDPOINTS: etcd:2379
Expand Down Expand Up @@ -77,7 +77,7 @@ services:

standaloneslave:
container_name: milvus-javasdk-test-slave-standalone
image: milvusdb/milvus:v2.4.11
image: milvusdb/milvus:v2.4.15
command: ["milvus", "run", "standalone"]
environment:
ETCD_ENDPOINTS: etcdslave:2379
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/milvus/client/MilvusClientDockerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MilvusClientDockerTest {
private static final Random RANDOM = new Random();

@Container
private static final MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:v2.4.11");
private static final MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:v2.4.15");

@BeforeAll
public static void setUp() {
Expand Down
92 changes: 50 additions & 42 deletions src/test/java/io/milvus/client/MilvusMultiClientDockerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,62 +52,74 @@ class MilvusMultiClientDockerTest {
private static final int dimension = 128;
private static final Boolean useDockerCompose = Boolean.TRUE;

private static void startDockerContainer() {
if (!useDockerCompose) {
return;
}

// start the test container
Runtime runtime = Runtime.getRuntime();
String bashCommand = "docker compose up -d";

try {
System.out.print(bashCommand);
Process pro = runtime.exec(bashCommand);
int status = pro.waitFor();
if (status != 0) {
System.out.print("Failed to start docker compose, status " + status);
}

System.out.print("Milvus service started");
} catch (Throwable t) {
System.out.print("Failed to execute docker compose up: " + t.getMessage());
}

ConnectParam connectParam = connectParamBuilder().withAuthorization("root", "Milvus").build();
MilvusServiceClient tempClient = new MilvusServiceClient(connectParam);
private static void waitMilvusServerReady(String host, int port) {
ConnectParam connectParam = connectParamBuilder(host, port)
.withAuthorization("root", "Milvus")
.build();
long waitTime = 0;
while (true) {
// although milvus container is alive, it is still in initializing,
// connection will failed and get error "proxy not health".
// connection will fail and get error "proxy not health".
// check health state for every few seconds, until the server is ready.
long checkInterval = 3;
try {
TimeUnit.SECONDS.sleep(checkInterval);
} catch (InterruptedException t) {
System.out.print("Interrupted: " + t.getMessage());
System.out.println("Interrupted: " + t.getMessage());
break;
}

try{
MilvusServiceClient tempClient = new MilvusServiceClient(connectParam);
R<CheckHealthResponse> resp = tempClient.checkHealth();
if (resp.getData().getIsHealthy()) {
System.out.print(String.format("Milvus service is ready after %d seconds", waitTime));
System.out.println(String.format("Milvus service is ready after %d seconds", waitTime));
break;
}
System.out.print("Milvus service is not ready, waiting...");
System.out.println("Milvus service is not ready, waiting...");
} catch (Throwable t) {
System.out.print("Milvus service is in initialize, not able to connect: " + t.getMessage());
System.out.println("Milvus service is in initialize, not able to connect: " + t.getMessage());
}

waitTime += checkInterval;
if (waitTime > 120) {
System.out.print(String.format("Milvus service failed to start within %d seconds", waitTime));
System.out.println(String.format("Milvus service failed to start within %d seconds", waitTime));
break;
}
}
}

private static void startDockerContainer() {
if (!useDockerCompose) {
return;
}

// start the test container
Runtime runtime = Runtime.getRuntime();
String bashCommand = "docker compose up -d";

try {
System.out.println(bashCommand);
Process pro = runtime.exec(bashCommand);
int status = pro.waitFor();
if (status != 0) {
System.out.println("Failed to start docker compose, status " + status);
}

System.out.println("Milvus service started");
} catch (Throwable t) {
System.out.println("Failed to execute docker compose up: " + t.getMessage());
}

MultiConnectParam connectParam = multiConnectParamBuilder()
.withAuthorization("root", "Milvus")
.build();
List<ServerAddress> hosts = connectParam.getHosts();
for (ServerAddress host : hosts) {
waitMilvusServerReady(host.getHost(), host.getPort());
}
}

private static void stopDockerContainer() {
if (!useDockerCompose) {
return;
Expand All @@ -118,34 +130,34 @@ private static void stopDockerContainer() {
String bashCommand = "docker compose down";

try {
System.out.print("Milvus service stopping...");
System.out.println("Milvus service stopping...");
TimeUnit.SECONDS.sleep(5);
System.out.print(bashCommand);
System.out.println(bashCommand);
Process pro = runtime.exec(bashCommand);
int status = pro.waitFor();
if (status != 0) {
System.out.print("Failed to stop test docker containers" + pro.getOutputStream().toString());
System.out.println("Failed to stop test docker containers" + pro.getOutputStream().toString());
}
} catch (Throwable t) {
System.out.print("Failed to execute docker compose down: " + t.getMessage());
System.out.println("Failed to execute docker compose down: " + t.getMessage());
}

// clean up log dir
runtime = Runtime.getRuntime();
bashCommand = "docker compose rm";

try {
System.out.print(bashCommand);
System.out.println(bashCommand);
Process pro = runtime.exec(bashCommand);
int status = pro.waitFor();
if (status != 0) {
System.out.print("Failed to clean up test docker containers" + pro.getOutputStream().toString());
System.out.println("Failed to clean up test docker containers" + pro.getOutputStream().toString());
}

System.out.print("Clean up volume directory of Docker");
System.out.println("Clean up volume directory of Docker");
FileUtils.deleteDirectory("volumes");
} catch (Throwable t) {
System.out.print("Failed to remove docker compose volume:" + t.getMessage());
System.out.println("Failed to remove docker compose volume:" + t.getMessage());
}
}

Expand All @@ -170,10 +182,6 @@ public static void tearDown() {
stopDockerContainer();
}

protected static ConnectParam.Builder connectParamBuilder() {
return connectParamBuilder("localhost", 19530);
}

private static ConnectParam.Builder connectParamBuilder(String host, int port) {
return ConnectParam.newBuilder().withHost(host).withPort(port);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class MilvusClientV2DockerTest {
private static final Random RANDOM = new Random();

@Container
private static final MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:v2.4.11");
private static final MilvusContainer milvus = new MilvusContainer("milvusdb/milvus:v2.4.15");

@BeforeAll
public static void setUp() {
Expand Down

0 comments on commit e0135b9

Please sign in to comment.