def test_iface_type_can_be_null(self): store = ValueProvider() def ret_values(value: str) -> Any: data = { 'server_node': { 'MACH_ID': 'stub' }, 'server_node>MACH_ID>name': 'mynodename', 'server_node>MACH_ID>hostname': 'myhost', 'server_node>MACH_ID>storage>cvg': [{'data_devices': ['/dev/sdb'], 'metadata_devices': ['/dev/meta']}], 'server_node>MACH_ID>storage>cvg[0]>data_devices': ['/dev/sdb'], 'server_node>MACH_ID>network>data>interface_type': None, 'server_node>MACH_ID>network>data>private_fqdn': 'srvnode-1.data.private', 'cortx>software>s3>service>instances': 1, 'cortx>software>motr>service>client_instances': 2, 'server_node>MACH_ID>network>data>private_interfaces': ['eth1', 'eno2'] } return data[value] store._raw_get = Mock(side_effect=ret_values) cdf = CdfGenerator(provider=store, motr_provider=Mock()) cdf._get_m0d_per_cvg = Mock(return_value=1) ret = cdf._create_node_descriptions() self.assertEqual('None (P)', str(ret[0].data_iface_type))
def is_content_ok(content: str, mocker, kv_adapter) -> bool: if len(content) < 4: # Some templates represent empty JSONs and should be skipped return True _, path = tempfile.mkstemp() try: with open(path, 'w') as f: f.write(content) store = ConfStoreProvider(f'json://{path}') mocker.patch.object(store, 'get_machine_id', return_value='machine-id') mocker.patch.object(store, 'get_machine_ids_for_service', return_value=['machine-id']) motr_store = ValueProvider() mocker.patch.object(motr_store, '_raw_get', return_value='/dev/dummy') # # the method will raise an exception if either # Dhall is unhappy or some values are not found in ConfStore generator = CdfGenerator(provider=store) generator.utils.kv = kv_adapter generator.generate() return True finally: if os.path.isfile(path): os.unlink(path)
def generate_cdf(url: str, motr_md_url: str) -> str: # ConfStoreProvider creates an empty file, if file does not exist. # So, we are validating the file is present or not. if not os.path.isfile(urlparse(motr_md_url).path): raise FileNotFoundError(f'config file: {motr_md_url} does not exist') motr_provider = ConfStoreProvider(motr_md_url, index='motr_md') generator = CdfGenerator(ConfStoreProvider(url), motr_provider) return generator.generate()
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()
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)
def test_multiple_nodes_supported(self): store = ValueProvider() def ret_values(value: str) -> Any: data = { 'cluster>server_nodes': { "blah": "srvnode_1", "zweite": "srvnode_2" }, 'cluster>srvnode_1>hostname': 'myhost', 'cluster>srvnode_1>network>data>public_interfaces': ['eth1', 'eno2'], 'cluster>srvnode_1>storage>data_devices': ['/dev/sdb'], 'cluster>srvnode_2>hostname': 'host-2', 'cluster>srvnode_2>network>data>public_interfaces': ['eno1'], 'cluster>srvnode_2>storage>data_devices': ['/dev/sdb'] } return data[value] store._raw_get = Mock(side_effect=ret_values) ret = CdfGenerator(provider=store)._create_node_descriptions() self.assertIsInstance(ret, list) self.assertEqual(2, len(ret)) self.assertEqual(Text('myhost'), ret[0].hostname) self.assertEqual(Text('eth1'), ret[0].data_iface) self.assertEqual(Text('host-2'), ret[1].hostname) self.assertEqual(Text('eno1'), ret[1].data_iface)
def test_provided_values_respected(self): store = ValueProvider() def ret_values(value: str) -> Any: data = { 'cluster>server_nodes': { "blah": "srvnode_1" }, 'cluster>srvnode_1>hostname': 'myhost', 'cluster>srvnode_1>storage>data_devices': ['/dev/sdb'], 'cluster>srvnode_1>network>data>private_interfaces': ['eth1', 'eno2'], 'cluster>srvnode_1>storage>metadata_devices': ['/dev/meta'], 'cluster>srvnode_1>s3_instances': 1, 'cluster>srvnode_1>network>data>interface_type': 'o2ib', } return data[value] store._raw_get = Mock(side_effect=ret_values) ret = CdfGenerator(provider=store)._create_node_descriptions() self.assertIsInstance(ret, list) self.assertEqual(1, len(ret)) self.assertEqual(Text('myhost'), ret[0].hostname) self.assertEqual(Text('eth1'), ret[0].data_iface) self.assertEqual(1, ret[0].s3_instances)
def test_template_sane(self): _, path = tempfile.mkstemp() try: with open(path, 'w') as f: f.write(self._get_confstore_template()) store = ConfStoreProvider(f'json://{path}') store.get_machine_id = Mock(return_value='1114a50a6bf6f9c93ebd3c49d07d3fd4') # # the method will raise an exception if either # Dhall is unhappy or some values are not found in ConfStore cdf = CdfGenerator(provider=store, motr_provider=Mock()) cdf._get_m0d_per_cvg = Mock(return_value=1) cdf.generate() finally: os.unlink(path)
def test_invalid_storage_set_configuration_rejected(self): ''' This test case checks whether exception will be raise if total number of data devices are less than data_units + parity_units + spare_units ''' 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]>durability>sns': {'stub': 1}, 'cluster>CLUSTER_ID>storage_set[0]>durability>sns>data': 4, '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]>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_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) with self.assertRaisesRegex(RuntimeError, r'Invalid storage set configuration'): CdfGenerator(provider=store, motr_provider=Mock())._create_pool_descriptions()
def test_metadata_is_hardcoded(self): store = ValueProvider() motr_store = ValueProvider() def ret_values(value: str) -> Any: data = { 'server_node': { 'MACH_ID': 'stub' }, 'server_node>MACH_ID>hostname': 'myhost', 'server_node>MACH_ID>name': 'mynodename', 'server_node>MACH_ID>storage>cvg': [{'data_devices': ['/dev/sdb'], 'metadata_devices': ['/dev/meta1']}, {'data_devices': ['/dev/sdc'], 'metadata_devices': ['/dev/meta2']}], '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'], 'cortx>software>s3>service>instances': 1, 'cortx>software>motr>service>client_instances': 2, 'server_node>MACH_ID>network>data>interface_type': 'o2ib', 'server_node>MACH_ID>network>data>private_fqdn': 'srvnode-1.data.private', } return data[value] store._raw_get = Mock(side_effect=ret_values) 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('/dev/vg_srvnode-1_md1/lv_raw_md1'), (ret[0].m0_servers.value.value)[0].io_disks.meta_data.value) self.assertEqual(Text('/dev/vg_srvnode-1_md2/lv_raw_md2'), (ret[0].m0_servers.value.value)[1].io_disks.meta_data.value)
def test_md_pool_ignored(self): 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]>durability>md': { '1': 2 }, 'cluster>CLUSTER_ID>storage_set[0]>durability>md>data': 2, 'cluster>CLUSTER_ID>storage_set[0]>durability>md>parity': 0, 'cluster>CLUSTER_ID>storage_set[0]>durability>md>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_interfaces': ['eth1', 'eno2'], 'cortx>software>s3>service>instances': 1, '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'], } return data.get(value) store._raw_get = Mock(side_effect=ret_values) ret = CdfGenerator(provider=store, motr_provider=Mock())._create_pool_descriptions() self.assertEqual(0, len(ret))
def test_it_works(self): store = ValueProvider() def ret_values(value: str) -> Any: data = { 'cluster>server_nodes': { "blah": "srvnode_1" }, 'cluster>srvnode_1>hostname': 'myhost', 'cluster>srvnode_1>storage>data_devices': ['/dev/sdb'], 'cluster>srvnode_1>network>data>public_interfaces': ['eth1', 'eno2'] } return data[value] store._raw_get = Mock(side_effect=ret_values) CdfGenerator(provider=store).generate()
def test_metadata_is_hardcoded(self): store = ValueProvider() def ret_values(value: str) -> Any: data = { 'cluster>server_nodes': { "blah": "srvnode_1" }, 'cluster>srvnode_1>hostname': 'myhost', 'cluster>srvnode_1>storage>data_devices': ['/dev/sdb'], 'cluster>srvnode_1>network>data>public_interfaces': ['eth1', 'eno2'] } return data[value] store._raw_get = Mock(side_effect=ret_values) ret = CdfGenerator(provider=store)._create_node_descriptions() self.assertIsInstance(ret, list) self.assertEqual(1, len(ret)) self.assertEqual(Text('/dev/vg_metadata_srvnode-1/lv_raw_metadata'), ret[0].meta_data)
def test_iface_type_can_be_null(self): store = ValueProvider() def ret_values(value: str) -> Any: data = { 'cluster>server_nodes': { "blah": "srvnode_1" }, 'cluster>srvnode_1>hostname': 'myhost', 'cluster>srvnode_1>storage>data_devices': ['/dev/sdb'], 'cluster>srvnode_1>network>data>interface_type': None, 'cluster>srvnode_1>s3_instances': 1, 'cluster>srvnode_1>network>data>private_interfaces': ['eth1', 'eno2'] } return data[value] store._raw_get = Mock(side_effect=ret_values) ret = CdfGenerator(provider=store)._create_node_descriptions() self.assertEqual('None P', str(ret[0].data_iface_type))
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()
def generate_cdf(url: str) -> str: generator = CdfGenerator(ConfStoreProvider(url)) return generator.generate()
def test_multiple_nodes_supported(self): store = ValueProvider() def ret_values(value: str) -> Any: data = { 'server_node': { 'MACH_ID': 'stub', 'MACH_2_ID': 'stub' }, 'cluster>92f444df-87cc-4137-b680-aab3b35d1695>site>storage_set_count': 1, 'cluster>92f444df-87cc-4137-b680-aab3b35d1695>storage_set>server_node_count': 2, 'cluster>92f444df-87cc-4137-b680-aab3b35d1695>storage_set[0]>name': 'StorageSet-1', 'cluster>92f444df-87cc-4137-b680-aab3b35d1695>storage_set[0]>server_nodes': ['srvnode_1', 'srvnode_2'], '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'], 'cortx>software>s3>service>instances': 1, 'cortx>software>motr>service>client_instances': 2, 'server_node>MACH_ID>storage>cvg': [{ 'data_devices': ['/dev/sdb'], 'metadata_devices': ['/dev/meta'] }], '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_2_ID>name': 'host-2', 'server_node>MACH_2_ID>hostname': 'host-2', 'server_node>MACH_2_ID>network>data>interface_type': 'tcp', 'server_node>MACH_2_ID>network>data>private_fqdn': 'srvnode-2.data.private', 'server_node>MACH_2_ID>network>data>private_interfaces': ['eno1'], 'cortx>software>s3>service>instances': 1, 'cortx>software>motr>service>client_instances': 2, 'server_node>MACH_2_ID>storage>cvg': [{ 'data_devices': ['/dev/sdb'], 'metadata_devices': ['/dev/meta'] }], 'server_node>MACH_2_ID>storage>cvg[0]>data_devices': ['/dev/sdb'], 'server_node>MACH_2_ID>storage>cvg[0]>metadata_devices': ['/dev/meta'], } return data[value] store._raw_get = Mock(side_effect=ret_values) cdf = CdfGenerator(provider=store, motr_provider=Mock()) cdf._get_m0d_per_cvg = Mock(return_value=1) ret = cdf._create_node_descriptions() self.assertIsInstance(ret, list) self.assertEqual(2, 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) self.assertEqual(Text('srvnode-2.data.private'), ret[1].hostname) self.assertEqual(Text('eno1'), ret[1].data_iface) self.assertEqual(1, ret[1].s3_instances) self.assertEqual(2, ret[1].client_instances) self.assertEqual('Some (P.o2ib)', str(ret[0].data_iface_type)) self.assertEqual('Some (P.tcp)', str(ret[1].data_iface_type))
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
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])