[virt-tools-list] Problems with virtinst NIC tests

Cole Robinson crobinso at redhat.com
Fri Feb 11 15:27:27 UTC 2011


On 02/11/2011 07:02 AM, Daniel P. Berrange wrote:
> On one of my machines I have bridging setup and this confuses the
> virtinst test suite:
> 
> ======================================================================
> FAIL: testAlterNics (tests.xmlparse.XMLParseTest)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/var/lib/builder/source-root/virtinst/tests/xmlparse.py", line 368, in testAlterNics
>     check("bridge", None, "newbr0")
>   File "/var/lib/builder/source-root/virtinst/tests/xmlparse.py", line 81, in check
>     return self._set_and_check(obj, name, initval, newval)
>   File "/var/lib/builder/source-root/virtinst/tests/xmlparse.py", line 71, in _set_and_check
>     self.assertEquals(initval, curval)
> AssertionError: None != ['bridge', 'br0']
> 
> 
> The root cause is VirtualNetworkInterface.py in
> 
>     def get_bridge(self):
>         if not self._bridge and self.type == self.TYPE_BRIDGE:
>             return self._generate_default_bridge()
>         return self._bridge
> 
> Because my machine has several bridges present, _generate_default_bridge()
> is filling one in, so instead of returning 'None', it returns '[bridge, br0]'
> 
> The hack solution is to change the order in the test suite, so we try
> to query the bridge name before setting the type
> 
> diff -r c71298ab7565 tests/xmlparse.py
> --- a/tests/xmlparse.py	Thu Feb 10 12:53:32 2011 -0500
> +++ b/tests/xmlparse.py	Fri Feb 11 11:59:10 2011 +0000
> @@ -363,9 +363,9 @@
>  
>          check = self._make_checker(dev2)
>          self.assertEquals(dev2.get_source(), "default")
> +        check("bridge", None, "newbr0")
>          check("type", "network", "bridge")
>          check("network", "default", None)
> -        check("bridge", None, "newbr0")
>          check("model", "e1000", "virtio")
>  
>          check = self._make_checker(dev3)
> 

Thanks, pushed a similar fix now:

http://hg.fedorahosted.org/hg/python-virtinst/rev/1f94ed6c4fc8

> 
> Once that's done I see another failure because change-nics-out.xml
> has XML elements in the wrong order:
> 
> 
> diff -r c71298ab7565 tests/xmlparse-xml/change-nics-out.xml
> --- a/tests/xmlparse-xml/change-nics-out.xml	Thu Feb 10 12:53:32 2011 -0500
> +++ b/tests/xmlparse-xml/change-nics-out.xml	Fri Feb 11 11:59:10 2011 +0000
> @@ -24,9 +24,9 @@
>        <source bridge="br0" network="route"/>
>      </interface>
>      <interface type="bridge">
> +      <source bridge="newbr0"/>
>        <mac address="11:22:33:44:55:66"/>
>        <model type="virtio"/>
> -      <source bridge="newbr0"/>
>      </interface>
>      <interface type="bridge">
>        <source bridge="newfoo0" network="default"/>
> 

The xmlparse test is using virtinst to alter an XML definition in place, which
can cause XML elements to come and go. New elements are always added at the
end of the block, so it won't always generate the same ordering as libvirt uses.

Thanks,
Cole




More information about the virt-tools-list mailing list