Exemple #1
0
    def _test_progress(self):
        cmd = os.path.join(self.scriptDir, 'test.sh')
        LOG.debug('cmd = %s' % cmd)

        testExec = ExecThread(self.threadMgr, cmd)
        testExec.setTimeout(30)
        testExec.setProgressTimeout(10)

        testExec.start()

        # make sure the script is running
        tm = time.time()
        while (testExec.getCmdPid() == None and tm + 10 > time.time()):
            time.sleep(0.1)

        assert testExec.getCmdPid() != None
        print '****** cmd pid = %d' % testExec.getCmdPid()

        progress = 10
        # check that we increment the progress to 100
        tm = time.time()
        while (progress < 101 and tm + 5 > time.time()):
            LOG.debug('progress == %s: %s' %
                      (str(testExec.getStatus()['progress']), str(progress)))
            if (int(testExec.getStatus()['progress']) == int(progress)):
                LOG.debug('sending sigint')
                try:
                    #The script itself traps the signal in increments its progress.
                    os.kill(testExec.getCmdPid(), signal.SIGINT)
                except OSError:
                    pass

                progress += 10
            time.sleep(0.05)

        self.printStatus(testExec.getStatus())
        if (not os.name == 'nt'):
            assert int(testExec.getStatus()['progress']) == 100
Exemple #2
0
    def test_nonending_script(self):
        cmd = os.path.join(self.scriptDir, 'test.sh')
        LOG.debug('cmd = %s' % cmd)

        testExec = ExecThread(self.threadMgr, cmd)
        testExec.setTimeout(1)
        testExec.setProgressTimeout(10)
        testExec.start()

        # make sure the script is running
        tm = time.time()
        while (testExec.getCmdPid() == None and tm + 15 > time.time()):
            pass
        assert testExec.getCmdPid() != None

        tm = time.time()
        while (int(testExec.getStatus()['httpStatus']) != 500 and tm + 20 > time.time()):
            pass

        self.printStatus(testExec.getStatus())

        assert int(testExec.getStatus()['httpStatus']) == 500
        assert testExec.getStatus()['error'] == Errors.AGENT_THREAD_TIMEDOUT
Exemple #3
0
    def _test_progress(self):
        cmd = os.path.join(self.scriptDir, 'test.sh')
        LOG.debug('cmd = %s' % cmd)

        testExec = ExecThread(self.threadMgr, cmd)
        testExec.setTimeout(30)
        testExec.setProgressTimeout(10)

        testExec.start()

        # make sure the script is running
        tm = time.time()
        while (testExec.getCmdPid() == None and tm + 10 > time.time()):
            time.sleep(0.1)

        assert testExec.getCmdPid() != None
        print '****** cmd pid = %d' % testExec.getCmdPid()

        progress = 10
        # check that we increment the progress to 100
        tm = time.time()
        while (progress < 101 and tm + 5 > time.time()):
            LOG.debug('progress == %s: %s' % (str(testExec.getStatus()['progress']), str(progress)))
            if (int(testExec.getStatus()['progress']) == int(progress)):
                LOG.debug('sending sigint')
                try:
                    #The script itself traps the signal in increments its progress.
                    os.kill(testExec.getCmdPid(), signal.SIGINT)
                except OSError:
                    pass

                progress += 10
            time.sleep(0.05)

        self.printStatus(testExec.getStatus())
        if (not os.name == 'nt'):
            assert int(testExec.getStatus()['progress']) == 100
Exemple #4
0
    def test_nonending_script(self):
        cmd = os.path.join(self.scriptDir, 'test.sh')
        LOG.debug('cmd = %s' % cmd)

        testExec = ExecThread(self.threadMgr, cmd)
        testExec.setTimeout(1)
        testExec.setProgressTimeout(10)
        testExec.start()

        # make sure the script is running
        tm = time.time()
        while (testExec.getCmdPid() == None and tm + 15 > time.time()):
            pass
        assert testExec.getCmdPid() != None

        tm = time.time()
        while (int(testExec.getStatus()['httpStatus']) != 500
               and tm + 20 > time.time()):
            pass

        self.printStatus(testExec.getStatus())

        assert int(testExec.getStatus()['httpStatus']) == 500
        assert testExec.getStatus()['error'] == Errors.AGENT_THREAD_TIMEDOUT