Ejemplo n.º 1
0
    def test_invalid_parameters(self):
        with pytest.raises(TypeError) as err:
            akey = VosObject(count="rubbish")
        assert "count parameter must be of type int" in str(err.value)

        with pytest.raises(TypeError) as err:
            akey = VosObject(count=10, dkeys=["rubbish"])
        assert "must be of type" in str(err.value)
Ejemplo n.º 2
0
    def setUp(self):
        akey1 = AKey(key="A-key 1",
                     value_type="single_value",
                     values=self.test_data.create_values())
        akey2 = AKey(key="A-key 2",
                     value_type="array",
                     values=self.test_data.create_values())
        self.dkey1 = DKey(key="D-key 1", akeys=[akey1, akey2])
        self.dkey2 = DKey(key="D-key 2", akeys=[akey1, akey2])

        self.vos_object1 = VosObject(count=100, dkeys=[self.dkey1, self.dkey2])
        self.vos_object2 = VosObject(count=200, dkeys=[self.dkey1, self.dkey2])
Ejemplo n.º 3
0
        def get_mock_dfs_superblock_obj(self):
            dkey_sb = DKey(key="DFS_SB_METADATA", overhead=Overhead.META)
            dkey_sb.add_value(self._create_sb_akey(key="DFS_MAGIC", size=8))
            dkey_sb.add_value(
                self._create_sb_akey(key="DFS_SB_VERSION", size=2))
            dkey_sb.add_value(
                self._create_sb_akey(key="DFS_LAYOUT_VERSION", size=2))
            dkey_sb.add_value(
                self._create_sb_akey(key="DFS_CHUNK_SIZE", size=8))
            dkey_sb.add_value(self._create_sb_akey(key="DFS_OBJ_CLASS",
                                                   size=2))

            inode_value = VosValue(size=64)
            akey_inode = AKey(key="DFS_INODE",
                              overhead=Overhead.META,
                              value_type=ValType.ARRAY)
            akey_inode.add_value(inode_value)
            dkey_root = DKey(key="/")
            dkey_root.add_value(akey_inode)

            superblock_obj = VosObject()
            superblock_obj.add_value(dkey_sb)
            superblock_obj.add_value(dkey_root)

            return superblock_obj
Ejemplo n.º 4
0
    def create_file_obj(self, file_size, identical_files=1):
        file_object = VosObject()
        file_object.add_value(self._dkey0)
        file_object.set_count(identical_files)

        file_object = self._add_chunk_size_elements(file_object, file_size)
        file_object = self._add_chunk_size_remainder(file_object, file_size)

        self._objects.append(file_object)
Ejemplo n.º 5
0
def get_dfs_sb_obj():
    try:
        dfs_sb = DFS_SB()
        dkey = dfs_sb.get_dfs_sb_dkey()
        dfs_inode = dfs_sb.get_dfs_inode_akey()
    except Exception as err:
        raise Exception(
            'Failed to get the DFS superblock VOS object: {0}'.format(err))

    sb_obj = VosObject()
    sb_obj.add_value(dkey)

    root_dkey = DKey(key='/', overhead=Overhead.USER)
    root_dkey.add_value(dfs_inode)
    sb_obj.add_value(root_dkey)

    return sb_obj
Ejemplo n.º 6
0
Archivo: explorer.py Proyecto: liw/daos
    def create_file_obj(self, file_size, identical_files=1):
        parity_stats = CellStats(self._verbose)

        self._debug('adding {0} file(s) of size of {1}'.format(
            identical_files, file_size))
        file_object = VosObject()
        file_object.set_num_of_targets(self._oclass.get_file_targets())
        file_object.set_count(identical_files)

        self._add_file_dkey0(file_object, parity_stats)
        self._add_chunk_size_elements(file_object, file_size, parity_stats)
        self._add_chunk_size_remainder(file_object, file_size, parity_stats)

        parity_stats.mul(identical_files)
        parity_stats.show()
        self._all_ec_stats.add(parity_stats)

        self._objects.append(file_object)
Ejemplo n.º 7
0
    def add_obj(self):
        oid = len(self._objects)
        self._objects.append(VosObject())

        return oid
Ejemplo n.º 8
0
    def test_add_value(self):
        with pytest.raises(VosValueError) as err:
            dkey = VosObject()
            dkey.dump()
        assert "list of dkeys must not be empty" in str(err.value)

        with pytest.raises(TypeError) as err:
            dkey = VosObject()
            dkey.add_value("rubbish")
        assert "must be of type" in str(err.value)

        vos_object = VosObject(count=200)
        vos_object.add_value(self.dkey2)
        vos_object.add_value(self.dkey1)
        want = self.test_data.create_default_object(count=200)
        assert want == vos_object.dump()
Ejemplo n.º 9
0
 def test_constructor(self):
     vos_object = VosObject(count=100, dkeys=[self.dkey1, self.dkey2])
     want = self.test_data.create_default_object(count=100)
     assert want == vos_object.dump()