示例#1
0
class ProvisionerZooKeeperStoreProxyKillTests(BaseProvisionerStoreTests, ZooKeeperTestMixin):

    # this runs all of the BaseProvisionerStoreTests tests plus any
    # ZK-specific ones, but uses a proxy in front of ZK and restarts
    # the proxy before each call to the store. The effect is that for each store
    # operation, the first call to kazoo fails with a connection error, but the
    # client should handle that and retry

    def setUp(self):
        self.setup_zookeeper(base_path_prefix="/provisioner_store_tests_", use_proxy=True)
        self.real_store = ProvisionerZooKeeperStore(self.zk_hosts,
            self.zk_base_path, use_gevent=self.use_gevent)

        self.real_store.initialize()

        # have the tests use a wrapped store that restarts the connection before each call
        self.store = SocatProxyRestartWrapper(self.proxy, self.real_store)

    def tearDown(self):
        if self.store:
            self.store.shutdown()
        self.teardown_zookeeper()

    def test_the_fixture(self):
        # make sure test fixture actually works like we think

        def fake_operation():
            self.store.kazoo.get("/")
        self.real_store.fake_operation = fake_operation

        self.assertRaises(ConnectionLoss, self.store.fake_operation)
    def setup_store(self):

        self.setup_zookeeper(base_path_prefix="/provisioner_service_tests_")
        store = ProvisionerZooKeeperStore(self.zk_hosts, self.zk_base_path, use_gevent=self.use_gevent)
        store.initialize()

        return store
示例#3
0
    def setUp(self):
        self.setup_zookeeper(base_path_prefix="/provisioner_store_tests_", use_proxy=True)
        self.real_store = ProvisionerZooKeeperStore(self.zk_hosts,
            self.zk_base_path, use_gevent=self.use_gevent)

        self.real_store.initialize()

        # have the tests use a wrapped store that restarts the connection before each call
        self.store = SocatProxyRestartWrapper(self.proxy, self.real_store)
示例#4
0
    def setUp(self):
        self.setup_zookeeper()

        self.store = ProvisionerZooKeeperStore(self.zk_hosts,
            self.zk_base_path, use_gevent=self.use_gevent)
        self.store.initialize()
示例#5
0
class ProvisionerZooKeeperStoreTests(BaseProvisionerStoreTests, ZooKeeperTestMixin):

    # this runs all of the BaseProvisionerStoreTests tests plus any
    # ZK-specific ones

    def setUp(self):
        self.setup_zookeeper()

        self.store = ProvisionerZooKeeperStore(self.zk_hosts,
            self.zk_base_path, use_gevent=self.use_gevent)
        self.store.initialize()

    def tearDown(self):
        if self.store:
            self.store.shutdown()
        self.teardown_zookeeper()

    def test_leader_election(self):
        leader = FakeLeader()
        self.store.contend_leader(leader)

        with leader.condition:
            if not leader.is_leader:
                leader.condition.wait(5)
                self.assertTrue(leader.is_leader)

    def test_disable(self):
        self.assertFalse(self.store.is_disabled())
        self.assertFalse(self.store.is_disabled_agreed())

        self.store.disable_provisioning()

        # peek into internals
        with self.store._disabled_condition:
            if not self.store.is_disabled():
                self.store._disabled_condition.wait(5)
        self.assertTrue(self.store.is_disabled())
        self.assertTrue(self.store.is_disabled_agreed())

        self.store.enable_provisioning()
        with self.store._disabled_condition:
            if self.store.is_disabled():
                self.store._disabled_condition.wait(5)
        self.assertFalse(self.store.is_disabled())
        self.assertFalse(self.store.is_disabled_agreed())