Exemplo n.º 1
0
    def test_dix_pool_uses_metadata_devices(self):
        store = ValueProvider()

        def ret_values(value: str) -> Any:
            data = {
                'server_node>MACH_ID>storage>cvg_count': 1,
                'cluster>CLUSTER_ID>site>storage_set_count':
                1,
                'cluster>CLUSTER_ID>storage_set>server_node_count':
                1,
                'cluster>CLUSTER_ID>storage_set[0]>durability>dix': {'1':2},
                'cluster>CLUSTER_ID>storage_set[0]>durability>dix>data': 1,
                'cluster>CLUSTER_ID>storage_set[0]>durability>dix>parity': 0,
                'cluster>CLUSTER_ID>storage_set[0]>durability>dix>spare': 0,
                'cluster>CLUSTER_ID>storage_set[0]>name':
                'StorageSet-1',
                'cluster>CLUSTER_ID>storage_set[0]>server_nodes': ['MACH_ID'],
                'cluster>cluster_id':
                'CLUSTER_ID',
                'server_node': {
                    'MACH_ID': {
                        'cluster_id': 'CLUSTER_ID'
                    }
                },
                'server_node>MACH_ID>cluster_id':
                'CLUSTER_ID',
                'server_node>MACH_ID>hostname':
                'myhost',
                'server_node>MACH_ID>network>data>interface_type':
                'o2ib',
                'server_node>MACH_ID>network>data>private_fqdn':
                    'srvnode-1.data.private',
                'server_node>MACH_ID>network>data>private_interfaces':
                ['eth1', 'eno2'],
                'cortx>software>s3>service>instances':
                1,
                'server_node>MACH_ID>storage>cvg_count':
                2,
                'cortx>software>motr>service>client_instances':
                2,
                'server_node>MACH_ID>storage>cvg[0]>data_devices':
                ['/dev/sdb'],
                'server_node>MACH_ID>storage>cvg[0]>metadata_devices':
                ['/dev/meta'],
                'server_node>MACH_ID>storage>cvg[1]>data_devices':
                ['/dev/sdc'],
                'server_node>MACH_ID>storage>cvg[1]>metadata_devices':
                ['/dev/meta1'],
            }
            return data.get(value)

        store._raw_get = Mock(side_effect=ret_values)
        store.get_machine_id = Mock(return_value='MACH_ID')
        store.get_storage_set_nodes = Mock(return_value=['MACH_ID'])
        ret = CdfGenerator(provider=store,
                           motr_provider=Mock())._create_pool_descriptions()
        self.assertEqual(1, len(ret))
        diskrefs = ret[0].disk_refs.get()
        self.assertEqual(2, len(diskrefs))
        self.assertEqual(Text('/dev/meta'), diskrefs[0].path)
Exemplo n.º 2
0
    def test_disk_refs_can_be_empty(self):
        store = ValueProvider()

        def ret_values(value: str) -> Any:
            data = {
                'server_node>MACH_ID>storage>cvg_count': 1,
                'cluster>CLUSTER_ID>site>storage_set_count': 1,
                'cluster>CLUSTER_ID>storage_set>server_node_count': 1,
                'cluster>CLUSTER_ID>storage_set[0]>name': 'StorageSet-1',
                'cluster>CLUSTER_ID>storage_set[0]>server_nodes': ['srvnode_1'],
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns': {'stub': 1},
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>data': 1,
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>parity': 0,
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>spare': 0,
                'cluster>cluster_id':
                'CLUSTER_ID',
                'server_node': {
                    'srvnode_1': {
                        'cluster_id': 'CLUSTER_ID'
                    }
                },
                'server_node>srvnode_1>cluster_id':
                'CLUSTER_ID',
                'server_node>srvnode_1>name':
                'myhost',
                'server_node>srvnode_1>hostname':
                'myhost',
                'server_node>srvnode_1>network>data>interface_type':
                'o2ib',
                'server_node>srvnode_1>network>data>private_fqdn':
                    'srvnode-1.data.private',
                'server_node>srvnode_1>network>data>private_interfaces':
                ['eth1', 'eno2'],
                'cortx>software>s3>service>instances':
                1,
                'server_node>srvnode_1>storage>cvg_count':
                2,
                'cortx>software>motr>service>client_instances':
                2,
                'server_node>srvnode_1>storage>cvg':
                [{'data_devices': ['/dev/sdb', '/dev/sdc'], 'metadata_devices': ['/dev/meta', '/dev/meta1']}],
                'server_node>srvnode_1>storage>cvg[0]>data_devices':
                ['/dev/sdb'],
                'server_node>srvnode_1>storage>cvg[1]>data_devices':
                ['/dev/sdc'],
            }
            return data.get(value)

        store._raw_get = Mock(side_effect=ret_values)
        store.get_machine_id = Mock(return_value='MACH_ID')
        store.get_storage_set_nodes = Mock(return_value=['MACH_ID'])
        cdf = CdfGenerator(provider=store, motr_provider=Mock())
        cdf._get_m0d_per_cvg = Mock(return_value=1)
        cdf.generate()
Exemplo n.º 3
0
    def allowed_failure_generation(self, layout: Layout):
        store = ValueProvider()

        def ret_values(value: str) -> Any:
            data = {
                'cluster>CLUSTER_ID>site>storage_set_count':
                1,
                'cluster>CLUSTER_ID>storage_set[0]>name':
                'StorageSet-1',
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns': {
                    'data': 4,
                    'parity': 2,
                    'spare': 0
                },
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>data':
                layout.data,
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>parity':
                layout.parity,
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>spare':
                layout.spare,
                'cluster>CLUSTER_ID>storage_set[0]>server_nodes':
                ['MACH_ID1', 'MACH_ID2', 'MACH_ID3'],
                'cluster>CLUSTER_ID>storage_set>server_node_count':
                3,
                'cluster>cluster_id':
                'CLUSTER_ID',
                'server_node': {
                    'MACH_ID1': {
                        'cluster_id': 'CLUSTER_ID'
                    }
                },
                'server_node>MACH_ID1>cluster_id':
                'CLUSTER_ID',
                'server_node>MACH_ID2>cluster_id':
                'CLUSTER_ID',
                'server_node>MACH_ID3>cluster_id':
                'CLUSTER_ID',
                'server_node>MACH_ID1>storage>cvg': [{
                    'data_devices':
                    ['/dev/sda', '/dev/sdb', '/dev/sdc', '/dev/sdd'],
                    'metadata_devices': ['/dev/meta1']
                }, {
                    'data_devices':
                    ['/dev/sde', '/dev/sdf', '/dev/sdg', '/dev/sdh'],
                    'metadata_devices': ['/dev/meta2']
                }],
                'server_node>MACH_ID2>storage>cvg': [{
                    'data_devices':
                    ['/dev/sda', '/dev/sdb', '/dev/sdc', '/dev/sdd'],
                    'metadata_devices': ['/dev/meta1']
                }, {
                    'data_devices':
                    ['/dev/sde', '/dev/sdf', '/dev/sdg', '/dev/sdh'],
                    'metadata_devices': ['/dev/meta2']
                }],
                'server_node>MACH_ID3>storage>cvg': [{
                    'data_devices':
                    ['/dev/sda', '/dev/sdb', '/dev/sdc', '/dev/sdd'],
                    'metadata_devices': ['/dev/meta1']
                }, {
                    'data_devices':
                    ['/dev/sde', '/dev/sdf', '/dev/sdg', '/dev/sdh'],
                    'metadata_devices': ['/dev/meta2']
                }],
                'server_node>MACH_ID1>storage>cvg_count':
                '2',
                'server_node>MACH_ID1>storage>cvg[0]>data_devices':
                ['/dev/sda', '/dev/sdb', '/dev/sdc', '/dev/sdd'],
                'server_node>MACH_ID1>storage>cvg[1]>data_devices':
                ['/dev/sde', '/dev/sdf', '/dev/sdg', '/dev/sdh'],
                'server_node>MACH_ID1>storage>cvg[0]>metadata_devices':
                ['/dev/meta1'],
                'server_node>MACH_ID1>storage>cvg[1]>metadata_devices':
                ['/dev/meta2'],
                'server_node>MACH_ID1>hostname':
                'myhost',
                'server_node>MACH_ID1>name':
                'mynodename',
                'server_node>MACH_ID1>network>data>interface_type':
                'o2ib',
                'server_node>MACH_ID1>network>data>private_fqdn':
                'srvnode-1.data.private',
                'server_node>MACH_ID1>network>data>private_interfaces':
                ['eth1', 'eno2'],
                'cortx>software>s3>service>instances':
                1,
                'server_node>MACH_ID2>storage>cvg_count':
                '2',
                'server_node>MACH_ID2>storage>cvg[0]>data_devices':
                ['/dev/sda', '/dev/sdb', '/dev/sdc', '/dev/sdd'],
                'server_node>MACH_ID2>storage>cvg[1]>data_devices':
                ['/dev/sde', '/dev/sdf', '/dev/sdg', '/dev/sdh'],
                'server_node>MACH_ID2>storage>cvg[0]>metadata_devices':
                ['/dev/meta1'],
                'server_node>MACH_ID2>storage>cvg[1]>metadata_devices':
                ['/dev/meta2'],
                'server_node>MACH_ID2>hostname':
                'myhost',
                'server_node>MACH_ID2>name':
                'mynodename',
                'server_node>MACH_ID2>network>data>interface_type':
                'o2ib',
                'server_node>MACH_ID2>network>data>private_fqdn':
                'srvnode-2.data.private',
                'server_node>MACH_ID2>network>data>private_interfaces':
                ['eth1', 'eno2'],
                'cortx>software>s3>service>instances':
                1,
                'server_node>MACH_ID3>storage>cvg_count':
                '2',
                'server_node>MACH_ID3>storage>cvg[0]>data_devices':
                ['/dev/sda', '/dev/sdb', '/dev/sdc', '/dev/sdd'],
                'server_node>MACH_ID3>storage>cvg[1]>data_devices': [
                    '/dev/sde', '/dev/sdf', '/dev/sdg', '/dev/sdh'
                ],
                'server_node>MACH_ID3>storage>cvg[0]>metadata_devices': [
                    '/dev/meta1'
                ],
                'server_node>MACH_ID3>storage>cvg[1]>metadata_devices': [
                    '/dev/meta2'
                ],
                'server_node>MACH_ID3>hostname':
                'myhost',
                'server_node>MACH_ID3>name':
                'mynodename',
                'server_node>MACH_ID3>network>data>interface_type':
                'o2ib',
                'server_node>MACH_ID3>network>data>private_fqdn':
                'srvnode-3.data.private',
                'server_node>MACH_ID3>network>data>private_interfaces': [
                    'eth1', 'eno2'
                ],
                'cortx>software>s3>service>instances':
                1,
            }
            return data.get(value)

        store._raw_get = Mock(side_effect=ret_values)
        store.get_machine_id = Mock(return_value='MACH_ID1')
        store.get_storage_set_nodes = Mock(
            return_value=['MACH_ID1', 'MACH_ID2', 'MACH_ID3'])

        ret = CdfGenerator(provider=store,
                           motr_provider=Mock())._create_pool_descriptions()
        self.assertIsInstance(ret, list)
        return ret
Exemplo n.º 4
0
    def test_provided_values_respected(self):
        store = ValueProvider()
        motr_store = ValueProvider()

        def ret_values(value: str) -> Any:
            data = {
                'cluster>CLUSTER_ID>site>storage_set_count':
                1,
                'cluster>CLUSTER_ID>storage_set>server_node_count':
                1,
                'cluster>CLUSTER_ID>storage_set[0]>name':
                'StorageSet-1',
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns': {
                    'a': 42
                },
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>data':
                1,
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>parity':
                0,
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>spare':
                0,
                'cluster>CLUSTER_ID>storage_set[0]>server_nodes': ['MACH_ID'],
                'cluster>CLUSTER_ID>storage_set>server_node_count':
                1,
                'cluster>cluster_id':
                'CLUSTER_ID',
                'server_node': {
                    'MACH_ID': {
                        'cluster_id': 'CLUSTER_ID'
                    }
                },
                'server_node>MACH_ID>cluster_id':
                'CLUSTER_ID',
                'server_node>MACH_ID>storage>cvg_count':
                2,
                'server_node>MACH_ID>storage>cvg': [{
                    'data_devices': ['/dev/sdb', '/dev/sdc'],
                    'metadata_devices': ['/dev/meta', '/dev/meta1']
                }],
                'server_node>MACH_ID>storage>cvg[0]>data_devices':
                ['/dev/sdb'],
                'server_node>MACH_ID>storage>cvg[0]>metadata_devices':
                ['/dev/meta'],
                'server_node>MACH_ID>storage>cvg[1]>data_devices':
                ['/dev/sdc'],
                'server_node>MACH_ID>storage>cvg[1]>metadata_devices':
                ['/dev/meta1'],
                'server_node>MACH_ID>hostname':
                'myhost',
                'server_node>MACH_ID>name':
                'mynodename',
                'server_node>MACH_ID>network>data>interface_type':
                'o2ib',
                'server_node>MACH_ID>network>data>private_fqdn':
                'srvnode-1.data.private',
                'server_node>MACH_ID>network>data>private_interfaces':
                ['eth1', 'eno2'],
                'cortx>software>s3>service>instances':
                1,
                'cortx>software>motr>service>client_instances':
                2,
            }
            return data.get(value)

        store._raw_get = Mock(side_effect=ret_values)
        store.get_machine_id = Mock(return_value='MACH_ID')
        store.get_storage_set_nodes = Mock(return_value=['MACH_ID'])

        def ret_motr_mdvalues(value: str) -> Any:
            data = {
                'server>mynodename>cvg[0]>m0d':
                ['/dev/vg_srvnode-1_md1/lv_raw_md1'],
                'server>mynodename>cvg[0]>m0d[0]>md_seg1':
                '/dev/vg_srvnode-1_md1/lv_raw_md1',
                'server>mynodename>cvg[1]>m0d':
                ['/dev/vg_srvnode-1_md2/lv_raw_md2'],
                'server>mynodename>cvg[1]>m0d[0]>md_seg1':
                '/dev/vg_srvnode-1_md2/lv_raw_md2'
            }
            return data.get(value)

        motr_store._raw_get = Mock(side_effect=ret_motr_mdvalues)

        ret = CdfGenerator(
            provider=store,
            motr_provider=motr_store)._create_node_descriptions()
        self.assertIsInstance(ret, list)
        self.assertEqual(1, len(ret))
        self.assertEqual(Text('srvnode-1.data.private'), ret[0].hostname)
        self.assertEqual(Text('eth1'), ret[0].data_iface)
        self.assertEqual(1, ret[0].s3_instances)
        self.assertEqual(2, ret[0].client_instances)

        ret = CdfGenerator(provider=store,
                           motr_provider=Mock())._create_pool_descriptions()
        self.assertIsInstance(ret, list)
        self.assertEqual(1, len(ret))
        self.assertEqual(Text('StorageSet-1__sns'), ret[0].name)
        self.assertEqual(PoolType.sns, ret[0].type)
        self.assertEqual(1, ret[0].data_units)
        self.assertEqual(0, ret[0].parity_units)
        self.assertEqual(0, ret[0].spare_units.get())
        disk_refs = ret[0].disk_refs.value
        self.assertEqual(Text('srvnode-1.data.private'),
                         disk_refs.value[0].node.value)
        self.assertEqual(Text('/dev/sdb'), disk_refs.value[0].path)
        self.assertEqual(0, ret[0].allowed_failures.value.site)
        self.assertEqual(0, ret[0].allowed_failures.value.rack)
        self.assertEqual(0, ret[0].allowed_failures.value.encl)
        self.assertEqual(0, ret[0].allowed_failures.value.ctrl)
        self.assertEqual(0, ret[0].allowed_failures.value.disk)

        ret = CdfGenerator(
            provider=store,
            motr_provider=Mock())._create_profile_descriptions(ret)
        self.assertIsInstance(ret, list)
        self.assertEqual(1, len(ret))
        self.assertEqual(Text('Profile_the_pool'), ret[0].name)
        self.assertEqual(1, len(ret[0].pools.value))
        self.assertEqual(Text('StorageSet-1__sns'), ret[0].pools.value[0])
Exemplo n.º 5
0
    def test_it_works(self):
        store = ValueProvider()
        motr_store = ValueProvider()

        def ret_values(value: str) -> Any:
            data = {
                'cluster>cluster_id':
                'CLUSTER_ID',
                'server_node>MACH_ID>name':
                'myhost',
                'server_node>MACH_ID>hostname':
                'myhost',
                'server_node>MACH_ID>network>data>interface_type':
                'tcp',
                'server_node>MACH_ID>network>data>private_fqdn':
                'srvnode-1.data.private',
                'server_node>MACH_ID>storage>cvg[0]>data_devices':
                ['/dev/sdb'],
                'server_node>MACH_ID>storage>cvg[1]>data_devices':
                ['/dev/sdc'],
                'server_node>MACH_ID>network>data>private_interfaces':
                ['eth1', 'eno2'],
                'server_node>MACH_ID>storage>cvg_count':
                2,
                'server_node>MACH_ID>storage>cvg': [{
                    'data_devices': ['/dev/sdb', '/dev/sdc'],
                    'metadata_devices': ['/dev/meta', '/dev/meta1']
                }],
                'server_node>MACH_ID>storage>cvg[0]>metadata_devices':
                ['/dev/meta'],
                'server_node>MACH_ID>storage>cvg[1]>metadata_devices':
                ['/dev/meta1'],
                'cortx>software>s3>service>instances':
                1,
                'cortx>software>motr>service>client_instances':
                2,
                'server_node>MACH_ID>storage>cvg_count':
                1,
                'cluster>CLUSTER_ID>site>storage_set_count':
                1,
                'cluster>CLUSTER_ID>storage_set>server_node_count':
                1,
                'cluster>CLUSTER_ID>storage_set[0]>name':
                'StorageSet-1',
                'cluster>CLUSTER_ID>storage_set[0]>server_nodes': ['MACH_ID'],
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns': {
                    'stub': 1
                },
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>data':
                1,
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>parity':
                0,
                'cluster>CLUSTER_ID>storage_set[0]>durability>sns>spare':
                0,
                'server_node>MACH_ID>cluster_id':
                'CLUSTER_ID',
                'server_node': {
                    'MACH_ID': {
                        'cluster_id': 'CLUSTER_ID'
                    }
                }
            }
            return data.get(value)

        store._raw_get = Mock(side_effect=ret_values)
        store.get_machine_id = Mock(return_value='MACH_ID')
        store.get_storage_set_nodes = Mock(return_value=['MACH_ID'])

        def ret_motr_mdvalues(value: str) -> Any:
            data = {
                'server>myhost>cvg[0]>m0d':
                ['/dev/vg_srvnode-1_md1/lv_raw_md1'],
                'server>myhost>cvg[0]>m0d[0]>md_seg1':
                '/dev/vg_srvnode-1_md1/lv_raw_md1',
                'server>myhost>cvg[1]>m0d':
                ['/dev/vg_srvnode-1_md2/lv_raw_md2'],
                'server>myhost>cvg[1]>m0d[0]>md_seg1':
                '/dev/vg_srvnode-1_md2/lv_raw_md2'
            }
            return data.get(value)

        motr_store._raw_get = Mock(side_effect=ret_motr_mdvalues)

        CdfGenerator(provider=store, motr_provider=motr_store).generate()