[ML] Fix streaming the process update request (elastic/x-pack-elasticsearch#2928)

Original commit: elastic/x-pack-elasticsearch@cf76c13a2b
This commit is contained in:
David Kyle 2017-11-08 16:22:43 +00:00
parent 17ae4899c8
commit cba4421a75
2 changed files with 4 additions and 2 deletions

View File

@ -142,7 +142,7 @@ public class UpdateProcessAction extends
super.readFrom(in);
modelPlotConfig = in.readOptionalWriteable(ModelPlotConfig::new);
if (in.readBoolean()) {
in.readList(JobUpdate.DetectorUpdate::new);
detectorUpdates = in.readList(JobUpdate.DetectorUpdate::new);
}
}

View File

@ -9,6 +9,7 @@ import org.elasticsearch.test.AbstractStreamableTestCase;
import org.elasticsearch.xpack.ml.job.config.JobUpdate;
import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import java.util.ArrayList;
import java.util.List;
public class UpdateProcessActionRequestTests extends AbstractStreamableTestCase<UpdateProcessAction.Request> {
@ -22,9 +23,10 @@ public class UpdateProcessActionRequestTests extends AbstractStreamableTestCase<
}
List<JobUpdate.DetectorUpdate> updates = null;
if (randomBoolean()) {
updates = new ArrayList<>();
int detectorUpdateCount = randomIntBetween(0, 5);
for (int i = 0; i < detectorUpdateCount; i++) {
new JobUpdate.DetectorUpdate(randomInt(), randomAlphaOfLength(10), null);
updates.add(new JobUpdate.DetectorUpdate(randomInt(), randomAlphaOfLength(10), null));
}
}
return new UpdateProcessAction.Request(randomAlphaOfLength(10), config, updates);