diff options
| author | Clark Boylan <clark.boylan@gmail.com> | 2012-12-06 18:01:54 -0800 |
|---|---|---|
| committer | Clark Boylan <clark.boylan@gmail.com> | 2012-12-07 16:52:23 -0800 |
| commit | 87ced20aff04b062d3b5ec46124a9a6d154e3690 (patch) | |
| tree | ba2f978b88f42242af4c07142196e71c1dcaac79 /nova | |
| parent | 86cc905734f81c5363c1dc86ea2bba662bb18892 (diff) | |
Fix fname concurrency tests.
It was possible for thread2 to run before thread1 in the fname
concurrency tests. When this happens the assertions in the fname
concurrency tests fail. In each fname test block until thread 1 signals
the test before creating thread 2. In the different fname test block
until thread 2 signals the test before beginning the actual test work.
This ensures everyone has started as expected before checking the
expected done values.
Part of blueprint grizzly-testtools
Change-Id: I119fb03423324c9db9847b97d9bb69e71fef2aad
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/tests/test_libvirt.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 872c0498d..112da43c8 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -82,7 +82,8 @@ _fake_stub_out_get_nw_info = fake_network.stub_out_nw_api_get_instance_nw_info _ipv4_like = fake_network.ipv4_like -def _concurrency(wait, done, target): +def _concurrency(signal, wait, done, target): + signal.send() wait.wait() done.send() @@ -491,12 +492,21 @@ class CacheConcurrencyTestCase(test.TestCase): backend = imagebackend.Backend(False) wait1 = eventlet.event.Event() done1 = eventlet.event.Event() + sig1 = eventlet.event.Event() thr1 = eventlet.spawn(backend.image('instance', 'name').cache, - _concurrency, 'fname', None, wait=wait1, done=done1) + _concurrency, 'fname', None, + signal=sig1, wait=wait1, done=done1) + eventlet.sleep(0) + # Thread 1 should run before thread 2. + sig1.wait() + wait2 = eventlet.event.Event() done2 = eventlet.event.Event() + sig2 = eventlet.event.Event() thr2 = eventlet.spawn(backend.image('instance', 'name').cache, - _concurrency, 'fname', None, wait=wait2, done=done2) + _concurrency, 'fname', None, + signal=sig2, wait=wait2, done=done2) + wait2.send() eventlet.sleep(0) try: @@ -516,12 +526,24 @@ class CacheConcurrencyTestCase(test.TestCase): backend = imagebackend.Backend(False) wait1 = eventlet.event.Event() done1 = eventlet.event.Event() + sig1 = eventlet.event.Event() thr1 = eventlet.spawn(backend.image('instance', 'name').cache, - _concurrency, 'fname2', None, wait=wait1, done=done1) + _concurrency, 'fname2', None, + signal=sig1, wait=wait1, done=done1) + eventlet.sleep(0) + # Thread 1 should run before thread 2. + sig1.wait() + wait2 = eventlet.event.Event() done2 = eventlet.event.Event() + sig2 = eventlet.event.Event() thr2 = eventlet.spawn(backend.image('instance', 'name').cache, - _concurrency, 'fname1', None, wait=wait2, done=done2) + _concurrency, 'fname1', None, + signal=sig2, wait=wait2, done=done2) + eventlet.sleep(0) + # Wait for thread 2 to start. + sig2.wait() + wait2.send() eventlet.sleep(0) try: |
