Example #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)
Example #2
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)