-
Notifications
You must be signed in to change notification settings - Fork 25.2k
SQL: improve timezone sensitive JDBC tests to account for offset differences #51592
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
Conversation
* Changed several tests to compare only the relevant parts of the conversion failure error message and ignore the actual datetime String from the error message itself
Pinging @elastic/es-search (:Search/SQL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
doWithQuery(SELECT_ALL_FIELDS, (results) -> { | ||
// Create simple timezones (in the form of Z/GMT+/-x so that timezones offsets differences between | ||
// Java versions (the one server runs on and the one the test runs on) will not skew the tests' results | ||
int hoursOffset = randomIntBetween(0, 18); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a comment here, for the 18
(maximum offset)?
int totalSeconds = (hoursOffset * 3600 + subHours * 60) * plusMinus; | ||
|
||
ZoneOffset randomFixedZone = ZoneOffset.ofTotalSeconds(totalSeconds); | ||
String zoneString = (hoursOffset == 0 && subHours == 0) ? "Z" : "GMT" + randomFixedZone.getId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: while GMT
and UTC
are identical in this timezones context, my impression is that there is a shift towards using the UTC
for references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What basically happens is that the server runs on a java version where a certain timezone has a set of offset rules, while the test itself runs on a java version where the same timezone has changed offset rules (think about a country deciding to use utc+x instead of utc+y). With this change the timezone used in testGettingTimeWithoutCalendar is randomly generated by creating a fixed offset timezone (ie GMT+X or Z instead of Australia/West timezone) so that the offset is always fixed, thus avoiding the described issue. Similar fix to #51592 Fixes: #52650
Original PR: #51290
Based on the discussion here decision has been made to merge this PR in 6.8 only.
This PR addresses CI failures reported in #45035 and #48234, but also other even more rare CI failures looking like
What basically happens is that the server runs on a java version where a certain timezone has a set of offset rules, while the test itself runs on a java version where the same timezone has changed offset rules (think about a country deciding to use utc+x instead of utc+y).
This PR changed several tests to compare only the relevant parts of the conversion failure error message and ignore the actual datetime String from the error message itself (thus, ignoring the value of the datetime itself that's part of the error message).
Also, there is another change fixing the second issue mentioned above where a timezone in
testGettingDateWithoutCalendar
is randomly generated by creating a fixed offset timezone (ieGMT+X
orZ
instead ofAustralia/West
timezone) so that the offset is always fixed.