Bug #14878

[API] Fix unreliable test

Added by Tom Clegg 3 months ago. Updated 8 days ago.

Status:
New
Priority:
Normal
Assigned To:
Category:
Tests
Target version:
Start date:
Due date:
% Done:

0%

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

Description

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

Subtasks

Task #14955: ReviewNewEric Biagiotti

History

#1 Updated by Tom Clegg 3 months ago

  • Description updated (diff)

#2 Updated by Tom Morris 2 months ago

  • Target version set to 2019-03-27 Sprint

#3 Updated by Lucas Di Pentima 2 months ago

  • Assigned To set to Lucas Di Pentima

#4 Updated by Tom Morris about 2 months ago

  • Target version changed from 2019-03-27 Sprint to 2019-04-10 Sprint

#5 Updated by Lucas Di Pentima about 1 month ago

  • Target version changed from 2019-04-10 Sprint to 2019-04-24 Sprint

#6 Updated by Lucas Di Pentima 27 days ago

  • Target version changed from 2019-04-24 Sprint to 2019-05-08 Sprint

#7 Updated by Lucas Di Pentima 12 days ago

  • Target version changed from 2019-05-08 Sprint to 2019-05-22 Sprint

Also available in: Atom PDF