Beispiel #1
0
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])
Beispiel #2
0
    def start_rebuild(self, ranks, daos_log):
        """Kill the specific server ranks using this pool.

        Args:
            ranks (list): a list of daos server ranks (int) to kill
            daos_log (DaosLog): object for logging messages

        Returns:
            bool: True if the server ranks have been killed and the ranks have
            been excluded from the pool; False if the pool is undefined

        """
        msg = "Killing DAOS ranks {} from server group {}".format(
            ranks, self.name.value)
        self.log.info(msg)
        daos_log.info(msg)
        for rank in ranks:
            server = DaosServer(self.context, self.name.value, rank)
            self._call_method(server.kill, {"force": 1})
        return self.exclude(ranks, daos_log)
Beispiel #3
0
    def start_rebuild(self, ranks, daos_log):
        """Kill/Stop the specific server ranks using this pool.

        Args:
            ranks (list): a list of daos server ranks (int) to kill
            daos_log (DaosLog): object for logging messages

        Returns:
            bool: True if the server ranks have been killed/stopped and the
            ranks have been excluded from the pool; False otherwise.

        """
        msg = "Killing DAOS ranks {} from server group {}".format(
            ranks, self.name.value)
        self.log.info(msg)
        daos_log.info(msg)

        if self.control_method.value == self.USE_API:
            # Stop desired ranks using kill
            for rank in ranks:
                server = DaosServer(self.context, self.name.value, rank)
                self._call_method(server.kill, {"force": 1})
            return True

        elif self.control_method.value == self.USE_DMG and self.dmg:
            # Stop desired ranks using dmg
            self.dmg.system_stop(ranks=convert_list(value=ranks))
            return True

        elif self.control_method.value == self.USE_DMG:
            self.log.error("Error: Undefined dmg command")

        else:
            self.log.error("Error: Undefined control_method: %s",
                           self.control_method.value)

        return False
Beispiel #4
0
    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")
Beispiel #5
0
    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")