Martin Polednik has uploaded a new change for review.
Change subject: virt: use new mocking in hostdevTests ......................................................................
virt: use new mocking in hostdevTests
With unified mocking mechanism for host devices, hostdevTests can now be converted to use the mechanism. This does not really change any functionality, but creates a pool of device XMLs that can be used in future tests.
Change-Id: I2e21dcaf6f645acb8229c01f40569785e1416cc2 Signed-off-by: Martin Polednik mpolednik@redhat.com --- M tests/devices/data/Makefile.am A tests/devices/data/net_em1_28_d2_44_55_66_88.xml A tests/devices/data/pci_0000_00_02_0.xml A tests/devices/data/pci_0000_00_09_0.xml A tests/devices/data/pci_0000_00_19_0.xml A tests/devices/data/pci_0000_00_1a_0.xml A tests/devices/data/pci_0000_00_1b_0.xml A tests/devices/data/pci_0000_00_1f_2.xml A tests/devices/data/pci_0000_05_00_1.xml A tests/devices/data/pci_0000_05_10_7.xml A tests/devices/data/scsi_0_0_0_0.xml A tests/devices/data/scsi_host0.xml A tests/devices/data/scsi_target0_0_0.xml A tests/devices/data/usb_1_1.xml A tests/devices/data/usb_1_1_4.xml A tests/devices/data/usb_usb1.xml M tests/hostdevTests.py 17 files changed, 282 insertions(+), 293 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/40905/1
diff --git a/tests/devices/data/Makefile.am b/tests/devices/data/Makefile.am index 0ead0e2..179a5de 100644 --- a/tests/devices/data/Makefile.am +++ b/tests/devices/data/Makefile.am @@ -21,5 +21,20 @@ vdsmdevdatatestsdir = ${vdsmtestsdir}/devices/data
dist_vdsmdevdatatests_DATA = \ + net_em1_28_d2_44_55_66_88.xml \ + pci_0000_00_02_0.xml \ + pci_0000_00_09_0.xml \ + pci_0000_00_19_0.xml \ + pci_0000_00_1a_0.xml \ + pci_0000_00_1b_0.xml \ + pci_0000_00_1f_2.xml \ + pci_0000_05_00_1.xml \ + pci_0000_05_10_7.xml \ + scsi_0_0_0_0.xml \ + scsi_host0.xml \ + scsi_target0_0_0.xml \ testComplexVm.xml \ + usb_1_1.xml \ + usb_1_1_4.xml \ + usb_usb1.xml \ $(NULL) diff --git a/tests/devices/data/net_em1_28_d2_44_55_66_88.xml b/tests/devices/data/net_em1_28_d2_44_55_66_88.xml new file mode 100644 index 0000000..15c6d2a --- /dev/null +++ b/tests/devices/data/net_em1_28_d2_44_55_66_88.xml @@ -0,0 +1,11 @@ +<device> + <name>net_em1_28_d2_44_55_66_88</name> + <path>/sys/devices/pci0000:00/0000:00:19.0/net/em1</path> + <parent>pci_0000_00_19_0</parent> + <capability type='net'> + <interface>em1</interface> + <address>28:d2:44:55:66:88</address> + <link state='down'/> + <capability type='80203'/> + </capability> +</device> diff --git a/tests/devices/data/pci_0000_00_02_0.xml b/tests/devices/data/pci_0000_00_02_0.xml new file mode 100644 index 0000000..909b37e --- /dev/null +++ b/tests/devices/data/pci_0000_00_02_0.xml @@ -0,0 +1,16 @@ +<device> + <name>pci_0000_00_02_0</name> + <path>/sys/devices/pci0000:00/0000:00:02.0</path> + <parent>computer</parent> + <driver> + <name>i915</name> + </driver> + <capability type='pci'> + <domain>0</domain> + <bus>0</bus> + <slot>2</slot> + <function>0</function> + <product id='0x0126'>2nd Generation Core Processor Family Integrated Graphics Controller</product> + <vendor id='0x8086'>Intel Corporation</vendor> + </capability> +</device> diff --git a/tests/devices/data/pci_0000_00_09_0.xml b/tests/devices/data/pci_0000_00_09_0.xml new file mode 100644 index 0000000..eba2426 --- /dev/null +++ b/tests/devices/data/pci_0000_00_09_0.xml @@ -0,0 +1,19 @@ +<device> + <name>pci_0000_00_09_0</name> + <path>/sys/devices/pci0000:00/0000:00:09.0</path> + <parent>computer</parent> + <driver> + <name>pcieport</name> + </driver> + <capability type='pci'> + <domain>0</domain> + <bus>0</bus> + <slot>9</slot> + <function>0</function> + <product id='0x3410'>7500/5520/5500/X58 I/O Hub PCI Express Root Port 9</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <iommuGroup number='4'> + <address domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> + </iommuGroup> + </capability> +</device> diff --git a/tests/devices/data/pci_0000_00_19_0.xml b/tests/devices/data/pci_0000_00_19_0.xml new file mode 100644 index 0000000..b98c145 --- /dev/null +++ b/tests/devices/data/pci_0000_00_19_0.xml @@ -0,0 +1,16 @@ +<device> + <name>pci_0000_00_19_0</name> + <path>/sys/devices/pci0000:00/0000:00:19.0</path> + <parent>computer</parent> + <driver> + <name>e1000e</name> + </driver> + <capability type='pci'> + <domain>0</domain> + <bus>0</bus> + <slot>25</slot> + <function>0</function> + <product id='0x1502'>82579LM Gigabit Network Connection</product> + <vendor id='0x8086'>Intel Corporation</vendor> + </capability> +</device> diff --git a/tests/devices/data/pci_0000_00_1a_0.xml b/tests/devices/data/pci_0000_00_1a_0.xml new file mode 100644 index 0000000..bf068a8 --- /dev/null +++ b/tests/devices/data/pci_0000_00_1a_0.xml @@ -0,0 +1,16 @@ +<device> + <name>pci_0000_00_1a_0</name> + <path>/sys/devices/pci0000:00/0000:00:1a.0</path> + <parent>computer</parent> + <driver> + <name>ehci-pci</name> + </driver> + <capability type='pci'> + <domain>0</domain> + <bus>0</bus> + <slot>26</slot> + <function>0</function> + <product id='0x1c2d'>6 Series/C200 Series Chipset Family USB Enhanced Host Controller #2</product> + <vendor id='0x8086'>Intel Corporation</vendor> + </capability> +</device> diff --git a/tests/devices/data/pci_0000_00_1b_0.xml b/tests/devices/data/pci_0000_00_1b_0.xml new file mode 100644 index 0000000..d7614f3 --- /dev/null +++ b/tests/devices/data/pci_0000_00_1b_0.xml @@ -0,0 +1,16 @@ +<device> + <name>pci_0000_00_1b_0</name> + <path>/sys/devices/pci0000:00/0000:00:1b.0</path> + <parent>computer</parent> + <driver> + <name>snd_hda_intel</name> + </driver> + <capability type='pci'> + <domain>0</domain> + <bus>0</bus> + <slot>27</slot> + <function>0</function> + <product id='0x1c20'>6 Series/C200 Series Chipset Family High Definition Audio Controller</product> + <vendor id='0x8086'>Intel Corporation</vendor> + </capability> +</device> diff --git a/tests/devices/data/pci_0000_00_1f_2.xml b/tests/devices/data/pci_0000_00_1f_2.xml new file mode 100644 index 0000000..ba25dd8 --- /dev/null +++ b/tests/devices/data/pci_0000_00_1f_2.xml @@ -0,0 +1,16 @@ +<device> + <name>pci_0000_00_1f_2</name> + <path>/sys/devices/pci0000:00/0000:00:1f.2</path> + <parent>computer</parent> + <driver> + <name>ahci</name> + </driver> + <capability type='pci'> + <domain>0</domain> + <bus>0</bus> + <slot>31</slot> + <function>2</function> + <product id='0x1c03'>6 Series/C200 Series Chipset Family 6 port SATA AHCI Controller</product> + <vendor id='0x8086'>Intel Corporation</vendor> + </capability> +</device> diff --git a/tests/devices/data/pci_0000_05_00_1.xml b/tests/devices/data/pci_0000_05_00_1.xml new file mode 100644 index 0000000..2f75019 --- /dev/null +++ b/tests/devices/data/pci_0000_05_00_1.xml @@ -0,0 +1,29 @@ +<device> + <name>pci_0000_05_00_1</name> + <path>/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.1</path> + <parent>pci_0000_00_09_0</parent> + <driver> + <name>igb</name> + </driver> + <capability type='pci'> + <domain>0</domain> + <bus>5</bus> + <slot>0</slot> + <function>1</function> + <product id='0x10c9'>82576 Gigabit Network Connection</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='virt_functions'> + <address domain='0x0000' bus='0x05' slot='0x10' function='0x1'/> + <address domain='0x0000' bus='0x05' slot='0x10' function='0x3'/> + <address domain='0x0000' bus='0x05' slot='0x10' function='0x5'/> + <address domain='0x0000' bus='0x05' slot='0x10' function='0x7'/> + <address domain='0x0000' bus='0x05' slot='0x11' function='0x1'/> + <address domain='0x0000' bus='0x05' slot='0x11' function='0x3'/> + <address domain='0x0000' bus='0x05' slot='0x11' function='0x5'/> + </capability> + <iommuGroup number='15'> + <address domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> + <address domain='0x0000' bus='0x05' slot='0x00' function='0x1'/> + </iommuGroup> + </capability> +</device> diff --git a/tests/devices/data/pci_0000_05_10_7.xml b/tests/devices/data/pci_0000_05_10_7.xml new file mode 100644 index 0000000..297528e --- /dev/null +++ b/tests/devices/data/pci_0000_05_10_7.xml @@ -0,0 +1,22 @@ +<device> + <name>pci_0000_05_10_7</name> + <path>/sys/devices/pci0000:00/0000:00:09.0/0000:05:10.7</path> + <parent>pci_0000_00_09_0</parent> + <driver> + <name>igbvf</name> + </driver> + <capability type='pci'> + <domain>0</domain> + <bus>5</bus> + <slot>16</slot> + <function>7</function> + <product id='0x10ca'>82576 Virtual Function</product> + <vendor id='0x8086'>Intel Corporation</vendor> + <capability type='phys_function'> + <address domain='0x0000' bus='0x05' slot='0x00' function='0x1'/> + </capability> + <iommuGroup number='25'> + <address domain='0x0000' bus='0x05' slot='0x10' function='0x7'/> + </iommuGroup> + </capability> +</device> diff --git a/tests/devices/data/scsi_0_0_0_0.xml b/tests/devices/data/scsi_0_0_0_0.xml new file mode 100644 index 0000000..3d3b4f6 --- /dev/null +++ b/tests/devices/data/scsi_0_0_0_0.xml @@ -0,0 +1,15 @@ +<device> + <name>scsi_0_0_0_0</name> + <path>/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0</path> + <parent>scsi_target0_0_0</parent> + <driver> + <name>sd</name> + </driver> + <capability type='scsi'> + <host>0</host> + <bus>0</bus> + <target>0</target> + <lun>0</lun> + <type>disk</type> + </capability> +</device> diff --git a/tests/devices/data/scsi_host0.xml b/tests/devices/data/scsi_host0.xml new file mode 100644 index 0000000..f20c3a1 --- /dev/null +++ b/tests/devices/data/scsi_host0.xml @@ -0,0 +1,8 @@ +<device> + <name>scsi_host0</name> + <path>/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0</path> + <parent>pci_0000_00_1f_2</parent> + <capability type='scsi_host'> + <host>0</host> + </capability> +</device> diff --git a/tests/devices/data/scsi_target0_0_0.xml b/tests/devices/data/scsi_target0_0_0.xml new file mode 100644 index 0000000..399374c --- /dev/null +++ b/tests/devices/data/scsi_target0_0_0.xml @@ -0,0 +1,8 @@ +<device> + <name>scsi_target0_0_0</name> + <path>/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0</path> + <parent>scsi_host0</parent> + <capability type='scsi_target'> + <target>target0:0:0</target> + </capability> +</device> diff --git a/tests/devices/data/usb_1_1.xml b/tests/devices/data/usb_1_1.xml new file mode 100644 index 0000000..7c0dacd --- /dev/null +++ b/tests/devices/data/usb_1_1.xml @@ -0,0 +1,14 @@ +<device> + <name>usb_1_1</name> + <path>/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1</path> + <parent>usb_usb1</parent> + <driver> + <name>usb</name> + </driver> + <capability type='usb_device'> + <bus>1</bus> + <device>2</device> + <product id='0x0024' /> + <vendor id='0x8087' /> + </capability> +</device> diff --git a/tests/devices/data/usb_1_1_4.xml b/tests/devices/data/usb_1_1_4.xml new file mode 100644 index 0000000..35a0aee --- /dev/null +++ b/tests/devices/data/usb_1_1_4.xml @@ -0,0 +1,14 @@ +<device> + <name>usb_1_1_4</name> + <path>/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4</path> + <parent>usb_1_1</parent> + <driver> + <name>usb</name> + </driver> + <capability type='usb_device'> + <bus>1</bus> + <device>10</device> + <product id='0x217f'>Broadcom Bluetooth Device</product> + <vendor id='0x0a5c'>Broadcom Corp</vendor> + </capability> +</device> diff --git a/tests/devices/data/usb_usb1.xml b/tests/devices/data/usb_usb1.xml new file mode 100644 index 0000000..586a450 --- /dev/null +++ b/tests/devices/data/usb_usb1.xml @@ -0,0 +1,14 @@ +<device> + <name>usb_usb1</name> + <path>/sys/devices/pci0000:00/0000:00:1a.0/usb1</path> + <parent>pci_0000_00_1a_0</parent> + <driver> + <name>usb</name> + </driver> + <capability type='usb_device'> + <bus>1</bus> + <device>1</device> + <product id='0x0002'>EHCI Host Controller</product> + <vendor id='0x1d6b'>Linux 3.10.0-123.6.3.el7.x86_64 ehci_hcd</vendor> + </capability> +</device> diff --git a/tests/hostdevTests.py b/tests/hostdevTests.py index 71274e4..6cf7b78 100644 --- a/tests/hostdevTests.py +++ b/tests/hostdevTests.py @@ -28,290 +28,14 @@
from vdsm import libvirtconnection
-PCI_DEVICE_XML = [ - """ - <device> - <name>pci_0000_00_1a_0</name> - <path>/sys/devices/pci0000:00/0000:00:1a.0</path> - <parent>computer</parent> - <driver> - <name>ehci-pci</name> - </driver> - <capability type='pci'> - <domain>0</domain> - <bus>0</bus> - <slot>26</slot> - <function>0</function> - <product id='0x1c2d'>6 Series/C200 Series Chipset Family USB \ -Enhanced Host Controller #2</product> - <vendor id='0x8086'>Intel Corporation</vendor> - </capability> - </device> - """, - """ - <device> - <name>pci_0000_00_1f_2</name> - <path>/sys/devices/pci0000:00/0000:00:1f.2</path> - <parent>computer</parent> - <driver> - <name>ahci</name> - </driver> - <capability type='pci'> - <domain>0</domain> - <bus>0</bus> - <slot>31</slot> - <function>2</function> - <product id='0x1c03'>6 Series/C200 Series Chipset Family 6 port \ -SATA AHCI Controller</product> - <vendor id='0x8086'>Intel Corporation</vendor> - </capability> - </device> - """, - """ - <device> - <name>pci_0000_00_02_0</name> - <path>/sys/devices/pci0000:00/0000:00:02.0</path> - <parent>computer</parent> - <driver> - <name>i915</name> - </driver> - <capability type='pci'> - <domain>0</domain> - <bus>0</bus> - <slot>2</slot> - <function>0</function> - <product id='0x0126'>2nd Generation Core Processor Family \ -Integrated Graphics Controller</product> - <vendor id='0x8086'>Intel Corporation</vendor> - </capability> - </device> - """, - # in reality, the device above would be unavailable for passthrough, - # but in case of tests that does not really matter as we can't - # call real release() - """ - <device> - <name>pci_0000_00_19_0</name> - <path>/sys/devices/pci0000:00/0000:00:19.0</path> - <parent>computer</parent> - <driver> - <name>e1000e</name> - </driver> - <capability type='pci'> - <domain>0</domain> - <bus>0</bus> - <slot>25</slot> - <function>0</function> - <product id='0x1502'>82579LM Gigabit Network Connection</product> - <vendor id='0x8086'>Intel Corporation</vendor> - </capability> - </device> - """, - """ - <device> - <name>pci_0000_00_1b_0</name> - <path>/sys/devices/pci0000:00/0000:00:1b.0</path> - <parent>computer</parent> - <driver> - <name>snd_hda_intel</name> - </driver> - <capability type='pci'> - <domain>0</domain> - <bus>0</bus> - <slot>27</slot> - <function>0</function> - <product id='0x1c20'>6 Series/C200 Series Chipset Family High \ -Definition Audio Controller</product> - <vendor id='0x8086'>Intel Corporation</vendor> - </capability> - </device> - """] - -USB_DEVICE_XML = [ - """ - <device> - <name>usb_usb1</name> - <path>/sys/devices/pci0000:00/0000:00:1a.0/usb1</path> - <parent>pci_0000_00_1a_0</parent> - <driver> - <name>usb</name> - </driver> - <capability type='usb_device'> - <bus>1</bus> - <device>1</device> - <product id='0x0002'>EHCI Host Controller</product> - <vendor id='0x1d6b'>Linux 3.10.0-123.6.3.el7.x86_64 \ -ehci_hcd</vendor> - </capability> - </device> - """, - """ - <device> - <name>usb_1_1</name> - <path>/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1</path> - <parent>usb_usb1</parent> - <driver> - <name>usb</name> - </driver> - <capability type='usb_device'> - <bus>1</bus> - <device>2</device> - <product id='0x0024' /> - <vendor id='0x8087' /> - </capability> - </device> - """, - """ - <device> - <name>usb_1_1_4</name> - <path>/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4</path> - <parent>usb_1_1</parent> - <driver> - <name>usb</name> - </driver> - <capability type='usb_device'> - <bus>1</bus> - <device>10</device> - <product id='0x217f'>Broadcom Bluetooth Device</product> - <vendor id='0x0a5c'>Broadcom Corp</vendor> - </capability> - </device> - """] - -SCSI_DEVICE_XML = [ - """ - <device> - <name>scsi_host0</name> - <path>/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0</path> - <parent>pci_0000_00_1f_2</parent> - <capability type='scsi_host'> - <host>0</host> - </capability> - </device> - """, - """ - <device> - <name>scsi_target0_0_0</name> - <path>/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/\ -target0:0:0</path> - <parent>scsi_host0</parent> - <capability type='scsi_target'> - <target>target0:0:0</target> - </capability> - </device> - """, - """ - <device> - <name>scsi_0_0_0_0</name> - <path>/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/\ -target0:0:0/0:0:0:0</path> - <parent>scsi_target0_0_0</parent> - <driver> - <name>sd</name> - </driver> - <capability type='scsi'> - <host>0</host> - <bus>0</bus> - <target>0</target> - <lun>0</lun> - <type>disk</type> - </capability> - </device> - """] - -_SRIOV_PF_XML = """ - <device> - <name>pci_0000_05_00_1</name> - <path>/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.1</path> - <parent>pci_0000_00_09_0</parent> - <driver> - <name>igb</name> - </driver> - <capability type='pci'> - <domain>0</domain> - <bus>5</bus> - <slot>0</slot> - <function>1</function> - <product id='0x10c9'>82576 Gigabit Network Connection</product> - <vendor id='0x8086'>Intel Corporation</vendor> - <capability type='virt_functions'> - <address domain='0x0000' bus='0x05' slot='0x10' function='0x1'/> - <address domain='0x0000' bus='0x05' slot='0x10' function='0x3'/> - <address domain='0x0000' bus='0x05' slot='0x10' function='0x5'/> - <address domain='0x0000' bus='0x05' slot='0x10' function='0x7'/> - <address domain='0x0000' bus='0x05' slot='0x11' function='0x1'/> - <address domain='0x0000' bus='0x05' slot='0x11' function='0x3'/> - <address domain='0x0000' bus='0x05' slot='0x11' function='0x5'/> - </capability> - <iommuGroup number='15'> - <address domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> - <address domain='0x0000' bus='0x05' slot='0x00' function='0x1'/> - </iommuGroup> - </capability> - </device> - """ - -_SRIOV_VF_XML = """ - <device> - <name>pci_0000_05_10_7</name> - <path>/sys/devices/pci0000:00/0000:00:09.0/0000:05:10.7</path> - <parent>pci_0000_00_09_0</parent> - <driver> - <name>igbvf</name> - </driver> - <capability type='pci'> - <domain>0</domain> - <bus>5</bus> - <slot>16</slot> - <function>7</function> - <product id='0x10ca'>82576 Virtual Function</product> - <vendor id='0x8086'>Intel Corporation</vendor> - <capability type='phys_function'> - <address domain='0x0000' bus='0x05' slot='0x00' function='0x1'/> - </capability> - <iommuGroup number='25'> - <address domain='0x0000' bus='0x05' slot='0x10' function='0x7'/> - </iommuGroup> - </capability> - </device> - """ - -ADDITIONAL_DEVICE = """ - <device> - <name>pci_0000_00_09_0</name> - <path>/sys/devices/pci0000:00/0000:00:09.0</path> - <parent>computer</parent> - <driver> - <name>pcieport</name> - </driver> - <capability type='pci'> - <domain>0</domain> - <bus>0</bus> - <slot>9</slot> - <function>0</function> - <product id='0x3410'>7500/5520/5500/X58 I/O Hub PCI Express Root \ -Port 9</product> - <vendor id='0x8086'>Intel Corporation</vendor> - <iommuGroup number='4'> - <address domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> - </iommuGroup> - </capability> - </device> - """ - -_NET_DEVICE = """ -<device> - <name>net_em1_28_d2_44_55_66_88</name> - <path>/sys/devices/pci0000:00/0000:00:19.0/net/em1</path> - <parent>pci_0000_00_19_0</parent> - <capability type='net'> - <interface>em1</interface> - <address>28:d2:44:55:66:88</address> - <link state='down'/> - <capability type='80203'/> - </capability> -</device> -""" +_PCI_DEVICES = ['pci_0000_00_1a_0', 'pci_0000_00_1f_2', 'pci_0000_00_02_0', + 'pci_0000_00_19_0', 'pci_0000_00_1b_0'] +_USB_DEVICES = ['usb_usb1', 'usb_1_1', 'usb_1_1_4'] +_SCSI_DEVICES = ['scsi_host0', 'scsi_target0_0_0', 'scsi_0_0_0_0'] +_SRIOV_PF = 'pci_0000_05_00_1' +_SRIOV_VF = 'pci_0000_05_10_7' +_ADDITIONAL_DEVICE = 'pci_0000_00_09_0' +_NET_DEVICE = 'net_em1_28_d2_44_55_66_88'
DEVICES_PARSED = {u'pci_0000_00_1b_0': {'product': '6 Series/C200 Series ' 'Chipset Family High Definition ' @@ -485,11 +209,15 @@ def __init__(self, *args): self._virNodeDevices = []
- for device in PCI_DEVICE_XML + USB_DEVICE_XML + SCSI_DEVICE_XML: - self._virNodeDevices.append(fake.VirNodeDeviceStub(device)) + for device in _PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES: + self._virNodeDevices.append( + fake.Connection.nodeDeviceLookupByName(device))
def listAllDevices(self, flags=0): return self._virNodeDevices + + def nodeDeviceLookupByName(self, device_xml_filename): + return fake.Connection.nodeDeviceLookupByName(device_xml_filename)
def _fake_totalvfs(device_name): @@ -506,22 +234,34 @@ class HostdevTests(TestCaseBase):
def testParseDeviceParams(self): - deviceXML = hostdev._parse_device_params(ADDITIONAL_DEVICE) + deviceXML = hostdev._parse_device_params( + libvirtconnection.get().nodeDeviceLookupByName( + _ADDITIONAL_DEVICE).XMLDesc() + )
self.assertEquals(ADDITIONAL_DEVICE_PARSED, deviceXML)
def testParseSRIOV_PFDeviceParams(self): - deviceXML = hostdev._parse_device_params(_SRIOV_PF_XML) + deviceXML = hostdev._parse_device_params( + libvirtconnection.get().nodeDeviceLookupByName( + _SRIOV_PF).XMLDesc() + )
self.assertEquals(_SRIOV_PF_PARSED, deviceXML)
def testParseSRIOV_VFDeviceParams(self): - deviceXML = hostdev._parse_device_params(_SRIOV_VF_XML) + deviceXML = hostdev._parse_device_params( + libvirtconnection.get().nodeDeviceLookupByName( + _SRIOV_VF).XMLDesc() + )
self.assertEquals(_SRIOV_VF_PARSED, deviceXML)
def testParseNetDeviceParams(self): - deviceXML = hostdev._parse_device_params(_NET_DEVICE) + deviceXML = hostdev._parse_device_params( + libvirtconnection.get().nodeDeviceLookupByName( + _NET_DEVICE).XMLDesc() + )
self.assertEquals(_NET_DEVICE_PARSED, deviceXML)
@@ -530,9 +270,9 @@
self.assertEqual(DEVICES_PARSED, libvirt_devices) self.assertEqual(len(libvirt_devices), - len(PCI_DEVICE_XML) + - len(USB_DEVICE_XML) + - len(SCSI_DEVICE_XML)) + len(_PCI_DEVICES) + + len(_USB_DEVICES) + + len(_SCSI_DEVICES))
@permutations([[''], [('pci',)], [('usb_device',)], [('pci', 'usb_device')]])
automation@ovirt.org has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Martin Polednik has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 3: Verified+1
Dan Kenigsberg has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 3:
(2 comments)
I want to see this patch in, but maybe it can be improved.
https://gerrit.ovirt.org/#/c/40905/3/tests/hostdevTests.py File tests/hostdevTests.py:
Line 206: Line 207: class Connection(fake.Connection): Line 208: Line 209: def __init__(self, *args): Line 210: self._virNodeDevices = [] self._virNodeDevices = [ self.nodeDeviceLookupByName(device) for device in _PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES]
is so much cooler Line 211: Line 212: for device in _PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES: Line 213: self._virNodeDevices.append(self.nodeDeviceLookupByName(device)) Line 214:
Line 212: for device in _PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES: Line 213: self._virNodeDevices.append(self.nodeDeviceLookupByName(device)) Line 214: Line 215: def listAllDevices(self, flags=0): Line 216: return self._virNodeDevices frankly, we don't really need the _virNodeDevices cache - we can listdir() in fake.Connection.
If we keep it, we have (since the former patch) duplicate possibly-inconsistent data:
_virNodeDevice may not list a device, but if its file exists on disk, nodeDeviceLookupByName would report it. Line 217: Line 218: Line 219: def _fake_totalvfs(device_name): Line 220: if device_name == 'pci_0000_05_00_1':
Dan Kenigsberg has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 3:
-1 mostly for visibility
Dan Kenigsberg has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 3: Code-Review-1
Martin Polednik has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 3:
(2 comments)
https://gerrit.ovirt.org/#/c/40905/3/tests/hostdevTests.py File tests/hostdevTests.py:
Line 206: Line 207: class Connection(fake.Connection): Line 208: Line 209: def __init__(self, *args): Line 210: self._virNodeDevices = []
self._virNodeDevices = [
yep! will coolify Line 211: Line 212: for device in _PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES: Line 213: self._virNodeDevices.append(self.nodeDeviceLookupByName(device)) Line 214:
Line 212: for device in _PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES: Line 213: self._virNodeDevices.append(self.nodeDeviceLookupByName(device)) Line 214: Line 215: def listAllDevices(self, flags=0): Line 216: return self._virNodeDevices
frankly, we don't really need the _virNodeDevices cache - we can listdir()
good point, will fix Line 217: Line 218: Line 219: def _fake_totalvfs(device_name): Line 220: if device_name == 'pci_0000_05_00_1':
Martin Polednik has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 3:
(1 comment)
https://gerrit.ovirt.org/#/c/40905/3/tests/hostdevTests.py File tests/hostdevTests.py:
Line 212: for device in _PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES: Line 213: self._virNodeDevices.append(self.nodeDeviceLookupByName(device)) Line 214: Line 215: def listAllDevices(self, flags=0): Line 216: return self._virNodeDevices
good point, will fix
Actually, it's not that good. The devices/data directory contains (will contain) data for all relevant device tests. Therefore, just listing the directory returns xml files of e.g. libvirt domains. nodeDeviceLookupByName will not report anything that is not asked for - I don't understand the issue. Line 217: Line 218: Line 219: def _fake_totalvfs(device_name): Line 220: if device_name == 'pci_0000_05_00_1':
automation@ovirt.org has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 4:
unrelated failure
DEBUG util.py:378: http://mirror.pnl.gov/fedora/linux/updates/21/x86_64/repodata/8a211cb546751d...: [Errno 14] HTTP Error 404 - Not Found
Martin Polednik has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 4: Verified+1
Verified manually, but jenkins would be awesome to have.
Dan Kenigsberg has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 3:
(1 comment)
https://gerrit.ovirt.org/#/c/40905/3/tests/hostdevTests.py File tests/hostdevTests.py:
Line 212: for device in _PCI_DEVICES + _USB_DEVICES + _SCSI_DEVICES: Line 213: self._virNodeDevices.append(self.nodeDeviceLookupByName(device)) Line 214: Line 215: def listAllDevices(self, flags=0): Line 216: return self._virNodeDevices
Actually, it's not that good. The devices/data directory contains (will con
The point is that there is a case the asking nodeDeviceLookupByName would return a device that does not show up in listAllDevices Line 217: Line 218: Line 219: def _fake_totalvfs(device_name): Line 220: if device_name == 'pci_0000_05_00_1':
Dan Kenigsberg has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 4: Code-Review+2
Dan Kenigsberg has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 4: Continuous-Integration+1
Dan Kenigsberg has submitted this change and it was merged.
Change subject: virt: use new mocking in hostdevTests ......................................................................
virt: use new mocking in hostdevTests
With unified mocking mechanism for host devices, hostdevTests can now be converted to use the mechanism. This does not really change any functionality, but creates a pool of device XMLs that can be used in future tests.
Change-Id: I2e21dcaf6f645acb8229c01f40569785e1416cc2 Signed-off-by: Martin Polednik mpolednik@redhat.com Reviewed-on: https://gerrit.ovirt.org/40905 Reviewed-by: Dan Kenigsberg danken@redhat.com Continuous-Integration: Dan Kenigsberg danken@redhat.com --- M tests/devices/data/Makefile.am A tests/devices/data/net_em1_28_d2_44_55_66_88.xml A tests/devices/data/pci_0000_00_02_0.xml A tests/devices/data/pci_0000_00_09_0.xml A tests/devices/data/pci_0000_00_19_0.xml A tests/devices/data/pci_0000_00_1a_0.xml A tests/devices/data/pci_0000_00_1b_0.xml A tests/devices/data/pci_0000_00_1f_2.xml A tests/devices/data/pci_0000_05_00_1.xml A tests/devices/data/pci_0000_05_10_7.xml A tests/devices/data/scsi_0_0_0_0.xml A tests/devices/data/scsi_host0.xml A tests/devices/data/scsi_target0_0_0.xml A tests/devices/data/usb_1_1.xml A tests/devices/data/usb_1_1_4.xml A tests/devices/data/usb_usb1.xml M tests/hostdevTests.py 17 files changed, 280 insertions(+), 295 deletions(-)
Approvals: Dan Kenigsberg: Looks good to me, approved; Passed CI tests Martin Polednik: Verified
automation@ovirt.org has posted comments on this change.
Change subject: virt: use new mocking in hostdevTests ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org