From b9f83da5ac737cf6f9d0a564301ae321ed75f7ec Mon Sep 17 00:00:00 2001 From: Dimitrios Athanasiou Date: Tue, 21 Feb 2017 12:47:46 +0000 Subject: [PATCH] [ML] Include all fields in Job copy constructor Fields were missing from the job's copy constructor. This was the cause of intermittent test failures. Original commit: elastic/x-pack-elasticsearch@3cd705ab3c1a09bd365736942ccc571f7ea32b76 --- .../java/org/elasticsearch/xpack/ml/job/config/Job.java | 4 ++++ .../xpack/ml/datafeed/DatafeedConfigTests.java | 8 ++++++++ .../org/elasticsearch/xpack/ml/job/config/JobTests.java | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java index 5680251284d..52ae9f7037f 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java @@ -515,6 +515,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent this.id = job.getId(); this.description = job.getDescription(); this.analysisConfig = job.getAnalysisConfig(); + this.analysisLimits = job.getAnalysisLimits(); this.dataDescription = job.getDataDescription(); this.createTime = job.getCreateTime(); this.finishedTime = job.getFinishedTime(); @@ -522,9 +523,12 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent this.modelDebugConfig = job.getModelDebugConfig(); this.renormalizationWindowDays = job.getRenormalizationWindowDays(); this.backgroundPersistInterval = job.getBackgroundPersistInterval(); + this.modelSnapshotRetentionDays = job.getModelSnapshotRetentionDays(); this.resultsRetentionDays = job.getResultsRetentionDays(); this.customSettings = job.getCustomSettings(); this.modelSnapshotId = job.getModelSnapshotId(); + this.resultsIndexName = job.getResultsIndexName(); + this.deleted = job.isDeleted(); } public void setId(String id) { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java index ccaacb1f2e0..69832c58fd2 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigTests.java @@ -95,6 +95,14 @@ public class DatafeedConfigTests extends AbstractSerializingTestCase { // JobConfigurationVerifierTests: + public void testCopyConstructor() { + for (int i = 0; i < NUMBER_OF_TESTQUERIES; i++) { + Job job = createTestInstance(); + Job copy = new Job.Builder(job).build(); + assertEquals(job, copy); + } + } + public void testCheckValidId_IdTooLong() { Job.Builder builder = buildJobBuilder("foo"); builder.setId("averyveryveryaveryveryveryaveryveryveryaveryveryveryaveryveryveryaveryveryverylongid");