Flushing a closed job should not return a 200 (elastic/elasticsearch#625)

Original commit: elastic/x-pack-elasticsearch@419389e1af
This commit is contained in:
David Kyle 2017-01-03 16:44:13 +00:00 committed by GitHub
parent c58d1d43d6
commit 7a7ec570ae
2 changed files with 35 additions and 2 deletions

View File

@ -137,8 +137,9 @@ public class AutodetectProcessManager extends AbstractComponent implements DataP
logger.debug("Flushing job {}", jobId);
AutodetectCommunicator communicator = autoDetectCommunicatorByJob.get(jobId);
if (communicator == null) {
logger.debug("Cannot flush: no active autodetect process for job {}", jobId);
return;
String message = String.format(Locale.ROOT, "[%s] Cannot flush: no active autodetect process for job", jobId);
logger.debug(message);
throw new IllegalArgumentException(message);
}
try {
communicator.flushJob(params);

View File

@ -16,6 +16,20 @@ setup:
}
}
- do:
xpack.prelert.put_job:
body: >
{
"job_id":"closed_job",
"description":"A closed job",
"analysis_config" : {
"detectors" :[{"function":"metric","field_name":"responsetime","by_field_name":"airline"}]
},
"data_description" : {
"format":"JSON"
}
}
- do:
xpack.prelert.open_job:
job_id: farequote
@ -149,3 +163,21 @@ setup:
catch: missing
xpack.prelert.close_job:
job_id: not_a_job
---
"Test flushing, posting and closing a closed job":
- do:
catch: /illegal_argument_exception/
xpack.prelert.flush_job:
job_id: closed_job
- do:
catch: /illegal_argument_exception/
xpack.prelert.close_job:
job_id: closed_job
- do:
catch: /illegal_argument_exception/
xpack.prelert.job_data:
job_id: closed_job
body: {}