def test_destroy_withdata(self): """Destroy Pool with data. Test destroy and recreate one right after the other multiple times Should fail. :avocado: tags=pool,pooldestroy,destroydata """ hostlist_servers = self.hostlist_servers[:1] group_hosts = {self.server_group: hostlist_servers} self.start_servers(group_hosts) # parameters used in pool create createmode = self.params.get("mode", "/run/pool/*") createsetid = self.params.get("name", "/run/pool/*") createsize = self.params.get("scm_size", "/run/pool/*") # parameters used in pool create self.pool = get_pool( self.context, createmode, createsize, createsetid, log=self.log) pool_uuid = self.pool.get_uuid_str() self.log.info("Connected to pool %s", pool_uuid) self.container = get_container(self.context, self.pool, self.log) cont_uuid = self.container.get_uuid_str() self.log.info("Writing 4096 bytes to the container %s", cont_uuid) self.container.write_an_obj("123456789", 9, "DKEY", "AKEY", obj_cls=1) self.assertTrue( check_pool_files( self.log, hostlist_servers, pool_uuid.lower()), "Pool data not detected on servers before destroy") self.log.info("Attempting to destroy a connected pool %s", self.pool.get_uuid_str()) try: # destroy pool with connection open ret_code = self.pool.destroy(0) except DaosApiError as result: self.log.info( "Detected exception that was expected %s", str(result)) if ret_code == 0: self.log.info( "destroy-pool destroyed a connected pool") self.fail( "destroy-pool was expected to fail but PASSED") self.log.info( "destroy-pool failed as expected ") self.assertTrue( check_pool_files( self.log, hostlist_servers, pool_uuid.lower()), "Pool data not detected on servers after destroy")
def check_files(self, hosts): """Check if pool files exist on the specified list of hosts. Args: hosts (list): list of hosts Returns: bool: True if the files for this pool exist on each host; False otherwise """ return check_pool_files(self.log, hosts, self.uuid.lower())
else: self.log.error("Unexpected exception - destroying pool %s: %s", case, result) if not exception_detected and exception_expected: # The pool-destroy did not raise an exception as expected self.log.error("Exception did not occur - destroying pool %s", case) # If we failed to destroy the pool, check if we still have the pool files. if exception_detected: self.log.info( "Check pool data still exists after a failed pool destroy") self.assertTrue( check_pool_files(log=self.log, hosts=hosts, uuid=valid_uuid.lower()), "Pool data was not detected on servers after " "failing to destroy a pool {}".format(case)) else: self.log.info( "Check pool data does not exist after the pool destroy") self.assertFalse( check_pool_files(log=self.log, hosts=hosts, uuid=valid_uuid.lower()), "Pool data was detected on servers after destroying a pool {}". format(case)) self.assertEqual(exception_detected, exception_expected, "No exception when deleting a pool {}".format(case))