def kill_server(server_group, context, rank, pool, log=None): """Kill a specific server rank. Args: server_group (str): daos server group name context (DaosContext): the context to use to create the DaosServer rank (int): daos server rank to kill pool (DaosPool): the DaosPool from which to exclude the rank log (DaosLog|None): object for logging messages Returns: None """ if log: log.info("Killing DAOS server {} (rank {})".format(server_group, rank)) server = DaosServer(context, server_group, rank) server.kill(1) if log: log.info("Excluding server rank {}".format(rank)) pool.exclude([rank])
def test_poolsvc(self): """ Test svc arg during pool create. :avocado: tags=all,pool,pr,medium,svc,DAOS_5610 """ # parameter used in pool create createsvc = self.params.get("svc", '/run/createtests/createsvc/*/') expected_result = createsvc[1] # initialize a python pool object then create the underlying # daos storage self.pool = TestPool(self.context, self.get_dmg_command()) self.pool.get_params(self) self.pool.svcn.update(createsvc[0]) try: self.pool.create() if expected_result == RESULT_FAIL: self.fail("Test was expected to fail, but it passed.\n") except TestFail as excep: print("## TestFail exception is caught at pool create!") print(excep) print(traceback.format_exc()) if expected_result == RESULT_PASS: self.fail("Test was expected to pass but it failed.\n") # FAIL case should fail at above pool create, so do below only for # PASS case if expected_result == RESULT_PASS: self.log.debug("self.pool.svc_ranks = %s", self.pool.svc_ranks) self.assertTrue(999999 not in self.pool.svc_ranks, "999999 is in the pool's service ranks.") self.assertEqual(len(self.pool.svc_ranks), self.pool.svcn.value, "Length of Returned Rank list is not equal to " + "the number of Pool Service members.") # Verify there are no duplicate ranks in the rank list self.assertEqual(len(self.pool.svc_ranks), len(set(self.pool.svc_ranks)), "Duplicate values in returned rank list") try: self.pool.get_info() leader = self.pool.info.pi_leader if createsvc[0] == 3: # kill pool leader and exclude it self.pool.pool.pool_svc_stop() self.pool.exclude([leader], self.d_log) # perform pool disconnect, try connect again and disconnect self.pool.disconnect() self.pool.connect() self.pool.disconnect() # kill another server which is not a leader and exclude it server = DaosServer(self.context, self.server_group, 3) server.kill(1) self.pool.exclude([3], self.d_log) # perform pool connect self.pool.connect() # Use TestFail instead of DaosApiError because create method has # @fail_on except TestFail as excep: print("## TestFail exception caught") print(excep) print(traceback.format_exc()) self.fail("Test was expected to pass but it failed.\n")
def test_poolsvc(self): """ Test svc arg during pool create. :avocado: tags=all,pool,pr,medium,svc """ # parameters used in pool create createmode = self.params.get("mode", '/run/createtests/createmode/*/') createuid = os.geteuid() creategid = os.getegid() createsetid = self.params.get("setname", '/run/createtests/createset/') createsize = self.params.get("size", '/run/createtests/createsize/') createsvc = self.params.get("svc", '/run/createtests/createsvc/*/') expected_result = createsvc[1] try: # initialize a python pool object then create the underlying # daos storage self.pool = DaosPool(self.context) self.pool.create(createmode, createuid, creategid, createsize, createsetid, None, None, createsvc[0]) self.pool.connect(1 << 1) # checking returned rank list for server more than 1 iterator = 0 while ( int(self.pool.svc.rl_ranks[iterator]) > 0 and int(self.pool.svc.rl_ranks[iterator]) <= createsvc[0] and int(self.pool.svc.rl_ranks[iterator]) != 999999 ): iterator += 1 if iterator != createsvc[0]: self.fail("Length of Returned Rank list is not equal to " "the number of Pool Service members.\n") rank_list = [] for iterator in range(createsvc[0]): rank_list.append(int(self.pool.svc.rl_ranks[iterator])) if len(rank_list) != len(set(rank_list)): self.fail("Duplicate values in returned rank list") self.pool.pool_query() leader = self.pool.pool_info.pi_leader if createsvc[0] == 3: # kill pool leader and exclude it self.pool.pool_svc_stop() self.pool.exclude([leader]) # perform pool disconnect, try connect again and disconnect self.pool.disconnect() self.pool.connect(1 << 1) self.pool.disconnect() # kill another server which is not a leader and exclude it server = DaosServer(self.context, self.server_group, 3) server.kill(1) self.pool.exclude([3]) # perform pool connect self.pool.connect(1 << 1) if expected_result in ['FAIL']: self.fail("Test was expected to fail but it passed.\n") except DaosApiError as excep: print(excep) print(traceback.format_exc()) if expected_result == 'PASS': self.fail("Test was expected to pass but it failed.\n")