mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
[ML] Mute test failing due to Java 11 date time format parsing bug (#31899)
This commit is contained in:
parent
dadf96a840
commit
d268b494d7
@ -353,7 +353,8 @@ public class DataDescription implements ToXContentObject, Writeable {
|
|||||||
try {
|
try {
|
||||||
DateTimeFormatterTimestampConverter.ofPattern(format, ZoneOffset.UTC);
|
DateTimeFormatterTimestampConverter.ofPattern(format, ZoneOffset.UTC);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw ExceptionsHelper.badRequestException(Messages.getMessage(Messages.JOB_CONFIG_INVALID_TIMEFORMAT, format));
|
throw ExceptionsHelper.badRequestException(
|
||||||
|
Messages.getMessage(Messages.JOB_CONFIG_INVALID_TIMEFORMAT, format), e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timeFormat = format;
|
timeFormat = format;
|
||||||
|
@ -54,9 +54,9 @@ public class DateTimeFormatterTimestampConverter implements TimestampConverter {
|
|||||||
.parseDefaulting(ChronoField.YEAR_OF_ERA, LocalDate.now(defaultTimezone).getYear())
|
.parseDefaulting(ChronoField.YEAR_OF_ERA, LocalDate.now(defaultTimezone).getYear())
|
||||||
.toFormatter();
|
.toFormatter();
|
||||||
|
|
||||||
String now = formatter.format(ZonedDateTime.ofInstant(Instant.ofEpochSecond(0), ZoneOffset.UTC));
|
String formattedTime = formatter.format(ZonedDateTime.ofInstant(Instant.ofEpochSecond(0), ZoneOffset.UTC));
|
||||||
try {
|
try {
|
||||||
TemporalAccessor parsed = formatter.parse(now);
|
TemporalAccessor parsed = formatter.parse(formattedTime);
|
||||||
boolean hasTimeZone = parsed.isSupported(ChronoField.INSTANT_SECONDS);
|
boolean hasTimeZone = parsed.isSupported(ChronoField.INSTANT_SECONDS);
|
||||||
if (hasTimeZone) {
|
if (hasTimeZone) {
|
||||||
Instant.from(parsed);
|
Instant.from(parsed);
|
||||||
@ -67,7 +67,7 @@ public class DateTimeFormatterTimestampConverter implements TimestampConverter {
|
|||||||
return new DateTimeFormatterTimestampConverter(formatter, hasTimeZone, defaultTimezone);
|
return new DateTimeFormatterTimestampConverter(formatter, hasTimeZone, defaultTimezone);
|
||||||
}
|
}
|
||||||
catch (DateTimeException e) {
|
catch (DateTimeException e) {
|
||||||
throw new IllegalArgumentException("Timestamp cannot be derived from pattern: " + pattern);
|
throw new IllegalArgumentException("Timestamp cannot be derived from pattern: " + pattern, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ import org.elasticsearch.test.AbstractSerializingTestCase;
|
|||||||
import org.elasticsearch.xpack.core.ml.job.config.DataDescription.DataFormat;
|
import org.elasticsearch.xpack.core.ml.job.config.DataDescription.DataFormat;
|
||||||
import org.elasticsearch.xpack.core.ml.job.messages.Messages;
|
import org.elasticsearch.xpack.core.ml.job.messages.Messages;
|
||||||
|
|
||||||
|
import java.time.DateTimeException;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
@ -51,8 +53,12 @@ public class DataDescriptionTests extends AbstractSerializingTestCase<DataDescri
|
|||||||
description.setTimeFormat("epoch");
|
description.setTimeFormat("epoch");
|
||||||
description.setTimeFormat("epoch_ms");
|
description.setTimeFormat("epoch_ms");
|
||||||
description.setTimeFormat("yyyy-MM-dd HH");
|
description.setTimeFormat("yyyy-MM-dd HH");
|
||||||
String goodFormat = "yyyy.MM.dd G 'at' HH:mm:ss z";
|
}
|
||||||
description.setTimeFormat(goodFormat);
|
|
||||||
|
@AwaitsFix(bugUrl = "https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8206980")
|
||||||
|
public void testVerify_GivenValidFormat_Java11Bug() {
|
||||||
|
DataDescription.Builder description = new DataDescription.Builder();
|
||||||
|
description.setTimeFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testVerify_GivenInValidFormat() {
|
public void testVerify_GivenInValidFormat() {
|
||||||
@ -68,6 +74,10 @@ public class DataDescriptionTests extends AbstractSerializingTestCase<DataDescri
|
|||||||
e = expectThrows(ElasticsearchException.class, () -> description.setTimeFormat("y-M-dd"));
|
e = expectThrows(ElasticsearchException.class, () -> description.setTimeFormat("y-M-dd"));
|
||||||
assertEquals(Messages.getMessage(Messages.JOB_CONFIG_INVALID_TIMEFORMAT, "y-M-dd"), e.getMessage());
|
assertEquals(Messages.getMessage(Messages.JOB_CONFIG_INVALID_TIMEFORMAT, "y-M-dd"), e.getMessage());
|
||||||
expectThrows(ElasticsearchException.class, () -> description.setTimeFormat("YYY-mm-UU hh:mm:ssY"));
|
expectThrows(ElasticsearchException.class, () -> description.setTimeFormat("YYY-mm-UU hh:mm:ssY"));
|
||||||
|
|
||||||
|
Throwable cause = e.getCause();
|
||||||
|
assertNotNull(cause);
|
||||||
|
assertThat(cause, instanceOf(DateTimeException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTransform_GivenDelimitedAndEpoch() {
|
public void testTransform_GivenDelimitedAndEpoch() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user