diff --git a/fuelweb_test/models/fuel_web_client.py b/fuelweb_test/models/fuel_web_client.py index 1523e56ce..f46c38537 100644 --- a/fuelweb_test/models/fuel_web_client.py +++ b/fuelweb_test/models/fuel_web_client.py @@ -3130,6 +3130,113 @@ class FuelWebClient29(object): } return _net_pool + def setup_hugepages(self, nailgun_node_id, + hp_2mb=0, hp_1gb=0, hp_dpdk_mb=0): + node_attributes = self.client.get_node_attributes(nailgun_node_id) + node_attributes['hugepages']['nova']['value']['2048'] = hp_2mb + node_attributes['hugepages']['nova']['value']['1048576'] = hp_1gb + node_attributes['hugepages']['dpdk']['value'] = hp_dpdk_mb + self.client.upload_node_attributes(node_attributes, nailgun_node_id) + + def check_dpdk(self, nailgun_node_id, net='private'): + compute_net = self.client.get_node_interfaces(nailgun_node_id) + dpdk_available = False + dpdk_enabled = False + for interface in compute_net: + if net not in [n['name'] for n in interface['assigned_networks']]: + continue + if 'dpdk' not in interface['interface_properties']: + continue + + dpdk_available = interface['interface_properties']['dpdk'][ + 'available'] + if 'enabled' in interface['interface_properties']['dpdk']: + dpdk_enabled = interface['interface_properties']['dpdk'][ + 'enabled'] + break + + return {'available': dpdk_available, 'enabled': dpdk_enabled} + + def enable_dpdk(self, nailgun_node_id, switch_to=True, net='private', + forceEnable=False): + if not forceEnable: + assert_true(self.check_dpdk(nailgun_node_id, net=net)['available'], + 'DPDK not available on selected interface') + + compute_net = self.client.get_node_interfaces( + nailgun_node_id) + for interface in compute_net: + for ids in interface['assigned_networks']: + if ids['name'] == net: + if interface['type'] == 'bond': + interface['bond_properties']['type__'] = 'dpdkovs' + interface['interface_properties']['dpdk'].update( + {'enabled': switch_to}) + else: + interface['interface_properties']['dpdk'][ + 'enabled'] = switch_to + break + + self.client.put_node_interfaces( + [{'id': nailgun_node_id, 'interfaces': compute_net}]) + + return self.check_dpdk( + nailgun_node_id, net=net)['enabled'] == switch_to + + def check_sriov(self, nailgun_node_id): + nailgun_node_ifaces = self.client.get_node_interfaces( + nailgun_node_id) + devops_node = self.get_devops_node_by_nailgun_node( + nailgun_node_id) + devops_sriov_macs = [i.mac_address for i in devops_node.interfaces + if 'sriov' in i.features] + nailgun_sriov_nics = [] + devops_sriov_nics = [] + for interface in nailgun_node_ifaces: + if interface['mac'] in devops_sriov_macs: + devops_sriov_nics.append(interface['name']) + if interface['assigned_networks']: + continue + if 'sriov' not in interface['interface_properties']: + continue + sriov_available = interface['interface_properties']['sriov'][ + 'available'] + if sriov_available: + nailgun_sriov_nics.append(interface['name']) + return set(devops_sriov_nics).intersection(nailgun_sriov_nics) + + def enable_sriov(self, nailgun_node_id): + nics_to_enable_sriov = self.check_sriov(nailgun_node_id) + assert_true(nics_to_enable_sriov, + 'There are no NICs with SR-IOV support on ' + 'node with ID {0}!'.format(nailgun_node_id)) + node_networks = self.client.get_node_interfaces(nailgun_node_id) + for interface in node_networks: + if interface['name'] not in nics_to_enable_sriov: + continue + interface['interface_properties']['sriov']['enabled'] = True + interface['interface_properties']['sriov']['sriov_numvfs'] = \ + interface['interface_properties']['sriov']['sriov_totalvfs'] + + self.client.put_node_interfaces( + [{'id': nailgun_node_id, 'interfaces': node_networks}]) + + def enable_cpu_pinning(self, nailgun_node_id, cpu_count=None): + nailgun_node = [node for node in self.client.list_nodes() + if node['id'] == nailgun_node_id].pop() + vcpu_total = nailgun_node['meta']['cpu']['total'] + node_attrs = self.client.get_node_attributes(nailgun_node_id) + if cpu_count is None: + cpu_count = vcpu_total - 1 + else: + assert_true( + cpu_count < vcpu_total, + "Too many cpu requested for cpu pinning! Should be less" + "than vcpu count (requested {!r}, vcpu found {!r}".format( + cpu_count, vcpu_total)) + node_attrs['cpu_pinning']['nova']['value'] = cpu_count + self.client.upload_node_attributes(node_attrs, nailgun_node_id) + class FuelWebClient30(FuelWebClient29): """FuelWebClient that works with fuel-devops 3.0 diff --git a/fuelweb_test/settings.py b/fuelweb_test/settings.py index 886d8527e..09f8ca3ed 100644 --- a/fuelweb_test/settings.py +++ b/fuelweb_test/settings.py @@ -114,7 +114,14 @@ HARDWARE = { "admin_node_cpu": int(os.environ.get("ADMIN_NODE_CPU", 2)), "slave_node_cpu": int(os.environ.get("SLAVE_NODE_CPU", 1)), "slave_node_memory": int(os.environ.get("SLAVE_NODE_MEMORY", 3584)), - "numa_nodes": int(os.environ.get("NUMA_NODES", 0))} + "numa_nodes": int(os.environ.get("NUMA_NODES", 0)) +} +if OPENSTACK_RELEASE_UBUNTU in OPENSTACK_RELEASE: + slave_mem_default = 2560 +else: + slave_mem_default = 2048 +HARDWARE["slave_node_memory"] = int( + os.environ.get("SLAVE_NODE_MEMORY", slave_mem_default)) NODE_VOLUME_SIZE = int(os.environ.get('NODE_VOLUME_SIZE', 50)) NODES_COUNT = int(os.environ.get('NODES_COUNT', 10)) diff --git a/fuelweb_test/tests/test_dpdk.py b/fuelweb_test/tests/test_dpdk.py index 909cf6555..7096023be 100644 --- a/fuelweb_test/tests/test_dpdk.py +++ b/fuelweb_test/tests/test_dpdk.py @@ -91,61 +91,6 @@ class TestDPDK(TestBasic): os_conn.delete_instance(server) os_conn.delete_flavor(flavor) - def setup_hugepages(self, nailgun_node, - hp_2mb=0, hp_1gb=0, hp_dpdk_mb=0): - node_attributes = self.fuel_web.client.get_node_attributes( - nailgun_node['id']) - node_attributes['hugepages']['nova']['value']['2048'] = hp_2mb - node_attributes['hugepages']['nova']['value']['1048576'] = hp_1gb - node_attributes['hugepages']['dpdk']['value'] = hp_dpdk_mb - self.fuel_web.client.upload_node_attributes(node_attributes, - nailgun_node['id']) - - def check_dpdk(self, nailgun_node, net='private'): - compute_net = self.fuel_web.client.get_node_interfaces( - nailgun_node['id']) - dpdk_available = False - dpdk_enabled = False - for interface in compute_net: - if net not in [n['name'] for n in interface['assigned_networks']]: - continue - if 'dpdk' not in interface['interface_properties']: - continue - - dpdk_available = interface['interface_properties']['dpdk'][ - 'available'] - if 'enabled' in interface['interface_properties']['dpdk']: - dpdk_enabled = interface['interface_properties']['dpdk'][ - 'enabled'] - break - - return {'available': dpdk_available, 'enabled': dpdk_enabled} - - def enable_dpdk(self, nailgun_node, switch_to=True, net='private', - forceEnable=False): - if not forceEnable: - assert_true(self.check_dpdk(nailgun_node, net=net)['available'], - 'DPDK not available on selected interface') - - compute_net = self.fuel_web.client.get_node_interfaces( - nailgun_node['id']) - for interface in compute_net: - for ids in interface['assigned_networks']: - if ids['name'] == net: - if interface['type'] == 'bond': - interface['bond_properties']['type__'] = 'dpdkovs' - interface['interface_properties']['dpdk'].update( - {'enabled': switch_to}) - else: - interface['interface_properties']['dpdk'][ - 'enabled'] = switch_to - break - - self.fuel_web.client.put_node_interfaces( - [{'id': nailgun_node['id'], 'interfaces': compute_net}]) - - return self.check_dpdk(nailgun_node, net=net)['enabled'] == switch_to - @test(groups=["support_dpdk"]) class SupportDPDK(TestDPDK): @@ -201,10 +146,11 @@ class SupportDPDK(TestDPDK): cluster_id, ['compute'], role_status='pending_roles')[0] self.show_step(4) - self.setup_hugepages(compute, hp_2mb=256, hp_dpdk_mb=128) + self.fuel_web.setup_hugepages( + compute['id'], hp_2mb=256, hp_dpdk_mb=128) self.show_step(5) - self.enable_dpdk(compute) + self.fuel_web.enable_dpdk(compute['id']) self.show_step(6) self.fuel_web.verify_network(cluster_id) @@ -276,12 +222,13 @@ class SupportDPDK(TestDPDK): cluster_id, ['compute'], role_status='pending_roles')[0] self.show_step(4) - self.setup_hugepages(compute, hp_2mb=256, hp_dpdk_mb=128) + self.fuel_web.setup_hugepages( + compute['id'], hp_2mb=256, hp_dpdk_mb=128) self.show_step(5) assert_raises( exceptions.BadRequest, - self.enable_dpdk, compute, + self.fuel_web.enable_dpdk, compute['id'], forceEnable=True) @test(depends_on=[SetupEnvironment.prepare_slaves_3], @@ -324,7 +271,8 @@ class SupportDPDK(TestDPDK): cluster_id, ['compute'], role_status='pending_roles')[0] self.show_step(4) - self.setup_hugepages(compute, hp_2mb=256, hp_dpdk_mb=128) + self.fuel_web.setup_hugepages( + compute['id'], hp_2mb=256, hp_dpdk_mb=128) self.show_step(5) assigned_networks = { @@ -338,7 +286,7 @@ class SupportDPDK(TestDPDK): interfaces_dict=assigned_networks) assert_raises( exceptions.BadRequest, - self.enable_dpdk, compute, + self.fuel_web.enable_dpdk, compute['id'], forceEnable=True) @@ -410,11 +358,12 @@ class SupportDPDKBond(BondingTestDPDK, TestDPDK): self.show_step(5) for node in computes: - self.setup_hugepages(node, hp_2mb=256, hp_dpdk_mb=128) + self.fuel_web.setup_hugepages( + node['id'], hp_2mb=256, hp_dpdk_mb=128) self.show_step(6) for node in computes: - self.enable_dpdk(node) + self.fuel_web.enable_dpdk(node['id']) self.show_step(7) self.fuel_web.verify_network(cluster_id) diff --git a/fuelweb_test/tests/test_sriov.py b/fuelweb_test/tests/test_sriov.py index dfb4d4b46..131a145b8 100644 --- a/fuelweb_test/tests/test_sriov.py +++ b/fuelweb_test/tests/test_sriov.py @@ -23,45 +23,6 @@ from fuelweb_test.tests.base_test_case import TestBasic @test(groups=['sriov']) class TestSRIOV(TestBasic): - def check_sriov(self, nailgun_node): - nailgun_node_ifaces = self.fuel_web.client.get_node_interfaces( - nailgun_node['id']) - devops_node = self.fuel_web.get_devops_node_by_nailgun_node( - nailgun_node) - devops_sriov_macs = [i.mac_address for i in devops_node.interfaces - if 'sriov' in i.features] - nailgun_sriov_nics = [] - devops_sriov_nics = [] - for interface in nailgun_node_ifaces: - if interface['mac'] in devops_sriov_macs: - devops_sriov_nics.append(interface['name']) - if interface['assigned_networks']: - continue - if 'sriov' not in interface['interface_properties']: - continue - sriov_available = interface['interface_properties']['sriov'][ - 'available'] - if sriov_available: - nailgun_sriov_nics.append(interface['name']) - return set(devops_sriov_nics).intersection(nailgun_sriov_nics) - - def enable_sriov(self, nailgun_node): - nics_to_enable_sriov = self.check_sriov(nailgun_node) - assert_true(nics_to_enable_sriov, - 'There are no NICs with SR-IOV support on ' - 'node with ID {0}!'.format(nailgun_node['id'])) - node_networks = self.fuel_web.client.get_node_interfaces( - nailgun_node['id']) - for interface in node_networks: - if interface['name'] not in nics_to_enable_sriov: - continue - interface['interface_properties']['sriov']['enabled'] = True - interface['interface_properties']['sriov']['sriov_numvfs'] = \ - interface['interface_properties']['sriov']['sriov_totalvfs'] - - self.fuel_web.client.put_node_interfaces( - [{'id': nailgun_node['id'], 'interfaces': node_networks}]) - @test(depends_on_groups=['prepare_slaves_all'], groups=['deploy_cluster_with_sriov']) @log_snapshot_after_test @@ -103,7 +64,8 @@ class TestSRIOV(TestBasic): ) self.show_step(2) nodes = self.fuel_web.client.list_nodes() - sriov_nailgun_nodes = [n for n in nodes if self.check_sriov(n)] + sriov_nailgun_nodes = [n for n in nodes + if self.fuel_web.check_sriov(n['id'])] assert_true(len(sriov_nailgun_nodes) >= 2, 'At least 2 nodes with SR-IOV support are required for ' 'this test! But, only {0} nodes are ' @@ -142,12 +104,12 @@ class TestSRIOV(TestBasic): cluster_id, ['compute'], role_status='pending_roles') computes_with_sriov_support = [n for n in computes - if self.check_sriov(n)] + if self.fuel_web.check_sriov(n['id'])] assert_true(computes_with_sriov_support, 'There is no compute with ' 'SR-IOV support available!') for compute in computes_with_sriov_support: - self.enable_sriov(compute) + self.fuel_web.enable_sriov(compute['id']) self.show_step(5) self.fuel_web.verify_network(cluster_id)