Timezone issues with Tests
Zynde opened this issue · 4 comments
I'm still having real issues with the timezone stuff in my timezone. I was following a suggestion by @gs-rezaem to run the TestPostgresGeneralTestCases
to make sure it worked with AWS Aurora (PostgreSQL). I was initially making sure all the tests ran locally with normal PostgreSQL.
I think the issue might lie in this bit of code in MithraTimestamp
protected static int getOffsetFromTimeZoneToUtc(TimeZone tz, Date date)
{
if (date.getTime() <= TIME_FOR_1950_01_01)
{
return DateTimeZone.forTimeZone(tz).getOffset(date.getTime());
}
else
{
int offset = tz.getRawOffset();
if (tz.inDaylightTime(date))
{
offset += tz.getDSTSavings();
}
return offset;
}
}
My run of a test I was looking at goes in to the else. The date in question happens to be a date that was in a Daylight Saving period. So the check if (tz.inDaylightTime(date))
is true. It then gets the current Daylight savings offset with tz.getDSTSavings()
which is not currently in a Daylight Savings period so the date is offset incorrectly by 1 hour. So when the date is retrieved it is not the original date but out by 1 hour.
Am I on the right track and does that make any sense?
Also is there a way of running all the tests for a specific timezone for both the user and database I guess I'm asking.
We're aware that the test cases only run correctly in America/New_York (#28 ). Use -Duser.timezone=America/New_York to run the test in that zone.
I don't think the database timezone should matter.
As for the piece of code above, you're likely correct. Does it work for you if you change 1950 t0 1995?
build.sh is setup for continuous build, but it's not hard to repurpose it for a single vendor run.
I typically either run a single vendor test from an IDE, or do this:
- edit build.xml and comment out all the vendors except the one you want in
run-reladomo-vendor-test-suite
- make sure
credentials.properties
has the right values for your destination database. - In your case, you'll also want to edit the macro
exec-test-suite
to add an extrajvmarg
for the timezone. build.sh run-reladomo-vendor-test-suite