Exemple #1
0
 def testRemountAndSetting(self):
     """
     Test remounting to a different location.
     """
     # Check that the setting for the mount location matches the current
     # mount and a file is reachable where we expect.
     setting = Setting().get(SettingKey.GIRDER_MOUNT_INFORMATION, None)
     self.assertEqual(setting['path'], self.mountPath)
     self.assertTrue(os.path.exists(os.path.join(self.mountPath, self.publicFileName)))
     self.assertFalse(os.path.exists(os.path.join(self.extraMountPath, self.publicFileName)))
     mount.unmountServer(self.mountPath)
     # After unmounting, the setting should be cleared (though perhaps not
     # instantly) and files shouldn't be reachable.
     endTime = time.time() + 10  # maximum time to wait
     while time.time() < endTime:
         setting = Setting().get(SettingKey.GIRDER_MOUNT_INFORMATION, None)
         if setting is None:
             break
         time.sleep(0.05)
     setting = Setting().get(SettingKey.GIRDER_MOUNT_INFORMATION, None)
     self.assertIsNone(setting)
     self.assertFalse(os.path.exists(os.path.join(self.mountPath, self.publicFileName)))
     self.assertFalse(os.path.exists(os.path.join(self.extraMountPath, self.publicFileName)))
     # Remounting to a different path should update the setting and make
     # files visible again.
     self._mountServer(path=self.extraMountPath)
     setting = Setting().get(SettingKey.GIRDER_MOUNT_INFORMATION, None)
     self.assertEqual(setting['path'], self.extraMountPath)
     self.assertFalse(os.path.exists(os.path.join(self.mountPath, self.publicFileName)))
     self.assertTrue(os.path.exists(os.path.join(self.extraMountPath, self.publicFileName)))
Exemple #2
0
 def testRemountAndSetting(self):
     """
     Test remounting to a different location.
     """
     # Check that the setting for the mount location matches the current
     # mount and a file is reachable where we expect.
     setting = Setting().get(SettingKey.GIRDER_MOUNT_INFORMATION, None)
     self.assertEqual(setting['path'], self.mountPath)
     self.assertTrue(os.path.exists(os.path.join(self.mountPath, self.publicFileName)))
     self.assertFalse(os.path.exists(os.path.join(self.extraMountPath, self.publicFileName)))
     mount.unmountServer(self.mountPath)
     # After unmounting, the setting should be cleared (though perhaps not
     # instantly) and files shouldn't be reachable.
     endTime = time.time() + 10  # maximum time to wait
     while time.time() < endTime:
         setting = Setting().get(SettingKey.GIRDER_MOUNT_INFORMATION, None)
         if setting is None:
             break
         time.sleep(0.05)
     setting = Setting().get(SettingKey.GIRDER_MOUNT_INFORMATION, None)
     self.assertIsNone(setting)
     self.assertFalse(os.path.exists(os.path.join(self.mountPath, self.publicFileName)))
     self.assertFalse(os.path.exists(os.path.join(self.extraMountPath, self.publicFileName)))
     # Remounting to a different path should update the setting and make
     # files visible again.
     self._mountServer(path=self.extraMountPath)
     setting = Setting().get(SettingKey.GIRDER_MOUNT_INFORMATION, None)
     self.assertEqual(setting['path'], self.extraMountPath)
     self.assertFalse(os.path.exists(os.path.join(self.mountPath, self.publicFileName)))
     self.assertTrue(os.path.exists(os.path.join(self.extraMountPath, self.publicFileName)))
Exemple #3
0
 def tearDown(self):
     super().tearDown()
     mount.unmountServer(self.mountPath, quiet=True)
     mount.unmountServer(self.extraMountPath, quiet=True)
     os.rmdir(self.mountPath)
     os.rmdir(self.extraMountPath)
     # Join threads that are done
     for thread in self._mountThreads:
         thread.join()
     self._mountThreads = []
Exemple #4
0
 def tearDown(self):
     super(ServerFuseTestCase, self).tearDown()
     mount.unmountServer(self.mountPath, quiet=True)
     mount.unmountServer(self.extraMountPath, quiet=True)
     os.rmdir(self.mountPath)
     os.rmdir(self.extraMountPath)
     # Join threads that are done
     for thread in self._mountThreads:
         thread.join()
     self._mountThreads = []
Exemple #5
0
 def testUnmountWithOpenFiles(self):
     """
     Unmounting with open files will return a non-zero value.
     """
     path = os.path.join(self.mountPath, self.publicFileName)
     fh = open(path)
     fh.read(1)
     self.assertNotEqual(mount.unmountServer(self.mountPath, quiet=True), 0)
     # We should still be able to read from the file.
     fh.read(1)
     fh.close()
     # Now we can unmount successefully
     self.assertEqual(mount.unmountServer(self.mountPath, quiet=True), 0)
Exemple #6
0
 def testUnmountWithOpenFiles(self):
     """
     Unmounting with open files will return a non-zero value.
     """
     path = os.path.join(self.mountPath, self.publicFileName)
     fh = open(path)
     fh.read(1)
     self.assertNotEqual(mount.unmountServer(self.mountPath, quiet=True), 0)
     # We should still be able to read from the file.
     fh.read(1)
     fh.close()
     # Now we can unmount successefully
     self.assertEqual(mount.unmountServer(self.mountPath, quiet=True), 0)
Exemple #7
0
 def testLazyUnmountWithOpenFiles(self):
     """
     Lazy unmounting with open files will return a non-zero value.
     """
     path = os.path.join(self.mountPath, self.publicFileName)
     fh = open(path)
     fh.read(1)
     self.assertEqual(mount.unmountServer(self.mountPath, lazy=True, quiet=True), 0)
     # We should still be able to read from the file.
     fh.read(1)
     fh.close()
     # If we wait, the mount will close
     endTime = time.time() + 10  # maximum time to wait
     while time.time() < endTime:
         if not os.path.exists(path):
             break
         time.sleep(0.05)
     self.assertFalse(os.path.exists(path))
Exemple #8
0
 def testLazyUnmountWithOpenFiles(self):
     """
     Lazy unmounting with open files will return a non-zero value.
     """
     path = os.path.join(self.mountPath, self.publicFileName)
     fh = open(path)
     fh.read(1)
     self.assertEqual(mount.unmountServer(self.mountPath, lazy=True, quiet=True), 0)
     # We should still be able to read from the file.
     fh.read(1)
     fh.close()
     # If we wait, the mount will close
     endTime = time.time() + 10  # maximum time to wait
     while time.time() < endTime:
         if not os.path.exists(path):
             break
         time.sleep(0.05)
     self.assertFalse(os.path.exists(path))