Skip to content

Commit 35a8da9

Browse files
committed
[ML] Assert that a no-op job creates no results nor state
If a job is opened and then closed and does nothing in between then it should not persist any results or state documents. This change adapts the no-op job test to assert no results in addition to no state, and to log any documents that cause this assertion to fail. Relates elastic/ml-cpp#512 Relates elastic#43680
1 parent 6db8104 commit 35a8da9

File tree

1 file changed

+6
-6
lines changed
  • x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.List;
2424
import java.util.stream.Collectors;
2525

26+
import static org.hamcrest.Matchers.empty;
2627
import static org.hamcrest.Matchers.equalTo;
2728
import static org.hamcrest.Matchers.is;
2829

@@ -178,13 +179,12 @@ public void testPersistJobOnGracefulShutdown_givenNoDataAndNoTimeAdvance() throw
178179
closeJob(jobId);
179180

180181
// Check that state has not been persisted
181-
SearchResponse stateDocsResponse = client().prepareSearch(AnomalyDetectorsIndex.jobStateIndexPattern())
182-
.setFetchSource(false)
183-
.setTrackTotalHits(true)
184-
.setSize(10000)
185-
.get();
182+
SearchResponse stateDocsResponse = client().prepareSearch(AnomalyDetectorsIndex.jobStateIndexPattern()).get();
183+
assertThat(Arrays.asList(stateDocsResponse.getHits().getHits()), empty());
186184

187-
assertThat(stateDocsResponse.getHits().getTotalHits().value, equalTo(0L));
185+
// Check that results have not been persisted
186+
SearchResponse resultsDocsResponse = client().prepareSearch(AnomalyDetectorsIndex.jobResultsAliasedName(jobId)).get();
187+
assertThat(Arrays.asList(resultsDocsResponse.getHits().getHits()), empty());
188188

189189
deleteJob(jobId);
190190
}

0 commit comments

Comments
 (0)