Example #1
0
 def stopTest(self, test):
     leaked_processes = self._child_processes() - self._start_processes
     if leaked_processes:
         info = [dict(pid=pid, cmdline=utils.getCmdArgs(pid))
                 for pid in leaked_processes]
         raise AssertionError("Test leaked child processes:\n" +
                              json.dumps(info, indent=4))
Example #2
0
 def test(self):
     args = [EXT_SLEEP, "4"]
     sproc = utils.execCmd(args, sync=False)
     try:
         self.assertEquals(utils.getCmdArgs(sproc.pid), tuple(args))
     finally:
         sproc.kill()
         sproc.wait()
Example #3
0
 def test(self):
     args = [EXT_SLEEP, "4"]
     sproc = utils.execCmd(args, sync=False)
     try:
         self.assertEquals(utils.getCmdArgs(sproc.pid), tuple(args))
     finally:
         sproc.kill()
         sproc.wait()
Example #4
0
 def stopTest(self, test):
     leaked_processes = self._child_processes() - self._start_processes
     if leaked_processes:
         info = [
             dict(pid=pid, cmdline=utils.getCmdArgs(pid))
             for pid in leaked_processes
         ]
         raise AssertionError("Test leaked child processes:\n" +
                              json.dumps(info, indent=4))
Example #5
0
    def __handleStuckUmount(cls, masterDir):
        umountPids = utils.pgrep("umount")
        try:
            masterMount = mount.getMountFromTarget(masterDir)
        except OSError as ex:
            if ex.errno == errno.ENOENT:
                return

            raise

        for umountPid in umountPids:
            try:
                state = utils.pidStat(umountPid).state
                mountPoint = utils.getCmdArgs(umountPid)[-1]
            except:
                # Process probably exited
                continue

            if mountPoint != masterDir:
                continue

            if state != "D":
                # If the umount is not in d state there
                # is a possibility that the world might
                # be in flux and umount will get stuck
                # in an unkillable state that is not D
                # which I don't know about, perhaps a
                # bug in umount will cause umount to
                # wait for something unrelated that is
                # not the syscall. Waiting on a process
                # which is not your child is race prone
                # I will just call for another umount
                # and wait for it to finish. That way I
                # know that a umount ended.
                try:
                    masterMount.umount()
                except mount.MountError:
                    # timeout! we are stuck again.
                    # if you are here spmprotect forgot to
                    # reboot the machine but in any case
                    # continue with the disconnection.
                    pass

            try:
                vgName = masterDir.rsplit("/", 2)[1]
                masterDev = os.path.join(
                    "/dev/mapper",
                    vgName.replace("-", "--") + "-" + MASTERLV)
            except KeyError:
                # Umount succeeded after all
                return

            cls.log.warn(
                "master mount resource is `%s`, trying to disconnect "
                "underlying storage", masterDev)
            iscsi.disconnectFromUndelyingStorage(masterDev)
Example #6
0
 def testZombie(self):
     args = [EXT_SLEEP, "0"]
     sproc = commands.execCmd(args, sync=False)
     sproc.kill()
     try:
         test = lambda: self.assertEquals(utils.getCmdArgs(sproc.pid),
                                          tuple())
         utils.retry(AssertionError, test, tries=10, sleep=0.1)
     finally:
         sproc.wait()
Example #7
0
 def testZombie(self):
     args = [EXT_SLEEP, "0"]
     sproc = utils.execCmd(args, sync=False)
     sproc.kill()
     try:
         test = lambda: self.assertEquals(utils.getCmdArgs(sproc.pid),
                                          tuple())
         utils.retry(AssertionError, test, tries=10, sleep=0.1)
     finally:
         sproc.wait()
Example #8
0
 def testZombie(self):
     args = [EXT_SLEEP, "0"]
     sproc = commands.start(args)
     sproc.kill()
     try:
         test = lambda: self.assertEqual(utils.getCmdArgs(sproc.pid), tuple(
         ))
         function.retry(AssertionError, test, tries=10, sleep=0.1)
     finally:
         sproc.wait()
Example #9
0
 def test(self):
     args = [EXT_SLEEP, "4"]
     sproc = utils.execCmd(args, sync=False)
     try:
         cmd_args = utils.getCmdArgs(sproc.pid)
         # let's ignore optional taskset at the beginning
         self.assertEquals(cmd_args[-len(args):], tuple(args))
     finally:
         sproc.kill()
         sproc.wait()
Example #10
0
 def test(self):
     args = [EXT_SLEEP, "4"]
     sproc = commands.start(args)
     try:
         cmd_args = utils.getCmdArgs(sproc.pid)
         # let's ignore optional taskset at the beginning
         self.assertEqual(cmd_args[-len(args):], tuple(args))
     finally:
         sproc.kill()
         sproc.wait()
Example #11
0
    def __handleStuckUmount(cls, masterDir):
        umountPids = utils.pgrep("umount")
        try:
            masterMount = mount.getMountFromTarget(masterDir)
        except OSError as ex:
            if ex.errno == errno.ENOENT:
                return

            raise

        for umountPid in umountPids:
            try:
                state = utils.pidStat(umountPid).state
                mountPoint = utils.getCmdArgs(umountPid)[-1]
            except:
                # Process probably exited
                continue

            if mountPoint != masterDir:
                continue

            if state != "D":
                # If the umount is not in d state there
                # is a possibility that the world might
                # be in flux and umount will get stuck
                # in an unkillable state that is not D
                # which I don't know about, perhaps a
                # bug in umount will cause umount to
                # wait for something unrelated that is
                # not the syscall. Waiting on a process
                # which is not your child is race prone
                # I will just call for another umount
                # and wait for it to finish. That way I
                # know that a umount ended.
                try:
                    masterMount.umount()
                except mount.MountError:
                    # timeout! we are stuck again.
                    # if you are here spmprotect forgot to
                    # reboot the machine but in any case
                    # continue with the disconnection.
                    pass

            try:
                vgName = masterDir.rsplit("/", 2)[1]
                masterDev = os.path.join(
                    "/dev/mapper", vgName.replace("-", "--") + "-" + MASTERLV)
            except KeyError:
                # Umount succeeded after all
                return

            cls.log.warn("master mount resource is `%s`, trying to disconnect "
                         "underlying storage", masterDev)
            iscsi.disconnectFromUndelyingStorage(masterDev)
Example #12
0
 def test(self):
     args = [EXT_SLEEP, "4"]
     sproc = commands.execCmd(args, sync=False)
     try:
         cmd_args = utils.getCmdArgs(sproc.pid)
         # let's ignore optional taskset at the beginning
         self.assertEquals(cmd_args[-len(args):],
                           tuple(args))
     finally:
         sproc.kill()
         sproc.wait()