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

Change time zone used in tests to better test date/time/zone/JVM-related corner cases #10078

Closed
3 tasks
findepi opened this issue Mar 2, 2018 · 16 comments · Fixed by #10128
Closed
3 tasks
Labels

Comments

@findepi
Copy link
Contributor

findepi commented Mar 2, 2018

All tests are run with Asia/Kathmandu time zone. I think it was chosen because:

  1. it's zone offset has changed since 1970
  2. it's zone offset is not whole hours (was it the case?)

These are nice properties, but there are other nice properties a time zone could have:

  1. DST (breaks so many things)
  2. having DST change at midnight (breaks all those code paths that represent date as local time at midnight)

Since it's not possible to change JVM default zone for just a single test, using Asia/Kathmandu makes it not possible to test functionalities around DST changes. For example, reading TIMESTAMP values using JDBC ResultSet.getTimestamp() cannot succeed when TIMESTAMP value to be returned never occurred in JVM time zone, was skipped (DST change forward).

For these reasons, I'd like to change time zone used in tests to one having DST. Unfortunately there isn't a zone that has all 4 properties on regular basis. I wish we could create a new one, just for programs testing..

I think we should choose one of these:

  • Pacific/Chatham (has properties: 1, 2, 3 and partially 4)

    • offset Jan 1970: +12:45, offset Jan 2018: +13:45
    • DST on Jan '18: true
    • doesn't have DST change at midnight... but had twice in the past, most recently on Tuesday, 1 January 1946, 00:00:00 clocks were turned forward 0:30 hours
      • maybe one DST change at midnight is actually enough. I'd prefer a year >1970 however
  • Pacific/Apia (has properties: 1, 1, 1, 1, 1, 1, 1, 2-, 3, 4)

    • offset Jan 1970: -11:00, offset Jan 2018: +14:00 (25h difference, the only one such: on Friday, 30 December 2011, 00:00:00 clocks were turned forward 24 hours)
    • DST on Jan '18: true
    • .. but doesn't have not-whole-hours-offset (i'm unsure how important is that)
    • doesn't have DST change at midnight, but had several times in the past, most recently on Sunday, 26 September 2010, 00:00:00 clocks were turned forward 1 hour
      • one DST change at midnight is actually enough

I am aware changing time zone will require changing expected values in tests, whenever TIMESTAMP is touched, due to #7122.

cc @losipiuk @martint @electrum @haozhun


@dain
Copy link
Contributor

dain commented Mar 2, 2018

2. it's zone offset is not whole hours (was it the case?) 

Yes... It makes it easy to detect bugs/error because the printed time is so different from the current time.

I'm ok with either choice. For Pacific/Chatham I agree that the < 1970 is a bit annoying.... I'd lean towards Pacific/Apia, but not super strong preference.

@ArturGajowy
Copy link
Contributor

How about choosing one of the hard timezones randomly on test start? 😈

@kokosing
Copy link
Contributor

kokosing commented Mar 3, 2018

Maybe we could have couple test suites where each would leverage different TZ (different JVM fork)? It is a bit annoying infrastructure but that would cover all the corner cases.

@findepi
Copy link
Contributor Author

findepi commented Mar 3, 2018

@kokosing with this approach, what would become possible to test, what isn't possible if we go with e.g. Pacific/Apia?

@kokosing
Copy link
Contributor

kokosing commented Mar 3, 2018

I meant that we could stay with Asia/Kathmandu for regular tests and use Pacific/Apia for tests around DST. I am not sure if it is worth to stay with Asia/Kathmandu just to keep not whole hours zone offset.

@findepi
Copy link
Contributor Author

findepi commented Mar 5, 2018

Actually there are two time zone definitions used in tests:

  • pom.xml's <air.test.timezone>Asia/Katmandu</air.test.timezone> -- this controls JVM time zone, which impacts how java.sql.{Date,Time,Timestamp} behave (and also what values are representable)
  • TestingSession's .setTimeZoneKey(UTC_KEY) -- this controls session time zone, and this impacts Presto behavior (most importantly: TIMESTAMP behaviour does not match sql standard #7122). With session in UTC zone, some problems go unnoticed.

I was initially thinking about the first one, but now I think we should change both and to some different zones.

@findepi findepi added the tests label Mar 5, 2018
@findepi
Copy link
Contributor Author

findepi commented Mar 5, 2018

Also, the proposed zones have local time change at midnight only forward. Forward change is more important as it affects representability of date-time values in java.sql.{Date,Timestamp} classes.
If, however, we wanted a zone that has DST change both forward and backward, we need to give up property #2 (zone offset is not whole hours)... Then America/Asuncion would be a candidate (properties 1, 3, 4+).

The bad news is that there is other interesting property:

  1. zone offset change on Jan 1, 1970: this affects time representability for java.sql.Time as well as Presto's TIME WITH TIME ZONE (see this comment in "TIMESTAMP official").

There are 3 zones that have properties (1, 3, 4-, 5):

            America/Bahia_Banderas:  offset Jan 1970: -08:00, offset Jan 2018: -06:00,  DST Jan '18: false, DST Jul '18:  true, shift on 1970-01-01: true
                  America/Mazatlan:  offset Jan 1970: -08:00, offset Jan 2018: -07:00,  DST Jan '18: false, DST Jul '18:  true, shift on 1970-01-01: true
                    Mexico/BajaSur:  offset Jan 1970: -08:00, offset Jan 2018: -07:00,  DST Jan '18: false, DST Jul '18:  true, shift on 1970-01-01: true

@findepi
Copy link
Contributor Author

findepi commented Mar 5, 2018

My apologies. I intended this to be well-prepared proposal before posting this issue, but it turned into thinking aloud...

There simply isn't a time zone that is a perfect fit.

@findepi findepi changed the title Change time zone used in tests Change time zone used in tests to better test date/time/zone/JVM-related corner cases Mar 6, 2018
@findepi
Copy link
Contributor Author

findepi commented Mar 6, 2018

Doing this change may help with testing in #7122.

@findepi
Copy link
Contributor Author

findepi commented Mar 7, 2018

@dain, I singled out America/Bahia_Banderas as my candidate. Zone offset changes on Jan 1, 1970 are invaluable.
For now, I use this zone in #10114 in postgres and mysql modules as tests JVM zone, but I think we could apply it universally.
I didn't make my mind yet as to what should the default session zone in tests be.

@haozhun
Copy link
Contributor

haozhun commented Mar 7, 2018

@findepi

I wasn't involved with Presto when the decision was made. But one of the very important reasons here (that I remember @dain talking about) is that its offset is positive. Given Presto team works in a negative zone, we had bugs that only affect users in positive zones. And that went unnoticed.

I don't care that much about whole-hour. Assuming basic competitiveness of the code, I can't think of a way non-whole-hour zone can break.

@findepi
Copy link
Contributor Author

findepi commented Mar 7, 2018

@haozhun let's use a positive offset zone for default session zone in tests (TestingSession). Anyway, we shouldn't have zones: (1) tests JVM zone and (2) tests' default session zone both default to the same (or similar) things. What do you think?

findepi added a commit to starburstdata/facebook-presto that referenced this issue Apr 4, 2018
@findepi
Copy link
Contributor Author

findepi commented Apr 6, 2018

i added checkboxes to the issue description

@findepi
Copy link
Contributor Author

findepi commented Jun 24, 2018

I am updating #10128 to cover product tests too (switching them to America/Bahia_Banderas).
Once we don't use Kathmandu zone for JVM zone any more, i think we could use it for default session zone (TestingSession). I previously proposed Vilnius zone for this, but I forgot why I did so :)

@findepi
Copy link
Contributor Author

findepi commented Jun 24, 2018

Once we don't use Kathmandu zone for JVM zone any more, i think we could use it for default session zone (TestingSession). I previously proposed Vilnius zone for this, but I forgot why I did so :)

I remember now. Kathmandu doesn't have DST.

findepi added a commit to starburstdata/facebook-presto that referenced this issue Jun 29, 2018
findepi added a commit to starburstdata/facebook-presto that referenced this issue Jun 29, 2018
findepi added a commit to starburstdata/facebook-presto that referenced this issue Jul 13, 2018
findepi added a commit to starburstdata/facebook-presto that referenced this issue Jul 13, 2018
@findepi
Copy link
Contributor Author

findepi commented Jul 13, 2018

As explained in #10940 (comment), we cannot use a zone with "property 5" (forward offset change at 1970-01-01 00:00:00 local time) as product tests's zone.
Thus, we are going to have 2 different JVM zones:

I propose to use Pacific/Apia (having properties 1++,2-,3,4) for product tests, instead of Kathmandu used today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants