コード例 #1
0
ファイル: bad_evict.py プロジェクト: daos-stack/daos
    def test_evict(self):
        """
        Test ID: DAOS-427
        Test Description: Pass bad parameters to the pool evict clients call.

        :avocado: tags=pool,poolevict,badparam,badevict
        """

        # parameters used in pool create
        createmode = self.params.get("mode", '/run/evicttests/createmode/')
        createsetid = self.params.get("setname", '/run/evicttests/createset/')
        createsize = self.params.get("size", '/run/evicttests/createsize/')

        createuid = os.geteuid()
        creategid = os.getegid()

        # Accumulate a list of pass/fail indicators representing what is
        # expected for each parameter then "and" them to determine the
        # expected result of the test
        expected_for_param = []

        svclist = self.params.get("ranklist", '/run/evicttests/svrlist/*/')
        svc = svclist[0]
        expected_for_param.append(svclist[1])

        setlist = self.params.get("setname",
                                  '/run/evicttests/connectsetnames/*/')
        evictset = setlist[0]
        expected_for_param.append(setlist[1])

        uuidlist = self.params.get("uuid", '/run/evicttests/UUID/*/')
        excludeuuid = uuidlist[0]
        expected_for_param.append(uuidlist[1])

        # if any parameter is FAIL then the test should FAIL, in this test
        # virtually everyone should FAIL since we are testing bad parameters
        expected_result = 'PASS'
        for result in expected_for_param:
            if result == 'FAIL':
                expected_result = 'FAIL'
                break

        saveduuid = None
        savedgroup = None
        savedsvc = None
        pool = None

        try:
            # setup the DAOS python API
            with open('../../../.build_vars.json') as build_file:
                data = json.load(build_file)
            context = DaosContext(data['PREFIX'] + '/lib/')

            # initialize a python pool object then create the underlying
            # daos storage
            pool = DaosPool(context)
            pool.create(createmode, createuid, creategid,
                        createsize, createsetid, None)

            # trash the the pool service rank list
            if not svc == 'VALID':
                savedsvc = pool.svc
                rl_ranks = ctypes.POINTER(ctypes.c_uint)()
                pool.svc = RankList(rl_ranks, 1)

            # trash the pool group value
            if evictset is None:
                savedgroup = pool.group
                pool.group = None

            # trash the UUID value in various ways
            if excludeuuid is None:
                saveduuid = (ctypes.c_ubyte * 16)(0)
                for i in range(0, len(saveduuid)):
                    saveduuid[i] = pool.uuid[i]
                pool.uuid[0:] = [0 for i in range(0, len(pool.uuid))]
            if excludeuuid == 'JUNK':
                saveduuid = (ctypes.c_ubyte * 16)(0)
                for i in range(0, len(saveduuid)):
                    saveduuid[i] = pool.uuid[i]
                pool.uuid[4] = 244

            pool.evict()

            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 in ['PASS']:
                self.fail("Test was expected to pass but it failed.\n")
        finally:
            if pool is not None:
                # if the test trashed some pool parameter, put it back the
                # way it was
                if savedgroup is not None:
                    pool.group = savedgroup
                if saveduuid is not None:
                    for i in range(0, len(saveduuid)):
                        pool.uuid[i] = saveduuid[i]
                if savedsvc is not None:
                    pool.svc = savedsvc
                pool.destroy(1)
コード例 #2
0
ファイル: BadEvict.py プロジェクト: sydneyvanda/daos
    def test_evict(self):
        """
        Test ID: DAOS-427
        Test Description: Pass bad parameters to the pool evict clients call.

        :avocado: tags=pool,poolevict,badparam,badevict
        """

        # parameters used in pool create
        createmode = self.params.get("mode", '/run/evicttests/createmode/')
        createsetid = self.params.get("setname", '/run/evicttests/createset/')
        createsize = self.params.get("size", '/run/evicttests/createsize/')

        createuid = os.geteuid()
        creategid = os.getegid()

        # Accumulate a list of pass/fail indicators representing what is
        # expected for each parameter then "and" them to determine the
        # expected result of the test
        expected_for_param = []

        svclist = self.params.get("ranklist", '/run/evicttests/svrlist/*/')
        svc = svclist[0]
        expected_for_param.append(svclist[1])

        setlist = self.params.get("setname",
                                  '/run/evicttests/connectsetnames/*/')
        evictset = setlist[0]
        expected_for_param.append(setlist[1])

        uuidlist = self.params.get("uuid", '/run/evicttests/UUID/*/')
        excludeuuid = uuidlist[0]
        expected_for_param.append(uuidlist[1])

        # if any parameter is FAIL then the test should FAIL, in this test
        # virtually everyone should FAIL since we are testing bad parameters
        expected_result = 'PASS'
        for result in expected_for_param:
            if result == 'FAIL':
                expected_result = 'FAIL'
                break

        saveduuid = None
        savedgroup = None
        savedsvc = None
        pool = None

        try:
            # setup the DAOS python API
            with open('../../../.build_vars.json') as f:
                data = json.load(f)
            context = DaosContext(data['PREFIX'] + '/lib/')

            # initialize a python pool object then create the underlying
            # daos storage
            pool = DaosPool(context)
            pool.create(createmode, createuid, creategid, createsize,
                        createsetid, None)

            # trash the the pool service rank list
            if not svc == 'VALID':
                savedsvc = pool.svc
                rl_ranks = ctypes.POINTER(ctypes.c_uint)()
                pool.svc = RankList(rl_ranks, 1)

            # trash the pool group value
            if evictset == None:
                savedgroup = pool.group
                pool.group = None

            # trash the UUID value in various ways
            if excludeuuid == None:
                saveduuid = (ctypes.c_ubyte * 16)(0)
                for i in range(0, len(saveduuid)):
                    saveduuid[i] = pool.uuid[i]
                pool.uuid[0:] = [0 for i in range(0, len(pool.uuid))]
            if excludeuuid == 'JUNK':
                saveduuid = (ctypes.c_ubyte * 16)(0)
                for i in range(0, len(saveduuid)):
                    saveduuid[i] = pool.uuid[i]
                pool.uuid[4] = 244

            pool.evict()

            if expected_result in ['FAIL']:
                self.fail("Test was expected to fail but it passed.\n")

        except DaosApiError as e:
            print(e)
            print(traceback.format_exc())
            if expected_result in ['PASS']:
                self.fail("Test was expected to pass but it failed.\n")
        finally:
            if pool is not None:
                # if the test trashed some pool parameter, put it back the
                # way it was
                if savedgroup is not None:
                    pool.group = savedgroup
                if saveduuid is not None:
                    for i in range(0, len(saveduuid)):
                        pool.uuid[i] = saveduuid[i]
                if savedsvc is not None:
                    pool.svc = savedsvc
                pool.destroy(1)
コード例 #3
0
    def test_evict(self):
        """
        Pass bad parameters to the pool evict clients call.

        :avocado: tags=pool,poolevict,badparam,badevict
        """
        global basepath

        # parameters used in pool create
        createmode = self.params.get("mode",'/run/evicttests/createmode/')
        createuid  = self.params.get("uid",'/run/evicttests/createuid/')
        creategid  = self.params.get("gid",'/run/evicttests/creategid/')
        createsetid = self.params.get("setname",'/run/evicttests/createset/')
        createsize  = self.params.get("size",'/run/evicttests/createsize/')

        # Accumulate a list of pass/fail indicators representing what is
        # expected for each parameter then "and" them to determine the
        # expected result of the test
        expected_for_param = []

        svclist = self.params.get("ranklist",'/run/evicttests/svrlist/*/')
        svc = svclist[0]
        expected_for_param.append(svclist[1])

        setlist = self.params.get("setname",
            '/run/evicttests/connectsetnames/*/')
        evictset = setlist[0]
        expected_for_param.append(setlist[1])

        uuidlist = self.params.get("uuid",'/run/evicttests/UUID/*/')
        excludeuuid = uuidlist[0]
        expected_for_param.append(uuidlist[1])

        # if any parameter is FAIL then the test should FAIL, in this test
        # virtually everyone should FAIL since we are testing bad parameters
        expected_result = 'PASS'
        for result in expected_for_param:
               if result == 'FAIL':
                      expected_result = 'FAIL'
                      break

        try:
            # setup the DAOS python API
            with open('../../../.build_vars.json') as f:
                data = json.load(f)
            CONTEXT = DaosContext(data['PREFIX'] + '/lib/')

            # initialize a python pool object then create the underlying
            # daos storage
            POOL = DaosPool(CONTEXT)
            POOL.create(createmode, createuid, creategid,
                        createsize, createsetid, None)

            # trash the the pool service rank list
            if not svc == 'VALID':
                rl_ranks = ctypes.POINTER(ctypes.c_uint)()
                POOL.svc = RankList(rl_ranks, 1);

            # trash the pool group value
            if evictset == None:
                POOL.group = None

            # trash the UUID value in various ways
            if excludeuuid == None:
                POOL.uuid = None
            if excludeuuid == 'JUNK':
                POOL.uuid[4] = 244

            POOL.evict()

            if expected_result in ['FAIL']:
                   self.fail("Test was expected to fail but it passed.\n")

        except ValueError as e:
            print e
            print traceback.format_exc()
            if expected_result in ['PASS']:
                   self.fail("Test was expected to pass but it failed.\n")
        except Exception as e:
            self.fail("Daos code segfaulted most likely %s" % e)