Fix race condition in test for *FileID functions
authorMichael Hanselmann <hansmi@google.com>
Wed, 30 Nov 2011 11:49:09 +0000 (12:49 +0100)
committerMichael Hanselmann <hansmi@google.com>
Wed, 30 Nov 2011 13:18:39 +0000 (14:18 +0100)
In this test the “file ID” of a temporary file is compared against the
file ID gathered via an open file descriptor to the same file. For
reasons unknown to me utime(2) is called in-between to update the
inode's a- and mtime. Depending on the file system's timestamp
resolution this can lead to a different file ID.

Found by chance during QA and reproduced by adding a delay before the
call to utime(2).

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

test/ganeti.utils.io_unittest.py

index 503ae18..a383203 100755 (executable)
@@ -383,7 +383,6 @@ class TestFileID(testutils.GanetiTestCase):
   def testUpdate(self):
     name = self._CreateTempFile()
     oldi = utils.GetFileID(path=name)
-    os.utime(name, None)
     fd = os.open(name, os.O_RDWR)
     try:
       newi = utils.GetFileID(fd=fd)