Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/watcher java time migration #6

Open
wants to merge 191 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
19e3035
Core: Move aggs/mapping code over to java time
spinscale Sep 20, 2018
baf7acd
run test on java9 only
spinscale Sep 20, 2018
efe5661
fix compilation error
spinscale Sep 20, 2018
b856795
fix randomized test to use java time
spinscale Sep 20, 2018
443bdea
silence another test for now on java8 due to BWC issues without syste…
spinscale Sep 20, 2018
995855d
Merge branch 'master' into java-time
spinscale Sep 21, 2018
739ca1f
Merge branch 'master' into java-time
spinscale Sep 24, 2018
af7abc8
Merge branch 'master' into java-time
spinscale Sep 25, 2018
e6d61d2
Merge branch 'master' into java-time
spinscale Sep 26, 2018
a464a05
Merge branch 'master' into java-time
spinscale Sep 27, 2018
79f2ebb
Merge branch 'master' into java-time
spinscale Sep 27, 2018
a9de009
fix wrong casting
spinscale Sep 27, 2018
c9b7e22
Merge branch 'master' into java-time
spinscale Sep 28, 2018
5d34a06
fix import
spinscale Sep 28, 2018
121b208
Merge branch 'master' into java-time
spinscale Sep 28, 2018
4ab9cc2
fix compilation errors
spinscale Sep 28, 2018
13301c1
Merge branch 'master' into java-time
spinscale Sep 28, 2018
8f4564e
fix unit test
spinscale Sep 28, 2018
720caf8
Merge branch 'master' into java-time
spinscale Oct 1, 2018
26905c9
Merge branch 'master' into java-time
spinscale Oct 1, 2018
7b88806
Merge branch 'master' into java-time
spinscale Oct 2, 2018
d9b241c
Merge branch 'master' into java-time
spinscale Oct 2, 2018
3f8e10a
fix compilation errors
spinscale Oct 2, 2018
3df911f
fix tests
spinscale Oct 2, 2018
a1987ef
remove unused imports
spinscale Oct 2, 2018
8cd9cfa
Merge branch 'master' into java-time
spinscale Oct 3, 2018
d8af35d
Merge branch 'master' into java-time
spinscale Oct 4, 2018
5e50374
Merge branch 'master' into java-time
spinscale Oct 5, 2018
50e86b5
Merge branch 'master' into java-time
spinscale Oct 6, 2018
c58040f
Merge branch 'master' into java-time
spinscale Oct 8, 2018
80f7e69
fix test by not using root locale
spinscale Oct 8, 2018
3f74ffb
Merge branch 'master' into java-time
spinscale Oct 9, 2018
a8fd14c
Merge branch 'master' into java-time
spinscale Oct 10, 2018
ae50fcc
Merge branch 'master' into java-time
spinscale Oct 11, 2018
0d8c7e3
Add floating point parsing of epoch millis
spinscale Oct 11, 2018
fc99549
Merge branch 'master' into java-time
spinscale Oct 15, 2018
dee1b8e
catch both exceptions, fixes tests properly
spinscale Oct 15, 2018
113eb93
add another test for epoch millis date formatter
spinscale Oct 16, 2018
2861b7c
Merge branch 'master' into java-time
spinscale Oct 16, 2018
390ca93
Merge branch 'master' into java-time
spinscale Oct 16, 2018
dab811d
remove some TODOs
spinscale Oct 16, 2018
982c418
Merge branch 'master' into java-time
spinscale Oct 17, 2018
f56a596
Merge branch 'master' into java-time
spinscale Oct 17, 2018
7bdc090
Merge branch 'master' into java-time
spinscale Oct 18, 2018
418444f
Merge branch 'master' into java-time
spinscale Oct 23, 2018
87c49d1
remove more TODOs
spinscale Oct 23, 2018
5735433
fix HLRC compilation error
spinscale Oct 23, 2018
64cae08
Merge branch 'master' into java-time
spinscale Oct 24, 2018
01d7bdf
Merge branch 'master' into java-time
spinscale Oct 24, 2018
603be5d
Merge branch 'master' into java-time
spinscale Oct 25, 2018
8fbf1f1
remove import
spinscale Oct 25, 2018
e5b0cd0
Merge branch 'master' into java-time
spinscale Oct 25, 2018
50dd0ff
Merge branch 'master' into java-time
spinscale Oct 26, 2018
f49b2dd
Merge branch 'master' into java-time
spinscale Oct 26, 2018
2ce818d
Merge branch 'master' into java-time
spinscale Oct 29, 2018
a0c24af
fix checkstyle
spinscale Oct 29, 2018
b087623
Merge branch 'master' into java-time
spinscale Oct 31, 2018
e76d474
Merge branch 'master' into java-time
spinscale Nov 2, 2018
594dcc9
Merge branch 'master' into java-time
spinscale Nov 2, 2018
2a4ef79
fix range query test
spinscale Nov 2, 2018
436af3d
Merge branch 'master' into java-time
spinscale Nov 2, 2018
1e83827
Merge branch 'master' into java-time
spinscale Nov 5, 2018
1a96c92
Merge branch 'master' into java-time
spinscale Nov 6, 2018
ca0344b
Merge branch 'master' into java-time
spinscale Nov 7, 2018
1d7f1f2
Merge branch 'master' into java-time
spinscale Nov 7, 2018
cc80caf
fix compilation errors
spinscale Nov 7, 2018
7e44ddf
Merge branch 'master' into java-time
spinscale Nov 8, 2018
a2b5ef5
Merge branch 'master' into java-time
spinscale Nov 9, 2018
fb2810b
fix compilation
spinscale Nov 9, 2018
89e5fd1
fix tests
spinscale Nov 9, 2018
9421ce6
Merge branch 'master' into java-time
spinscale Nov 26, 2018
4cf8463
removed import
spinscale Nov 26, 2018
568c1b5
Merge branch 'master' into java-time
spinscale Nov 26, 2018
101eeae
Merge branch 'master' into java-time
spinscale Nov 26, 2018
1245bbe
Merge branch 'master' into java-time
spinscale Nov 27, 2018
cb250c4
fix casting to java-time in ML
spinscale Nov 27, 2018
14403c3
Merge branch 'master' into java-time
spinscale Nov 27, 2018
501d02d
remove unused import
spinscale Nov 27, 2018
5e32ce0
Merge branch 'master' into java-time
spinscale Nov 28, 2018
3a27760
Core: Migrating from joda to java.time. ML package (#35949)
pgomulka Nov 28, 2018
bf3a942
Merge branch 'master' into java-time
spinscale Nov 29, 2018
8b32091
Merge branch 'master' into java-time
spinscale Nov 30, 2018
3a76b95
Merge branch 'master' into java-time
spinscale Nov 30, 2018
972e5a4
Merge branch 'master' into java-time
spinscale Dec 3, 2018
3d91e31
Merge branch 'master' into java-time
spinscale Dec 3, 2018
f486f63
Fix java date parsing to be compatible with joda (#36155)
pgomulka Dec 3, 2018
34fc485
Deprecate /_xpack/monitoring/* in favor of /_monitoring/* (#36130)
jakelandis Dec 3, 2018
94832de
Improve painless docs for score, similarity, weight and sort (#35629)
romseygeek Dec 3, 2018
5926e4b
Remove the deprecated _termvector endpoint. (#36131)
jtibshirani Dec 3, 2018
c15c3bb
Fix broken links in painless docs (#36170)
romseygeek Dec 3, 2018
a188931
[ILM] fix ilm.remove_policy rest-spec (#36165)
talevy Dec 3, 2018
3d35bdb
Added soft limit to open scroll contexts #25244 (#36009)
joaofcmb Dec 3, 2018
7c51625
[DOCS] Fixes peer link
lcawl Dec 3, 2018
83a2054
[DOCs] More broken painless links
lcawl Dec 3, 2018
41cb9df
[test] generate unique user names (#36179)
andyb-elastic Dec 3, 2018
0686a13
[test] mute RemoveCorruptedShardDataCommandIT
andyb-elastic Dec 4, 2018
2ecd87d
[HLRC] Added support for CCR Get Auto Follow Pattern apis (#36049)
martijnvg Dec 4, 2018
277cfaf
Testclusters: implement starting, waiting for and stopping single clu…
alpar-t Dec 4, 2018
3aec7eb
(Minor) Fix some typos (#36180)
glenacota Dec 4, 2018
11f6448
Merge branch 'master' into java-time
spinscale Dec 5, 2018
ee6c1a6
Merge branch 'master' into java-time
spinscale Dec 6, 2018
97ed0d5
Merge branch 'master' into java-time
spinscale Dec 6, 2018
f0a719c
Merge branch 'master' into java-time
spinscale Dec 7, 2018
9520605
fix compilation errors
spinscale Dec 7, 2018
f907699
cleanups
spinscale Dec 7, 2018
ea2281c
Merge branch 'master' into java-time
spinscale Dec 7, 2018
971e5d0
fix checkstyle
spinscale Dec 7, 2018
03c67ee
Merge branch 'master' into java-time
spinscale Dec 10, 2018
ba6b1f1
Merge branch 'master' into java-time
spinscale Dec 10, 2018
fbc79c9
fix tests
spinscale Dec 10, 2018
275a33e
Merge branch 'master' into java-time
spinscale Dec 10, 2018
62995e3
fix rest tests
spinscale Dec 10, 2018
1f36baf
Merge branch 'master' into java-time
spinscale Dec 11, 2018
9d6c33e
fix test
spinscale Dec 11, 2018
a177c3a
Merge branch 'master' into java-time
spinscale Dec 11, 2018
3fa2a1b
fix another test
spinscale Dec 11, 2018
62dff53
simplify serialization code
spinscale Dec 11, 2018
c036c40
restore accidentally removed ccr snippet
spinscale Dec 11, 2018
17b3aa2
Fix failing licence test (#36482)
pgomulka Dec 11, 2018
ce8411a
normalize date to prevent UTC/Z to string issues in tests
spinscale Dec 11, 2018
8b8970c
Merge branch 'master' into java-time
spinscale Dec 11, 2018
4634a93
Merge branch 'master' into java-time
spinscale Dec 11, 2018
9273268
catch correct date parse exception
spinscale Dec 12, 2018
b5a92db
Merge branch 'master' into java-time
spinscale Dec 12, 2018
b225148
fix tests
spinscale Dec 12, 2018
2ee4510
review comments
spinscale Dec 12, 2018
a25e91e
Merge branch 'master' into java-time
spinscale Dec 12, 2018
409c12b
add exception handling
spinscale Dec 12, 2018
1d4d9c4
Merge branch 'master' into java-time
spinscale Dec 13, 2018
d678d71
fix rollupindexertests
spinscale Dec 13, 2018
acf17e0
fix compilation of new field mappers
spinscale Dec 13, 2018
79a6079
Merge branch 'master' into java-time
spinscale Dec 13, 2018
5fe53db
initial watcher changes
pgomulka Nov 23, 2018
88d7da9
Merge branch 'master' into java-time
spinscale Dec 14, 2018
8064c85
Merge branch 'master' into java-time
spinscale Dec 14, 2018
c9df2f9
Merge branch 'master' into java-time
spinscale Dec 17, 2018
5307643
Merge branch 'master' into java-time
spinscale Dec 18, 2018
f7471f0
Merge branch 'master' into java-time
spinscale Dec 18, 2018
7ab754c
Merge branch 'master' into java-time
spinscale Dec 19, 2018
03b4a3c
Merge branch 'master' into java-time
spinscale Dec 19, 2018
3fcd88f
Merge branch 'master' into feature/watcher-java-time-migration
pgomulka Dec 20, 2018
bf2528b
Merge branch 'master' into java-time
spinscale Dec 21, 2018
e2acbc8
Merge branch 'master' into java-time
spinscale Dec 30, 2018
5f336c9
fix tests using week based year
spinscale Dec 30, 2018
81526f6
Merge branch 'java-time' into feature/watcher-java-time-migration
pgomulka Dec 31, 2018
acc4c71
Merge branch 'master' into java-time
spinscale Jan 7, 2019
ad08cdd
Merge branch 'master' into java-time
spinscale Jan 7, 2019
2d23dd9
Add super simple benchmark to check joda/java time conversion differe…
spinscale Jan 7, 2019
71c4f2d
add missing license
spinscale Jan 7, 2019
aea63a8
Merge branch 'master' into java-time
spinscale Jan 8, 2019
2aca1f9
Merge branch 'master' into java-time
spinscale Jan 8, 2019
ed71785
Merge branch 'master' into java-time
spinscale Jan 9, 2019
cbbd3c0
Merge branch 'master' into java-time
spinscale Jan 9, 2019
fdb1d9d
fix tests by checking for java 8
spinscale Jan 9, 2019
1040e2c
Merge branch 'master' into java-time
spinscale Jan 9, 2019
a191118
fix a few more tests for java 8
spinscale Jan 9, 2019
cc1ed73
Merge branch 'master' into java-time
spinscale Jan 10, 2019
9ccabad
fix formatter
spinscale Jan 10, 2019
d33f5ba
Merge branch 'master' into java-time
spinscale Jan 10, 2019
8d2ad6c
allow to parse nanoseconds by default in date field mapper
spinscale Jan 10, 2019
de6ac15
add clarifying comment
spinscale Jan 10, 2019
ce22809
Merge branch 'master' into java-time
spinscale Jan 10, 2019
fbe4d46
fix failing test
spinscale Jan 11, 2019
3180107
Merge branch 'master' into java-time
spinscale Jan 11, 2019
d15ad93
Merge branch 'master' into java-time
spinscale Jan 11, 2019
451b724
Merge branch 'master' into java-time
spinscale Jan 11, 2019
af8dd13
Merge branch 'master' into java-time
spinscale Jan 12, 2019
197e215
fix some ML tests by providing useful date ranges
spinscale Jan 12, 2019
32e81c4
work around java 8 time formatting issues
spinscale Jan 12, 2019
383d5e7
fix checkstyle and fix some tests due to moving formatter
spinscale Jan 13, 2019
e65470d
fix unused import
spinscale Jan 13, 2019
c49c2df
fix tests on java 8
spinscale Jan 13, 2019
c6f6167
removed unused import
spinscale Jan 13, 2019
640f5c4
Merge branch 'java-time' into feature/watcher-java-time-migration
pgomulka Jan 14, 2019
8b59368
Merge branch 'master' into feature/watcher-java-time-migration
pgomulka Jan 25, 2019
cc86c92
milisecond part 6digits
pgomulka Jan 25, 2019
8ca7889
test case
pgomulka Jan 25, 2019
d098dcd
code review follow up
pgomulka Jan 29, 2019
0c57f3b
Merge branch 'master' into feature/watcher-java-time-migration
pgomulka Jan 29, 2019
7d6dcfa
adding missing zone
pgomulka Jan 30, 2019
779ff27
asserting about UTC
pgomulka Jan 31, 2019
8c6fd07
Merge branch 'master' into feature/watcher-java-time-migration
pgomulka Jan 31, 2019
1fec75b
tozoneddate->from
pgomulka Jan 31, 2019
9258b30
->from
pgomulka Jan 31, 2019
cac4a47
Merge branch 'master' into feature/watcher-java-time-migration
pgomulka Jan 31, 2019
d821da0
Fixing WatchTests
pgomulka Jan 31, 2019
d72f2f7
remove toString
pgomulka Jan 31, 2019
28fd682
change the logging message to reflect index pattern
pgomulka Feb 1, 2019
e1c02dc
code review follow up
pgomulka Feb 4, 2019
fa22a68
Merge branch 'master' into feature/watcher-java-time-migration
pgomulka Feb 4, 2019
c3c1c96
remove todo
pgomulka Feb 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.XContentParser;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

import java.io.IOException;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Locale;
import java.util.Objects;

Expand Down Expand Up @@ -119,15 +119,16 @@ public enum State {
ACKED;
}

private final DateTime timestamp;
private final ZonedDateTime timestamp;
private final State state;

public AckStatus(DateTime timestamp, State state) {
this.timestamp = timestamp.toDateTime(DateTimeZone.UTC);
public AckStatus(ZonedDateTime timestamp, State state) {
assert timestamp.getOffset() == ZoneOffset.UTC;
this.timestamp = timestamp;
this.state = state;
}

public DateTime timestamp() {
public ZonedDateTime timestamp() {
return timestamp;
}

Expand All @@ -151,7 +152,7 @@ public int hashCode() {
}

public static AckStatus parse(String actionId, XContentParser parser) throws IOException {
DateTime timestamp = null;
ZonedDateTime timestamp = null;
State state = null;

String currentFieldName = null;
Expand Down Expand Up @@ -181,25 +182,25 @@ public static AckStatus parse(String actionId, XContentParser parser) throws IOE

public static class Execution {

public static Execution successful(DateTime timestamp) {
public static Execution successful(ZonedDateTime timestamp) {
return new Execution(timestamp, true, null);
}

public static Execution failure(DateTime timestamp, String reason) {
public static Execution failure(ZonedDateTime timestamp, String reason) {
return new Execution(timestamp, false, reason);
}

private final DateTime timestamp;
private final ZonedDateTime timestamp;
private final boolean successful;
private final String reason;

private Execution(DateTime timestamp, boolean successful, String reason) {
this.timestamp = timestamp.toDateTime(DateTimeZone.UTC);
private Execution(ZonedDateTime timestamp, boolean successful, String reason) {
this.timestamp = timestamp.withZoneSameInstant(ZoneOffset.UTC);
this.successful = successful;
this.reason = reason;
}

public DateTime timestamp() {
public ZonedDateTime timestamp() {
return timestamp;
}

Expand Down Expand Up @@ -229,7 +230,7 @@ public int hashCode() {
}

public static Execution parse(String actionId, XContentParser parser) throws IOException {
DateTime timestamp = null;
ZonedDateTime timestamp = null;
Boolean successful = null;
String reason = null;

Expand Down Expand Up @@ -269,15 +270,15 @@ public static Execution parse(String actionId, XContentParser parser) throws IOE

public static class Throttle {

private final DateTime timestamp;
private final ZonedDateTime timestamp;
private final String reason;

public Throttle(DateTime timestamp, String reason) {
this.timestamp = timestamp.toDateTime(DateTimeZone.UTC);
public Throttle(ZonedDateTime timestamp, String reason) {
this.timestamp = timestamp.withZoneSameInstant(ZoneOffset.UTC);
this.reason = reason;
}

public DateTime timestamp() {
public ZonedDateTime timestamp() {
return timestamp;
}

Expand All @@ -300,7 +301,7 @@ public int hashCode() {
}

public static Throttle parse(String actionId, XContentParser parser) throws IOException {
DateTime timestamp = null;
ZonedDateTime timestamp = null;
String reason = null;

String currentFieldName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.xcontent.XContentParser;
import org.joda.time.DateTime;

import java.io.IOException;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -35,24 +36,23 @@
import static java.util.Collections.unmodifiableMap;
import static org.elasticsearch.client.watcher.WatchStatusDateParser.parseDate;
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
import static org.joda.time.DateTimeZone.UTC;

public class WatchStatus {

private final State state;

private final ExecutionState executionState;
private final DateTime lastChecked;
private final DateTime lastMetCondition;
private final ZonedDateTime lastChecked;
private final ZonedDateTime lastMetCondition;
private final long version;
private final Map<String, ActionStatus> actions;
@Nullable private Map<String, String> headers;

public WatchStatus(long version,
State state,
ExecutionState executionState,
DateTime lastChecked,
DateTime lastMetCondition,
ZonedDateTime lastChecked,
ZonedDateTime lastMetCondition,
Map<String, ActionStatus> actions,
Map<String, String> headers) {
this.version = version;
Expand All @@ -72,11 +72,11 @@ public boolean checked() {
return lastChecked != null;
}

public DateTime lastChecked() {
public ZonedDateTime lastChecked() {
return lastChecked;
}

public DateTime lastMetCondition() {
public ZonedDateTime lastMetCondition() {
return lastMetCondition;
}

Expand Down Expand Up @@ -123,8 +123,8 @@ public int hashCode() {
public static WatchStatus parse(XContentParser parser) throws IOException {
State state = null;
ExecutionState executionState = null;
DateTime lastChecked = null;
DateTime lastMetCondition = null;
ZonedDateTime lastChecked = null;
ZonedDateTime lastMetCondition = null;
Map<String, ActionStatus> actions = null;
Map<String, String> headers = Collections.emptyMap();
long version = -1;
Expand Down Expand Up @@ -203,9 +203,9 @@ public static WatchStatus parse(XContentParser parser) throws IOException {
public static class State {

private final boolean active;
private final DateTime timestamp;
private final ZonedDateTime timestamp;

public State(boolean active, DateTime timestamp) {
public State(boolean active, ZonedDateTime timestamp) {
this.active = active;
this.timestamp = timestamp;
}
Expand All @@ -214,7 +214,7 @@ public boolean isActive() {
return active;
}

public DateTime getTimestamp() {
public ZonedDateTime getTimestamp() {
return timestamp;
}

Expand All @@ -223,7 +223,7 @@ public static State parse(XContentParser parser) throws IOException {
throw new ElasticsearchParseException("expected an object but found [{}] instead", parser.currentToken());
}
boolean active = true;
DateTime timestamp = DateTime.now(UTC);
ZonedDateTime timestamp = ZonedDateTime.now(ZoneOffset.UTC);
String currentFieldName = null;
XContentParser.Token token;
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@

import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.common.time.DateFormatters;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

import java.io.IOException;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;

public final class WatchStatusDateParser {

Expand All @@ -36,14 +38,14 @@ private WatchStatusDateParser() {
// Prevent instantiation.
}

public static DateTime parseDate(String fieldName, XContentParser parser) throws IOException {
public static ZonedDateTime parseDate(String fieldName, XContentParser parser) throws IOException {
XContentParser.Token token = parser.currentToken();
if (token == XContentParser.Token.VALUE_NUMBER) {
return new DateTime(parser.longValue(), DateTimeZone.UTC);
return Instant.ofEpochMilli(parser.longValue()).atZone(ZoneOffset.UTC);
}
if (token == XContentParser.Token.VALUE_STRING) {
DateTime dateTime = parseDate(parser.text());
return dateTime.toDateTime(DateTimeZone.UTC);
ZonedDateTime dateTime = parseDate(parser.text());
return dateTime.withZoneSameInstant(ZoneOffset.UTC);
}
if (token == XContentParser.Token.VALUE_NULL) {
return null;
Expand All @@ -52,7 +54,7 @@ public static DateTime parseDate(String fieldName, XContentParser parser) throws
"to be either a number or a string but found [{}] instead", fieldName, token);
}

public static DateTime parseDate(String text) {
return FORMATTER.parseJoda(text);
public static ZonedDateTime parseDate(String text) {
return DateFormatters.from(FORMATTER.parse(text));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.XContentTestUtils;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

import java.io.IOException;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.function.Predicate;

public class WatchStatusTests extends ESTestCase {
Expand All @@ -50,32 +51,32 @@ public void testBasicParsing() throws IOException {
assertEquals(expectedVersion, watchStatus.version());
assertEquals(expectedExecutionState, watchStatus.getExecutionState());

assertEquals(new DateTime(1432663467763L, DateTimeZone.UTC), watchStatus.lastChecked());
assertEquals(DateTime.parse("2015-05-26T18:04:27.763Z"), watchStatus.lastMetCondition());
assertEquals(Instant.ofEpochMilli(1432663467763L).atZone(ZoneOffset.UTC), watchStatus.lastChecked());
assertEquals(ZonedDateTime.parse("2015-05-26T18:04:27.763Z"), watchStatus.lastMetCondition());

WatchStatus.State watchState = watchStatus.state();
assertEquals(expectedActive, watchState.isActive());
assertEquals(DateTime.parse("2015-05-26T18:04:27.723Z"), watchState.getTimestamp());
assertEquals(ZonedDateTime.parse("2015-05-26T18:04:27.723Z"), watchState.getTimestamp());

ActionStatus actionStatus = watchStatus.actionStatus("test_index");
assertNotNull(actionStatus);

ActionStatus.AckStatus ackStatus = actionStatus.ackStatus();
assertEquals(DateTime.parse("2015-05-26T18:04:27.763Z"), ackStatus.timestamp());
assertEquals(ZonedDateTime.parse("2015-05-26T18:04:27.763Z"), ackStatus.timestamp());
assertEquals(expectedAckState, ackStatus.state());

ActionStatus.Execution lastExecution = actionStatus.lastExecution();
assertEquals(DateTime.parse("2015-05-25T18:04:27.733Z"), lastExecution.timestamp());
assertEquals(ZonedDateTime.parse("2015-05-25T18:04:27.733Z"), lastExecution.timestamp());
assertFalse(lastExecution.successful());
assertEquals("failed to send email", lastExecution.reason());

ActionStatus.Execution lastSuccessfulExecution = actionStatus.lastSuccessfulExecution();
assertEquals(DateTime.parse("2015-05-25T18:04:27.773Z"), lastSuccessfulExecution.timestamp());
assertEquals(ZonedDateTime.parse("2015-05-25T18:04:27.773Z"), lastSuccessfulExecution.timestamp());
assertTrue(lastSuccessfulExecution.successful());
assertNull(lastSuccessfulExecution.reason());

ActionStatus.Throttle lastThrottle = actionStatus.lastThrottle();
assertEquals(DateTime.parse("2015-04-25T18:05:23.445Z"), lastThrottle.timestamp());
assertEquals(ZonedDateTime.parse("2015-04-25T18:05:23.445Z"), lastThrottle.timestamp());
assertEquals("throttling interval is set to [5 seconds] ...", lastThrottle.reason());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public void testRoundupFormatterWithEpochDates() {
assertRoundupFormatter("strict_date_optional_time||epoch_millis", "2018-10-10T12:13:14.123Z", 1539173594123L);
assertRoundupFormatter("strict_date_optional_time||epoch_millis", "1234567890", 1234567890L);
assertRoundupFormatter("strict_date_optional_time||epoch_millis", "2018-10-10", 1539215999999L);
assertRoundupFormatter("strict_date_optional_time||epoch_millis", "2019-01-25T15:37:17.346928Z", 1548430637346L);
assertRoundupFormatter("uuuu-MM-dd'T'HH:mm:ss.SSS||epoch_millis", "2018-10-10T12:13:14.123", 1539173594123L);
assertRoundupFormatter("uuuu-MM-dd'T'HH:mm:ss.SSS||epoch_millis", "1234567890", 1234567890L);

Expand Down
Loading