Skip to content

Commit 917903d

Browse files
authored
[ML] Unmute MlJobIT tests (#114553)
A large number (almost the entirety) of tests in the `MlJobIT` tests suite have been muted. In all cases the cause of failure of the tests is the same, persistent tasks for `cluster:admin/xpack/ml/job/close` and `cluster:admin/xpack/ml/job/close[n]` have been detected as present after the test case has completed. Examination of the tests show that the majority of them do not call either `close` directly or indirectly, indicating that the root cause lies with some previous test. As the `close` task inherits the default timeout of half an hour, an instance of it lingering about can cause a lot of damage to subsequent tests. The approach taken in this PR is to call the `_task/_cancel` endpoint after every test execution in the `MlJobIT` suite as the final operation. This should restrict the impact of the lingering `close` task to the test responsible, and the reduction in noise should permit better identification of the culprit. Closes #105239, #113581, #113046, #112729, #113528, #112701, #113742, #113370, #112823, #112088, #112212, #112730, #113654, #113655, #112381, #113477, #112382, #113651, #112510
1 parent 8ccfb22 commit 917903d

File tree

2 files changed

+22
-49
lines changed

2 files changed

+22
-49
lines changed

muted-tests.yml

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ tests:
8383
- class: org.elasticsearch.xpack.inference.InferenceRestIT
8484
method: test {p0=inference/80_random_rerank_retriever/Random rerank retriever predictably shuffles results}
8585
issue: https://github.com/elastic/elasticsearch/issues/111999
86-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
87-
method: testDeleteJobAfterMissingIndex
88-
issue: https://github.com/elastic/elasticsearch/issues/112088
8986
- class: org.elasticsearch.smoketest.SmokeTestMultiNodeClientYamlTestSuiteIT
9087
issue: https://github.com/elastic/elasticsearch/issues/112147
9188
- class: org.elasticsearch.smoketest.WatcherYamlRestIT
@@ -94,15 +91,9 @@ tests:
9491
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
9592
method: test {p0=ml/inference_processor/Test create processor with missing mandatory fields}
9693
issue: https://github.com/elastic/elasticsearch/issues/112191
97-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
98-
method: testDeleteJobAsync
99-
issue: https://github.com/elastic/elasticsearch/issues/112212
10094
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
10195
method: test {yaml=reference/rest-api/watcher/put-watch/line_120}
10296
issue: https://github.com/elastic/elasticsearch/issues/99517
103-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
104-
method: testMultiIndexDelete
105-
issue: https://github.com/elastic/elasticsearch/issues/112381
10697
- class: org.elasticsearch.xpack.esql.expression.function.aggregate.SpatialCentroidTests
10798
method: "testAggregateIntermediate {TestCase=<geo_point> #2}"
10899
issue: https://github.com/elastic/elasticsearch/issues/112461
@@ -129,9 +120,6 @@ tests:
129120
- class: org.elasticsearch.xpack.esql.EsqlAsyncSecurityIT
130121
method: testIndexPatternErrorMessageComparison_ESQL_SearchDSL
131122
issue: https://github.com/elastic/elasticsearch/issues/112630
132-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
133-
method: testPutJob_GivenFarequoteConfig
134-
issue: https://github.com/elastic/elasticsearch/issues/112382
135123
- class: org.elasticsearch.packaging.test.PackagesSecurityAutoConfigurationTests
136124
method: test20SecurityNotAutoConfiguredOnReInstallation
137125
issue: https://github.com/elastic/elasticsearch/issues/112635
@@ -147,26 +135,11 @@ tests:
147135
- class: org.elasticsearch.xpack.sql.qa.single_node.JdbcSqlSpecIT
148136
method: test {case-functions.testUcaseInline3}
149137
issue: https://github.com/elastic/elasticsearch/issues/112643
150-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
151-
method: testDelete_multipleRequest
152-
issue: https://github.com/elastic/elasticsearch/issues/112701
153-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
154-
method: testCreateJobInSharedIndexUpdatesMapping
155-
issue: https://github.com/elastic/elasticsearch/issues/112729
156-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
157-
method: testGetJob_GivenNoSuchJob
158-
issue: https://github.com/elastic/elasticsearch/issues/112730
159138
- class: org.elasticsearch.script.StatsSummaryTests
160139
method: testEqualsAndHashCode
161140
issue: https://github.com/elastic/elasticsearch/issues/112439
162-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
163-
method: testDeleteJobAfterMissingAliases
164-
issue: https://github.com/elastic/elasticsearch/issues/112823
165141
- class: org.elasticsearch.repositories.blobstore.testkit.analyze.HdfsRepositoryAnalysisRestIT
166142
issue: https://github.com/elastic/elasticsearch/issues/112889
167-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
168-
method: testCreateJob_WithClashingFieldMappingsFails
169-
issue: https://github.com/elastic/elasticsearch/issues/113046
170143
- class: org.elasticsearch.xpack.sql.qa.security.JdbcSqlSpecIT
171144
method: test {case-functions.testUcaseInline1}
172145
issue: https://github.com/elastic/elasticsearch/issues/112641
@@ -218,9 +191,6 @@ tests:
218191
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
219192
method: test {yaml=reference/ccr/apis/follow/post-resume-follow/line_84}
220193
issue: https://github.com/elastic/elasticsearch/issues/113343
221-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
222-
method: testDeleteJob_TimingStatsDocumentIsDeleted
223-
issue: https://github.com/elastic/elasticsearch/issues/113370
224194
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
225195
method: test {p0=search/500_date_range/from, to, include_lower, include_upper deprecated}
226196
issue: https://github.com/elastic/elasticsearch/pull/113286
@@ -233,15 +203,6 @@ tests:
233203
- class: org.elasticsearch.xpack.inference.InferenceCrudIT
234204
method: testSupportedStream
235205
issue: https://github.com/elastic/elasticsearch/issues/113430
236-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
237-
method: testOutOfOrderData
238-
issue: https://github.com/elastic/elasticsearch/issues/113477
239-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
240-
method: testCreateJobsWithIndexNameOption
241-
issue: https://github.com/elastic/elasticsearch/issues/113528
242-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
243-
method: testCantCreateJobWithSameID
244-
issue: https://github.com/elastic/elasticsearch/issues/113581
245206
- class: org.elasticsearch.integration.KibanaUserRoleIntegTests
246207
method: testFieldMappings
247208
issue: https://github.com/elastic/elasticsearch/issues/113592
@@ -254,12 +215,6 @@ tests:
254215
- class: org.elasticsearch.smoketest.MlWithSecurityIT
255216
method: test {yaml=ml/3rd_party_deployment/Test start and stop multiple deployments}
256217
issue: https://github.com/elastic/elasticsearch/issues/101458
257-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
258-
method: testGetJobs_GivenMultipleJobs
259-
issue: https://github.com/elastic/elasticsearch/issues/113654
260-
- class: org.elasticsearch.xpack.ml.integration.MlJobIT
261-
method: testGetJobs_GivenSingleJob
262-
issue: https://github.com/elastic/elasticsearch/issues/113655
263218
- class: org.elasticsearch.xpack.security.authz.interceptor.SearchRequestCacheDisablingInterceptorTests
264219
method: testHasRemoteIndices
265220
issue: https://github.com/elastic/elasticsearch/issues/113660

x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlJobIT.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,15 @@ public void testMultiIndexDelete() throws Exception {
747747
}
748748
}
749749
}""", AnomalyDetectorsIndex.jobResultsAliasedName(jobId), Job.ID, jobId));
750-
client().performRequest(extraIndex1);
750+
751+
// Creating an index with a leading dot (".") is now deprecated.
752+
// Ensure the ensuing warning exception doesn't cause a test case failure
753+
try {
754+
client().performRequest(extraIndex1);
755+
} catch (org.elasticsearch.client.WarningFailureException e) {
756+
logger.warn(e.getMessage());
757+
}
758+
751759
Request extraIndex2 = new Request("PUT", indexName + "-002");
752760
extraIndex2.setJsonEntity(Strings.format("""
753761
{
@@ -762,7 +770,14 @@ public void testMultiIndexDelete() throws Exception {
762770
}
763771
}
764772
}""", AnomalyDetectorsIndex.jobResultsAliasedName(jobId), Job.ID, jobId));
765-
client().performRequest(extraIndex2);
773+
774+
// Creating an index with a leading dot (".") is now deprecated.
775+
// Ensure the ensuing warning exception doesn't cause a test case failure
776+
try {
777+
client().performRequest(extraIndex2);
778+
} catch (org.elasticsearch.client.WarningFailureException e) {
779+
logger.warn(e.getMessage());
780+
}
766781

767782
// Use _cat/indices/.ml-anomalies-* instead of _cat/indices/_all to workaround https://github.com/elastic/elasticsearch/issues/45652
768783
String indicesBeforeDelete = EntityUtils.toString(
@@ -983,10 +998,10 @@ private Response openJob(String jobId, Optional<TimeValue> timeout) throws IOExc
983998
}
984999

9851000
private void closeJob(String jobId) throws IOException {
986-
Response openResponse = client().performRequest(
1001+
Response closeResponse = client().performRequest(
9871002
new Request("POST", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_close")
9881003
);
989-
assertThat(entityAsMap(openResponse), hasEntry("closed", true));
1004+
assertThat(entityAsMap(closeResponse), hasEntry("closed", true));
9901005
}
9911006

9921007
private Response putJob(String jobId, String jsonBody) throws IOException {
@@ -1000,5 +1015,8 @@ public void clearMlState() throws Exception {
10001015
new MlRestTestStateCleaner(logger, adminClient()).resetFeatures();
10011016
// Don't check analytics jobs as they are independent of anomaly detection jobs and should not be created by this test.
10021017
waitForPendingTasks(adminClient(), taskName -> taskName.contains(MlTasks.DATA_FRAME_ANALYTICS_TASK_NAME));
1018+
// Finally, clean up any lingering persistent tasks (such as "_close", "_close[n]" etc.) that may negatively
1019+
// impact subsequent tests.
1020+
client().performRequest(new Request("POST", "/_tasks/_cancel"));
10031021
}
10041022
}

0 commit comments

Comments
 (0)