add a test case to ensure NaN's aren't accepted (elastic/x-pack-elasticsearch#2395)
Original commit: elastic/x-pack-elasticsearch@72879c4f7c
This commit is contained in:
parent
91635608ef
commit
381bb4ed7d
|
@ -6,6 +6,7 @@
|
|||
package org.elasticsearch.xpack.ml.job.process.autodetect.output;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.common.ParsingException;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles;
|
||||
|
@ -401,6 +402,21 @@ public class AutodetectResultsParserTests extends ESTestCase {
|
|||
assertEquals("unexpected token [START_ARRAY]", e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that we do not accept NaN values
|
||||
*/
|
||||
public void testParsingExceptionNaN() {
|
||||
String json = "[{\"bucket\": {\"job_id\":\"foo\",\"timestamp\":1359453600000,\"bucket_span\":10,\"records\":"
|
||||
+ "[{\"timestamp\":1359453600000,\"bucket_span\":10,\"job_id\":\"foo\",\"probability\":NaN,"
|
||||
+ "\"by_field_name\":\"airline\",\"by_field_value\":\"JZA\", \"typical\":[1020.08],\"actual\":[0],"
|
||||
+ "\"field_name\":\"responsetime\",\"function\":\"max\",\"partition_field_name\":\"\",\"partition_field_value\":\"\"}]}}]";
|
||||
InputStream inputStream = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));
|
||||
AutodetectResultsParser parser = new AutodetectResultsParser(Settings.EMPTY);
|
||||
|
||||
expectThrows(ParsingException.class,
|
||||
() -> parser.parseResults(inputStream).forEachRemaining(a -> {}));
|
||||
}
|
||||
|
||||
public void testConsumeAndCloseStream() throws IOException {
|
||||
String json = "some string of data";
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));
|
||||
|
|
Loading…
Reference in New Issue