def tearDown(self): self.client.close() self.client2 = ZookeeperClient("127.0.0.1:2181") yield self.client2.connect() utils.deleteTree(handle=self.client2.handle) yield self.client2.close() super(SessionClientExpireTests, self).tearDown()
def test_wait_for_initialize(self): """ A connection to a zookeeper that is running, but whose juju state is not ready, should wait until that state is ready. """ client = ZookeeperClient() self.client = client # for poke_zk self.mock_connect(False, succeed(client)) self.mocker.replay() zookeeper.set_debug_level(0) yield client.connect(get_test_zookeeper_address()) provider = DummyProvider(ProviderMachine("i-amok", "foo.example.com")) d = provider.connect() client_result = [] d.addCallback(client_result.append) # Give it a chance to do it incorrectly. yield self.poke_zk() try: self.assertEquals(client_result, []) yield client.create("/initialized") yield d self.assertTrue(client_result, client_result) self.assertIdentical(client_result[0], client) finally: deleteTree("/", client.handle) client.close()
def tearDown(self): cleanup = False for client in self.clients: if not cleanup and client.connected: utils.deleteTree(handle=client.handle) cleanup = True client.close()
def tearDown(self): if self.agent.client and self.agent.client.connected: self.agent.client.close() if self.client.connected: deleteTree("/", self.client.handle) self.client.close()
def tearDown(self): yield super(LogTestBase, self).tearDown() if self.client.connected: self.client.close() client = yield self.get_zookeeper_client().connect() deleteTree(handle=client.handle) yield client.close()
def tearDown(self): super(NodeTest, self).tearDown() deleteTree(handle=self.client.handle) if self.client.connected: self.client.close() if self.client2 and self.client2.connected: self.client2.close() zookeeper.set_debug_level(zookeeper.LOG_LEVEL_DEBUG)
def tearDown(self): # Close and reopen connection, so that watches set during # testing are not affected by the cleaning up. self.client.close() client = self.get_zookeeper_client() yield client.connect() deleteTree(handle=client.handle) client.close() yield super(StateTestBase, self).tearDown()
def tearDown(self): # Close and reopen connection, so that watches set during # testing are not affected by the cleaning up. self.client.close() client = ZookeeperClient(get_test_zookeeper_address()) yield client.connect() deleteTree(handle=client.handle) client.close() yield super(StateTestBase, self).tearDown()
def tearDown(self): if self.client.connected: utils.deleteTree(handle=self.client.handle) self.client.close() if self.client2 and self.client2.connected: self.client2.close() super(ClientTests, self).tearDown()
def tearDown(self): zookeeper.set_debug_level(0) if self.proxied_client.connected: yield self.proxied_client.close() if not self.direct_client.connected: yield self.direct_client.connect() utils.deleteTree(handle=self.direct_client.handle) yield self.direct_client.close() self.proxy.lose_connection() yield self.proxy_port.stopListening()
def tearDown(self): cleanup = False for client in self.clients: if not cleanup and client.connected: utils.deleteTree(handle=client.handle) cleanup = True if client.connected: client.close() super(QueueTests, self).tearDown()
def test_fast_connection(self): """Verify connection when requirements are available at time of conn. This includes /initialized is already set. In addition, also verifies that if multiple ZKs are available, one is selected via random.choice. """ log = self.capture_logging(level=logging.DEBUG) client = ZookeeperClient() self.mock_connect(False, succeed(client)) def get_choice(lst): for item in lst: if item.dns_name == "foo.example.com": return item raise AssertionError("expected choice not seen") self.patch(random, "choice", get_choice) self.mocker.replay() provider = DummyProvider( ProviderMachine("i-am-picked", "foo.example.com"), ProviderMachine("i-was-not", "bar.example.com")) zookeeper.set_debug_level(0) yield client.connect(get_test_zookeeper_address()) try: yield client.create("/initialized") yield provider.connect() self.assertEqual( "Connecting to environment...\n" "Connecting to environment using foo.example.com...\n" "Environment is initialized.\n" "Connected to environment.\n", log.getvalue()) finally: deleteTree("/", client.handle) client.close()
def tearDown(self): deleteTree("/", self.client.handle) self.client.close() super(CharmPublisherTest, self).tearDown()
def tearDown(self): deleteTree("/", self.client.handle) self.client.close()
def tearDown(self): yield self.client.close() client = self.get_zookeeper_client() yield client.connect() deleteTree("/", client.handle) yield client.close()
def tearDown(self): utils.deleteTree(handle=self.test_cleanup_connection.handle) for client in self.clients: if client.connected: client.close() self.test_cleanup_connection.close()