commit 6e6b10482bb5d469266a67510613e8d6acd45894 Author: James Parker Date: Thu Aug 6 14:49:17 2020 -0400 Assert hugepages exist in domain XML Add new checks to NUMALiveMigrationTest.test_hugepages to confirm hugepages are present in the server XML and the page size is correct and does not change after live migration. Added two new helper methods to NUMALiveMigrationTest, _get_hugepage_xml_element and _validate_hugepage_elements. The first method gets all hugepage XML elements in the domain of a provided instance id. The second method confirms there is only one hugepage xml element found on the instance domain and that it is the correct page size. The testcase method test_hugepages validates the hugepages element is present on both instances and the configured pagesize matches the pagesize found on the host. The test also rechecks server_b after it is live migrated to confirm the element is still present and pagesize is accurate. Fixed a problem in baremetal scenarios were determined ram value was a float rather than an int. Explicitly setting it to int when providing it to flavor creation. Change-Id: I8fd32a68f2aea91145c0b444d1161f13ba1ae300 diff --git a/whitebox_tempest_plugin/api/compute/test_cpu_pinning.py b/whitebox_tempest_plugin/api/compute/test_cpu_pinning.py index adc57e6..6cd472c 100644 --- a/whitebox_tempest_plugin/api/compute/test_cpu_pinning.py +++ b/whitebox_tempest_plugin/api/compute/test_cpu_pinning.py @@ -415,6 +415,26 @@ class NUMALiveMigrationBase(BasePinningTest): cpuset = root.find('./vcpu').attrib.get('cpuset', None) return whitebox_utils.parse_cpu_spec(cpuset) + def _get_hugepage_xml_element(self, server_id): + """Gather and return all instances of the page element from XML element + 'memoryBacking/hugepages' in a given server's domain. + """ + root = self.get_server_xml(server_id) + huge_pages = root.findall('.memoryBacking/hugepages/page') + return huge_pages + + def _validate_hugepage_elements(self, server_id, pagesize): + """Analyze the hugepage xml element(s) from a provided instance. Expect + to find only one hugepage element in the domain. Return boolean result + comparing if the found page size is equal to the expected page size. + """ + huge_pages_list = self._get_hugepage_xml_element(server_id) + self.assertEqual(len(huge_pages_list), 1, "Expected to find 1 " + "hugepage XML element on server %s but found %s" + % (server_id, len(huge_pages_list))) + huge_page_xml = huge_pages_list[0] + return int(huge_page_xml.attrib['size']) == pagesize + class NUMALiveMigrationTest(NUMALiveMigrationBase): @@ -668,7 +688,7 @@ class NUMALiveMigrationTest(NUMALiveMigrationBase): ram = pagesize_a / 1024 * min_free specs = {'hw:numa_nodes': '1', 'hw:mem_page_size': 'large'} - flavor = self.create_flavor(vcpus=len(topo_a[0]), ram=ram, + flavor = self.create_flavor(vcpus=len(topo_a[0]), ram=int(ram), extra_specs=specs) # Boot two servers @@ -677,6 +697,15 @@ class NUMALiveMigrationTest(NUMALiveMigrationBase): flavor=flavor['id'], scheduler_hints={'different_host': server_a['id']}) + # Assert hugepage XML element is present on both servers and the + # pagesize is correct + for server_id in [server_a['id'], server_b['id']]: + self.assertTrue( + self._validate_hugepage_elements(server_id, pagesize_a), + "Expected pagesize of %s not found on server %s before " + "live-migration" % (pagesize_a, server_id) + ) + # We expect them to end up with the same cell pin - specifically, guest # cell 0 to host cell 0. pin_a = self.get_server_cell_pinning(server_a['id']) @@ -692,6 +721,14 @@ class NUMALiveMigrationTest(NUMALiveMigrationBase): compute_a = self.get_host_other_than(server_b['id']) self.live_migrate(server_b['id'], compute_a, 'ACTIVE') + # Assert hugepage XML element is still present and correct size for + # server_b after live migration + self.assertTrue( + self._validate_hugepage_elements(server_b['id'], pagesize_a), + "Expected pagesize of %s not found on %s after live-migration" % + (pagesize_a, server_b['id']) + ) + # Their guest NUMA node 0 should be on different host nodes pin_a = self.get_server_cell_pinning(server_a['id']) pin_b = self.get_server_cell_pinning(server_b['id'])