Race condition causes unit test to occasionally fail

Bug #796820 reported by Lorin Hochstein
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
USC-ISI

Bug Description

Occasionally, I get the following unit test failure:

======================================================================
FAIL: test_run_instances (nova.tests.test_direct.DirectCloudTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/lorin/nova/trunk/nova/tests/test_cloud.py", line 469, in test_run_instances
    self.assertEqual(instance['instanceState']['name'], 'networking')
AssertionError: u'scheduling' != 'networking'

----------------------------------------------------------------------

The issue seems to be that the test assumes that the rpc.cast in nova.compute.api:create completes on time, and sometimes it doesn't.

The test code (test_cloud.py) already has the following code to reduce the probability of this happening:

        rpc_cast = rpc.cast

        def finish_cast(*args, **kwargs):
            rpc_cast(*args, **kwargs)
            greenthread.sleep(0.2)

        self.stubs.Set(rpc, 'cast', finish_cast)

---

If you comment out the sleep statement, the bug can be reliably reproduced.

Related branches

Thierry Carrez (ttx)
Changed in nova:
assignee: nobody → USC-ISI (usc-isi)
importance: Undecided → Low
status: New → In Progress
Thierry Carrez (ttx)
Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → diablo-2
Thierry Carrez (ttx)
Changed in nova:
milestone: diablo-2 → 2011.3
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.