Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
przemekwitek committed Jul 8, 2019
1 parent 4d5ff2a commit aa64029
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ public DatafeedConfig build() {
if (!MlStrings.isValidId(id)) {
throw ExceptionsHelper.badRequestException(Messages.getMessage(Messages.INVALID_ID, ID.getPreferredName(), id));
}
if (indices == null || indices.isEmpty() || indices.contains("")) {
if (indices == null || indices.isEmpty() || indices.contains(null) || indices.contains("")) {
throw invalidOptionValue(INDICES.getPreferredName(), indices);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testDatafeedStatsToXContent() throws IOException {
assertThat(nodeAttributes, hasEntry("ml.max_open_jobs", "5"));

Map<String, Object> timingStatsMap = (Map<String, Object>) dfStatsMap.get("timing_stats");
assertThat(timingStatsMap.size(), is(equalTo(2)));
assertThat(timingStatsMap.size(), is(equalTo(3)));
assertThat(timingStatsMap, hasEntry("job_id", "my-job-id"));
assertThat(timingStatsMap, hasEntry("search_count", 5));
assertThat(timingStatsMap, hasEntry("total_search_time_ms", 123.456));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,17 @@ public void testCreateDataExtractorFactoryGivenRollupAndRemoteIndex() {
},
e -> fail()
);
DataExtractorFactory.create(client, datafeedConfig.build(), jobBuilder.build(new Date()), xContentRegistry(), listener);
DataExtractorFactory.create(
client, datafeedConfig.build(), jobBuilder.build(new Date()), xContentRegistry(), timingStatsReporter, listener);

// Test with remote index, aggregation, and chunking
datafeedConfig.setChunkingConfig(ChunkingConfig.newAuto());
listener = ActionListener.wrap(
dataExtractorFactory -> assertThat(dataExtractorFactory, instanceOf(ChunkedDataExtractorFactory.class)),
e -> fail()
);
DataExtractorFactory.create(client, datafeedConfig.build(), jobBuilder.build(new Date()), xContentRegistry(), listener);
DataExtractorFactory.create(
client, datafeedConfig.build(), jobBuilder.build(new Date()), xContentRegistry(), timingStatsReporter, listener);

// Test with remote index, no aggregation, and no chunking
datafeedConfig = DatafeedManagerTests.createDatafeedConfig("datafeed1", "foo");
Expand All @@ -276,15 +278,17 @@ public void testCreateDataExtractorFactoryGivenRollupAndRemoteIndex() {
e -> fail()
);

DataExtractorFactory.create(client, datafeedConfig.build(), jobBuilder.build(new Date()), xContentRegistry(), listener);
DataExtractorFactory.create(
client, datafeedConfig.build(), jobBuilder.build(new Date()), xContentRegistry(), timingStatsReporter, listener);

// Test with remote index, no aggregation, and chunking
datafeedConfig.setChunkingConfig(ChunkingConfig.newAuto());
listener = ActionListener.wrap(
dataExtractorFactory -> assertThat(dataExtractorFactory, instanceOf(ChunkedDataExtractorFactory.class)),
e -> fail()
);
DataExtractorFactory.create(client, datafeedConfig.build(), jobBuilder.build(new Date()), xContentRegistry(), listener);
DataExtractorFactory.create(
client, datafeedConfig.build(), jobBuilder.build(new Date()), xContentRegistry(), timingStatsReporter, listener);
}

public void testCreateDataExtractorFactoryGivenRollupAndValidAggregationAndAutoChunk() {
Expand Down

0 comments on commit aa64029

Please sign in to comment.