Certain Scheduler Service tests fail when they should not

Steps to reproduce

I think this issue may be related to time zones/side effect of JVM changing internal time zone.

Steps to reproduce:
1. travel to a different time zone (ha!). A UTC+2 time zone seems to do the trick
2. run `mvn clean install` to build OC + perform tests

Actual Results:
A number of Scheduler Service tests will fail

Expected Results:
Tests should not fail.

Workaround (if any):

One of the failing tests:

@Test
public void removeScheduledRecordingsBeforeBufferInputOneEvent() throws Exception {
Date start = new Date(System.currentTimeMillis() - 160000);
Date end = new Date(System.currentTimeMillis() - 60000);
String captureDeviceID = "demo";
MediaPackage mp = generateEvent(Opt.<String> none());
...
schedSvc.addEvent(arguments related to mp generated above); //add an event
schedSvc.removeScheduledRecordingsBeforeBuffer(X); //this should remove the recently added event

where no events are removed if X is between -3539 and 0 (0 is the current/default value used in the test). -3539 above probably isn't arbitrary and could be related to my timezone of Africa/Johannesburg = UTC+2 (perhaps 3600 seconds - 1 min = 3540 onwards works?)

Activity

Show:
duncan smith
December 3, 2018, 3:40 PM

Changing timezones with timedatectl changes test results (Berlin seems to be the only timezone that passes all tests for me):

$ sudo timedatectl set-timezone "Australia/Sydney" && mvn clean install
[ERROR] Failures:
[ERROR] SchedulerServiceImplTest.removeScheduledRecordingsBeforeBufferInputOneEvent:2191
[ERROR] SchedulerServiceImplTest.testCalendarCutoff:1595 expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testCalendarCutoffWithStartedEvent:1618 expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testEventManagement:2090
[ERROR] SchedulerServiceImplTest.testFindConflictingEvents:1893 expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testPersistence:477
[ERROR] SchedulerServiceImplTest.testTransactionCleanup:1240
[ERROR] SchedulerServiceImplTest.testTransactionCommit:611 Transaction create lock not working!
[ERROR] SchedulerServiceImplTest.testTransactionConflicts:1269 Transaction create lock not working!
[ERROR] Errors:
[ERROR] SchedulerServiceImplTest.testTransactionCommitCleanup:669 » SchedulerConflict ...
[ERROR] SchedulerServiceImplTest.testTransactionCommitCollision:735 » SchedulerConflict
[ERROR] SchedulerServiceImplTest.testTransactionCommitConflict:891 » SchedulerConflict
[ERROR] SchedulerServiceImplTest.testTransactionRollback:1141 » SchedulerConflict Tran...
[ERROR] SchedulerServiceImplTest.testUpdateExpiredEvent » Unexpected exception, expec...
[INFO]
[ERROR] Tests run: 44, Failures: 9, Errors: 5, Skipped: 0

$ sudo timedatectl set-timezone "Africa/Johannesburg" && mvn clean install
[ERROR] Failures:
[ERROR] SchedulerServiceImplTest.removeScheduledRecordingsBeforeBufferInputOneEvent:2191
[ERROR] SchedulerServiceImplTest.testCalendarCutoff:1595 expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testEventManagement:2090
[ERROR] SchedulerServiceImplTest.testFindConflictingEvents:1893 expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testPersistence:477
[ERROR] SchedulerServiceImplTest.testTransactionCleanup:1240
[ERROR] SchedulerServiceImplTest.testTransactionCommit:611 Transaction create lock not working!
[ERROR] SchedulerServiceImplTest.testTransactionConflicts:1269 Transaction create lock not working!
[ERROR] Errors:
[ERROR] SchedulerServiceImplTest.testGetCalendarInputRegularOptedOutBlacklistedExpectsOnlyRegularEvents:2149->createEvents:2382 » SchedulerConflict
[ERROR] SchedulerServiceImplTest.testTransactionCommitCleanup:669 » SchedulerConflict ...
[ERROR] SchedulerServiceImplTest.testTransactionCommitCollision:735 » SchedulerConflict
[ERROR] SchedulerServiceImplTest.testTransactionCommitConflict:891 » SchedulerConflict
[ERROR] SchedulerServiceImplTest.testTransactionRollback:1141 » SchedulerConflict Tran...
[ERROR] SchedulerServiceImplTest.testUpdateExpiredEvent » Unexpected exception, expec...
[INFO]
[ERROR] Tests run: 44, Failures: 8, Errors: 6, Skipped: 0

$ sudo timedatectl set-timezone "UTC" && mvn clean install
[ERROR] Failures:
[ERROR] SchedulerServiceImplTest.testFindConflictingEvents:1893 expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testPersistence:477
[ERROR] Errors:
[ERROR] SchedulerServiceImplTest.testCalendarNotModified:1468 » Scheduler Event ID b3b...
[ERROR] SchedulerServiceImplTest.testEventManagement:2106 » Scheduler Event ID 1604625...
[ERROR] SchedulerServiceImplTest.testTransactionCommit:624 » Scheduler Event ID 666a51...
[ERROR] SchedulerServiceImplTest.testTransactionCommitConflict:910 » Scheduler Event I...
[ERROR] SchedulerServiceImplTest.testTransactionConflicts:1288 » Scheduler Event ID 35...
[ERROR] SchedulerServiceImplTest.testTransactionRollback:1151 » Scheduler Event ID 7de...
[INFO]
[ERROR] Tests run: 44, Failures: 2, Errors: 6, Skipped: 0

$ sudo timedatectl set-timezone "America/Los_Angeles" && mvn clean install
[ERROR] Failures:
[ERROR] SchedulerServiceImplTest.testCalendarCutoff:1595 expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testCalendarCutoffWithStartedEvent:1618 expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testEventStatus:1523->checkEvent:2416->checkIcalFeed:2422 number of entries expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testFindConflictingEvents:1893 expected:<1> but was:<0>
[ERROR] SchedulerServiceImplTest.testGetCalendarInputRegularOptedOutBlacklistedExpectsOnlyRegularEvents:2165 All of the regular events should be in the calendar. expected:<14> but was:<2>
[ERROR] SchedulerServiceImplTest.testPersistence:477
[ERROR] SchedulerServiceImplTest.testUpdateEvent:2019->checkEvent:2416->checkIcalFeed:2422 number of entries expected:<1> but was:<0>
[ERROR] Errors:
[ERROR] SchedulerServiceImplTest.testCalendarNotModified:1468 » Scheduler Event ID 563...
[ERROR] SchedulerServiceImplTest.testEventManagement:2106 » Scheduler Event ID a8e21e4...
[ERROR] SchedulerServiceImplTest.testEventStatusFromSeries:1564 » Scheduler Event ID 3...
[ERROR] SchedulerServiceImplTest.testTransactionCommit:624 » Scheduler Event ID f03d26...
[ERROR] SchedulerServiceImplTest.testTransactionCommitConflict:910 » Scheduler Event I...
[ERROR] SchedulerServiceImplTest.testTransactionConflicts:1288 » Scheduler Event ID 78...
[ERROR] SchedulerServiceImplTest.testTransactionRollback:1151 » Scheduler Event ID fbe...
[INFO]
[ERROR] Tests run: 44, Failures: 7, Errors: 7, Skipped: 0

$ sudo timedatectl set-timezone "Europe/Berlin" && mvn clean install
[INFO] Tests run: 36, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.482 s - in org.opencastproject.scheduler.impl.SchedulerServiceImplTest
[INFO] Running org.opencastproject.scheduler.impl.SchedulerUtilTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.041 s - in org.opencastproject.scheduler.impl.SchedulerUtilTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 44, Failures: 0, Errors: 0, Skipped: 0

Stephen Marquard
February 16, 2019, 7:40 AM

Resolved by

Assignee

Unassigned

Reporter

duncan smith

Severity

Tests

Tags (folksonomy)

None

Components

Affects versions

Priority

Major
Configure