giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.31k stars 1.39k forks source link

[Linux] run "python3 -m psutil.tests", some test cases failed when nfs boot is used #2390

Open sandy-lcq opened 8 months ago

sandy-lcq commented 8 months ago

Summary

Description

python3 -m psutil.tests have some test cases failed when nfs boot is used

======================================================================
FAIL: psutil.tests.test_linux.TestRootFsDeviceFinder.test_against_findmnt
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/psutil/tests/test_linux.py", line 1434, in test_against_findmnt
    self.assertEqual(psutil_value, findmnt_value)
AssertionError: None != 'xxx.xxx.xxx.xxx:/path/to/rootfs'

======================================================================
FAIL: psutil.tests.test_linux.TestRootFsDeviceFinder.test_comparisons
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/psutil/tests/test_linux.py", line 1410, in test_comparisons
    self.assertIsNotNone(finder.find())
AssertionError: unexpectedly None

======================================================================
FAIL: psutil.tests.test_linux.TestRootFsDeviceFinder.test_disk_partitions_mocked
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/psutil/tests/test_linux.py", line 1444, in test_disk_partitions_mocked
    self.assertNotEqual(part.device, "/dev/root")
AssertionError: '/dev/root' == '/dev/root'

======================================================================
FAIL: psutil.tests.test_linux.TestSystemVirtualMemoryAgainstFree.test_used
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/psutil/tests/__init__.py", line 740, in wrapper
    raise exc
  File "/usr/lib64/python3.12/site-packages/psutil/tests/__init__.py", line 732, in wrapper
    return fun(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/psutil/tests/test_linux.py", line 285, in test_used
    self.assertAlmostEqual(
AssertionError: 352862208 != 117112832 within 5242880 delta (235749376 difference)

======================================================================
FAIL: psutil.tests.test_linux.TestSystemVirtualMemoryAgainstVmstat.test_used
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/psutil/tests/__init__.py", line 740, in wrapper
    raise exc
  File "/usr/lib64/python3.12/site-packages/psutil/tests/__init__.py", line 732, in wrapper
    return fun(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/site-packages/psutil/tests/test_linux.py", line 349, in test_used
    self.assertAlmostEqual(
AssertionError: 353624064 != 117874688 within 5242880 delta (235749376 difference)

======================================================================
FAIL: psutil.tests.test_system.TestDiskAPIs.test_disk_partitions
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/psutil/tests/test_system.py", line 655, in test_disk_partitions
    self.assertTrue(ls, msg=ls)
AssertionError: [] is not true : []

======================================================================
FAIL: psutil.tests.test_system.TestMiscAPIs.test_users
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/psutil/tests/test_system.py", line 223, in test_users
    self.assertNotEqual(users, [])
AssertionError: [] == []

======================================================================
FAIL: psutil.tests.test_system.TestSensorsAPIs.test_sensors_temperatures
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/psutil/tests/test_system.py", line 919, in test_sensors_temperatures
    self.assertGreaterEqual(entry.current, 0)
AssertionError: -273.2 not greater than or equal to 0

======================================================================
FAIL: psutil.tests.test_contracts.TestAvailProcessAPIs.test_io_counters
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.12/site-packages/psutil/tests/test_contracts.py", line 173, in test_io_counters
    self.assertEqual(hasit, not (MACOS or SUNOS))
AssertionError: False != True

More info

For TestSystemVirtualMemoryAgainstVmstat.test_used and TestSystemVirtualMemoryAgainstVmstat.test_used, there is a similar issue: https://github.com/giampaolo/psutil/issues/2355

For test_io_counters, there is pull request for fix it: https://github.com/giampaolo/psutil/pull/2097

Other test cases should related to the nfs boot.

$mount xxx.xxx.xxx.xxx:/path/to/rootfs on / type nfs (rw,relatime,vers=3,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=xxx.xxx.xxx.xxx,mountvers=3,mountproto=tcp,local_lock=all,addr=xxx.xxx.xxx.xxx) $cat /proc/cmdline kernel console=ttyS0,115200n8 ip=dhcp selinux=0 enforcing=0 root=/dev/nfs rw nfsroot=xxx.xxx.xxx.xxx:/path/to/rootfs,tcp,v3