Closed mans0954 closed 1 year ago
We are running tests as root in our CI so we missed few changes that made the tests fail when running as non-root. #871 should fix this. I was able to successfully run the tests on Ubuntu 20.04 as a regular user.
@vojtechtrefny Thanks for the quick response. Your branch solves the Permission denied
errors for me (although I am now left with one different error:
======================================================================
ERROR: test_min_max_size_alignment (devices_test.partition_test.PartitionDeviceTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mans0954/src/python/blivet/vojtechtrefny-blivet/tests/devices_test/partition_test.py", line 165, in test_min_max_size_alignment
disk.format.add_partition(start, disk.format.parted_device.length - 1)
File "/home/mans0954/src/python/blivet/vojtechtrefny-blivet/blivet/threads.py", line 53, in run_with_lock
return m(*args, **kwargs)
File "/home/mans0954/src/python/blivet/vojtechtrefny-blivet/blivet/formats/disklabel.py", line 407, in add_partition
self.parted_disk.addPartition(partition=new_partition,
File "/usr/lib/python3/dist-packages/parted/decorators.py", line 42, in new
ret = fn(*args, **kwds)
File "/usr/lib/python3/dist-packages/parted/disk.py", line 244, in addPartition
result = self.__disk.add_partition(partition.getPedPartition(),
_ped.PartitionException: Unable to satisfy all constraints on the partition.
)
This is weird. With latest Debian testing this test case also fails for me, but on a different line (above your error) and only when running as non-root. And the test passes on Ubuntu 20.04 (both root and regular user).
Even weirder: adding /sbin
to PATH
fixes all the test failures for me. I never understood why Debian doesn't have /sbin
in PATH. I know only system tools should reside in /sbin
but it's still a valid use case to run these tools as a regular user to get the tool version or help (end of Debian rant :-). But I still don't understand how this could affect the partitioning test where no command line tools are involved -- everything is done with pyparted/libparted. I had some issues with libparted when running libblockdev tests on Debian so maybe we have newer (or patched) version of libparted on Fedora, but this doesn't really explain why tests works when running as root.
Anyway, we should definitely do a better job in separating unit tests and integration tests and run only unit tests when running as a regular users. Right now the tests are mixed together, but fixing this would be a tremendous job. I could simply skip this one test case when running as a regular user. It's not a real fix, but if it helps...
Btw. why are you trying to run blivet tests as a regular user? Yes, the readme says it should work, but blivet won't work without root privilegies, so it doesn't really make sense to run the tests as a regular user.
Btw. why are you trying to run blivet tests as a regular user? Yes, the readme says it should work, but blivet won't work without root privilegies, so it doesn't really make sense to run the tests as a regular user.
@vojtechtrefny sorry for the delay in replying. I'm trying to build a Debian package for blivet. Debian packages specify tests in two places - tests run by dh_auto_test
after the code has been built, but before the binary package has been created [1], and tests run by autopkgtest
, which are run against the package when it has been installed into a system [2]. The former must run as a non-root user, in a chroot environment, whereas the latter can specify restrictions on the test bed such as needs-root, isolation-machine
to run as root in a qemu/kvm virtual machine.
With the patches from your PR, the dh_auto_test
step passes on Debian unstable, but the autopkgtest
tests are still causing me some problems (expand details to see).
[1] https://salsa.debian.org/python-team/modules/blivet/-/blob/debian/master/debian/rules#L21 [2] https://salsa.debian.org/python-team/modules/blivet/-/blob/debian/master/debian/tests/control
I'm trying to build a Debian package for blivet.
That's great! Sorry our tests are causing so many problems.
but the autopkgtest tests are still causing me some problems (expand details to see).
I think I know what's the problem here. The edd_data
folder in tests/devicelibs_test
is a fake "sysfs" we use in the tests and it contains a lot of symlinks -- it looks like the symlinks are broken and that's why the tests are failing.
@mans0954 Is there something we can do to help here? We are already skipping some of the tests using environmental variables so maybe we could add similar "skip condition" for the edd tests to make this work for you?
All the failures should be now fixed and we also have a new CI job to run tests as a non-root user on Ubuntu in GH actions so we shouldn't break this in the future.
In the tests read me it says:
When I run
make test
I see several permissions errors like the following:How should I run the tests to circumvent this? I have this problem on both Debian unstable and Ubuntu 20.04. (Assuming that I want to run the tests which don't require root as an unprivileged user.)
Thanks.