|
@@ -426,7 +426,6 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase {
|
|
|
assertTrue(response.isAcknowledged());
|
|
|
}
|
|
|
|
|
|
- @AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/33966")
|
|
|
public void testStartDatafeed() throws Exception {
|
|
|
String jobId = "test-start-datafeed";
|
|
|
String indexName = "start_data_1";
|
|
@@ -437,18 +436,18 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase {
|
|
|
highLevelClient().indices().create(createIndexRequest, RequestOptions.DEFAULT);
|
|
|
BulkRequest bulk = new BulkRequest();
|
|
|
bulk.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
|
|
- long now = System.currentTimeMillis();
|
|
|
- long oneDayAgo = now - 86400000;
|
|
|
+ long now = (System.currentTimeMillis()/1000)*1000;
|
|
|
+ long thePast = now - 60000;
|
|
|
int i = 0;
|
|
|
- long dayAgoCopy = oneDayAgo;
|
|
|
- while(dayAgoCopy < now) {
|
|
|
+ long pastCopy = thePast;
|
|
|
+ while(pastCopy < now) {
|
|
|
IndexRequest doc = new IndexRequest();
|
|
|
doc.index(indexName);
|
|
|
doc.type("doc");
|
|
|
doc.id("id" + i);
|
|
|
- doc.source("{\"total\":" +randomInt(1000) + ",\"timestamp\":"+ dayAgoCopy +"}", XContentType.JSON);
|
|
|
+ doc.source("{\"total\":" +randomInt(1000) + ",\"timestamp\":"+ pastCopy +"}", XContentType.JSON);
|
|
|
bulk.add(doc);
|
|
|
- dayAgoCopy += 1000000;
|
|
|
+ pastCopy += 1000;
|
|
|
i++;
|
|
|
}
|
|
|
highLevelClient().bulk(bulk, RequestOptions.DEFAULT);
|
|
@@ -470,9 +469,9 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase {
|
|
|
|
|
|
|
|
|
StartDatafeedRequest startDatafeedRequest = new StartDatafeedRequest(datafeedId);
|
|
|
- startDatafeedRequest.setStart(String.valueOf(oneDayAgo));
|
|
|
+ startDatafeedRequest.setStart(String.valueOf(thePast));
|
|
|
// Should only process two documents
|
|
|
- startDatafeedRequest.setEnd(String.valueOf(oneDayAgo + 2000000));
|
|
|
+ startDatafeedRequest.setEnd(String.valueOf(thePast + 2000));
|
|
|
StartDatafeedResponse response = execute(startDatafeedRequest,
|
|
|
machineLearningClient::startDatafeed,
|
|
|
machineLearningClient::startDatafeedAsync);
|
|
@@ -701,7 +700,8 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase {
|
|
|
.setDetectorDescription(randomAlphaOfLength(10))
|
|
|
.build();
|
|
|
AnalysisConfig.Builder configBuilder = new AnalysisConfig.Builder(Arrays.asList(detector));
|
|
|
- configBuilder.setBucketSpan(new TimeValue(randomIntBetween(1, 10), TimeUnit.SECONDS));
|
|
|
+ //should not be random, see:https://github.com/elastic/ml-cpp/issues/208
|
|
|
+ configBuilder.setBucketSpan(new TimeValue(5, TimeUnit.SECONDS));
|
|
|
builder.setAnalysisConfig(configBuilder);
|
|
|
|
|
|
DataDescription.Builder dataDescription = new DataDescription.Builder();
|