failing libvirt tests: need ordering

Bug #1841667 reported by Thomas Goirand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
New
Undecided
Unassigned
Stein
New
Undecided
Unassigned

Bug Description

When rebuilding Nova from Stein in Debian Sid, I get 3 unit test errors, probably due to a more recent libvirt (ie: 5.6.0). See for example, on this first one:

<target bus="virtio" dev="vda"/>

we get bus= and dev= inverted.

======================================================================
FAIL: nova.tests.unit.virt.libvirt.test_driver.LibvirtDriverTestCase.test_get_disk_xml
nova.tests.unit.virt.libvirt.test_driver.LibvirtDriverTestCase.test_get_disk_xml
----------------------------------------------------------------------
_StringException: pythonlogging:'': {{{2019-08-27 20:26:05,026 WARNING [os_brick.initiator.connectors.remotefs] Connection details not present. RemoteFsClient may not initialize properly.}}}

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/nova/tests/unit/virt/libvirt/test_driver.py", line 20926, in test_get_disk_xml
    self.assertEqual(diska_xml.strip(), actual_diska_xml.strip())
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 411, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 498, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: !=:
reference = '''\
<disk type="file" device="disk">
  <source file="disk1_file"/>
  <target bus="virtio" dev="vda"/>
  <serial>0e38683e-f0af-418f-a3f1-6b67ea0f919d</serial>
</disk>'''
actual = '''\
<disk type="file" device="disk">
  <source file="disk1_file"/>
  <target dev="vda" bus="virtio"/>
  <serial>0e38683e-f0af-418f-a3f1-6b67ea0f919d</serial>
</disk>'''

======================================================================
FAIL: nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_detach_volume_with_vir_domain_affect_live_flag
nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_detach_volume_with_vir_domain_affect_live_flag
----------------------------------------------------------------------
_StringException: pythonlogging:'': {{{2019-08-27 20:26:31,189 WARNING [os_brick.initiator.connectors.remotefs] Connection details not present. RemoteFsClient may not initialize properly.}}}

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mock/mock.py", line 1330, in patched
    return func(*args, **keywargs)
  File "/<<PKGBUILDDIR>>/nova/tests/unit/virt/libvirt/test_driver.py", line 7955, in test_detach_volume_with_vir_domain_affect_live_flag
    """, flags=flags)
  File "/usr/lib/python3/dist-packages/mock/mock.py", line 944, in assert_called_with
    six.raise_from(AssertionError(_error_message(cause)), cause)
  File "<string>", line 3, in raise_from
AssertionError: expected call not found.
Expected: detachDeviceFlags('<disk type="file" device="disk">\n <source file="/path/to/fake-volume"/>\n <target bus="virtio" dev="vdc"/>\n</disk>\n', flags=3)
Actual: detachDeviceFlags('<disk type="file" device="disk">\n <source file="/path/to/fake-volume"/>\n <target dev="vdc" bus="virtio"/>\n</disk>\n', flags=3)

======================================================================
FAIL: nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_update_volume_xml
nova.tests.unit.virt.libvirt.test_driver.LibvirtConnTestCase.test_update_volume_xml
----------------------------------------------------------------------
_StringException: pythonlogging:'': {{{2019-08-27 20:26:37,451 WARNING [os_brick.initiator.connectors.remotefs] Connection details not present. RemoteFsClient may not initialize properly.}}}

Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/nova/tests/unit/virt/libvirt/test_driver.py", line 10157, in test_update_volume_xml
    etree.tostring(config, encoding='unicode'))
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 411, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 498, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: !=:
reference = '<domain type="kvm"><devices><disk type="block" device="disk"><driver name="qemu" type="raw" cache="none"/><source dev="/dev/disk/by-path/ip-1.2.3.4:3260-iqn.cde.67890.opst-lun-Z"/><target bus="virtio" dev="vdb"/><serial>58a84f6d-3f0c-4e19-a0af-eb657b790657</serial><address type="pci" domain="0x0" bus="0x0" slot="0x04" function="0x0"/></disk></devices></domain>'
actual = '<domain type="kvm"><devices><disk type="block" device="disk"><driver name="qemu" type="raw" cache="none"/><source dev="/dev/disk/by-path/ip-1.2.3.4:3260-iqn.cde.67890.opst-lun-Z"/><target dev="vdb" bus="virtio"/><serial>58a84f6d-3f0c-4e19-a0af-eb657b790657</serial><address type="pci" domain="0x0" bus="0x0" slot="0x04" function="0x0"/></disk></devices></domain>'

Revision history for this message
Matt Riedemann (mriedem) wrote :

The actual version of libvirt on the system shouldn't matter, these tests should not be running against a real libvirt, everything should be faked out. My guess is the tests are using unordered dicts and that's why the keys are in a different order, or something with the way the xml comparison code is asserting the attributes.

tags: added: libvirt testing
Revision history for this message
Matt Riedemann (mriedem) wrote :

Actually it might be a difference in lxml on Debian Sid.

Revision history for this message
Matt Riedemann (mriedem) wrote :

(3:46:54 PM) mriedem: zigo: what version of lxml is being used?
(3:47:20 PM) mriedem: prometheanfire: efried: wasn't there a recent issue with newer lxml and nova unit tests?
(3:47:23 PM) sean-k-mooney: ya i delete that after the hard reboot it was running on cloud-3 with the device claimed on cloud-4 so that is not good.
(3:47:39 PM) sean-k-mooney: im going to unstack and call it a night.
(3:47:40 PM) efried: mriedem: yes, sean-k-mooney was looking into it.
(3:47:49 PM) sean-k-mooney: mriedem: ya im ment to be looking into that
(3:47:52 PM) efried: had to do with attribute ordering.
(3:47:59 PM) mriedem: yup https://bugs.launchpad.net/nova/+bug/1841667
(3:47:59 PM) sean-k-mooney: it was what i had planned to do today...
(3:48:02 PM) openstack: Launchpad bug 1841667 in OpenStack Compute (nova) stein "failing libvirt tests: need ordering" [Undecided,New]
(3:48:05 PM) zigo: mriedem: 4.4.1.
(3:48:21 PM) mriedem: efried: sean-k-mooney: did we have a bug for it?
(3:48:22 PM) zigo: That's kind of new in Sid...

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to nova (master)

Related fix proposed to branch: master
Review: https://review.opendev.org/678964

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to nova (master)

Reviewed: https://review.opendev.org/678964
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=58ffff49ac716772b8d67ab487938215f5a0a658
Submitter: Zuul
Branch: master

commit 58ffff49ac716772b8d67ab487938215f5a0a658
Author: Sean Mooney <email address hidden>
Date: Tue Aug 27 23:16:38 2019 +0100

    fix lxml compatibility issues

    Some unit tests were performing string matches on xml data
    with inputs that were generated using lxml. This is problematic
    as while white space between element tags is important in xml
    ordering of attributes within a tag is not. In the latest version
    of lxml the ordering asserted in the test no longer matches the
    order returned by lxml on python 3.6+.

    This change updates the failing test to use the XMLMatcher
    class to compare xml strings instead.

    Closes-Bug: #1838666
    Related-Bug: #1841667
    Change-Id: I1649a850ccb9ac85d7a962936ffef51d573b6f78

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.