Bug #14878

Updated by Tom Clegg almost 3 years ago

"Update priority" tests fail occasionally.

From https://ci.curoverse.com/job/developer-run-tests-services-api/1095/console
1) Failure:
UpdatePriorityTest#test_priority_0_but_should_be_>0 [/home/ci-jenkins/.jenkins-slave/workspace/developer-run-tests-services-api/services/api/test/unit/update_priority_test.rb:20]:
Expected 0 to be < 0.

Possible explanation: if a background update task (@UpdatePriority.run_update_thread()@, started (started from an after_commit callback in a previous test) is still running when the test case does an explicit inline call to @UpdatePriority.update_priority()@, the inline call fails to get the lock, and returns immediately. But the background task's updates do not necessarily incorporate the latest priority updates, and even if they do, the resulting updates are not necessarily committed before the test case checks for them.

Possible ways to fix:
* Don't start the background update thread in the test environment.
* Pass a "block if needed" flag to update_priority(), so the test case works even when background tasks are running.