Bug #14878

[API] Fix unreliable test

Added by Tom Clegg 28 days ago. Updated 8 days ago.

Assigned To:
Target version:
Start date:
Due date:
% Done:


Estimated time:
(Total: 0.00 h)
Story points:


"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 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.


Task #14955: ReviewNewPeter Amstutz


#1 Updated by Tom Clegg 28 days ago

  • Description updated (diff)

#2 Updated by Tom Morris 8 days ago

  • Target version set to 2019-03-27 Sprint

#3 Updated by Lucas Di Pentima 8 days ago

  • Assigned To set to Lucas Di Pentima

Also available in: Atom PDF