Tests are very flaky and depend on the exact execution environment. It
is weird that it has gone well so far but started causing issues across
many of my builders.
Also started rewording some of the comments in the expression so
hopefully the next person looking at this has an easier time to
understand it.
On systems where swap is available and fully used tests fail like this:
> def test_swap_memory(self):
> mem = psutil.swap_memory()
> self.assertEqual(
> mem._fields, ('total', 'used', 'free', 'percent', 'sin', 'sout'))
>
> assert mem.total >= 0, mem
> assert mem.used >= 0, mem
> if mem.total > 0:
> # likely a system with no swap partition
> > assert mem.free > 0, mem
> E AssertionError: sswap(total=1048567808, used=1048567808, free=0, percent=100.0, sin=50741248, sout=1316823040)
> E assert 0 > 0
> E + where 0 = sswap(total=1048567808, used=1048567808, free=0, percent=100.0, sin=50741248, sout=1316823040).free
Upstream bug report: https://github.com/giampaolo/psutil/issues/1911
Systems where /proc/mounts doesn't expose any mount points to build the
tests fail like this:
> def test_disk_partitions(self):
> self.assertIsInstance(nt.device, str)
> def check_ntuple(nt):
> self.assertIsInstance(nt.mountpoint, str)
> self.assertIsInstance(nt.fstype, str)
> self.assertIsInstance(nt.opts, str)
> self.assertIsInstance(nt.maxfile, (int, type(None)))
> self.assertIsInstance(nt.maxpath, (int, type(None)))
> self.assertGreater(nt.maxfile, 0)
> if nt.maxfile is not None and not GITHUB_ACTIONS:
> if nt.maxpath is not None:
> self.assertGreater(nt.maxpath, 0)
>
> # all = False
> ls = psutil.disk_partitions(all=False)
> > self.assertTrue(ls, msg=ls)
> E AssertionError: [] is not true : []
Upstream bug report: https://github.com/giampaolo/psutil/issues/1912
By default, restic determines the location of the cache based on the XDG
base dir specification, which is `~/.cache/restic` when the environment
variable `$XDG_CACHE_HOME` isn't set.
As restic is executed as root by default, this resulted in the cache being
written to `/root/.cache/restic`, which is not quite right for a system
service and also meant, multiple backup services would use the same cache
directory - potentially causing issues with locking, data corruption,
etc.
The goal was to ensure, restic uses the correct cache location for a
system service - one cache per backup specification, using `/var/cache`
as the base directory for it.
systemd sets the environment variable `$CACHE_DIRECTORY` once
`CacheDirectory=` is defined, but restic doesn't change its behavior
based on the presence of this environment variable.
Instead, the specifier [1] `%C` can be used to point restic explicitly
towards the correct cache location using the `--cache-dir` argument.
Furthermore, the `CacheDirectoryMode=` was set to `0700`, as the default
of `0755` is far too open in this case, as the cache might contain
sensitive data.
[1] https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Specifiers
- Migrate from fetchFromGitHub to fetchPypi to ease SHA256 handling
- Drop tests (while not included with PyPI releases)
- Install a man page (as shipped by upstream)
- Move buildInputs to runtime only
Co-Authored-By: Silvan Mosberger <contact@infinisil.com>