<p dir="ltr">For short lists using sorted output will make the code easier to debug and test.</p>
<div class="gmail_extra"><br><div class="gmail_quote">בתאריך 13 באוק׳ 2016 11:03 לפנה״צ,‏ &quot;Francesco Romani&quot; &lt;<a href="mailto:fromani@redhat.com">fromani@redhat.com</a>&gt; כתב:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">----- Original Message -----<br>
&gt; From: &quot;Nir Soffer&quot; &lt;<a href="mailto:nsoffer@redhat.com">nsoffer@redhat.com</a>&gt;<br>
&gt; To: &quot;devel&quot; &lt;<a href="mailto:devel@ovirt.org">devel@ovirt.org</a>&gt;, &quot;Adam Litke&quot; &lt;<a href="mailto:alitke@redhat.com">alitke@redhat.com</a>&gt;, &quot;Dan Kenigsberg&quot; &lt;<a href="mailto:danken@redhat.com">danken@redhat.com</a>&gt;, &quot;Francesco<br>
&gt; Romani&quot; &lt;<a href="mailto:fromani@redhat.com">fromani@redhat.com</a>&gt;, &quot;Piotr Kliczewski&quot; &lt;<a href="mailto:pkliczew@redhat.com">pkliczew@redhat.com</a>&gt;, &quot;Martin Sivak&quot; &lt;<a href="mailto:msivak@redhat.com">msivak@redhat.com</a>&gt;<br>
&gt; Sent: Wednesday, October 12, 2016 8:14:11 PM<br>
&gt; Subject: [VDSM] Tests failing because of ordering dependencies<br>
&gt;<br>
&gt; Hi all,<br>
&gt;<br>
&gt; Trying to run vdsm tests via tox (so correct nose is used automatically),<br>
&gt; some of the tests fail.<br>
&gt;<br>
&gt; The failure are all about ordering expectations, which look wrong.<br>
&gt;<br>
&gt; Please check and fix your tests.<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Nir<br>
<br>
&gt; 18:04:10 -------------------- &gt;&gt; begin captured logging &lt;&lt;<br>
&gt; --------------------<br>
&gt; 18:04:10 2016-10-12 18:01:56,902 INFO    (MainThread) [MOM] Preparing<br>
&gt; MOM interface (momIF:49)<br>
&gt; 18:04:10 2016-10-12 18:01:56,903 INFO    (MainThread) [MOM] Using<br>
&gt; named unix socket /tmp/tmpqOQZvm/test_mom_vdsm.<wbr>sock (momIF:58)<br>
&gt; 18:04:10 --------------------- &gt;&gt; end captured logging &lt;&lt;<br>
&gt; ---------------------<br>
&gt; 18:04:10<br>
&gt; 18:04:10<br>
&gt; ==============================<wbr>==============================<wbr>==========<br>
&gt; 18:04:10 FAIL: test_disk_virtio_cache (vmStorageTests.DriveXMLTests)<br>
&gt; 18:04:10<br>
&gt; ------------------------------<wbr>------------------------------<wbr>----------<br>
&gt; 18:04:10 Traceback (most recent call last):<br>
&gt; 18:04:10   File<br>
&gt; &quot;/home/jenkins/workspace/vdsm_<wbr>master_check-patch-el7-x86_64/<wbr>vdsm/tests/vmStorageTests.py&quot;,<br>
&gt; line 84, in test_disk_virtio_cache<br>
&gt; 18:04:10     self.check(vm_conf, conf, xml, is_block_device=False)<br>
&gt; 18:04:10   File<br>
&gt; &quot;/home/jenkins/workspace/vdsm_<wbr>master_check-patch-el7-x86_64/<wbr>vdsm/tests/vmStorageTests.py&quot;,<br>
&gt; line 222, in check<br>
&gt; 18:04:10     self.assertXMLEqual(drive.<wbr>getXML().toxml(), xml)<br>
&gt; 18:04:10   File<br>
&gt; &quot;/home/jenkins/workspace/vdsm_<wbr>master_check-patch-el7-x86_64/<wbr>vdsm/tests/testlib.py&quot;,<br>
&gt; line 253, in assertXMLEqual<br>
&gt; 18:04:10     (actualXML, expectedXML))<br>
&gt; 18:04:10 AssertionError: XMLs are different:<br>
&gt; 18:04:10 Actual:<br>
&gt; 18:04:10 &lt;disk device=&quot;disk&quot; snapshot=&quot;no&quot; type=&quot;file&quot;&gt;<br>
&gt; 18:04:10     &lt;source file=&quot;/path/to/volume&quot; /&gt;<br>
&gt; 18:04:10     &lt;target bus=&quot;virtio&quot; dev=&quot;vda&quot; /&gt;<br>
&gt; 18:04:10     &lt;shareable /&gt;<br>
&gt; 18:04:10     &lt;serial&gt;54-a672-23e5b495a9ea&lt;/<wbr>serial&gt;<br>
&gt; 18:04:10     &lt;driver cache=&quot;writethrough&quot; error_policy=&quot;enospace&quot;<br>
&gt; io=&quot;threads&quot; name=&quot;qemu&quot; type=&quot;qcow2&quot; /&gt;<br>
&gt; 18:04:10     &lt;iotune&gt;<br>
&gt; 18:04:10         &lt;total_iops_sec&gt;800&lt;/total_<wbr>iops_sec&gt;<br>
&gt; 18:04:10         &lt;read_bytes_sec&gt;6120000&lt;/read_<wbr>bytes_sec&gt;<br>
&gt; 18:04:10     &lt;/iotune&gt;<br>
&gt; 18:04:10 &lt;/disk&gt;<br>
&gt; 18:04:10<br>
&gt; 18:04:10 Expected:<br>
&gt; 18:04:10 &lt;disk device=&quot;disk&quot; snapshot=&quot;no&quot; type=&quot;file&quot;&gt;<br>
&gt; 18:04:10     &lt;source file=&quot;/path/to/volume&quot; /&gt;<br>
&gt; 18:04:10     &lt;target bus=&quot;virtio&quot; dev=&quot;vda&quot; /&gt;<br>
&gt; 18:04:10     &lt;shareable /&gt;<br>
&gt; 18:04:10     &lt;serial&gt;54-a672-23e5b495a9ea&lt;/<wbr>serial&gt;<br>
&gt; 18:04:10     &lt;driver cache=&quot;writethrough&quot; error_policy=&quot;enospace&quot;<br>
&gt; io=&quot;threads&quot; name=&quot;qemu&quot; type=&quot;qcow2&quot; /&gt;<br>
&gt; 18:04:10     &lt;iotune&gt;<br>
&gt; 18:04:10         &lt;read_bytes_sec&gt;6120000&lt;/read_<wbr>bytes_sec&gt;<br>
&gt; 18:04:10         &lt;total_iops_sec&gt;800&lt;/total_<wbr>iops_sec&gt;<br>
&gt;<br>
&gt; Order of these elements differ, need to check why.<br>
<br>
Most likely because we build the xml like<br>
<br>
(vdsm/virt/vmdevices/storage.<wbr>py)<br>
<br>
    def _getIotuneXML(self):<br>
        iotune = vmxml.Element(&#39;iotune&#39;)<br>
        for key, value in self.specParams[&#39;ioTune&#39;].<wbr>iteritems():<br>
            iotune.appendChildWithArgs(<wbr>key, text=str(value))<br>
        return iotune<br>
<br>
and iteritems() ordering is not defined<br>
&gt; ------------------------------<wbr>------------------------------<wbr>----------<br>
&gt; 18:04:10 Traceback (most recent call last):<br>
&gt; 18:04:10   File<br>
&gt; &quot;/home/jenkins/workspace/vdsm_<wbr>master_check-patch-el7-x86_64/<wbr>vdsm/tests/vmTests.py&quot;,<br>
&gt; line 434, in testCpuXML<br>
&gt; 18:04:10     self.assertXMLEqual(find_xml_<wbr>element(xml, &quot;./cputune&quot;),<br>
&gt; cputuneXML)<br>
&gt; 18:04:10   File<br>
&gt; &quot;/home/jenkins/workspace/vdsm_<wbr>master_check-patch-el7-x86_64/<wbr>vdsm/tests/testlib.py&quot;,<br>
&gt; line 253, in assertXMLEqual<br>
&gt; 18:04:10     (actualXML, expectedXML))<br>
&gt; 18:04:10 AssertionError: XMLs are different:<br>
&gt; 18:04:10 Actual:<br>
&gt; 18:04:10 &lt;cputune&gt;<br>
&gt; 18:04:10     &lt;vcpupin cpuset=&quot;0-1&quot; vcpu=&quot;0&quot; /&gt;<br>
&gt; 18:04:10     &lt;vcpupin cpuset=&quot;2-3&quot; vcpu=&quot;1&quot; /&gt;<br>
&gt; 18:04:10 &lt;/cputune&gt;<br>
&gt; 18:04:10<br>
&gt; 18:04:10 Expected:<br>
&gt; 18:04:10 &lt;cputune&gt;<br>
&gt; 18:04:10     &lt;vcpupin cpuset=&quot;2-3&quot; vcpu=&quot;1&quot; /&gt;<br>
&gt; 18:04:10     &lt;vcpupin cpuset=&quot;0-1&quot; vcpu=&quot;0&quot; /&gt;<br>
&gt;<br>
&gt; Same<br>
<br>
(vdsm/virt/vmxml.py)<br>
<br>
    def appendCpus(self):<br>
        # lot of code<br>
<br>
        # CPU-pinning support<br>
        # see <a href="http://www.ovirt.org/wiki/Features/Design/cpu-pinning" rel="noreferrer" target="_blank">http://www.ovirt.org/wiki/<wbr>Features/Design/cpu-pinning</a><br>
        if &#39;cpuPinning&#39; in self.conf:<br>
            cputune = Element(&#39;cputune&#39;)<br>
            cpuPinning = self.conf.get(&#39;cpuPinning&#39;)<br>
            for cpuPin in cpuPinning.keys():<br>
                cputune.appendChildWithArgs(&#39;<wbr>vcpupin&#39;, vcpu=cpuPin,<br>
                                            cpuset=cpuPinning[cpuPin])<br>
            self.dom.appendChild(cputune)<br>
<br>
<br>
<br>
&gt; 18:04:10 &lt;/cputune&gt;<br>
&gt; 18:04:10<br>
&gt; 18:04:10<br>
&gt; 18:04:10<br>
&gt; 18:04:10<br>
&gt; ==============================<wbr>==============================<wbr>==========<br>
&gt; 18:04:10 FAIL: testSetIoTune (vmTests.TestVm)<br>
&gt; 18:04:10<br>
&gt; ------------------------------<wbr>------------------------------<wbr>----------<br>
&gt; 18:04:10 Traceback (most recent call last):<br>
&gt; 18:04:10   File<br>
&gt; &quot;/home/jenkins/workspace/vdsm_<wbr>master_check-patch-el7-x86_64/<wbr>vdsm/tests/vmTests.py&quot;,<br>
&gt; line 936, in testSetIoTune<br>
&gt; 18:04:10     self._xml_sanitizer(expected_<wbr>xml))<br>
&gt; 18:04:10 AssertionError: &#39;&lt;disk device=&quot;hdd&quot; snapshot=&quot;no&quot;<br>
&gt; type=&quot;block&quot;&gt;&lt;source dev=&quot;/dev/dummy&quot;/&gt;&lt;target bus=&quot;ide&quot;<br>
&gt; dev=&quot;hda&quot;/&gt;&lt;iotune&gt;&lt;write_<wbr>bytes_sec&gt;1&lt;/write_bytes_sec&gt;&lt;<wbr>total_bytes_sec&gt;0&lt;/total_<wbr>bytes_sec&gt;&lt;read_bytes_sec&gt;2&lt;/<wbr>read_bytes_sec&gt;&lt;/iotune&gt;&lt;/<wbr>disk&gt;&#39;<br>
&gt; != &#39;&lt;disk device=&quot;hdd&quot; snapshot=&quot;no&quot; type=&quot;block&quot;&gt;&lt;source<br>
&gt; dev=&quot;/dev/dummy&quot;/&gt;&lt;target bus=&quot;ide&quot;<br>
&gt; dev=&quot;hda&quot;/&gt;&lt;iotune&gt;&lt;read_<wbr>bytes_sec&gt;2&lt;/read_bytes_sec&gt;&lt;<wbr>write_bytes_sec&gt;1&lt;/write_<wbr>bytes_sec&gt;&lt;total_bytes_sec&gt;0&lt;/<wbr>total_bytes_sec&gt;&lt;/iotune&gt;&lt;/<wbr>disk&gt;&#39;<br>
&gt; 18:04:10 -------------------- &gt;&gt; begin captured logging &lt;&lt;<br>
&gt; --------------------<br>
&gt; 18:04:10 2016-10-12 18:03:34,110 INFO    (MainThread) [virt.vm]<br>
&gt; vmId=`TESTING`::New device XML for hda: &lt;disk device=&quot;hdd&quot;<br>
&gt; snapshot=&quot;no&quot; type=&quot;block&quot;&gt;<br>
&gt; 18:04:10 &lt;source dev=&quot;/dev/dummy&quot;/&gt;<br>
&gt; 18:04:10 &lt;target bus=&quot;ide&quot; dev=&quot;hda&quot;/&gt;<br>
&gt; 18:04:10 &lt;iotune&gt;<br>
&gt; 18:04:10 &lt;write_bytes_sec&gt;1&lt;/write_<wbr>bytes_sec&gt;<br>
&gt; 18:04:10 &lt;total_bytes_sec&gt;0&lt;/total_<wbr>bytes_sec&gt;<br>
&gt; 18:04:10 &lt;read_bytes_sec&gt;2&lt;/read_bytes_<wbr>sec&gt;<br>
&gt; 18:04:10 &lt;/iotune&gt;<br>
&gt; 18:04:10 &lt;/disk&gt;<br>
&gt;<br>
&gt; Seems that this test is not using assertXMLEqual so we don&#39;t get meaningful<br>
&gt; error like the tests above.<br>
<br>
Fixed the reporting: <a href="https://gerrit.ovirt.org/65417" rel="noreferrer" target="_blank">https://gerrit.ovirt.org/65417</a><br>
<br>
For the sloppy virt tests, I think the right call is to fix the tests rather than the code. The code is not wrong, because the ordering<br>
of the attributes is not relevant. We &quot;just&quot; need tests which can interpret XML on a deeper level.<br>
<br>
--<br>
Francesco Romani<br>
Red Hat Engineering Virtualization R &amp; D<br>
Phone: 8261328<br>
IRC: fromani<br>
</blockquote></div></div>