Esempio n. 1
0
    def runCheckTest(self):
        run_status = False
        self._printBegin('runCheckTest')
        if self.isTimeout:
            self.timeoutError = unittest.TestCase.failureException(
                "Test Timeout(%s sec). Consider increasing the value of '[TestingFramework]timeout' parameter in your test configuration file"
                % self.timeout)

        #if self.error is not None:

        checkTestCase = GPIPCheckTestCase(self.checkTest, "CheckTest",
                                          self.error, self.timeoutError)
        checkTestSuite = unittest.TestSuite([checkTestCase])

        test_extractor = apply_decorators(_full_extractor, [])

        for fixture in test_extractor(checkTestSuite):
            decorated_fixture = apply_decorators(fixture,
                                                 self.fixture_decorators)
            run_status = self.runner.run(decorated_fixture)

        if checkTestCase.runCheckError:
            self.runCheckError = checkTestCase.runCheckError

        if checkTestCase.errorTraceback:
            self.errorTraceback = checkTestCase.errorTraceback

        self.runner.done()
        self._printEnd('runCheckTest')
        return run_status
Esempio n. 2
0
    def runCheckTest(self):
        run_status = False
        self._printBegin('runCheckTest')
        if self.isTimeout:
            self.timeoutError = unittest.TestCase.failureException("Test Timeout(%s sec). Consider increasing the value of '[TestingFramework]timeout' parameter in your test configuration file" % self.timeout)

        #if self.error is not None:

        checkTestCase = GPIPCheckTestCase(self.checkTest, "CheckTest", self.error, self.timeoutError)
        checkTestSuite = unittest.TestSuite([checkTestCase])

        test_extractor = apply_decorators(_full_extractor, [])

        for fixture in test_extractor(checkTestSuite):
            decorated_fixture = apply_decorators(fixture, self.fixture_decorators)
            run_status = self.runner.run(decorated_fixture)

        if checkTestCase.runCheckError:
            self.runCheckError = checkTestCase.runCheckError

        if checkTestCase.errorTraceback:
            self.errorTraceback = checkTestCase.errorTraceback

        self.runner.done()
        self._printEnd('runCheckTest')
        return run_status
Esempio n. 3
0
    def run(self):
        """
                Execute file in a Ganga session
                """
        import time

        from pytf.testoob.running.fixture_decorators import BaseFixture
        fixture_decorators = [BaseFixture]

        test_extractor = apply_decorators(_full_extractor, [])

        runners_control = []

        failedTests = []

        start = time.time()

        # self.testsuite must be initialized in load()
        for fixture in test_extractor(self.testsuite):
            testName = fixture.method_name
            decorated_fixture = apply_decorators(fixture, fixture_decorators)
            runner = self._generate_runner(testName)
            runner_control = SimpleRunnerControl(testName, runner,
                                                 decorated_fixture,
                                                 fixture_decorators,
                                                 self.timeout)
            if runner_control is not None:
                runners_control.append(runner_control)

        for run_control in runners_control:
            run_status = run_control.runPreparationTestCase()
            if not run_status:
                run_control.setFinished(
                    True
                )  # Fail occurred while preparing the job, stop the test and write out the report.
                if run_control.preparationError:
                    failedTests.append([
                        "%s:%s" % (self.gpiptest_prefix, run_control.testName),
                        run_control.preparationError
                    ])
                else:
                    failedTests.append([
                        "%s:%s" % (self.gpiptest_prefix, run_control.testName),
                        'Failed in preparation somehow.'
                    ])

        all_done = False

        #start = time.time()

        duration = start - time.time()

        while not all_done and not (duration > self.timeout):
            all_done = True
            for run_control in runners_control:
                if not run_control.isReadyForCheck(
                ) and not run_control.isFinished():
                    all_done = False
            if not all_done:
                end = time.time()
                duration = end - start
            time.sleep(1)

        if duration > self.timeout:
            for run_control in runners_control:
                if not run_control.isReadyForCheck():
                    run_control.setTimeout(
                        True
                    )  # Mark the jobs which are still running with timeout 'True' flag.

        for run_control in runners_control:
            if not run_control.isFinished():
                if not run_control.runCheckTest():
                    if run_control.error:
                        failedTests.append([
                            "%s:%s" %
                            (self.gpiptest_prefix, run_control.testName),
                            run_control.errorTraceback
                        ])
                    elif run_control.timeoutError:
                        failedTests.append([
                            "%s:%s" %
                            (self.gpiptest_prefix, run_control.testName),
                            run_control.errorTraceback
                        ])
                    elif run_control.runCheckError:
                        failedTests.append([
                            "%s:%s" %
                            (self.gpiptest_prefix, run_control.testName),
                            run_control.errorTraceback
                        ])
                    else:
                        failedTests.append([
                            "%s:%s" %
                            (self.gpiptest_prefix, run_control.testName),
                            'Failed in running check test somehow.'
                        ])

        logger.info("[%d failed tests]" % len(failedTests))
        if len(failedTests) > 0:
            failedTestsException = FailedTestsException(failedTests)
            import traceback
            traceback.print_exc()
            raise failedTestsException
Esempio n. 4
0
    def run(self):
        """
                Execute file in a Ganga session
                """
        import time

        from pytf.testoob.running.fixture_decorators import BaseFixture

        fixture_decorators = [BaseFixture]

        test_extractor = apply_decorators(_full_extractor, [])

        runners_control = []

        failedTests = []

        start = time.time()

        # self.testsuite must be initialized in load()
        for fixture in test_extractor(self.testsuite):
            testName = fixture.method_name
            decorated_fixture = apply_decorators(fixture, fixture_decorators)
            runner = self._generate_runner(testName)
            runner_control = SimpleRunnerControl(testName, runner, decorated_fixture, fixture_decorators, self.timeout)
            if runner_control is not None:
                runners_control.append(runner_control)

        for run_control in runners_control:
            run_status = run_control.runPreparationTestCase()
            if not run_status:
                run_control.setFinished(
                    True
                )  # Fail occurred while preparing the job, stop the test and write out the report.
                if run_control.preparationError:
                    failedTests.append(
                        ["%s:%s" % (self.gpiptest_prefix, run_control.testName), run_control.preparationError]
                    )
                else:
                    failedTests.append(
                        ["%s:%s" % (self.gpiptest_prefix, run_control.testName), "Failed in preparation somehow."]
                    )

        all_done = False

        # start = time.time()

        duration = start - time.time()

        while not all_done and not (duration > self.timeout):
            all_done = True
            for run_control in runners_control:
                if not run_control.isReadyForCheck() and not run_control.isFinished():
                    all_done = False
            if not all_done:
                end = time.time()
                duration = end - start
            time.sleep(1)

        if duration > self.timeout:
            for run_control in runners_control:
                if not run_control.isReadyForCheck():
                    run_control.setTimeout(True)  # Mark the jobs which are still running with timeout 'True' flag.

        for run_control in runners_control:
            if not run_control.isFinished():
                if not run_control.runCheckTest():
                    if run_control.error:
                        failedTests.append(
                            ["%s:%s" % (self.gpiptest_prefix, run_control.testName), run_control.errorTraceback]
                        )
                    elif run_control.timeoutError:
                        failedTests.append(
                            ["%s:%s" % (self.gpiptest_prefix, run_control.testName), run_control.errorTraceback]
                        )
                    elif run_control.runCheckError:
                        failedTests.append(
                            ["%s:%s" % (self.gpiptest_prefix, run_control.testName), run_control.errorTraceback]
                        )
                    else:
                        failedTests.append(
                            [
                                "%s:%s" % (self.gpiptest_prefix, run_control.testName),
                                "Failed in running check test somehow.",
                            ]
                        )

        logger.info("[%d failed tests]" % len(failedTests))
        if len(failedTests) > 0:
            failedTestsException = FailedTestsException(failedTests)
            import traceback

            traceback.print_exc()
            raise failedTestsException