From 0b33438d37c91c713da586e6379086073ef9f02b Mon Sep 17 00:00:00 2001 From: zane-neo Date: Tue, 15 Oct 2024 11:02:02 +0800 Subject: [PATCH] Move the setup mehtod body to test method body Signed-off-by: zane-neo --- .../ml/autoredeploy/MLModelAutoReDeployer.java | 6 +++++- .../ml/autoredeploy/MLModelAutoReDeployerIT.java | 10 +--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java b/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java index 247741bcc8..ac38ce24c6 100644 --- a/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java +++ b/plugin/src/main/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployer.java @@ -217,7 +217,7 @@ private void triggerUndeployModelsOnDataNodes(List dataNodeIds) { client.execute(MLUndeployModelAction.INSTANCE, undeployModelNodesRequest, undeployModelListener); } } - }, e -> { log.error("Failed to query need undeploy models, no action will be performed"); }); + }, e -> { log.error("Failed to query need undeploy models, no action will be performed", e); }); queryRunningModels(listener); } @@ -259,6 +259,10 @@ private void queryRunningModels(ActionListener listener) { @SuppressWarnings("unchecked") private void triggerModelRedeploy(ModelAutoRedeployArrangement modelAutoRedeployArrangement) { + if (modelAutoRedeployArrangement == null) { + log.info("No more models in arrangement, skipping the redeployment"); + return; + } String modelId = modelAutoRedeployArrangement.getSearchResponse().getId(); List addedNodes = modelAutoRedeployArrangement.getAddedNodes(); Map sourceAsMap = modelAutoRedeployArrangement.getSearchResponse().getSourceAsMap(); diff --git a/plugin/src/test/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployerIT.java b/plugin/src/test/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployerIT.java index a19c60d28c..1ab8218d2e 100644 --- a/plugin/src/test/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployerIT.java +++ b/plugin/src/test/java/org/opensearch/ml/autoredeploy/MLModelAutoReDeployerIT.java @@ -9,11 +9,9 @@ import static org.opensearch.ml.common.MLTask.MODEL_ID_FIELD; -import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import org.junit.Before; import org.opensearch.ml.common.MLTaskState; import org.opensearch.ml.rest.MLCommonsRestTestCase; @@ -21,8 +19,7 @@ public class MLModelAutoReDeployerIT extends MLCommonsRestTestCase { - @Before - public void setup() throws IOException { + public void testModelAutoRedeploy() { prepareModel(); } @@ -65,9 +62,4 @@ private void prepareModel() { }); } - public void testModelAutoRedeploy() { - // This is a tricky IT to test model auto redeploy, since model auto redeploy is not easily to test with IT, so adding this test - // to mimic a case when a cluster spin up and immediately deploy a model, the model auto redeployer also selected this deploying - // model to deploy, and the original deploy task should complete and the auto redeploy task should fail in background. - } }