James Parker 7385e1bc55 Remove NSM from emul thread tests
A continuation of [1] in which we are trying to reduce the dependency on
NovaServiceManager when interacting with cpu_dedicated_set and
cpu_shared_set.

This commit introduces two new configuration options:
 * whitebox_hardware.dedicated_cpus_per_numa
 * whitebox_hardware.shared_cpus_per_numa

These options describe the number of pCPUs alloacted to either shared or
dedicated sets for a given compute host. We are making the assumption
that although the pCPUs allocated to their respective sets may be
different on each compute host, the number of pCPUs allocated are the
same.

Commit also removes NSM from three of the four base emulator thread
testcases and reduces some of the complexity originally present in the
tests. Since vcpu_pin_set and cpu_dedicated_set are no longer
directly modified in the test, their respective child tests have been
removed leaving just the parent to covering scenarios based on the
deployment.

[1] cca33388c2

Change-Id: I57243d49de0d1715fecaa6496a92fc2c576c448a
2021-11-01 22:51:32 -04:00

59 lines
2.1 KiB
Python

# Copyright 2021 Red Hat
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from whitebox_tempest_plugin import hardware
class NUMAHelperMixin(object):
"""Mixin class containing helpers to obtain NUMA-related information about
a server from its XML.
"""
def get_pinning_as_set(self, server_id):
pinset = set()
root = self.get_server_xml(server_id)
vcpupins = root.findall('./cputune/vcpupin')
for pin in vcpupins:
pinset |= hardware.parse_cpu_spec(pin.get('cpuset'))
return pinset
def get_server_emulator_threads(self, server_id):
"""Get the host CPU numbers to which the server's emulator threads are
pinned.
:param server_id: The instance UUID to look up.
:return emulator_threads: A set of host CPU numbers.
"""
root = self.get_server_xml(server_id)
emulatorpins = root.findall('./cputune/emulatorpin')
emulator_threads = set()
for pin in emulatorpins:
emulator_threads |= hardware.parse_cpu_spec(
pin.get('cpuset'))
return emulator_threads
def get_host_pcpus_for_guest_vcpu(self, server_id, instance_cpu_id):
"""Search the xml vcpu element of the provided instance for its cpuset.
Convert cpuset found into a set of integers.
"""
xml_cpu_search = "./cputune/vcpupin[@vcpu='%s']" % instance_cpu_id
root = self.get_server_xml(server_id)
cpus = root.find(xml_cpu_search)
cpuset = cpus.attrib.get('cpuset')
return hardware.parse_cpu_spec(cpuset)