diff options
| author | Lance Bragstad <ldbragst@us.ibm.com> | 2013-06-28 02:53:24 +0000 |
|---|---|---|
| committer | Lance Bragstad <ldbragst@us.ibm.com> | 2013-08-01 20:18:58 +0000 |
| commit | cb2a2b6e234be9cb5a63409b5c7594cf6ac4a9d0 (patch) | |
| tree | 7ad353a1f191d57c1125b4e89d952772cf1c8d38 /tests | |
| parent | d4d81262ff74ff54e51db4065192fd9a0119ec34 (diff) | |
| download | oslo-cb2a2b6e234be9cb5a63409b5c7594cf6ac4a9d0.tar.gz oslo-cb2a2b6e234be9cb5a63409b5c7594cf6ac4a9d0.tar.xz oslo-cb2a2b6e234be9cb5a63409b5c7594cf6ac4a9d0.zip | |
Modify local.py to not be dependent on Eventlet
Change local.py to use threading.local instead of being dependent on
Eventlet corolocal.local.
Change-Id: Ib544be1485823f6c619312fdee5a04031f48bbb4
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/test_local.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/unit/test_local.py b/tests/unit/test_local.py index 37e5798..bc7b05d 100644 --- a/tests/unit/test_local.py +++ b/tests/unit/test_local.py @@ -15,7 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. -import eventlet +import threading from openstack.common import local from tests import utils @@ -31,6 +31,15 @@ class LocalStoreTestCase(utils.BaseTestCase): v2 = Dict(a='2') v3 = Dict(a='3') + def setUp(self): + super(LocalStoreTestCase, self).setUp() + # NOTE(mrodden): we need to make sure that local store + # gets imported in the current python context we are + # testing in (eventlet vs normal python threading) so + # we test the correct type of local store for the current + # threading model + reload(local) + def test_thread_unique_storage(self): """Make sure local store holds thread specific values.""" expected_set = [] @@ -44,8 +53,13 @@ class LocalStoreTestCase(utils.BaseTestCase): local.store.a = self.v3 expected_set.append(getattr(local.store, 'a')) - eventlet.spawn(do_something).wait() - eventlet.spawn(do_something2).wait() + t1 = threading.Thread(target=do_something) + t2 = threading.Thread(target=do_something2) + t1.start() + t2.start() + t1.join() + t2.join() + expected_set.append(getattr(local.store, 'a')) self.assertTrue(self.v1 in expected_set) |
