|
| 1 | +import pytest |
| 2 | + |
| 3 | +import subprocess |
| 4 | + |
| 5 | +from lib.host import Host |
| 6 | + |
| 7 | +# This smoke test runs xen-bugtool and verifies that the archive it generates |
| 8 | +# contains some of the expected logs and files. |
| 9 | +# |
| 10 | +# Requirements: |
| 11 | +# - an XCP-ng host |
| 12 | + |
| 13 | +def verify_contains(host: Host, archive: str, files: list[str]): |
| 14 | + listing = host.ssh(['tar', '-jtf', archive]) |
| 15 | + listing_clean = [x.split('/', maxsplit=1)[1] for x in listing.splitlines()] |
| 16 | + assert all(file in listing_clean for file in files) |
| 17 | + |
| 18 | +class TestsBugtool: |
| 19 | + # Verify a minimal bugtool invocation that only queries certain capabilities |
| 20 | + def test_bugtool_entries(self, host): |
| 21 | + try: |
| 22 | + filename = host.ssh(['xen-bugtool', '-y', '-s', |
| 23 | + '--entries=xenserver-logs,xenserver-databases,system-logs']) |
| 24 | + verify_contains(host, filename, |
| 25 | + [ |
| 26 | + "var/log/xensource.log", |
| 27 | + "var/log/SMlog", |
| 28 | + "xapi-db.xml", |
| 29 | + ]) |
| 30 | + finally: |
| 31 | + if filename: |
| 32 | + host.ssh(['rm', '-f', filename]) |
| 33 | + |
| 34 | + # Verify that a full xen-bugtool invocation contains the most essential files |
| 35 | + def test_bugtool_all(self, host): |
| 36 | + try: |
| 37 | + filename = host.ssh(['xen-bugtool', '-y', '-s']) |
| 38 | + verify_contains(host, filename, |
| 39 | + [ |
| 40 | + "var/log/xensource.log", |
| 41 | + "var/log/SMlog", |
| 42 | + "xapi-db.xml", |
| 43 | + "acpidump.out", |
| 44 | + "etc/fstab", |
| 45 | + "etc/xapi.conf", |
| 46 | + "etc/xensource/pool.conf", |
| 47 | + ]) |
| 48 | + finally: |
| 49 | + if filename: |
| 50 | + host.ssh(['rm', '-f', filename]) |
0 commit comments