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


Python utils.assertReadFromAll函数代码示例

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


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

示例1: test_passive_and_hidden

    def test_passive_and_hidden(self):
        self.c = MongoReplicaSetClient(
            self.seed, replicaSet=self.name, use_greenlets=use_greenlets)

        passives = ha_tools.get_passives()
        passives = partition_nodes(passives)
        self.assertEqual(self.c.secondaries, set(passives))

        for mode in SECONDARY, SECONDARY_PREFERRED:
            utils.assertReadFromAll(self, self.c, passives, mode)

        ha_tools.kill_members(ha_tools.get_passives(), 2)
        sleep(2 * MONITOR_INTERVAL)
        utils.assertReadFrom(self, self.c, self.c.primary, SECONDARY_PREFERRED)
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:14,代码来源:test_ha.py

示例2: test_passive_and_hidden

    def test_passive_and_hidden(self):
        self.c = MongoClient(
            self.seed,
            replicaSet=self.name,
            serverSelectionTimeoutMS=self.server_selection_timeout)

        passives = ha_tools.get_passives()
        passives = partition_nodes(passives)
        self.assertEqual(self.c.secondaries, set(passives))

        for mode in SECONDARY, SECONDARY_PREFERRED:
            utils.assertReadFromAll(self, self.c, passives, mode)

        ha_tools.kill_members(ha_tools.get_passives(), 2)
        time.sleep(2 * self.heartbeat_frequency)
        utils.assertReadFrom(self, self.c, self.c.primary, SECONDARY_PREFERRED)
开发者ID:BiosPsucheZoe,项目名称:mongo-python-driver,代码行数:16,代码来源:test_ha.py

示例3: test_monitor_removes_recovering_member

    def test_monitor_removes_recovering_member(self):
        self.c = MongoReplicaSetClient(
            self.seed, replicaSet=self.name, use_greenlets=use_greenlets)

        secondaries = ha_tools.get_secondaries()

        for mode in SECONDARY, SECONDARY_PREFERRED:
            partitioned_secondaries = partition_nodes(secondaries)
            utils.assertReadFromAll(self, self.c, partitioned_secondaries, mode)

        secondary, recovering_secondary = secondaries
        ha_tools.set_maintenance(recovering_secondary, True)
        sleep(2 * MONITOR_INTERVAL)

        for mode in SECONDARY, SECONDARY_PREFERRED:
            # Don't read from recovering member
            utils.assertReadFrom(self, self.c, _partition_node(secondary), mode)
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:17,代码来源:test_ha.py

示例4: test_recovering

    def test_recovering(self):
        self.c = ReplicaSetConnection(
            self.seed, replicaSet=self.name, use_greenlets=use_greenlets,
            auto_start_request=False)

        secondaries = ha_tools.get_secondaries()

        for mode in SECONDARY, SECONDARY_PREFERRED:
            partitioned_secondaries = [_partition_node(s) for s in secondaries]
            utils.assertReadFromAll(self, self.c, partitioned_secondaries, mode)

        secondary, recovering_secondary = secondaries
        ha_tools.set_maintenance(recovering_secondary, True)
        sleep(2 * MONITOR_INTERVAL)

        for mode in SECONDARY, SECONDARY_PREFERRED:
            # Don't read from recovering member
            utils.assertReadFrom(self, self.c, _partition_node(secondary), mode)
开发者ID:renjupaul,项目名称:mongo-python-driver,代码行数:18,代码来源:test_ha.py

示例5: test_monitor_removes_recovering_member

    def test_monitor_removes_recovering_member(self):
        self.c = MongoClient(
            self.seed,
            replicaSet=self.name,
            serverSelectionTimeoutMS=self.server_selection_timeout)

        secondaries = ha_tools.get_secondaries()

        for mode in SECONDARY, SECONDARY_PREFERRED:
            partitioned_secondaries = partition_nodes(secondaries)
            utils.assertReadFromAll(self, self.c, partitioned_secondaries, mode)

        secondary, recovering_secondary = secondaries
        ha_tools.set_maintenance(recovering_secondary, True)
        time.sleep(2 * self.heartbeat_frequency)

        for mode in SECONDARY, SECONDARY_PREFERRED:
            # Don't read from recovering member
            utils.assertReadFrom(self, self.c, partition_node(secondary), mode)
开发者ID:BiosPsucheZoe,项目名称:mongo-python-driver,代码行数:19,代码来源:test_ha.py

示例6: test_pinned_member

    def test_pinned_member(self):
        conn = self._get_connection(
            auto_start_request=False, secondary_acceptable_latency_ms=1000*1000)

        host = read_from_which_host(conn, ReadPreference.SECONDARY)
        self.assertTrue(host in conn.secondaries)

        # No pinning since we're not in a request
        assertReadFromAll(
            self, conn, conn.secondaries, ReadPreference.SECONDARY)

        assertReadFromAll(
            self, conn, list(conn.secondaries) + [conn.primary],
            ReadPreference.NEAREST)

        conn.start_request()
        host = read_from_which_host(conn, ReadPreference.SECONDARY)
        self.assertTrue(host in conn.secondaries)
        assertReadFrom(self, conn, host, ReadPreference.SECONDARY)

        # Repin
        primary = read_from_which_host(conn, ReadPreference.PRIMARY)
        self.assertEqual(conn.primary, primary)
        assertReadFrom(self, conn, primary, ReadPreference.NEAREST)

        # Repin again
        host = read_from_which_host(conn, ReadPreference.SECONDARY)
        self.assertTrue(host in conn.secondaries)
        assertReadFrom(self, conn, host, ReadPreference.SECONDARY)

        # Unpin
        conn.end_request()
        assertReadFromAll(
            self, conn, list(conn.secondaries) + [conn.primary],
            ReadPreference.NEAREST)
开发者ID:colinhowe,项目名称:mongo-python-driver,代码行数:35,代码来源:test_replica_set_connection.py

示例7: test_pinned_member

    def test_pinned_member(self):
        latency = 1000 * 1000
        conn = self._get_connection(
            auto_start_request=False, secondary_acceptable_latency_ms=latency)

        host = read_from_which_host(conn, ReadPreference.SECONDARY)
        self.assertTrue(host in conn.secondaries)

        # No pinning since we're not in a request
        assertReadFromAll(
            self, conn, conn.secondaries,
            ReadPreference.SECONDARY, None, latency)

        assertReadFromAll(
            self, conn, list(conn.secondaries) + [conn.primary],
            ReadPreference.NEAREST, None, latency)

        conn.start_request()
        host = read_from_which_host(conn, ReadPreference.SECONDARY)
        self.assertTrue(host in conn.secondaries)
        assertReadFrom(self, conn, host, ReadPreference.SECONDARY)

        # Oddly, we expect PRIMARY_PREFERRED to keep reading from secondary,
        # since the secondary is pinned and "matches" the preference.
        assertReadFrom(self, conn, host, ReadPreference.PRIMARY_PREFERRED)

        # Repin
        primary = read_from_which_host(conn, ReadPreference.PRIMARY)
        self.assertEqual(conn.primary, primary)
        assertReadFrom(self, conn, primary, ReadPreference.NEAREST)
        assertReadFrom(self, conn, primary, ReadPreference.PRIMARY_PREFERRED)

        # Since the we're pinned to primary we still use it
        assertReadFrom(self, conn, primary, ReadPreference.SECONDARY_PREFERRED)

        # Repin again
        host = read_from_which_host(conn, ReadPreference.SECONDARY)
        self.assertTrue(host in conn.secondaries)
        assertReadFrom(self, conn, host, ReadPreference.SECONDARY)

        # Unpin
        conn.end_request()
        assertReadFromAll(
            self, conn, list(conn.secondaries) + [conn.primary],
            ReadPreference.NEAREST, None, latency)
开发者ID:SiroDiazPalazon,项目名称:mongo-python-driver,代码行数:45,代码来源:test_replica_set_connection.py

示例8: test_pinned_member

    def test_pinned_member(self):
        latency = 1000 * 1000
        conn = self._get_connection(
            auto_start_request=False, secondary_acceptable_latency_ms=latency)

        host = read_from_which_host(conn, ReadPreference.SECONDARY)
        self.assertTrue(host in conn.secondaries)

        # No pinning since we're not in a request
        assertReadFromAll(
            self, conn, conn.secondaries,
            ReadPreference.SECONDARY, None, latency)

        assertReadFromAll(
            self, conn, list(conn.secondaries) + [conn.primary],
            ReadPreference.NEAREST, None, latency)

        conn.start_request()
        host = read_from_which_host(conn, ReadPreference.SECONDARY)
        self.assertTrue(host in conn.secondaries)
        assertReadFrom(self, conn, host, ReadPreference.SECONDARY)

        # Changing any part of read preference (mode, tag_sets, latency)
        # unpins the current host and pins to a new one
        primary = conn.primary
        assertReadFrom(self, conn, primary, ReadPreference.PRIMARY_PREFERRED)

        host = read_from_which_host(conn, ReadPreference.NEAREST)
        assertReadFrom(self, conn, host, ReadPreference.NEAREST)

        assertReadFrom(self, conn, primary, ReadPreference.PRIMARY_PREFERRED)

        host = read_from_which_host(conn, ReadPreference.SECONDARY_PREFERRED)
        self.assertTrue(host in conn.secondaries)
        assertReadFrom(self, conn, host, ReadPreference.SECONDARY_PREFERRED)

        # Unpin
        conn.end_request()
        assertReadFromAll(
            self, conn, list(conn.secondaries) + [conn.primary],
            ReadPreference.NEAREST, None, latency)
开发者ID:jtwaleson,项目名称:mongo-python-driver,代码行数:41,代码来源:test_replica_set_connection.py

示例9: test_pinned_member

    def test_pinned_member(self):
        raise SkipTest("skipping due to Tokutek/mongo#77")
        latency = 1000 * 1000
        client = self._get_client(secondary_acceptable_latency_ms=latency)

        host = read_from_which_host(client, ReadPreference.SECONDARY)
        self.assertTrue(host in client.secondaries)

        # No pinning since we're not in a request
        assertReadFromAll(
            self, client, client.secondaries,
            ReadPreference.SECONDARY, None, latency)

        assertReadFromAll(
            self, client, list(client.secondaries) + [client.primary],
            ReadPreference.NEAREST, None, latency)

        client.start_request()
        host = read_from_which_host(client, ReadPreference.SECONDARY)
        self.assertTrue(host in client.secondaries)
        assertReadFrom(self, client, host, ReadPreference.SECONDARY)

        # Changing any part of read preference (mode, tag_sets, latency)
        # unpins the current host and pins to a new one
        primary = client.primary
        assertReadFrom(self, client, primary, ReadPreference.PRIMARY_PREFERRED)

        host = read_from_which_host(client, ReadPreference.NEAREST)
        assertReadFrom(self, client, host, ReadPreference.NEAREST)

        assertReadFrom(self, client, primary, ReadPreference.PRIMARY_PREFERRED)

        host = read_from_which_host(client, ReadPreference.SECONDARY_PREFERRED)
        self.assertTrue(host in client.secondaries)
        assertReadFrom(self, client, host, ReadPreference.SECONDARY_PREFERRED)

        # Unpin
        client.end_request()
        assertReadFromAll(
            self, client, list(client.secondaries) + [client.primary],
            ReadPreference.NEAREST, None, latency)
开发者ID:Tokutek,项目名称:mongo-python-driver,代码行数:41,代码来源:test_replica_set_client.py

示例10: assertReadFromAll

 def assertReadFromAll(members, *args, **kwargs):
     utils.assertReadFromAll(self, c, members, *args, **kwargs)
开发者ID:FlorianLudwig,项目名称:mongo-python-driver,代码行数:2,代码来源:test_ha.py


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