当前位置: 首页>>代码示例>>Python>>正文


Python tests.get_random_uuid函数代码示例

本文整理汇总了Python中tooz.tests.get_random_uuid函数的典型用法代码示例。如果您正苦于以下问题:Python get_random_uuid函数的具体用法?Python get_random_uuid怎么用?Python get_random_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_random_uuid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_lock_concurrency_locking2

    def test_get_lock_concurrency_locking2(self):
        # NOTE(sileht): some database based lock can have only
        # one lock per connection, this test ensures acquiring a
        # second lock doesn't release the first one.
        lock1 = self._coord.get_lock(tests.get_random_uuid())
        lock2 = self._coord.get_lock(tests.get_random_uuid())

        graceful_ending = threading.Event()
        thread_locked = threading.Event()

        def thread():
            with lock2:
                try:
                    self.assertFalse(lock1.acquire(blocking=False))
                except tooz.NotImplemented:
                    pass
                thread_locked.set()
            graceful_ending.set()

        t = threading.Thread(target=thread)
        t.daemon = True

        with lock1:
            t.start()
            thread_locked.wait()
            self.assertTrue(thread_locked.is_set())
        t.join()
        graceful_ending.wait()
        self.assertTrue(graceful_ending.is_set())
开发者ID:openstack,项目名称:tooz,代码行数:29,代码来源:test_coordination.py

示例2: test_client_failure_leave

 def test_client_failure_leave(self, mock_client_cls):
     mock_client = mock.MagicMock()
     mock_client_cls.return_value = mock_client
     member_id = tests.get_random_uuid()
     coord = coordination.get_coordinator(self.FAKE_URL, member_id)
     coord.start()
     mock_client.gets.side_effect = socket.timeout('timed-out')
     fut = coord.leave_group(tests.get_random_uuid())
     self.assertRaises(coordination.ToozConnectionError, fut.get)
开发者ID:openstack,项目名称:tooz,代码行数:9,代码来源:test_memcache.py

示例3: setUp

 def setUp(self):
     super(TestAPI, self).setUp()
     if self.url is None:
         self.skipTest("No URL set for this driver")
     self.useFixture(fixtures.NestedTempfile())
     self.group_id = tests.get_random_uuid()
     self.member_id = tests.get_random_uuid()
     self._coord = tooz.coordination.get_coordinator(self.url,
                                                     self.member_id)
     self._coord.start()
开发者ID:aarefiev22,项目名称:tooz,代码行数:10,代码来源:test_coordination.py

示例4: _do_test_get_lock_concurrency_locking_two_lock

 def _do_test_get_lock_concurrency_locking_two_lock(self, executor,
                                                    use_same_coord):
     name = tests.get_random_uuid()
     lock1 = self._coord.get_lock(name)
     with lock1:
         with executor(max_workers=1) as e:
             coord = self._coord if use_same_coord else None
             f = e.submit(try_to_lock_job, name, coord, self.url,
                          tests.get_random_uuid())
             self.assertFalse(f.result())
开发者ID:openstack,项目名称:tooz,代码行数:10,代码来源:test_coordination.py

示例5: _do_test_get_lock_serial_locking_two_lock

 def _do_test_get_lock_serial_locking_two_lock(self, executor,
                                               use_same_coord):
     name = tests.get_random_uuid()
     lock1 = self._coord.get_lock(name)
     lock1.acquire()
     lock1.release()
     with executor(max_workers=1) as e:
         coord = self._coord if use_same_coord else None
         f = e.submit(try_to_lock_job, name, coord, self.url,
                      tests.get_random_uuid())
         self.assertTrue(f.result())
开发者ID:openstack,项目名称:tooz,代码行数:11,代码来源:test_coordination.py

示例6: test_get_members

    def test_get_members(self):
        group_id_test2 = tests.get_random_uuid()
        member_id_test2 = tests.get_random_uuid()
        client2 = tooz.coordination.get_coordinator(self.url,
                                                    member_id_test2)
        client2.start()

        self._coord.create_group(group_id_test2).get()
        self._coord.join_group(group_id_test2).get()
        client2.join_group(group_id_test2).get()
        members_ids = self._coord.get_members(group_id_test2).get()
        self.assertEqual({self.member_id, member_id_test2}, members_ids)
开发者ID:openstack,项目名称:tooz,代码行数:12,代码来源:test_coordination.py

示例7: test_get_lock_locking_exclusive_and_shared

    def test_get_lock_locking_exclusive_and_shared(self):
        name = tests.get_random_uuid()
        lock1 = self._coord.get_lock(name)
        coord = tooz.coordination.get_coordinator(
            self.url, tests.get_random_uuid())
        coord.start()
        lock2 = coord.get_lock(name)

        self.assertTrue(lock1.acquire())
        self.assertFalse(lock2.acquire(shared=True, blocking=False))
        self.assertTrue(lock1.release())
        self.assertFalse(lock2.release())
开发者ID:openstack,项目名称:tooz,代码行数:12,代码来源:test_coordination.py

示例8: test_get_lock_multiple_coords

    def test_get_lock_multiple_coords(self):
        member_id2 = tests.get_random_uuid()
        client2 = tooz.coordination.get_coordinator(self.url,
                                                    member_id2)
        client2.start()

        lock_name = tests.get_random_uuid()
        lock = self._coord.get_lock(lock_name)
        self.assertTrue(lock.acquire())

        lock2 = client2.get_lock(lock_name)
        self.assertFalse(lock2.acquire(blocking=False))
        self.assertTrue(lock.release())
        self.assertTrue(lock2.acquire(blocking=True))
        self.assertTrue(lock2.release())
开发者ID:openstack,项目名称:tooz,代码行数:15,代码来源:test_coordination.py

示例9: test_watch_join_group_disappear

    def test_watch_join_group_disappear(self):
        if not hasattr(self._coord, '_destroy_group'):
            self.skipTest("This test only works with coordinators"
                          " that have the ability to destroy groups.")

        self._coord.create_group(self.group_id).get()
        self._coord.watch_join_group(self.group_id, self._set_event)
        self._coord.watch_leave_group(self.group_id, self._set_event)

        member_id_test2 = tests.get_random_uuid()
        client2 = tooz.coordination.get_coordinator(self.url,
                                                    member_id_test2)
        client2.start()
        client2.join_group(self.group_id).get()

        while True:
            if self._coord.run_watchers():
                break
        self.assertEqual(1, len(self.events))
        event = self.events[0]
        self.assertIsInstance(event, tooz.coordination.MemberJoinedGroup)
        self.events = []

        # Force the group to disappear...
        self._coord._destroy_group(self.group_id)

        while True:
            if self._coord.run_watchers():
                break

        self.assertEqual(1, len(self.events))
        event = self.events[0]
        self.assertIsInstance(event, tooz.coordination.MemberLeftGroup)
开发者ID:openstack,项目名称:tooz,代码行数:33,代码来源:test_coordination.py

示例10: test_watch_group_join

    def test_watch_group_join(self):
        member_id_test2 = tests.get_random_uuid()
        client2 = tooz.coordination.get_coordinator(self.url,
                                                    member_id_test2)
        client2.start()
        self._coord.create_group(self.group_id).get()

        # Watch the group
        self._coord.watch_join_group(self.group_id, self._set_event)

        # Join the group
        client2.join_group(self.group_id).get()
        members_ids = self._coord.get_members(self.group_id).get()
        self.assertIn(member_id_test2, members_ids)
        while True:
            if self._coord.run_watchers():
                break
        self.assertEqual(1, len(self.events))
        event = self.events[0]
        self.assertIsInstance(event, tooz.coordination.MemberJoinedGroup)
        self.assertEqual(member_id_test2, event.member_id)
        self.assertEqual(self.group_id, event.group_id)

        # Stop watching
        self._coord.unwatch_join_group(self.group_id, self._set_event)
        self.events = []

        # Leave and rejoin group
        client2.leave_group(self.group_id).get()
        client2.join_group(self.group_id).get()
        self._coord.run_watchers()
        self.assertEqual([], self.events)
开发者ID:openstack,项目名称:tooz,代码行数:32,代码来源:test_coordination.py

示例11: test_get_groups

 def test_get_groups(self):
     groups_ids = [tests.get_random_uuid() for _ in range(0, 5)]
     for group_id in groups_ids:
         self._coord.create_group(group_id).get()
     created_groups = self._coord.get_groups().get()
     for group_id in groups_ids:
         self.assertIn(group_id, created_groups)
开发者ID:openstack,项目名称:tooz,代码行数:7,代码来源:test_coordination.py

示例12: test_get_member_info_nonjoined_member

 def test_get_member_info_nonjoined_member(self):
     self._coord.create_group(self.group_id).get()
     member_id = tests.get_random_uuid()
     member_info = self._coord.get_member_info(self.group_id,
                                               member_id)
     self.assertRaises(tooz.coordination.MemberNotJoined,
                       member_info.get)
开发者ID:openstack,项目名称:tooz,代码行数:7,代码来源:test_coordination.py

示例13: test_watch_join_group_booted_out

    def test_watch_join_group_booted_out(self):
        self._coord.create_group(self.group_id).get()
        self._coord.join_group(self.group_id).get()
        self._coord.watch_join_group(self.group_id, self._set_event)
        self._coord.watch_leave_group(self.group_id, self._set_event)

        member_id_test2 = tests.get_random_uuid()
        client2 = tooz.coordination.get_coordinator(self.url,
                                                    member_id_test2)
        client2.start()
        client2.join_group(self.group_id).get()

        while True:
            if self._coord.run_watchers():
                break

        client3 = tooz.coordination.get_coordinator(self.url, self.member_id)
        client3.start()
        client3.leave_group(self.group_id).get()

        # Only works for clients that have access to the groups they are part
        # of, to ensure that after we got booted out by client3 that this
        # client now no longer believes its part of the group.
        if (hasattr(self._coord, '_joined_groups')
           and (self._coord.run_watchers
                == tooz.coordination.CoordinationDriverCachedRunWatchers.run_watchers)):  # noqa
            self.assertIn(self.group_id, self._coord._joined_groups)
            self._coord.run_watchers()
            self.assertNotIn(self.group_id, self._coord._joined_groups)
开发者ID:openstack,项目名称:tooz,代码行数:29,代码来源:test_coordination.py

示例14: test_get_multiple_locks_with_same_coord

 def test_get_multiple_locks_with_same_coord(self):
     name = tests.get_random_uuid()
     lock1 = self._coord.get_lock(name)
     lock2 = self._coord.get_lock(name)
     self.assertTrue(lock1.acquire())
     self.assertFalse(lock2.acquire(blocking=False))
     self.assertFalse(self._coord.get_lock(name).acquire(blocking=False))
     self.assertTrue(lock1.release())
开发者ID:openstack,项目名称:tooz,代码行数:8,代码来源:test_coordination.py

示例15: test_lock_context_manager_acquire_argument

 def test_lock_context_manager_acquire_argument(self):
     name = tests.get_random_uuid()
     blocking_value = 10.12
     lock = self._coord.get_lock(name)
     with mock.patch.object(lock, 'acquire', wraps=True, autospec=True) as \
             mock_acquire:
         with lock(blocking_value):
             mock_acquire.assert_called_once_with(blocking_value)
开发者ID:openstack,项目名称:tooz,代码行数:8,代码来源:test_coordination.py


注:本文中的tooz.tests.get_random_uuid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。