Test failures / errors #538

Closed
Arfrever opened this Issue Sep 25, 2014 · 16 comments

Comments

Projects
None yet
3 participants
@Arfrever

psutil 2.1.2 and trunk have test failures / errors.
I use Linux 3.16.3.

Result with Python 2.7 (similar with 2.6):

$ PYTHONPATH="build/lib.linux-x86_64-2.7" python2.7 test/test_psutil.py
...
======================================================================
ERROR: test_swapmem_free (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 401, in wrapper
    return fun(*args, **kwargs)
  File "/tmp/psutil/test/_linux.py", line 120, in test_swapmem_free
    free = int(lines[2].split()[3]) * 1024
IndexError: list index out of range

======================================================================
ERROR: test_swapmem_total (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/_linux.py", line 107, in test_swapmem_total
    total = int(lines[2].split()[1]) * 1024
IndexError: list index out of range

======================================================================
ERROR: test_swapmem_used (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 401, in wrapper
    return fun(*args, **kwargs)
  File "/tmp/psutil/test/_linux.py", line 113, in test_swapmem_used
    used = int(lines[2].split()[2]) * 1024
IndexError: list index out of range

======================================================================
FAIL: test_vmem_buffers (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 401, in wrapper
    return fun(*args, **kwargs)
  File "/tmp/psutil/test/_linux.py", line 96, in test_vmem_buffers
    delta=TOLERANCE)
AssertionError: 776048640 != 99074048L within 512000 delta

======================================================================
FAIL: test_vmem_cached (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 401, in wrapper
    return fun(*args, **kwargs)
  File "/tmp/psutil/test/_linux.py", line 103, in test_vmem_cached
    delta=TOLERANCE)
AssertionError: 896303104 != 472481792 within 512000 delta

======================================================================
FAIL: test_vmem_used (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 401, in wrapper
    return fun(*args, **kwargs)
  File "/tmp/psutil/test/_linux.py", line 82, in test_vmem_used
    delta=TOLERANCE)
AssertionError: 771649536 != 1547698176L within 512000 delta

----------------------------------------------------------------------
Ran 132 tests in 9.293s

FAILED (failures=3, errors=3, skipped=1)

Result with Python 3.4 (the same with 3.2, 3.3):

$ PYTHONPATH="build/lib.linux-x86_64-3.4" python3.4 test/test_psutil.py
...
======================================================================
ERROR: test_swapmem_free (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 401, in wrapper
    return fun(*args, **kwargs)
  File "/tmp/psutil/test/_linux.py", line 120, in test_swapmem_free
    free = int(lines[2].split()[3]) * 1024
IndexError: list index out of range

======================================================================
ERROR: test_swapmem_total (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/_linux.py", line 107, in test_swapmem_total
    total = int(lines[2].split()[1]) * 1024
IndexError: list index out of range

======================================================================
ERROR: test_swapmem_used (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 401, in wrapper
    return fun(*args, **kwargs)
  File "/tmp/psutil/test/_linux.py", line 113, in test_swapmem_used
    used = int(lines[2].split()[2]) * 1024
IndexError: list index out of range

======================================================================
ERROR: test_vmem_buffers (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 404, in wrapper
    raise
RuntimeError: No active exception to reraise

======================================================================
ERROR: test_vmem_cached (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 404, in wrapper
    raise
RuntimeError: No active exception to reraise

======================================================================
ERROR: test_vmem_used (_linux.LinuxSpecificTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/psutil/test/test_psutil.py", line 404, in wrapper
    raise
RuntimeError: No active exception to reraise

----------------------------------------------------------------------
Ran 132 tests in 10.721s

FAILED (errors=6, skipped=1)
@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo Sep 26, 2014

Owner

Those are test related issues, meaning tests are bugged, not psutil.
Can you paste the output of "free" command?

Owner

giampaolo commented Sep 26, 2014

Those are test related issues, meaning tests are bugged, not psutil.
Can you paste the output of "free" command?

@Arfrever

This comment has been minimized.

Show comment
Hide comment
@Arfrever

Arfrever Sep 27, 2014

$ free
              total        used        free      shared  buff/cache   available
Mem:        2043440      957312      168228       69248      917900      701000
Swap:      10474344      352136    10122208
$ free
              total        used        free      shared  buff/cache   available
Mem:        2043440      957312      168228       69248      917900      701000
Swap:      10474344      352136    10122208
@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo Jan 2, 2015

Owner

Looking back at this, it seems it happens because for some reason the output of your "free" command is different than mine. Here's mine:

             total       used       free     shared    buffers     cached
Mem:      10124380    9130136     994244     709672     566908    3441912
-/+ buffers/cache:    5121316    5003064
Swap:      2943996          0    2943996

Here's my free version:

~/svn/psutil {master}$ free -V
free from procps-ng 3.3.9

My OS is Ubuntu 14.04.

Owner

giampaolo commented Jan 2, 2015

Looking back at this, it seems it happens because for some reason the output of your "free" command is different than mine. Here's mine:

             total       used       free     shared    buffers     cached
Mem:      10124380    9130136     994244     709672     566908    3441912
-/+ buffers/cache:    5121316    5003064
Swap:      2943996          0    2943996

Here's my free version:

~/svn/psutil {master}$ free -V
free from procps-ng 3.3.9

My OS is Ubuntu 14.04.

@Arfrever

This comment has been minimized.

Show comment
Hide comment
@Arfrever

Arfrever Jan 2, 2015

# free -V
free from procps-ng 3.3.10

Maybe format of output was changed in newer version.

Arfrever commented Jan 2, 2015

# free -V
free from procps-ng 3.3.10

Maybe format of output was changed in newer version.

@jelly

This comment has been minimized.

Show comment
Hide comment
@jelly

jelly Oct 11, 2015

Contributor

procps-ng 3.3.10 indeed changed the output format and removed the -/+ buffers/cache line. I'll be looking into a fix for this issue. So that the tests pass on Arch Linux.

Contributor

jelly commented Oct 11, 2015

procps-ng 3.3.10 indeed changed the output format and removed the -/+ buffers/cache line. I'll be looking into a fix for this issue. So that the tests pass on Arch Linux.

jelly added a commit to jelly/psutil that referenced this issue Oct 12, 2015

Update tests using free for procps-ng >= 3.3.10
procps-ng 3.3.10 changed the output format of free
and removed the 'buffers/cache' line.
Update the tests which use free to be compatible with
this new version and for buffers/cache tests use vmstat.

References: #538

jelly added a commit to jelly/psutil that referenced this issue Oct 12, 2015

Update tests using free for procps-ng >= 3.3.10
procps-ng 3.3.10 changed the output format of free
and removed the 'buffers/cache' line.
Update the tests which use free to be compatible with
this new version and for buffers/cache tests use vmstat.

References: #538
@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo Oct 14, 2015

Owner

Now that I merged that PR can we close this issue?

Owner

giampaolo commented Oct 14, 2015

Now that I merged that PR can we close this issue?

@jelly

This comment has been minimized.

Show comment
Hide comment
@jelly

jelly Oct 14, 2015

Contributor

There are still two failing tests left, I'll have to look into them further.

Contributor

jelly commented Oct 14, 2015

There are still two failing tests left, I'll have to look into them further.

msarahan added a commit to msarahan/psutil that referenced this issue Oct 14, 2015

Update tests using free for procps-ng >= 3.3.10
procps-ng 3.3.10 changed the output format of free
and removed the 'buffers/cache' line.
Update the tests which use free to be compatible with
this new version and for buffers/cache tests use vmstat.

References: #538
@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo Feb 15, 2016

Owner

I should have fixed all of these failures deriving from bad parsing of free cmdline utility. Can somebody please check if they are ok now?

Owner

giampaolo commented Feb 15, 2016

I should have fixed all of these failures deriving from bad parsing of free cmdline utility. Can somebody please check if they are ok now?

@jelly

This comment has been minimized.

Show comment
Hide comment
@jelly

jelly Feb 15, 2016

Contributor

I still have these left

======================================================================
FAIL: test_memory_maps (test_linux.TestProcess)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/test_linux.py", line 711, in test_memory_maps
    self.assertEqual(int(rss) * 1024, this.rss)
AssertionError: 0 != 4096

======================================================================
FAIL: test_cached (test_linux.TestSystemVirtualMemory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/__init__.py", line 492, in wrapper
    raise exc
AssertionError: 2087776256 != 1787822080 within 512000 delta

======================================================================
FAIL: test_used (test_linux.TestSystemVirtualMemory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/__init__.py", line 492, in wrapper
    raise exc
AssertionError: 2048389120 != 4409942016 within 512000 delta

----------------------------------------------------------------------
Ran 336 tests in 5.292s
Contributor

jelly commented Feb 15, 2016

I still have these left

======================================================================
FAIL: test_memory_maps (test_linux.TestProcess)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/test_linux.py", line 711, in test_memory_maps
    self.assertEqual(int(rss) * 1024, this.rss)
AssertionError: 0 != 4096

======================================================================
FAIL: test_cached (test_linux.TestSystemVirtualMemory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/__init__.py", line 492, in wrapper
    raise exc
AssertionError: 2087776256 != 1787822080 within 512000 delta

======================================================================
FAIL: test_used (test_linux.TestSystemVirtualMemory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/__init__.py", line 492, in wrapper
    raise exc
AssertionError: 2048389120 != 4409942016 within 512000 delta

----------------------------------------------------------------------
Ran 336 tests in 5.292s
@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo Feb 15, 2016

Owner

I see from the code that's not the latest GIT version. Can you try this?

git clone https://github.com/giampaolo/psutil.git
cd psutil
make test
Owner

giampaolo commented Feb 15, 2016

I see from the code that's not the latest GIT version. Can you try this?

git clone https://github.com/giampaolo/psutil.git
cd psutil
make test
@jelly

This comment has been minimized.

Show comment
Hide comment
@jelly

jelly Feb 15, 2016

Contributor

You are right, just two left. I guess this because of vmstat?

======================================================================
FAIL: test_cached (test_linux.TestSystemVirtualMemory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/__init__.py", line 492, in wrapper
    raise exc
AssertionError: 3202662400 != 2871132160 within 512000 delta

======================================================================
FAIL: test_used (test_linux.TestSystemVirtualMemory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/__init__.py", line 492, in wrapper
    raise exc
AssertionError: 1858871296 != 5340176384 within 512000 delta

----------------------------------------------------------------------
Ran 336 tests in 5.286s
Contributor

jelly commented Feb 15, 2016

You are right, just two left. I guess this because of vmstat?

======================================================================
FAIL: test_cached (test_linux.TestSystemVirtualMemory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/__init__.py", line 492, in wrapper
    raise exc
AssertionError: 3202662400 != 2871132160 within 512000 delta

======================================================================
FAIL: test_used (test_linux.TestSystemVirtualMemory)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jelle/projects/psutil/psutil/tests/__init__.py", line 492, in wrapper
    raise exc
AssertionError: 1858871296 != 5340176384 within 512000 delta

----------------------------------------------------------------------
Ran 336 tests in 5.286s
@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo Feb 15, 2016

Owner

Can you put this into a script and run it?

import psutil, subprocess
print "psutil vmem used %s" % psutil.virtual_memory().used
print "psutil vmem cached %s" % psutil.virtual_memory().cached
print subprocess.check_output('free')
print subprocess.check_output(['cat', '/proc/meminfo'])
print subprocess.check_output('vmstat')
Owner

giampaolo commented Feb 15, 2016

Can you put this into a script and run it?

import psutil, subprocess
print "psutil vmem used %s" % psutil.virtual_memory().used
print "psutil vmem cached %s" % psutil.virtual_memory().cached
print subprocess.check_output('free')
print subprocess.check_output(['cat', '/proc/meminfo'])
print subprocess.check_output('vmstat')
@jelly

This comment has been minimized.

Show comment
Hide comment
@jelly

jelly Feb 15, 2016

Contributor
In [4]: print "psutil vmem used %s" % psutil.virtual_memory().used
psutil vmem used 5409505280

In [5]: print "psutil vmem cached %s" % psutil.virtual_memory().cached
psutil vmem cached 2979266560

In [6]: print subprocess.check_output('free')
              total        used        free      shared  buff/cache   available
Mem:        8112372     1750140     2830072      102952     3532160     6171444
Swap:       8388604           0     8388604


In [7]: print subprocess.check_output(['cat', '/proc/meminfo'])
MemTotal:        8112372 kB
MemFree:         2830748 kB
MemAvailable:    6172120 kB
Buffers:          281984 kB
Cached:          2909408 kB
SwapCached:            0 kB
Active:          3051632 kB
Inactive:        1711312 kB
Active(anon):    1605656 kB
Inactive(anon):    68860 kB
Active(file):    1445976 kB
Inactive(file):  1642452 kB
Unevictable:          16 kB
Mlocked:              16 kB
SwapTotal:       8388604 kB
SwapFree:        8388604 kB
Dirty:               592 kB
Writeback:             0 kB
AnonPages:       1571360 kB
Mapped:           401072 kB
Shmem:            102952 kB
Slab:             340768 kB
SReclaimable:     295352 kB
SUnreclaim:        45416 kB
KernelStack:        9344 kB
PageTables:        36552 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    12444788 kB
Committed_AS:    5747176 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
HardwareCorrupted:     0 kB
AnonHugePages:    354304 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      417760 kB
DirectMap2M:     7903232 kB


In [8]: print subprocess.check_output('vmstat')
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  1      0 2829984 281992 3250168    0    0    42    49   84  396  3  1 96  0  0
Contributor

jelly commented Feb 15, 2016

In [4]: print "psutil vmem used %s" % psutil.virtual_memory().used
psutil vmem used 5409505280

In [5]: print "psutil vmem cached %s" % psutil.virtual_memory().cached
psutil vmem cached 2979266560

In [6]: print subprocess.check_output('free')
              total        used        free      shared  buff/cache   available
Mem:        8112372     1750140     2830072      102952     3532160     6171444
Swap:       8388604           0     8388604


In [7]: print subprocess.check_output(['cat', '/proc/meminfo'])
MemTotal:        8112372 kB
MemFree:         2830748 kB
MemAvailable:    6172120 kB
Buffers:          281984 kB
Cached:          2909408 kB
SwapCached:            0 kB
Active:          3051632 kB
Inactive:        1711312 kB
Active(anon):    1605656 kB
Inactive(anon):    68860 kB
Active(file):    1445976 kB
Inactive(file):  1642452 kB
Unevictable:          16 kB
Mlocked:              16 kB
SwapTotal:       8388604 kB
SwapFree:        8388604 kB
Dirty:               592 kB
Writeback:             0 kB
AnonPages:       1571360 kB
Mapped:           401072 kB
Shmem:            102952 kB
Slab:             340768 kB
SReclaimable:     295352 kB
SUnreclaim:        45416 kB
KernelStack:        9344 kB
PageTables:        36552 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    12444788 kB
Committed_AS:    5747176 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
HardwareCorrupted:     0 kB
AnonHugePages:    354304 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      417760 kB
DirectMap2M:     7903232 kB


In [8]: print subprocess.check_output('vmstat')
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  1      0 2829984 281992 3250168    0    0    42    49   84  396  3  1 96  0  0
@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo Feb 15, 2016

Owner

No it has to be run "fast" (in a script) in order to avoid memory variations as much as possible.

Owner

giampaolo commented Feb 15, 2016

No it has to be run "fast" (in a script) in order to avoid memory variations as much as possible.

@jelly

This comment has been minimized.

Show comment
Hide comment
@jelly

jelly Feb 15, 2016

Contributor

psutil vmem used 5062635520
psutil vmem cached 2942230528
total used free shared buff/cache available
Mem: 8112372 1447768 3168272 61988 3496332 6515204
Swap: 8388604 0 8388604

MemTotal: 8112372 kB
MemFree: 3168252 kB
MemAvailable: 6515184 kB
Buffers: 282720 kB
Cached: 2873272 kB
SwapCached: 0 kB
Active: 2770696 kB
Inactive: 1667928 kB
Active(anon): 1316840 kB
Inactive(anon): 27768 kB
Active(file): 1453856 kB
Inactive(file): 1640160 kB
Unevictable: 16 kB
Mlocked: 16 kB
SwapTotal: 8388604 kB
SwapFree: 8388604 kB
Dirty: 2080 kB
Writeback: 0 kB
AnonPages: 1282644 kB
Mapped: 345532 kB
Shmem: 61988 kB
Slab: 340340 kB
SReclaimable: 295324 kB
SUnreclaim: 45016 kB
KernelStack: 8832 kB
PageTables: 32368 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 12444788 kB
Committed_AS: 4963740 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 309248 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 417760 kB
DirectMap2M: 7903232 kB

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 3168196 282720 3213612 0 0 41 48 86 403 3 1 96 0 0

Contributor

jelly commented Feb 15, 2016

psutil vmem used 5062635520
psutil vmem cached 2942230528
total used free shared buff/cache available
Mem: 8112372 1447768 3168272 61988 3496332 6515204
Swap: 8388604 0 8388604

MemTotal: 8112372 kB
MemFree: 3168252 kB
MemAvailable: 6515184 kB
Buffers: 282720 kB
Cached: 2873272 kB
SwapCached: 0 kB
Active: 2770696 kB
Inactive: 1667928 kB
Active(anon): 1316840 kB
Inactive(anon): 27768 kB
Active(file): 1453856 kB
Inactive(file): 1640160 kB
Unevictable: 16 kB
Mlocked: 16 kB
SwapTotal: 8388604 kB
SwapFree: 8388604 kB
Dirty: 2080 kB
Writeback: 0 kB
AnonPages: 1282644 kB
Mapped: 345532 kB
Shmem: 61988 kB
Slab: 340340 kB
SReclaimable: 295324 kB
SUnreclaim: 45016 kB
KernelStack: 8832 kB
PageTables: 32368 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 12444788 kB
Committed_AS: 4963740 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 309248 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 417760 kB
DirectMap2M: 7903232 kB

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 3168196 282720 3213612 0 0 41 48 86 403 3 1 96 0 0

@giampaolo

This comment has been minimized.

Show comment
Hide comment
@giampaolo

giampaolo Sep 18, 2016

Owner

Fixed in #887

Owner

giampaolo commented Sep 18, 2016

Fixed in #887

@giampaolo giampaolo closed this Sep 18, 2016

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