All of what we have found so far Run using maven You reproduce the error by running TaskHelperTest before SchedulerFormControllerTest. There are two errors that come up seemingly at random. At first, it was almost impossible to reproduce, but I've noticed that as I've been testing, it's becoming more unlikey that it'll pass through without an error. Even after rebuilding the whole thing. Could just be an anomaly though. ====== First Error ------------ Running org.openmrs.scheduler.web.controller.ATaskHelperTest setUP waitUntilTaskIsExecuting_shouldWaitUntilTaskIsExecuting setUP getTime_shouldGetATimeInTheFuture setUP waitUntilTaskIsExecuting_shouldRaiseATimeoutExceptionWhenTheTimeoutIsExceeded setUP getTime_shouldGetATimeInThePast setUP getScheduledTaskDefinition_shouldReturnATaskThatHasBeenStarted setUP getUnscheduledTaskDefinition_shouldReturnATaskThatHasNotBeenStarted Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 76.246 sec Running org.openmrs.scheduler.web.controller.CSchedulerFormControllerTest setUpSchedulerService onSubmit_shouldRescheduleACurrentlyScheduledTask setUpSchedulerService processFormSubmission_shouldNotThrowNullPointerExceptionIfRepeatIntervalIsNull setUpSchedulerService onSubmit_shouldNotRescheduleATaskThatIsNotCurrentlyScheduled setUpSchedulerService onSubmit_shouldNotRescheduleAnExecutingTask A setUpSchedulerService onSubmit_shouldNotRescheduleATaskIfTheStartTimeHasPassed Results : Tests in error: onSubmit_shouldNotRescheduleAnExecutingTask(org.openmrs.scheduler.web.controller.CSchedulerFormControllerTest): query did not return a unique result: 2 onSubmit_shouldNotRescheduleATaskIfTheStartTimeHasPassed(org.openmrs.scheduler.web.controller.CSchedulerFormControllerTest): query did not return a unique result: 2 Not much progress has been made on this error. I'm pretty sure the error is thrown from the taskHelper.getScheduledtaskDefinition(...) call for the onSubmit_shouldNotRescheduleAnExecutingTask test. As for the other, probably something similar. ====== Second Error (LUI-44) ------------ setUP waitUntilTaskIsExecuting_shouldWaitUntilTaskIsExecuting setUP getTime_shouldGetATimeInTheFuture setUP waitUntilTaskIsExecuting_shouldRaiseATimeoutExceptionWhenTheTimeoutIsExceeded setUP getTime_shouldGetATimeInThePast setUP getScheduledTaskDefinition_shouldReturnATaskThatHasBeenStarted setUP getUnscheduledTaskDefinition_shouldReturnATaskThatHasNotBeenStarted Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 72.958 sec Running org.openmrs.scheduler.web.controller.CSchedulerFormControllerTest setUpSchedulerService onSubmit_shouldRescheduleACurrentlyScheduledTask setUpSchedulerService processFormSubmission_shouldNotThrowNullPointerExceptionIfRepeatIntervalIsNull setUpSchedulerService onSubmit_shouldNotRescheduleATaskThatIsNotCurrentlyScheduled setUpSchedulerService onSubmit_shouldNotRescheduleAnExecutingTask A B C D E F G H I ERROR - SqlExceptionHelper.logExceptions(146) |2018-03-15 11:23:19,301| Unique index or primary key violation: "UK_IVY1J18CM9UC9WCL0N0TSA6BQ_INDEX_2 ON PUBLIC.SCHEDULER_TASK_CONFIG(UUID) VALUES ('29754c38-6711-11e0-9d74-18a905e044dc', 1)"; SQL statement: insert into scheduler_task_config (task_config_id, uuid, name, description, schedulable_class, repeat_interval, start_time, start_time_pattern, last_execution_time, start_on_startup, started, created_by, changed_by, date_created, date_changed) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [23505-187] J setUpSchedulerService onSubmit_shouldNotRescheduleATaskIfTheStartTimeHasPassed We can confirm that what throws the error is the deleteAllData() call from the onSubmit_shouldNotRescheduleAnExecutingTask test from the SchedulerFormControllerTest class. Contrary to previous theories, the waitUntiltaskisExecuting_shouldWaitUntilTaskIsExecuting test is not the cause of the error. I've commented out the whole test, and I still get the error. I will be trying to run individual TaskHelperTests to hopefully pinpoint the exact test that's causing it. It has nothing to do the order the tests are run. There's either some outside and currently unknown concurrent process that's involved. Either that, or the current time is messing thing's up as that's the only thing that changes between TaskHelperTest executions.