def test_serverset_destroy(self): testutil.initialize_kazoo_client_manager(ZK_HOSTS) client = KazooClientManager().get_client() client.start() fd, tmp_file = tempfile.mkstemp() server_set = ServerSet(ServerSetWithFileTestCase.SERVER_SET_DESTROY_PATH, ZK_HOSTS, waiting_in_secs=0.01) server_set.join(ServerSetWithFileTestCase.PORT_1, use_ip=False) server_set.join(ServerSetWithFileTestCase.PORT_2, use_ip=False) # update the local file manually here, suppose there is a daemon with open(tmp_file, 'w') as f: f.write(ServerSetWithFileTestCase.END_POINT_1 + "\n" + ServerSetWithFileTestCase.END_POINT_2) # Give time to let server set join to do its magic. gevent.sleep(1) server_set._destroy(ServerSetWithFileTestCase.END_POINT_1) # update the local file manually here, suppose there is a daemon with open(tmp_file, 'w') as f: f.write(ServerSetWithFileTestCase.END_POINT_2) gevent.sleep(1) children = client.get_children( ServerSetWithFileTestCase.SERVER_SET_DESTROY_PATH) for child in children: self.assertFalse(child.endswith(ServerSetWithFileTestCase.END_POINT_1)) self.FILE_WATCH._clear_all_watches() os.remove(tmp_file)
def test_serverset_destroy(self): testutil.initialize_kazoo_client_manager(ZK_HOSTS) client = KazooClientManager().get_client() client.start() fd, tmp_file = tempfile.mkstemp() server_set = ServerSet( ServerSetWithFileTestCase.SERVER_SET_DESTROY_PATH, ZK_HOSTS, waiting_in_secs=0.01) server_set.join(ServerSetWithFileTestCase.PORT_1, use_ip=False) server_set.join(ServerSetWithFileTestCase.PORT_2, use_ip=False) # update the local file manually here, suppose there is a daemon with open(tmp_file, 'w') as f: f.write(ServerSetWithFileTestCase.END_POINT_1 + "\n" + ServerSetWithFileTestCase.END_POINT_2) # Give time to let server set join to do its magic. gevent.sleep(1) server_set._destroy(ServerSetWithFileTestCase.END_POINT_1) # update the local file manually here, suppose there is a daemon with open(tmp_file, 'w') as f: f.write(ServerSetWithFileTestCase.END_POINT_2) gevent.sleep(1) children = client.get_children( ServerSetWithFileTestCase.SERVER_SET_DESTROY_PATH) for child in children: self.assertFalse( child.endswith(ServerSetWithFileTestCase.END_POINT_1)) self.FILE_WATCH._clear_all_watches() os.remove(tmp_file)
def test_serverset_destroy(self): testutil.initialize_kazoo_client_manager(ZK_HOSTS) client = KazooClientManager().get_client() server_set = ServerSet(ServerSetTestCase.SERVER_SET_DESTROY_PATH, ZK_HOSTS, waiting_in_secs=0.01) server_set.join(ServerSetTestCase.PORT_1, use_ip=False) server_set.join(ServerSetTestCase.PORT_2, use_ip=False) # Give time to let server set join to do its magic. gevent.sleep(1) server_set._destroy(ServerSetTestCase.END_POINT_1) gevent.sleep(1) children = client.get_children( ServerSetTestCase.SERVER_SET_DESTROY_PATH) for child in children: self.assertFalse(child.endswith(ServerSetTestCase.END_POINT_1))