dsoprea / PyInotify

An efficient and elegant inotify (Linux filesystem activity monitor) library for Python. Python 2 and 3 compatible.
GNU General Public License v2.0
242 stars 73 forks source link

Certain TestInotifyTree tests consistently failing #75

Closed dwvisser closed 5 years ago

dwvisser commented 5 years ago

I see the following failures on my Ubuntu 18.04 VM, running in a virtualenv (either Py2 or Py3):

FAIL: test__cycle (tests.test_inotify.TestInotifyTree)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dale/Git/PyInotify/tests/test_inotify.py", line 213, in test__cycle
    self.assertEquals(events, expected)
AssertionError: Lists differ: [(_IN[325 chars]T(wd=3, mask=256, cookie=0, len=16), ['IN_CREA[1517 chars]bb')] != [(_IN[325 chars]T(wd=2, mask=256, cookie=0, len=16), ['IN_CREA[1517 chars]bb')]

First differing element 3:
(_INOTIFY_EVENT(wd=3, mask=256, cookie=0, len=16), ['IN_CREA[41 chars]le2')
(_INOTIFY_EVENT(wd=2, mask=256, cookie=0, len=16), ['IN_CREA[41 chars]le2')

  [(_INOTIFY_EVENT(wd=1, mask=256, cookie=0, len=16),
    ['IN_CREATE'],
    '/tmp/tmprcjv466m',
    'seen_new_file1'),
   (_INOTIFY_EVENT(wd=1, mask=32, cookie=0, len=16),
    ['IN_OPEN'],
    '/tmp/tmprcjv466m',
    'seen_new_file1'),
   (_INOTIFY_EVENT(wd=1, mask=8, cookie=0, len=16),
    ['IN_CLOSE_WRITE'],
    '/tmp/tmprcjv466m',
    'seen_new_file1'),
-  (_INOTIFY_EVENT(wd=3, mask=256, cookie=0, len=16),
?                     ^

+  (_INOTIFY_EVENT(wd=2, mask=256, cookie=0, len=16),
?                     ^

    ['IN_CREATE'],
    '/tmp/tmprcjv466m/aa',
    'seen_new_file2'),
-  (_INOTIFY_EVENT(wd=3, mask=32, cookie=0, len=16),
?                     ^

+  (_INOTIFY_EVENT(wd=2, mask=32, cookie=0, len=16),
?                     ^

    ['IN_OPEN'],
    '/tmp/tmprcjv466m/aa',
    'seen_new_file2'),
-  (_INOTIFY_EVENT(wd=3, mask=8, cookie=0, len=16),
?                     ^

+  (_INOTIFY_EVENT(wd=2, mask=8, cookie=0, len=16),
?                     ^

    ['IN_CLOSE_WRITE'],
    '/tmp/tmprcjv466m/aa',
    'seen_new_file2'),
-  (_INOTIFY_EVENT(wd=2, mask=256, cookie=0, len=16),
?                     ^

+  (_INOTIFY_EVENT(wd=3, mask=256, cookie=0, len=16),
?                     ^

    ['IN_CREATE'],
    '/tmp/tmprcjv466m/bb',
    'seen_new_file3'),
-  (_INOTIFY_EVENT(wd=2, mask=32, cookie=0, len=16),
?                     ^

+  (_INOTIFY_EVENT(wd=3, mask=32, cookie=0, len=16),
?                     ^

    ['IN_OPEN'],
    '/tmp/tmprcjv466m/bb',
    'seen_new_file3'),
-  (_INOTIFY_EVENT(wd=2, mask=8, cookie=0, len=16),
?                     ^

+  (_INOTIFY_EVENT(wd=3, mask=8, cookie=0, len=16),
?                     ^

    ['IN_CLOSE_WRITE'],
    '/tmp/tmprcjv466m/bb',
    'seen_new_file3'),
   (_INOTIFY_EVENT(wd=1, mask=512, cookie=0, len=16),
    ['IN_DELETE'],
    '/tmp/tmprcjv466m',
    'seen_new_file1'),
-  (_INOTIFY_EVENT(wd=3, mask=512, cookie=0, len=16),
?                     ^

+  (_INOTIFY_EVENT(wd=2, mask=512, cookie=0, len=16),
?                     ^

    ['IN_DELETE'],
    '/tmp/tmprcjv466m/aa',
    'seen_new_file2'),
-  (_INOTIFY_EVENT(wd=2, mask=512, cookie=0, len=16),
?                     ^

+  (_INOTIFY_EVENT(wd=3, mask=512, cookie=0, len=16),
?                     ^

    ['IN_DELETE'],
    '/tmp/tmprcjv466m/bb',
    'seen_new_file3'),
-  (_INOTIFY_EVENT(wd=3, mask=1024, cookie=0, len=0),
?                     ^

+  (_INOTIFY_EVENT(wd=2, mask=1024, cookie=0, len=0),
?                     ^

    ['IN_DELETE_SELF'],
    '/tmp/tmprcjv466m/aa',
    ''),
-  (_INOTIFY_EVENT(wd=3, mask=32768, cookie=0, len=0),
?                     ^

+  (_INOTIFY_EVENT(wd=2, mask=32768, cookie=0, len=0),
?                     ^

    ['IN_IGNORED'],
    '/tmp/tmprcjv466m/aa',
    ''),
   (_INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16),
-   ['IN_DELETE', 'IN_ISDIR'],
+   ['IN_ISDIR', 'IN_DELETE'],
    '/tmp/tmprcjv466m',
    'aa'),
-  (_INOTIFY_EVENT(wd=2, mask=1024, cookie=0, len=0),
?                     ^

+  (_INOTIFY_EVENT(wd=3, mask=1024, cookie=0, len=0),
?                     ^

    ['IN_DELETE_SELF'],
    '/tmp/tmprcjv466m/bb',
    ''),
-  (_INOTIFY_EVENT(wd=2, mask=32768, cookie=0, len=0),
?                     ^

+  (_INOTIFY_EVENT(wd=3, mask=32768, cookie=0, len=0),
?                     ^

    ['IN_IGNORED'],
    '/tmp/tmprcjv466m/bb',
    ''),
   (_INOTIFY_EVENT(wd=1, mask=1073742336, cookie=0, len=16),
-   ['IN_DELETE', 'IN_ISDIR'],
+   ['IN_ISDIR', 'IN_DELETE'],
    '/tmp/tmprcjv466m',
    'bb')]
-------------------- >> begin captured logging << --------------------
inotify.adapters: DEBUG: Inotify handle is (3).
inotify.adapters: DEBUG: Adding initial watches on tree: [/tmp/tmprcjv466m]
inotify.adapters: DEBUG: Adding watch: [/tmp/tmprcjv466m]
inotify.adapters: DEBUG: Added watch (1): [/tmp/tmprcjv466m]
inotify.adapters: DEBUG: Adding watch: [/tmp/tmprcjv466m/bb]
inotify.adapters: DEBUG: Added watch (2): [/tmp/tmprcjv466m/bb]
inotify.adapters: DEBUG: Adding watch: [/tmp/tmprcjv466m/aa]
inotify.adapters: DEBUG: Added watch (3): [/tmp/tmprcjv466m/aa]
inotify.adapters: DEBUG: Events received from epoll: ['IN_ACCESS']
inotify.adapters: DEBUG: Events received in stream: ['IN_CREATE']
inotify.adapters: DEBUG: Events received in stream: ['IN_OPEN']
inotify.adapters: DEBUG: Events received in stream: ['IN_CLOSE_WRITE']
inotify.adapters: DEBUG: Events received in stream: ['IN_CREATE']
inotify.adapters: DEBUG: Events received in stream: ['IN_OPEN']
inotify.adapters: DEBUG: Events received in stream: ['IN_CLOSE_WRITE']
inotify.adapters: DEBUG: Events received in stream: ['IN_CREATE']
inotify.adapters: DEBUG: Events received in stream: ['IN_OPEN']
inotify.adapters: DEBUG: Events received in stream: ['IN_CLOSE_WRITE']
inotify.adapters: DEBUG: Events received in stream: ['IN_DELETE']
inotify.adapters: DEBUG: Events received in stream: ['IN_DELETE']
inotify.adapters: DEBUG: Events received in stream: ['IN_DELETE']
inotify.adapters: DEBUG: Events received in stream: ['IN_DELETE_SELF']
inotify.adapters: DEBUG: Events received in stream: ['IN_IGNORED']
inotify.adapters: DEBUG: Events received in stream: ['IN_DELETE', 'IN_ISDIR']
inotify.adapters: DEBUG: Events received in stream: ['IN_DELETE_SELF']
inotify.adapters: DEBUG: Events received in stream: ['IN_IGNORED']
inotify.adapters: DEBUG: Events received in stream: ['IN_DELETE', 'IN_ISDIR']
--------------------- >> end captured logging << ---------------------

======================================================================
FAIL: test__renames (tests.test_inotify.TestInotifyTree)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dale/Git/PyInotify/tests/test_inotify.py", line 235, in test__renames
    self.assertEquals(events1, expected)
AssertionError: Lists differ: [(_IN[52 chars], ['IN_CREATE', 'IN_ISDIR'], '/tmp/tmp6orzx4kp', 'old_folder')] != [(_IN[52 chars], ['IN_ISDIR', 'IN_CREATE'], '/tmp/tmp6orzx4kp', 'old_folder')]

First differing element 0:
(_INO[50 chars]), ['IN_CREATE', 'IN_ISDIR'], '/tmp/tmp6orzx4kp', 'old_folder')
(_INO[50 chars]), ['IN_ISDIR', 'IN_CREATE'], '/tmp/tmp6orzx4kp', 'old_folder')

  [(_INOTIFY_EVENT(wd=1, mask=1073742080, cookie=0, len=16),
-   ['IN_CREATE', 'IN_ISDIR'],
+   ['IN_ISDIR', 'IN_CREATE'],
    '/tmp/tmp6orzx4kp',
    'old_folder')]
-------------------- >> begin captured logging << --------------------
dwvisser commented 5 years ago

I suggest loosening the equality tests, to

  1. allow wd to differ, perhaps by no more than 1
  2. only require the type_names list to have the same elements, not have identical ordering

I'll create a pull request to this end.

dwvisser commented 5 years ago

I pushed a fix branch on my fork, but I'm closing this because whatever was causing the failures (consistently) yesterday is no longer affecting me‽