Allow for ethernet type in rx queue test

Update [1] and subsequent patches [2,3] changed the interface type of
instances from bridge to ethernet, e.g.

    <interface type='ethernet'>
      <mac address='fa:16:3e:3d:50:96'/>
      <target dev='tapa832f5ec-36'/>
      <model type='virtio'/>
      <driver name='vhost' rx_queue_size='1024'/>
      <mtu size='1372'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

This commit changes the test_rx_queue_size logic when searching a guest
for its interface type to check for 'ethernet' first and then fall back
to 'bridge' if it is not found. Also should be noted a conditional set
of the driver was attempted but due how ElementTree evaluates its
boolean [4], opted to check ethernet type first and then fall back to
bridge.

[1] https://review.opendev.org/c/openstack/nova/+/602432
[2] https://review.opendev.org/c/openstack/nova/+/797142
[3] https://review.opendev.org/c/openstack/nova/+/797428
[4] https://github.com/python/cpython/blob/3.9/Lib/xml/etree/ElementTree.py#L214

Change-Id: I29adec51ed510c32b0d00b4f0353f0a9527482b7
This commit is contained in:
James Parker 2021-08-04 15:41:28 -04:00
parent e5a9dc09be
commit a3ff33907a

View File

@ -71,8 +71,11 @@ class RxTxQueueSizeTest(base.BaseWhiteboxComputeTest):
'`rx_queue_size` must be set')
def test_rx_queue_size(self):
domain = self.get_server_xml(self.server_id)
driver = domain.find(
"devices/interface[@type='bridge']/driver[@name='vhost']")
interface_criteria = \
"devices/interface[@type='%s']/driver[@name='vhost']"
driver = domain.find(interface_criteria % 'ethernet')
driver = (driver if driver is not None else domain.find(
interface_criteria % 'bridge'))
self.assertEqual(
driver.attrib['rx_queue_size'], str(CONF.whitebox.rx_queue_size),
"Can't find interface with the proper rx_queue_size")