Skip to content

Commit

Permalink
[ML] Assert that a no-op job creates no results nor state (#43681)
Browse files Browse the repository at this point in the history
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 #43680
  • Loading branch information
droberts195 authored Jun 29, 2019
1 parent 956b630 commit c108b09
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

Expand Down Expand Up @@ -178,13 +179,12 @@ public void testPersistJobOnGracefulShutdown_givenNoDataAndNoTimeAdvance() throw
closeJob(jobId);

// Check that state has not been persisted
SearchResponse stateDocsResponse = client().prepareSearch(AnomalyDetectorsIndex.jobStateIndexPattern())
.setFetchSource(false)
.setTrackTotalHits(true)
.setSize(10000)
.get();
SearchResponse stateDocsResponse = client().prepareSearch(AnomalyDetectorsIndex.jobStateIndexPattern()).get();
assertThat(Arrays.asList(stateDocsResponse.getHits().getHits()), empty());

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

deleteJob(jobId);
}
Expand Down

0 comments on commit c108b09

Please sign in to comment.