|
@@ -68,22 +68,52 @@ class MilvusClientDockerTest {
|
|
|
// start the test container
|
|
|
Runtime runtime = Runtime.getRuntime();
|
|
|
String bashCommand = "docker-compose up -d";
|
|
|
-
|
|
|
try {
|
|
|
- logger.debug(bashCommand);
|
|
|
+
|
|
|
+ logger.info(bashCommand);
|
|
|
Process pro = runtime.exec(bashCommand);
|
|
|
int status = pro.waitFor();
|
|
|
if (status != 0) {
|
|
|
logger.error("Failed to start docker compose, status " + status);
|
|
|
}
|
|
|
|
|
|
- // here stop 10 seconds, reason: although milvus container is alive, it is still in initializing,
|
|
|
- // connection will failed and get error "proxy not health".
|
|
|
- TimeUnit.SECONDS.sleep(10);
|
|
|
- logger.debug("Milvus service started");
|
|
|
+ logger.info("Docker compose is up");
|
|
|
} catch (Throwable t) {
|
|
|
logger.error("Failed to execute docker compose up", t);
|
|
|
}
|
|
|
+
|
|
|
+ ConnectParam connectParam = connectParamBuilder().withAuthorization("root", "Milvus").build();
|
|
|
+ MilvusServiceClient tempClient = new MilvusServiceClient(connectParam);
|
|
|
+ long waitTime = 0;
|
|
|
+ while (true) {
|
|
|
+ // although milvus container is alive, it is still in initializing,
|
|
|
+ // connection will failed 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) {
|
|
|
+ logger.error("Interrupted", t);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ try{
|
|
|
+ R<CheckHealthResponse> resp = tempClient.checkHealth();
|
|
|
+ if (resp.getData().getIsHealthy()) {
|
|
|
+ logger.info(String.format("Milvus service is ready after %d seconds", waitTime));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ logger.info("Milvus service is not ready, waiting...");
|
|
|
+ } catch (Throwable t) {
|
|
|
+ logger.error("Milvus service is in initialize, not able to connect", t);
|
|
|
+ }
|
|
|
+
|
|
|
+ waitTime += checkInterval;
|
|
|
+ if (waitTime > 120) {
|
|
|
+ logger.error(String.format("Milvus service failed to start within %d seconds", waitTime));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private static void stopDockerContainer() {
|
|
@@ -96,9 +126,9 @@ class MilvusClientDockerTest {
|
|
|
String bashCommand = "docker-compose down";
|
|
|
|
|
|
try {
|
|
|
- logger.debug("Milvus service stopping...");
|
|
|
+ logger.info("Milvus service stopping...");
|
|
|
TimeUnit.SECONDS.sleep(5);
|
|
|
- logger.debug(bashCommand);
|
|
|
+ logger.info(bashCommand);
|
|
|
Process pro = runtime.exec(bashCommand);
|
|
|
int status = pro.waitFor();
|
|
|
if (status != 0) {
|
|
@@ -113,7 +143,7 @@ class MilvusClientDockerTest {
|
|
|
bashCommand = "docker-compose rm";
|
|
|
|
|
|
try {
|
|
|
- logger.debug(bashCommand);
|
|
|
+ logger.info(bashCommand);
|
|
|
Process pro = runtime.exec(bashCommand);
|
|
|
int status = pro.waitFor();
|
|
|
if (status != 0) {
|
|
@@ -121,7 +151,7 @@ class MilvusClientDockerTest {
|
|
|
}
|
|
|
|
|
|
logger.error("Clean up volume directory of Docker");
|
|
|
- FileUtils.deleteDirectory("volumes");
|
|
|
+ FileUtils.cleanDirectory("volumes");
|
|
|
} catch (Throwable t) {
|
|
|
logger.error("Failed to remove docker compose volume", t);
|
|
|
}
|