|
| 1 | +"""tests/integration/test_system_load.py: Test xen-bugtool --entries=system-load""" |
| 2 | +import os |
| 3 | + |
| 4 | +from utils import check_file, run_bugtool_entry, assert_content_from_dom0_template |
| 5 | + |
| 6 | + |
| 7 | +# In this test case we need to sleep for 1 sec, and it is sufficient |
| 8 | +# to test to only with zip archives to keep the test duration short: |
| 9 | +def test_system_load(output_archive_type="zip"): |
| 10 | + """Test xen-bugtool --entries=system-load in test jail created by auto-fixtures in conftest.py""" |
| 11 | + entry = "system-load" |
| 12 | + |
| 13 | + # Create test input files: |
| 14 | + os.mkdir("/var/log") |
| 15 | + os.mkdir("/var/log/sa") |
| 16 | + with open("/var/log/sa/sa01", "w") as sa01: |
| 17 | + sa01.write("sa01 test data") |
| 18 | + with open("/var/log/sa/sar31", "w") as sar31: |
| 19 | + sar31.write("sar31 test data") |
| 20 | + |
| 21 | + # Create a dummy sar script to assert that xen-bugtool captures its output: |
| 22 | + os.environ["PATH"] = "/var:" + os.environ["PATH"] |
| 23 | + with open("/var/sar", "w") as sar: |
| 24 | + sar.write("#!/bin/sh\nsleep 1;cat /etc/xensource-inventory\n") |
| 25 | + os.chmod("/var/sar", 0o777) |
| 26 | + |
| 27 | + run_bugtool_entry(output_archive_type, entry) |
| 28 | + |
| 29 | + assert_content_from_dom0_template("sar-A.out", "etc/xensource-inventory") |
| 30 | + assert check_file("var/log/sa/sa01") == "sa01 test data" |
| 31 | + assert check_file("var/log/sa/sar31") == "sar31 test data" |
0 commit comments