Skip to content
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

[linux] test_swap_memory fails when swap is fully used #1911

Closed
andir opened this issue Jan 31, 2021 · 1 comment
Closed

[linux] test_swap_memory fails when swap is fully used #1911

andir opened this issue Jan 31, 2021 · 1 comment

Comments

@andir
Copy link

andir commented Jan 31, 2021

Summary

  • OS: Linux, NixOS
  • Architecture: 64bit, 32bit
  • Psutil version: 5.8.0
  • Python version: python 3.8
  • Type: tests

Description

When running the tests on a box that has used 100% of the available swap space and still has plenty of RAM remaining the tests fail as follows:

    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    

I have no idea how to fix this test. It seems like it reads out the data correctly but what is the expectation? You can't expect swap to be fully unused. It might be fully used for stuff that isn't currently needed.

@andir andir added the bug label Jan 31, 2021
andir added a commit to andir/nixpkgs that referenced this issue Jan 31, 2021
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: giampaolo/psutil#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: giampaolo/psutil#1912
andir added a commit to andir/nixpkgs that referenced this issue Jan 31, 2021
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: giampaolo/psutil#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: giampaolo/psutil#1912
@giampaolo
Copy link
Owner

Same considerations as in #1912.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants