-
Notifications
You must be signed in to change notification settings - Fork 5
xen: Add test-ring0 tests #304
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
base: master
Are you sure you want to change the base?
Conversation
host.ssh(f"echo 1 > /sys/kernel/debug/xst/{testname}/run") | ||
host.ssh(f"grep -q 'status: pass' /sys/kernel/debug/xst/{testname}/results") | ||
finally: | ||
host.ssh(f"modprobe -r xst_{modname}", check=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to ignore modprobe
's exit status here (and on similar cases)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly since failure to remove test modules has no bearing on the test results, and the host is cleaned up afterwards by rebooting anyway.
tests/xen/test_ring0.py
Outdated
def test_xst_livepatch(self, host: Host): | ||
try: | ||
host.ssh("lsmod | grep -wq livepatch_tester") | ||
pytest.skip("livepatch_tester already loaded, needs reboot") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that rather be an error?
tests/xen/test_ring0.py
Outdated
except SSHCommandFailed: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it would be easier to read as something like
if host.ssh(...):
pytest.error(...)
tests/xen/test_ring0.py
Outdated
finally: | ||
host.ssh("modprobe -r xst_ioemu_msi", check=False) | ||
|
||
def test_xst_livepatch(self, host: Host): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without prior context, it is hard to understand what we're testing here. A detailed description and/or more comments seem to be needed
tests/xen/test_ring0.py
Outdated
import logging | ||
import secrets | ||
import time | ||
from typing import Optional | ||
import pytest | ||
|
||
from lib.commands import SSHCommandFailed | ||
from lib.host import Host | ||
from lib.vm import VM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be reordered. Straight imports first, alphabetically. Then a blank line. Then "from xxx" imports, alphabetically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Yann indicated above, I forgot about the split between external and internal libs, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from typing
here does not bother me much, and pep8 indeed does not seem to mandate any sorting within each of the 3 import blocks. IMO we should check what various checkers report.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stack Overflow most voted answer pushes for sorting, and that's also the convention we tend to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you were originally refering to pytest
not being sorted 😉
tests/xen/test_ring0.py
Outdated
host.ssh("lsmod | grep -wq livepatch_tester") | ||
pytest.skip("livepatch_tester already loaded, needs reboot") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We avoid skipping tests for such reasons. One might falsely think that the test was executed, in CI, as no one checks all skips one by one. What we do instead is check for prerequisites in a fixture and fail the test if the prerequisite is not met.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not use fail
, that's rather what error
is for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's appropriate, then we have a few fixtures to fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find pytest.error
anywhere. I'll use pytest.fail
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By moving the prerequisite test to a fixture as I suggested (and that's one of the things fixtures are here for in pytest), it would be obvious that the failure is in the prerequisites and not in the test itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, my bad, there does not seem to be another mechanism than fixtures to generate error rather than failure (https://docs.pytest.org/en/stable/explanation/fixtures.html#fixture-errors seems to be where they talk about it, but it does not spell out precisely that errors are solely coming from fixtures)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next question would be, do we want to do this in a host_without_livepatch_tester
fixture to be able to get an error rather than a failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's precisely what I'm talking about from the beginning :D (though in other fixtures we do use pytest.fail too at the moment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is, the test will be executed as part of the xen
job. This job is currently very short and runs at the beginning of our test pipeline, on real hardware. However, with a reboot, we'll go from 1 minute to close to 10 minutes.
Are the tests themselves long to execute?
Our options:
- keep as is
- move to a separate job that we'll run later in the pipeline
- split between fast tests that would not require a reboot (if any) and the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests themselves are quite short. I can split it to a separate job if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can keep them in the same job for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the xen
job description in jobs.py to indicate that it will reboot the master host.
8fcffa8
to
b4ce123
Compare
Signed-off-by: Tu Dinh <[email protected]>
Run the test-ring0 tests that are straightforward to run.
The ones that are not (e.g. legacy tests, tests that crash the host or leak resources infinitely) are skipped, but included for completeness.
test_xst_memory_leak
requires a custom kernel withCONFIG_DEBUG_KMEMLEAK
set.