From 10a2c009060e61bacfafc5edee6069a8a22d5fb2 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Wed, 15 Nov 2023 16:05:48 +0000 Subject: [PATCH] Adding more test assertions --- .../xpack/ml/integration/BasicDistributedJobsIT.java | 2 ++ .../elasticsearch/xpack/ml/integration/IndexLayoutIT.java | 5 +++++ .../elasticsearch/xpack/ml/integration/JobsAndModelsIT.java | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java index 815caccefa120..822f8df35949e 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java @@ -84,11 +84,13 @@ public void testFailOverBasics() throws Exception { internalCluster().stopRandomDataNode(); ensureStableCluster(3); awaitJobOpenedAndAssigned(job.getId(), null); + assertRecentLastTaskStateChangeTime(MlTasks.jobTaskId(job.getId()), Duration.of(10, ChronoUnit.SECONDS), null); ensureGreen(); // replicas must be assigned, otherwise we could lose a whole index internalCluster().stopRandomDataNode(); ensureStableCluster(2); awaitJobOpenedAndAssigned(job.getId(), null); + assertRecentLastTaskStateChangeTime(MlTasks.jobTaskId(job.getId()), Duration.of(10, ChronoUnit.SECONDS), null); } @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/82591") diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/IndexLayoutIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/IndexLayoutIT.java index 6ae040f9ba756..db88cb5dc266e 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/IndexLayoutIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/IndexLayoutIT.java @@ -9,6 +9,7 @@ import org.elasticsearch.client.internal.OriginSettingClient; import org.elasticsearch.common.unit.ByteSizeValue; +import org.elasticsearch.xpack.core.ml.MlTasks; import org.elasticsearch.xpack.core.ml.action.CloseJobAction; import org.elasticsearch.xpack.core.ml.action.GetJobsStatsAction; import org.elasticsearch.xpack.core.ml.action.OpenJobAction; @@ -21,6 +22,8 @@ import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex; import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase; +import java.time.Duration; +import java.time.temporal.ChronoUnit; import java.util.Collections; import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN; @@ -44,6 +47,7 @@ public void testCrudOnTwoJobsInSharedIndex() throws Exception { .actionGet(); assertEquals(statsResponse.getResponse().results().get(0).getState(), JobState.OPENED); }); + assertRecentLastTaskStateChangeTime(MlTasks.jobTaskId(jobId), Duration.of(10, ChronoUnit.SECONDS), null); assertBusy(() -> { GetJobsStatsAction.Response statsResponse = client().execute( GetJobsStatsAction.INSTANCE, @@ -51,6 +55,7 @@ public void testCrudOnTwoJobsInSharedIndex() throws Exception { ).actionGet(); assertEquals(statsResponse.getResponse().results().get(0).getState(), JobState.OPENED); }); + assertRecentLastTaskStateChangeTime(MlTasks.jobTaskId(jobId2), Duration.of(10, ChronoUnit.SECONDS), null); OriginSettingClient client = new OriginSettingClient(client(), ML_ORIGIN); assertThat( diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java index 54890c65f7576..1458b9ccf693c 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobsAndModelsIT.java @@ -15,6 +15,7 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.json.JsonXContent; +import org.elasticsearch.xpack.core.ml.MlTasks; import org.elasticsearch.xpack.core.ml.action.CloseJobAction; import org.elasticsearch.xpack.core.ml.action.GetJobsStatsAction; import org.elasticsearch.xpack.core.ml.action.GetTrainedModelsStatsAction; @@ -36,6 +37,8 @@ import org.elasticsearch.xpack.ml.inference.persistence.TrainedModelDefinitionDoc; import org.elasticsearch.xpack.ml.support.BaseMlIntegTestCase; +import java.time.Duration; +import java.time.temporal.ChronoUnit; import java.util.List; import java.util.Set; @@ -231,6 +234,8 @@ public void testCluster_GivenAnomalyDetectionJobAndTrainedModelDeployment_Should assertThat(jobStats.getNode(), is(not(equalTo(modelStats.getDeploymentStats().getNodeStats().get(0).getNode())))); }); + assertRecentLastTaskStateChangeTime(MlTasks.jobTaskId(jobId), Duration.of(10, ChronoUnit.SECONDS), null); + // Clean up client().execute(CloseJobAction.INSTANCE, new CloseJobAction.Request(jobId).setForce(true)).actionGet(); client().execute(StopTrainedModelDeploymentAction.INSTANCE, new StopTrainedModelDeploymentAction.Request(model.getModelId()))