[ML] Job's CreateTime must be non-null (elastic/x-pack-elasticsearch#616)

Also simplifies Job.Builder to only have one build() method.

Original commit: elastic/x-pack-elasticsearch@50e4b4c210
This commit is contained in:
Zachary Tong 2017-02-22 13:45:13 -05:00 committed by GitHub
parent 9a5b410110
commit 41811efcf1
17 changed files with 81 additions and 53 deletions

View File

@ -38,6 +38,7 @@ import org.elasticsearch.xpack.ml.job.JobManager;
import org.elasticsearch.xpack.ml.job.config.Job;
import java.io.IOException;
import java.util.Date;
import java.util.Objects;
public class PutJobAction extends Action<PutJobAction.Request, PutJobAction.Response, PutJobAction.RequestBuilder> {
@ -62,8 +63,14 @@ public class PutJobAction extends Action<PutJobAction.Request, PutJobAction.Resp
public static class Request extends AcknowledgedRequest<Request> implements ToXContent {
public static Request parseRequest(String jobId, XContentParser parser) {
Job job = Job.PARSER.apply(parser, null).build(true, jobId);
return new Request(job);
Job.Builder job = Job.PARSER.apply(parser, null);
if (job.getId() == null) {
job.setId(jobId);
}
if (job.getCreateTime() == null) {
job.setCreateTime(new Date());
}
return new Request(job.build());
}
private Job job;

View File

@ -28,6 +28,7 @@ import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.ml.job.config.Job;
import java.io.IOException;
import java.util.Date;
import java.util.Objects;
public class ValidateJobConfigAction
@ -66,7 +67,8 @@ extends Action<ValidateJobConfigAction.Request, ValidateJobConfigAction.Response
Job.Builder job = Job.PARSER.apply(parser, null);
// When jobs are PUT their ID must be supplied in the URL - assume this will
// be valid unless an invalid job ID is specified in the JSON to be validated
return new Request(job.build(true, (job.getId() != null) ? job.getId() : "ok"));
job.setId(job.getId() != null ? job.getId() : "ok");
return new Request(job.build());
}
Request() {

View File

@ -539,6 +539,10 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
return id;
}
public Date getCreateTime() {
return createTime;
}
public void setCustomSettings(Map<String, Object> customSettings) {
this.customSettings = customSettings;
}
@ -617,31 +621,16 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
}
public Job build() {
return build(false, null);
}
public Job build(boolean fromApi, String urlJobId) {
Date createTime;
Date finishedTime;
Date lastDataTime;
String modelSnapshotId;
if (fromApi) {
if (id == null) {
id = urlJobId;
} else if (!id.equals(urlJobId)) {
throw new IllegalArgumentException(Messages.getMessage(Messages.INCONSISTENT_ID, ID.getPreferredName(), id, urlJobId));
}
createTime = this.createTime == null ? new Date() : this.createTime;
finishedTime = null;
lastDataTime = null;
modelSnapshotId = null;
} else {
createTime = this.createTime;
createTime = ExceptionsHelper.requireNonNull(this.createTime, CREATE_TIME.getPreferredName());
finishedTime = this.finishedTime;
lastDataTime = this.lastDataTime;
modelSnapshotId = this.modelSnapshotId;
}
if (analysisConfig == null) {
throw new IllegalArgumentException(Messages.getMessage(Messages.JOB_CONFIG_MISSING_ANALYSISCONFIG));

View File

@ -53,7 +53,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool());
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build(true, "foo")), listener);
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build()), listener);
listener.actionGet();
fail("put job action should not be enabled!");
} catch (ElasticsearchSecurityException e) {
@ -70,7 +70,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool());
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build(true, "foo")), listener);
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build()), listener);
PutJobAction.Response response = listener.actionGet();
assertNotNull(response);
}
@ -83,7 +83,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool());
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build(true, "foo")), putJobListener);
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build()), putJobListener);
PutJobAction.Response response = putJobListener.actionGet();
assertNotNull(response);
}
@ -126,7 +126,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool());
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build(true, "foo")), putJobListener);
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build()), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
}
@ -171,7 +171,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool());
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build(true, "foo")), putJobListener);
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build()), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>(
@ -224,7 +224,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool());
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build(true, "foo")), putJobListener);
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build()), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>(
@ -264,7 +264,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool());
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build(true, "foo")), putJobListener);
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build()), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
PlainListenableActionFuture<PersistentActionResponse> openJobListener = new PlainListenableActionFuture<>(client.threadPool());
@ -294,7 +294,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool());
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build(true, "foo")), putJobListener);
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build()), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
}
@ -318,7 +318,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool());
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build(true, "foo")), putJobListener);
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo").build()), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>(

View File

@ -52,7 +52,7 @@ public class DatafeedJobsIT extends BaseMlIntegTestCase {
indexDocs("data-2", numDocs2, oneWeekAgo, now);
Job.Builder job = createScheduledJob("lookback-job");
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true, job.getId()));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build());
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
assertTrue(putJobResponse.isAcknowledged());
client().execute(OpenJobAction.INSTANCE, new OpenJobAction.Request(job.getId()));
@ -91,7 +91,7 @@ public class DatafeedJobsIT extends BaseMlIntegTestCase {
indexDocs("data", numDocs1, lastWeek, now);
Job.Builder job = createScheduledJob("realtime-job");
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true, job.getId()));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build());
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
assertTrue(putJobResponse.isAcknowledged());
client().execute(OpenJobAction.INSTANCE, new OpenJobAction.Request(job.getId()));

View File

@ -10,17 +10,20 @@ import org.elasticsearch.xpack.ml.action.PutJobAction.Request;
import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.support.AbstractStreamableXContentTestCase;
import java.util.Date;
import static org.elasticsearch.xpack.ml.job.config.JobTests.buildJobBuilder;
import static org.elasticsearch.xpack.ml.job.config.JobTests.randomValidJobId;
public class PutJobActionRequestTests extends AbstractStreamableXContentTestCase<Request> {
private final String jobId = randomValidJobId();
private final Date date = new Date();
@Override
protected Request createTestInstance() {
Job.Builder jobConfiguration = buildJobBuilder(jobId);
return new Request(jobConfiguration.build(true, jobConfiguration.getId()));
Job.Builder jobConfiguration = buildJobBuilder(jobId, date);
return new Request(jobConfiguration.build());
}
@Override

View File

@ -15,7 +15,9 @@ import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.support.AbstractStreamableXContentTestCase;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class ValidateJobConfigActionRequestTests extends AbstractStreamableXContentTestCase<ValidateJobConfigAction.Request> {
@ -72,7 +74,9 @@ public class ValidateJobConfigActionRequestTests extends AbstractStreamableXCont
if (randomBoolean()) {
job.setAnalysisLimits(new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong()));
}
return new Request(job.build(true, "ok"));
job.setCreateTime(new Date());
job.setId(randomAsciiOfLength(5).replace(".", "-").replace("_", "-").toLowerCase(Locale.ENGLISH));
return new Request(job.build());
}
@Override

View File

@ -310,6 +310,7 @@ public class DatafeedJobRunnerTests extends ESTestCase {
Job.Builder builder = new Job.Builder("foo");
builder.setAnalysisConfig(acBuilder);
builder.setCreateTime(new Date());
return builder;
}

View File

@ -257,6 +257,7 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase {
AnalysisConfig.Builder analysisConfBuilder = new AnalysisConfig.Builder(Collections.singletonList(detectorBuilder.build()));
analysisConfBuilder.setInfluencers(Collections.singletonList("influence_field"));
jobBuilder.setAnalysisConfig(analysisConfBuilder);
jobBuilder.setCreateTime(new Date());
ClusterState cs = ClusterState.builder(new ClusterName("_name"))
.metaData(MetaData.builder().putCustom(MlMetadata.TYPE, MlMetadata.EMPTY_METADATA).indices(ImmutableOpenMap.of())).build();

View File

@ -27,6 +27,7 @@ import org.elasticsearch.xpack.persistent.PersistentTasksInProgress.PersistentTa
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -42,7 +43,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase {
ensureStableCluster(4);
Job.Builder job = createJob("job_id");
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true, job.getId()));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build());
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
assertTrue(putJobResponse.isAcknowledged());
ensureGreen();
@ -79,7 +80,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase {
ensureStableCluster(4);
Job.Builder job = createScheduledJob("job_id");
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true, job.getId()));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build());
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
assertTrue(putJobResponse.isAcknowledged());
DatafeedConfig config = createDatafeed("data_feed_id", job.getId(), Collections.singletonList("*"));
@ -152,7 +153,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase {
ensureStableCluster(3);
Job.Builder job = createJob("job_id");
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true, job.getId()));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build());
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
assertTrue(putJobResponse.isAcknowledged());
@ -247,7 +248,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase {
int numJobs = numMlNodes * 10;
for (int i = 0; i < numJobs; i++) {
Job.Builder job = createJob(Integer.toString(i));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true, job.getId()));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build());
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
assertTrue(putJobResponse.isAcknowledged());

View File

@ -28,7 +28,7 @@ public class TooManyJobsIT extends BaseMlIntegTestCase {
// create and open first job, which succeeds:
Job.Builder job = createJob("1");
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true, job.getId()));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build());
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
assertTrue(putJobResponse.isAcknowledged());
client().execute(OpenJobAction.INSTANCE, new OpenJobAction.Request(job.getId())).get();
@ -40,7 +40,7 @@ public class TooManyJobsIT extends BaseMlIntegTestCase {
// create and try to open second job, which fails:
job = createJob("2");
putJobRequest = new PutJobAction.Request(job.build(true, job.getId()));
putJobRequest = new PutJobAction.Request(job.build());
putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
assertTrue(putJobResponse.isAcknowledged());
expectThrows(ElasticsearchStatusException.class,
@ -74,7 +74,7 @@ public class TooManyJobsIT extends BaseMlIntegTestCase {
int clusterWideMaxNumberOfJobs = numNodes * maxNumberOfJobsPerNode;
for (int i = 1; i <= (clusterWideMaxNumberOfJobs + 1); i++) {
Job.Builder job = createJob(Integer.toString(i));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build(true, job.getId()));
PutJobAction.Request putJobRequest = new PutJobAction.Request(job.build());
PutJobAction.Response putJobResponse = client().execute(PutJobAction.INSTANCE, putJobRequest).get();
assertTrue(putJobResponse.isAcknowledged());

View File

@ -37,7 +37,7 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
}
public void testConstructor_GivenEmptyJobConfiguration() {
Job job = buildJobBuilder("foo").build(true, "foo");
Job job = buildJobBuilder("foo").build();
assertEquals("foo", job.getId());
assertNotNull(job.getCreateTime());
@ -58,12 +58,7 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
}
public void testNoId() {
expectThrows(IllegalArgumentException.class, () -> buildJobBuilder("").build(true, ""));
}
public void testInconsistentId() {
Exception e = expectThrows(IllegalArgumentException.class, () -> buildJobBuilder("foo").build(true, "bar"));
assertEquals(Messages.getMessage(Messages.INCONSISTENT_ID, Job.ID.getPreferredName(), "foo", "bar"), e.getMessage());
expectThrows(IllegalArgumentException.class, () -> buildJobBuilder("").build());
}
public void testEquals_GivenDifferentClass() {
@ -82,42 +77,54 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
}
public void testEquals_GivenDifferentRenormalizationWindowDays() {
Date date = new Date();
Job.Builder jobDetails1 = new Job.Builder("foo");
jobDetails1.setAnalysisConfig(createAnalysisConfig());
jobDetails1.setRenormalizationWindowDays(3L);
jobDetails1.setCreateTime(date);
Job.Builder jobDetails2 = new Job.Builder("foo");
jobDetails2.setRenormalizationWindowDays(4L);
jobDetails2.setAnalysisConfig(createAnalysisConfig());
jobDetails2.setCreateTime(date);
assertFalse(jobDetails1.build().equals(jobDetails2.build()));
}
public void testEquals_GivenDifferentBackgroundPersistInterval() {
Date date = new Date();
Job.Builder jobDetails1 = new Job.Builder("foo");
jobDetails1.setAnalysisConfig(createAnalysisConfig());
jobDetails1.setBackgroundPersistInterval(10000L);
jobDetails1.setCreateTime(date);
Job.Builder jobDetails2 = new Job.Builder("foo");
jobDetails2.setBackgroundPersistInterval(8000L);
jobDetails2.setAnalysisConfig(createAnalysisConfig());
jobDetails2.setCreateTime(date);
assertFalse(jobDetails1.build().equals(jobDetails2.build()));
}
public void testEquals_GivenDifferentModelSnapshotRetentionDays() {
Date date = new Date();
Job.Builder jobDetails1 = new Job.Builder("foo");
jobDetails1.setAnalysisConfig(createAnalysisConfig());
jobDetails1.setModelSnapshotRetentionDays(10L);
jobDetails1.setCreateTime(date);
Job.Builder jobDetails2 = new Job.Builder("foo");
jobDetails2.setModelSnapshotRetentionDays(8L);
jobDetails2.setAnalysisConfig(createAnalysisConfig());
jobDetails2.setCreateTime(date);
assertFalse(jobDetails1.build().equals(jobDetails2.build()));
}
public void testEquals_GivenDifferentResultsRetentionDays() {
Date date = new Date();
Job.Builder jobDetails1 = new Job.Builder("foo");
jobDetails1.setAnalysisConfig(createAnalysisConfig());
jobDetails1.setCreateTime(date);
jobDetails1.setResultsRetentionDays(30L);
Job.Builder jobDetails2 = new Job.Builder("foo");
jobDetails2.setResultsRetentionDays(4L);
jobDetails2.setAnalysisConfig(createAnalysisConfig());
jobDetails2.setCreateTime(date);
assertFalse(jobDetails1.build().equals(jobDetails2.build()));
}
@ -333,9 +340,9 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
assertEquals(Messages.getMessage(Messages.INVALID_ID, Job.RESULTS_INDEX_NAME.getPreferredName()), e.getMessage());
}
public static Job.Builder buildJobBuilder(String id) {
public static Job.Builder buildJobBuilder(String id, Date date) {
Job.Builder builder = new Job.Builder(id);
builder.setCreateTime(new Date());
builder.setCreateTime(date);
AnalysisConfig.Builder ac = createAnalysisConfig();
DataDescription.Builder dc = new DataDescription.Builder();
builder.setAnalysisConfig(ac);
@ -343,6 +350,10 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
return builder;
}
public static Job.Builder buildJobBuilder(String id) {
return buildJobBuilder(id, new Date());
}
public static String randomValidJobId() {
CodepointSetGenerator generator = new CodepointSetGenerator("abcdefghijklmnopqrstuvwxyz".toCharArray());
return generator.ofCodePointsLength(random(), 10, 10);

View File

@ -13,6 +13,7 @@ import org.elasticsearch.xpack.ml.support.AbstractSerializingTestCase;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -125,6 +126,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase<JobUpdate> {
AnalysisConfig.Builder ac = new AnalysisConfig.Builder(Arrays.asList(d1.build(), d2.build()));
ac.setCategorizationFieldName("cat_field");
jobBuilder.setAnalysisConfig(ac);
jobBuilder.setCreateTime(new Date());
Job updatedJob = update.mergeWithJob(jobBuilder.build());

View File

@ -26,6 +26,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.time.Duration;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
@ -129,6 +130,7 @@ public class AutodetectCommunicatorTests extends ESTestCase {
builder.setDataDescription(dd);
builder.setAnalysisConfig(ac);
builder.setCreateTime(new Date());
return builder.build();
}

View File

@ -366,6 +366,7 @@ public class AutodetectProcessManagerTests extends ESTestCase {
Job.Builder builder = new Job.Builder(jobId);
builder.setDataDescription(dd);
builder.setAnalysisConfig(ac);
builder.setCreateTime(new Date());
return builder.build();
}

View File

@ -75,6 +75,7 @@ public class ScoresUpdaterTests extends ESTestCase {
AnalysisConfig.Builder configBuilder = new AnalysisConfig.Builder(detectors);
configBuilder.setBucketSpan(DEFAULT_BUCKET_SPAN);
jobBuilder.setAnalysisConfig(configBuilder);
jobBuilder.setCreateTime(new Date());
job = jobBuilder.build();

View File

@ -37,6 +37,7 @@ import org.elasticsearch.xpack.ml.job.process.autodetect.state.DataCounts;
import org.elasticsearch.xpack.persistent.RemovePersistentTaskAction;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
@ -84,6 +85,7 @@ public abstract class BaseMlIntegTestCase extends SecurityIntegTestCase {
Job.Builder builder = new Job.Builder();
builder.setId(id);
builder.setCreateTime(new Date());
builder.setAnalysisConfig(analysisConfig);
builder.setDataDescription(dataDescription);
@ -103,6 +105,7 @@ public abstract class BaseMlIntegTestCase extends SecurityIntegTestCase {
builder.setAnalysisConfig(analysisConfig);
builder.setDataDescription(dataDescription);
builder.setCreateTime(new Date());
return builder;
}