Skip to content

Improve test coverage #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions tests/data/all_ethN.biosdevname
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
BIOS device: eth0
Kernel name: eth0
Permanent MAC: EC:F4:BB:C3:AF:A8
Assigned MAC : EC:F4:BB:C3:AF:A8
Driver: ixgbe
Driver version: 5.9.4
Firmware version: 0x8000095c, 19.5.12
Bus Info: 0000:01:00.0
PCI name : 0000:01:00.0
PCI Slot : embedded
SMBIOS Device Type: Ethernet
SMBIOS Instance: 1
SMBIOS Label: Integrated NIC 1
sysfs Label: NIC1
Embedded Index: 1

BIOS device: eth1
Kernel name: eth1
Permanent MAC: EC:F4:BB:C3:AF:AA
Assigned MAC : EC:F4:BB:C3:AF:AA
Driver: ixgbe
Driver version: 5.9.4
Firmware version: 0x8000095c, 19.5.12
Bus Info: 0000:01:00.1
PCI name : 0000:01:00.1
PCI Slot : embedded
SMBIOS Device Type: Ethernet
SMBIOS Instance: 2
SMBIOS Label: Integrated NIC 2
sysfs Label: NIC2
Embedded Index: 2

BIOS device: eth2
Kernel name: eth2
Permanent MAC: EC:F4:BB:C3:AF:AC
Assigned MAC : EC:F4:BB:C3:AF:AC
Driver: igb
Driver version: 5.3.5.20
Firmware version: 1.67, 0x80000fab, 19.5.12
Bus Info: 0000:07:00.0
PCI name : 0000:07:00.0
PCI Slot : embedded
SMBIOS Device Type: Ethernet
SMBIOS Instance: 3
SMBIOS Label: Integrated NIC 3
sysfs Label: NIC3
VPD Port: 3
VPD Index: 1
VPD PCI master: 0000:07:00.0

BIOS device: eth3
Kernel name: eth3
Permanent MAC: EC:F4:BB:C3:AF:AD
Assigned MAC : EC:F4:BB:C3:AF:AD
Driver: igb
Driver version: 5.3.5.20
Firmware version: 1.67, 0x80000fab, 19.5.12
Bus Info: 0000:07:00.1
PCI name : 0000:07:00.1
PCI Slot : embedded
SMBIOS Device Type: Ethernet
SMBIOS Instance: 4
SMBIOS Label: Integrated NIC 4
sysfs Label: NIC4
VPD Port: 4
VPD Index: 1
VPD PCI master: 0000:07:00.1

5 changes: 5 additions & 0 deletions tests/data/grub-linux.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set default=0
menuentry 'linux' {
linux /boot/vmlinuz-1 ro
initrd /boot/initrd.img-1
}
35 changes: 35 additions & 0 deletions tests/data/grub.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
serial --unit=0 --speed=115200
terminal_input serial console
terminal_output serial console
set default=0
set timeout=5
menuentry 'XCP-ng' {
search --label --set root root-vgdorj
multiboot2 /boot/xen.gz dom0_mem=7584M,max:7584M watchdog ucode=scan dom0_max_vcpus=1-16 crashkernel=256M,below=4G console=vga vga=mode-0x0311
module2 /boot/vmlinuz-4.19-xen root=LABEL=root-vgdorj ro nolvm hpet=disable console=hvc0 console=tty0 quiet vga=785 splash plymouth.ignore-serial-consoles
module2 /boot/initrd-4.19-xen.img
}
menuentry 'XCP-ng (Serial)' {
search --label --set root root-vgdorj
multiboot2 /boot/xen.gz com1=115200,8n1 console=com1,vga dom0_mem=7584M,max:7584M watchdog ucode=scan dom0_max_vcpus=1-16 crashkernel=256M,below=4G
module2 /boot/vmlinuz-4.19-xen root=LABEL=root-vgdorj ro nolvm hpet=disable console=tty0 console=hvc0
module2 /boot/initrd-4.19-xen.img
}
menuentry 'XCP-ng in Safe Mode' {
search --label --set root root-vgdorj
multiboot2 /boot/xen.gz nosmp noreboot noirqbalance no-mce no-bootscrub no-numa no-hap no-mmcfg max_cstate=0 nmi=ignore allow_unsafe dom0_mem=7584M,max:7584M com1=115200,8n1 console=com1,vga
module2 /boot/vmlinuz-4.19-xen earlyprintk=xen root=LABEL=root-vgdorj ro nolvm hpet=disable console=tty0 console=hvc0
module2 /boot/initrd-4.19-xen.img
}
menuentry 'XCP-ng (Xen 4.13.1 / Linux 4.19.0+1)' {
search --label --set root root-vgdorj
multiboot2 /boot/xen-fallback.gz dom0_mem=7584M,max:7584M watchdog ucode=scan dom0_max_vcpus=1-16 crashkernel=256M,below=4G
module2 /boot/vmlinuz-fallback root=LABEL=root-vgdorj ro nolvm hpet=disable console=hvc0 console=tty0
module2 /boot/initrd-fallback.img
}
menuentry 'XCP-ng (Serial, Xen 4.13.1 / Linux 4.19.0+1)' {
search --label --set root root-vgdorj
multiboot2 /boot/xen-fallback.gz com1=115200,8n1 console=com1,vga dom0_mem=7584M,max:7584M watchdog ucode=scan dom0_max_vcpus=1-16 crashkernel=256M,below=4G
module2 /boot/vmlinuz-fallback root=LABEL=root-vgdorj ro nolvm hpet=disable console=tty0 console=hvc0
module2 /boot/initrd-fallback.img
}
23 changes: 23 additions & 0 deletions tests/data/inventory/etc/xensource-inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PRIMARY_DISK='/dev/disk/by-id/scsi-123456789012345678901234567899012'
PRODUCT_VERSION='8.2.1'
DOM0_VCPUS='16'
CONTROL_DOMAIN_UUID='3b1dccee-9da4-49c6-8250-e3725e0e4b2d'
DOM0_MEM='7584'
COMPANY_NAME_SHORT='Open Source'
MANAGEMENT_ADDRESS_TYPE='IPv4'
PARTITION_LAYOUT='ROOT,BACKUP,LOG,BOOT,SWAP,SR'
PRODUCT_VERSION_TEXT='8.2'
PRODUCT_BRAND='XCP-ng'
INSTALLATION_UUID='b8b63475-d28c-44d4-9d1e-c38298ad3a0d'
PRODUCT_VERSION_TEXT_SHORT='8.2'
BRAND_CONSOLE='XCP-ng Center'
PRODUCT_NAME='xenenterprise'
MANAGEMENT_INTERFACE='xapi1'
COMPANY_PRODUCT_BRAND='XCP-ng'
PLATFORM_VERSION='3.2.1'
BUILD_NUMBER='release/yangtze/master/58'
PLATFORM_NAME='XCP'
BRAND_CONSOLE_URL='https://xcp-ng.org'
BACKUP_PARTITION='/dev/disk/by-id/scsi-123456789012345678901234567899012-part2'
INSTALLATION_DATE='2021-08-03 16:39:24.077945'
COMPANY_NAME='Open Source'
36 changes: 36 additions & 0 deletions tests/data/lspci-mn
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
00:00.0 "0600" "1022" "1630" "1022" "1630"
00:00.2 "0806" "1022" "1631" "1022" "1631"
00:01.0 "0600" "1022" "1632" "" ""
00:01.1 "0604" "1022" "1633" "" ""
00:02.0 "0600" "1022" "1632" "" ""
00:02.1 "0604" "1022" "1634" "" ""
00:02.2 "0604" "1022" "1634" "" ""
00:02.3 "0604" "1022" "1634" "" ""
00:08.0 "0600" "1022" "1632" "" ""
00:08.1 "0604" "1022" "1635" "" ""
00:08.2 "0604" "1022" "1635" "" ""
00:14.0 "0c05" "1022" "790b" -r51 "1462" "12ac"
00:14.3 "0601" "1022" "790e" -r51 "1462" "12ac"
00:18.0 "0600" "1022" "1448" "" ""
00:18.1 "0600" "1022" "1449" "" ""
00:18.2 "0600" "1022" "144a" "" ""
00:18.3 "0600" "1022" "144b" "" ""
00:18.4 "0600" "1022" "144c" "" ""
00:18.5 "0600" "1022" "144d" "" ""
00:18.6 "0600" "1022" "144e" "" ""
00:18.7 "0600" "1022" "144f" "" ""
01:00.0 "0604" "1002" "1478" -rc1 "" ""
02:00.0 "0604" "1002" "1479" "" ""
03:00.0 "0380" "1002" "7340" -rc1 "1462" "12ac"
03:00.1 "0403" "1002" "ab38" "1462" "12ac"
04:00.0 "0280" "8086" "2723" -r1a "8086" "0084"
05:00.0 "0200" "10ec" "8168" -r15 "1462" "12ac"
06:00.0 "0108" "144d" "a808" -p02 "144d" "a801"
07:00.0 "0300" "1002" "1636" -rc6 "1462" "12ac"
07:00.2 "1080" "1022" "15df" "1022" "15df"
07:00.3 "0c03" "1022" "1639" -p30 "1462" "12ac"
07:00.4 "0c03" "1022" "1639" -p30 "1462" "12ac"
07:00.5 "0480" "1022" "15e2" -r01 "1462" "12ac"
07:00.6 "0403" "1022" "15e3" "1462" "12ac"
08:00.0 "0106" "1022" "7901" -r81 -p01 "1462" "12ac"
08:00.1 "0106" "1022" "7901" -r81 -p01 "1462" "12ac"
29 changes: 29 additions & 0 deletions tests/data/pci.ids
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Excerpt from /usr/share/hwdata/pci.ids

# Vendors, devices and subsystems. Please keep sorted.

# Syntax:
# vendor vendor_name
# device device_name <-- single tab
# subvendor subdevice subsystem_name <-- two tabs

1002 Advanced Micro Devices, Inc. [AMD/ATI]
1314 Wrestler HDMI Audio
174b 1001 PURE Fusion Mini
1636 Renoir
7340 Navi 14 [Radeon RX 5500/5500M / Pro 5500M]

# List of known device classes, subclasses and programming interfaces

# Syntax:
# C class class_name
# subclass subclass_name <-- single tab
# prog-if prog-if_name <-- two tabs

C 03 Display controller
00 VGA compatible controller
00 VGA controller
01 8514 controller
01 XGA compatible controller
02 3D controller
80 Display controller
68 changes: 68 additions & 0 deletions tests/data/physical.biosdevname
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
BIOS device: em1
Kernel name: eth0
Permanent MAC: EC:F4:BB:C3:AF:A8
Assigned MAC : EC:F4:BB:C3:AF:A8
Driver: ixgbe
Driver version: 5.9.4
Firmware version: 0x8000095c, 19.5.12
Bus Info: 0000:01:00.0
PCI name : 0000:01:00.0
PCI Slot : embedded
SMBIOS Device Type: Ethernet
SMBIOS Instance: 1
SMBIOS Label: Integrated NIC 1
sysfs Label: NIC1
Embedded Index: 1

BIOS device: em2
Kernel name: eth1
Permanent MAC: EC:F4:BB:C3:AF:AA
Assigned MAC : EC:F4:BB:C3:AF:AA
Driver: ixgbe
Driver version: 5.9.4
Firmware version: 0x8000095c, 19.5.12
Bus Info: 0000:01:00.1
PCI name : 0000:01:00.1
PCI Slot : embedded
SMBIOS Device Type: Ethernet
SMBIOS Instance: 2
SMBIOS Label: Integrated NIC 2
sysfs Label: NIC2
Embedded Index: 2

BIOS device: em3_1
Kernel name: eth2
Permanent MAC: EC:F4:BB:C3:AF:AC
Assigned MAC : EC:F4:BB:C3:AF:AC
Driver: igb
Driver version: 5.3.5.20
Firmware version: 1.67, 0x80000fab, 19.5.12
Bus Info: 0000:07:00.0
PCI name : 0000:07:00.0
PCI Slot : embedded
SMBIOS Device Type: Ethernet
SMBIOS Instance: 3
SMBIOS Label: Integrated NIC 3
sysfs Label: NIC3
VPD Port: 3
VPD Index: 1
VPD PCI master: 0000:07:00.0

BIOS device: em4_1
Kernel name: eth3
Permanent MAC: EC:F4:BB:C3:AF:AD
Assigned MAC : EC:F4:BB:C3:AF:AD
Driver: igb
Driver version: 5.3.5.20
Firmware version: 1.67, 0x80000fab, 19.5.12
Bus Info: 0000:07:00.1
PCI name : 0000:07:00.1
PCI Slot : embedded
SMBIOS Device Type: Ethernet
SMBIOS Instance: 4
SMBIOS Label: Integrated NIC 4
sysfs Label: NIC4
VPD Port: 4
VPD Index: 1
VPD PCI master: 0000:07:00.1

34 changes: 34 additions & 0 deletions tests/data/repo/.treeinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[platform]
name = XCP
version = 3.2.1

[branding]
name = XCP-ng
version = 8.2.1

[build]
number = release/yangtze/master/58

[keys]
key1 = RPM-GPG-KEY-CH-8
key2 = RPM-GPG-KEY-CH-8-LCM
key3 = RPM-GPG-KEY-Platform-V1

[general]
name = XCP-ng-8.2.1
family = XCP-ng
timestamp = 1645700813.00
variant =
version = 8.2.1
packagedir =
arch = x86_64

[images-x86_64]
kernel = boot/pxelinux/mboot.c32
initrd = boot/vmlinuz
boot.iso = boot/xen.gz

[images-xen]
kernel = boot/pxelinux/mboot.c32
initrd = boot/vmlinuz

Empty file added tests/data/repo/XS-PACKAGES
Empty file.
14 changes: 14 additions & 0 deletions tests/data/repo/XS-REPOSITORY
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<repository
originator="o"
name="n"
product="p"
version="12.3"
build="42"
>

<description>
Description
</description>

<requires name="dep" test="ge" version="1" />
</repository>
Empty file.
55 changes: 55 additions & 0 deletions tests/data/repo/repodata/repomd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
<revision>1645708616</revision>
<data type="primary">
<checksum type="sha256">f8454f26592a0669368825d673edc18a067d8a434f2d3ceaa03cdb45e72572e8</checksum>
<open-checksum type="sha256">6f2d69e90edbe7b3eb83654995dc07c6e577d8fc2f9ee7ec7f4f206ed486218b</open-checksum>
<location href="repodata/f8454f26592a0669368825d673edc18a067d8a434f2d3ceaa03cdb45e72572e8-primary.xml.gz"/>
<timestamp>1645708616</timestamp>
<size>208220</size>
<open-size>1449213</open-size>
</data>
<data type="filelists">
<checksum type="sha256">4e678f6ce4fc197faef2c75645d00c79ee8b70d3210aa2f692fe432ed223c695</checksum>
<open-checksum type="sha256">cea7a040a15876aba2238f3b8910cd48ded102ff0d4976df81903a3bc4ae8586</open-checksum>
<location href="repodata/4e678f6ce4fc197faef2c75645d00c79ee8b70d3210aa2f692fe432ed223c695-filelists.xml.gz"/>
<timestamp>1645708616</timestamp>
<size>265582</size>
<open-size>2704673</open-size>
</data>
<data type="other">
<checksum type="sha256">a19f12f68c74459bc9fc7887376408b4c8dc9e84876ebbf3301afec79f110a7b</checksum>
<open-checksum type="sha256">46a83a4100e33249a95462d7ed54cb71ee4a178db8f2346b83f1ba5f1a5d47dc</open-checksum>
<location href="repodata/a19f12f68c74459bc9fc7887376408b4c8dc9e84876ebbf3301afec79f110a7b-other.xml.gz"/>
<timestamp>1645708616</timestamp>
<size>204512</size>
<open-size>1054253</open-size>
</data>
<data type="primary_db">
<checksum type="sha256">34a89554a4214fde5b473ddcf1d9be796801e8e8676cda860a3d032a7e8b10d8</checksum>
<open-checksum type="sha256">1fc99d5403906556e8fc91d2121816354cac667741f1a04f51988b5cc3e01b98</open-checksum>
<location href="repodata/34a89554a4214fde5b473ddcf1d9be796801e8e8676cda860a3d032a7e8b10d8-primary.sqlite.bz2"/>
<timestamp>1645708616</timestamp>
<size>419050</size>
<open-size>1754112</open-size>
<database_version>10</database_version>
</data>
<data type="filelists_db">
<checksum type="sha256">f4c416c2cf253741749420300109cf8a046e0cdd27c269e69795a9ecc092669b</checksum>
<open-checksum type="sha256">1de3d29150b9da80b10c95b913c91369f3b7d03bb2ed57eedf511038e4537c50</open-checksum>
<location href="repodata/f4c416c2cf253741749420300109cf8a046e0cdd27c269e69795a9ecc092669b-filelists.sqlite.bz2"/>
<timestamp>1645708616</timestamp>
<size>323942</size>
<open-size>1380352</open-size>
<database_version>10</database_version>
</data>
<data type="other_db">
<checksum type="sha256">4a192c51fff556d2f1fdbb8f90b5454558c910a50674e65b7cdfacd5f791fdb5</checksum>
<open-checksum type="sha256">23dbdc6ce9ece7f1d3ac3d7b31cd61b4019e96ef01903975516fd5e3083de32a</open-checksum>
<location href="repodata/4a192c51fff556d2f1fdbb8f90b5454558c910a50674e65b7cdfacd5f791fdb5-other.sqlite.bz2"/>
<timestamp>1645708616</timestamp>
<size>243295</size>
<open-size>988160</open-size>
<database_version>10</database_version>
</data>
</repomd>
21 changes: 21 additions & 0 deletions tests/test_accessor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import unittest

import xcp.accessor

class TestAccessor(unittest.TestCase):
def test_http(self):
raise unittest.SkipTest("comment out if you really mean it")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain this in the commit message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

a = xcp.accessor.createAccessor("https://updates.xcp-ng.org/netinstall/8.2.1", True)
a.start()
self.assertTrue(a.access('.treeinfo'))
self.assertFalse(a.access('no_such_file'))
self.assertEqual(a.lastError, 404)
a.finish()

def test_file(self):
a = xcp.accessor.createAccessor("file://tests/data/repo/", True)
a.start()
self.assertTrue(a.access('.treeinfo'))
self.assertFalse(a.access('no_such_file'))
self.assertEqual(a.lastError, 404)
a.finish()
Loading