Beispiel #1
0
 def run(self):
     """Run a test in loop."""
     while (self.thread_signaller.running()):
         test_result = unittest.TestResult()
         self.test.clearContext()
         self.test(test_result)
         if test_result.wasSuccessful():
             if recording():
                 add_cycle_result('success')
                 if self.color:
                     trace(green_str('.'))
                 else:
                     trace('.')
         else:
             if len(test_result.errors):
                 if recording():
                     add_cycle_result('error')
                 if self.color:
                     trace(red_str('E'))
                 else:
                     trace('E')
             else:
                 if recording():
                     add_cycle_result('failure')
                 if self.color:
                     trace(red_str('F'))
                 else:
                     trace('F')
             if self.debug:
                 for (test, error) in test_result.errors:
                     trace("ERROR %s: %s" % (str(test), str(error)))
                 for (test, error) in test_result.failures:
                     trace("FAILURE %s: %s" % (str(test), str(error)))
         thread_sleep(self.sleep_time)
Beispiel #2
0
 def run(self):
     """Run a test in loop."""
     while (self.thread_signaller.running()):
         test_result = unittest.TestResult()
         self.test.clearContext()
         self.test(test_result)
         if test_result.wasSuccessful():
             if recording():
                 add_cycle_result('success')
                 if self.color:
                     trace(green_str('.'))
                 else:
                     trace('.')
         else:
             if len(test_result.errors):
                 if recording():
                     add_cycle_result('error')
                 if self.color:
                     trace(red_str('E'))
                 else:
                     trace('E')
             else:
                 if recording():
                     add_cycle_result('failure')
                 if self.color:
                     trace(red_str('F'))
                 else:
                     trace('F')
             if self.debug:
                 for (test, error) in test_result.errors:
                     trace("ERROR %s: %s" % (str(test), str(error)))
                 for (test, error) in test_result.failures:
                     trace("FAILURE %s: %s" % (str(test), str(error)))
         thread_sleep(self.sleep_time)
Beispiel #3
0
    def run(self):
        """Run a test in loop."""
        while (self.thread_signaller.running()):
            test_result = unittest.TestResult()
            self.test.clearContext()
            self.test(test_result)
            feedback = {}

            if test_result.wasSuccessful():
                if recording():
                    feedback['count'] = add_cycle_result('success')

                if self.color:
                    trace(green_str('.'))
                else:
                    trace('.')

                feedback['result'] = 'success'
            else:
                if len(test_result.errors):
                    if recording():
                        feedback['count'] = add_cycle_result('error')

                    if self.color:
                        trace(red_str('E'))
                    else:
                        trace('E')

                    feedback['result'] = 'error'

                else:
                    if recording():
                        feedback['count'] = add_cycle_result('failure')

                    if self.color:
                        trace(red_str('F'))
                    else:
                        trace('F')

                    feedback['result'] = 'failure'

                if self.debug:
                    feedback['errors'] = test_result.errors
                    feedback['failures'] = test_result.failures

                    for (test, error) in test_result.errors:
                        trace("ERROR %s: %s" % (str(test), str(error)))
                    for (test, error) in test_result.failures:
                        trace("FAILURE %s: %s" % (str(test), str(error)))

            if self.feedback is not None:
                self.feedback.test_done(feedback)

            thread_sleep(self.sleep_time)
Beispiel #4
0
    def run(self):
        """Run a test in loop."""
        while (self.thread_signaller.running()):
            test_result = unittest.TestResult()
            self.test.clearContext()
            self.test(test_result)
            feedback = {}

            if test_result.wasSuccessful():
                if recording():
                    feedback['count'] = add_cycle_result('success')

                if self.color:
                    trace(green_str('.'))
                else:
                    trace('.')

                feedback['result'] = 'success'
            else:
                if len(test_result.errors):
                    if recording():
                        feedback['count'] = add_cycle_result('error')

                    if self.color:
                        trace(red_str('E'))
                    else:
                        trace('E')

                    feedback['result'] = 'error'

                else:
                    if recording():
                        feedback['count'] = add_cycle_result('failure')

                    if self.color:
                        trace(red_str('F'))
                    else:
                        trace('F')

                    feedback['result'] = 'failure'

                if self.debug:
                    feedback['errors'] = test_result.errors
                    feedback['failures'] = test_result.failures

                    for (test, error) in test_result.errors:
                        trace("ERROR %s: %s" % (str(test), str(error)))
                    for (test, error) in test_result.failures:
                        trace("FAILURE %s: %s" % (str(test), str(error)))

            if self.feedback is not None:
                self.feedback.test_done(feedback)

            thread_sleep(self.sleep_time)
Beispiel #5
0
    def run(self):
        """Run a test in loop."""
        while self.thread_signaller.running():
            test_result = unittest.TestResult()
            self.test.clearContext()
            self.test(test_result)
            feedback = {}

            if test_result.wasSuccessful():
                if recording():
                    feedback["count"] = add_cycle_result("success")

                if self.color:
                    trace(green_str("."))
                else:
                    trace(".")

                feedback["result"] = "success"
            else:
                if len(test_result.errors):
                    if recording():
                        feedback["count"] = add_cycle_result("error")

                    if self.color:
                        trace(red_str("E"))
                    else:
                        trace("E")

                    feedback["result"] = "error"

                else:
                    if recording():
                        feedback["count"] = add_cycle_result("failure")

                    if self.color:
                        trace(red_str("F"))
                    else:
                        trace("F")

                    feedback["result"] = "failure"

                if self.debug:
                    feedback["errors"] = test_result.errors
                    feedback["failures"] = test_result.failures

                    for (test, error) in test_result.errors:
                        trace("ERROR %s: %s" % (str(test), str(error)))
                    for (test, error) in test_result.failures:
                        trace("FAILURE %s: %s" % (str(test), str(error)))

            if self.feedback is not None:
                self.feedback.test_done(feedback)

            thread_sleep(self.sleep_time)
Beispiel #6
0
 def printErrorList(self, flavour, errors):
     for test, err in errors:
         self.stream.writeln(self.separator1)
         self.stream.writeln("%s: %s" %
                             (red_str(flavour), self.getDescription(test)))
         self.stream.writeln(self.separator2)
         self.stream.writeln("%s" % err)
Beispiel #7
0
 def run(self, test):
     "Run the given test case or test suite."
     result = self._makeResult()
     startTime = time.time()
     test(result)
     stopTime = time.time()
     timeTaken = float(stopTime - startTime)
     result.printErrors()
     self.stream.writeln(result.separator2)
     run = result.testsRun
     self.stream.writeln("Ran %d test%s in %.3fs" %
                         (run, run != 1 and "s" or "", timeTaken))
     self.stream.writeln()
     if not result.wasSuccessful():
         self.stream.write(red_str("FAILED") + " (")
         failed, errored = map(len, (result.failures, result.errors))
         if failed:
             self.stream.write("failures=%d" % failed)
         if errored:
             if failed: self.stream.write(", ")
             self.stream.write("errors=%d" % errored)
         self.stream.writeln(")")
     else:
         self.stream.writeln(green_str("OK"))
     return result
Beispiel #8
0
 def run(self, test):
     "Run the given test case or test suite."
     result = self._makeResult()
     startTime = time.time()
     test(result)
     stopTime = time.time()
     timeTaken = float(stopTime - startTime)
     result.printErrors()
     self.stream.writeln(result.separator2)
     run = result.testsRun
     self.stream.writeln("Ran %d test%s in %.3fs" % (run, run != 1 and "s" or "", timeTaken))
     self.stream.writeln()
     if not result.wasSuccessful():
         self.stream.write(red_str("FAILED") + " (")
         failed, errored = map(len, (result.failures, result.errors))
         if failed:
             self.stream.write("failures=%d" % failed)
         if errored:
             if failed:
                 self.stream.write(", ")
             self.stream.write("errors=%d" % errored)
         self.stream.writeln(")")
     else:
         self.stream.writeln(green_str("OK"))
     return result
Beispiel #9
0
 def printErrorList(self, flavour, errors):
     for test, err in errors:
         self.stream.writeln(self.separator1)
         self.stream.writeln("%s: %s" % (red_str(flavour),
                                         self.getDescription(test)))
         self.stream.writeln(self.separator2)
         self.stream.writeln("%s" % err)
Beispiel #10
0
def get_status(success, failures, errors, color=False):
    """Return a status and an exit code."""
    if errors:
        status = 'ERROR'
        if color:
            status = red_str(status)
        code = -1
    elif failures:
        status = 'FAILURE'
        if color:
            status = red_str(status)
        code = 1
    else:
        status = 'SUCCESSFUL'
        if color:
            status = green_str(status)
        code = 0
    return status, code
Beispiel #11
0
def get_status(success, failures, errors, color=False):
    """Return a status and an exit code."""
    if errors:
        status = 'ERROR'
        if color:
            status = red_str(status)
        code = -1
    elif failures:
        status = 'FAILURE'
        if color:
            status = red_str(status)
        code = 1
    else:
        status = 'SUCCESSFUL'
        if color:
            status = green_str(status)
        code = 0
    return status, code
Beispiel #12
0
def run_distributed(options, module_name, class_name, method_name, sys_args):
    ret = None
    from funkload.Distributed import DistributionMgr
    global _manager

    try:
        distmgr = DistributionMgr(module_name, class_name, method_name,
                                  options, sys_args)
        _manager = distmgr
    except UserWarning, error:
        trace(red_str("Distribution failed with:%s \n" % (error)))
        return 1
Beispiel #13
0
def run_distributed(options, module_name, class_name, method_name, sys_args):
    ret = None
    from funkload.Distributed import DistributionMgr
    global _manager
    
    try:
        distmgr = DistributionMgr(
            module_name, class_name, method_name, options, sys_args)
        _manager = distmgr
    except UserWarning, error:
        trace(red_str("Distribution failed with:%s \n" % (error)))
        return 1
Beispiel #14
0
    def loadTestsFromTestCase(self, testCaseClass):
        if not issubclass(testCaseClass, FunkLoadTestCase):
            trace(red_str("Skipping "+ testCaseClass))
            return []
        testCaseNames = self.getTestCaseNames(testCaseClass)
        if not testCaseNames and hasattr(testCaseClass, 'runTest'):
            testCaseNames = ['runTest']

        return [dict(module_name = testCaseClass.__module__,
                     class_name = testCaseClass.__name__,
                     method_name = x)
                for x in testCaseNames]
Beispiel #15
0
    def loadTestsFromTestCase(self, testCaseClass):
        if not issubclass(testCaseClass, FunkLoadTestCase):
            trace(red_str("Skipping " + testCaseClass))
            return []
        testCaseNames = self.getTestCaseNames(testCaseClass)
        if not testCaseNames and hasattr(testCaseClass, 'runTest'):
            testCaseNames = ['runTest']

        return [
            dict(module_name=testCaseClass.__module__,
                 class_name=testCaseClass.__name__,
                 method_name=x) for x in testCaseNames
        ]
Beispiel #16
0
 def addError(self, test, err):
     unittest.TestResult.addError(self, test, err)
     if self.showAll:
         self.stream.writeln(red_str("ERROR"))
     elif self.dots:
         self.stream.write(red_str('E'))
Beispiel #17
0
def main(args=sys.argv[1:]):
    """Default main."""
    # enable to load module in the current path
    cur_path = os.path.abspath(os.path.curdir)
    sys.path.insert(0, cur_path)

    parser = OptionParser(USAGE, formatter=TitledHelpFormatter(),
                          version="FunkLoad %s" % get_version())
    parser.add_option("", "--config",
                      type="string",
                      dest="config",
                      metavar='CONFIG',
                      help="Path to alternative config file")
    parser.add_option("-u", "--url",
                      type="string",
                      dest="main_url",
                      help="Base URL to bench.")
    parser.add_option("-c", "--cycles",
                      type="string",
                      dest="bench_cycles",
                      help="Cycles to bench, colon-separated list of "
                           "virtual concurrent users. To run a bench with 3 "
                           "cycles of 5, 10 and 20 users, use: -c 5:10:20")
    parser.add_option("-D", "--duration",
                      type="string",
                      dest="bench_duration",
                      help="Duration of a cycle in seconds.")
    parser.add_option("-m", "--sleep-time-min",
                      type="string",
                      dest="bench_sleep_time_min",
                      help="Minimum sleep time between requests.")
    parser.add_option("-M", "--sleep-time-max",
                      type="string",
                      dest="bench_sleep_time_max",
                      help="Maximum sleep time between requests.")
    parser.add_option("-t", "--test-sleep-time",
                      type="string",
                      dest="bench_sleep_time",
                      help="Sleep time between tests.")
    parser.add_option("-s", "--startup-delay",
                      type="string",
                      dest="bench_startup_delay",
                      help="Startup delay between thread.")
    parser.add_option("-f", "--as-fast-as-possible",
                      action="store_true",
                      help="Remove sleep times between requests and between "
                           "tests, shortcut for -m0 -M0 -t0")
    parser.add_option("", "--no-color",
                      action="store_true",
                      help="Monochrome output.")
    parser.add_option("", "--accept-invalid-links",
                      action="store_true",
                      help="Do not fail if css/image links are not reachable.")
    parser.add_option("", "--simple-fetch",
                      action="store_true",
                      dest="bench_simple_fetch",
                      help="Don't load additional links like css or images "
                           "when fetching an html page.")
    parser.add_option("-l", "--label",
                      type="string",
                      help="Add a label to this bench run for easier "
                           "identification (it will be appended to the "
                           "directory name for reports generated from it).")
    parser.add_option("--enable-debug-server",
                      action="store_true",
                      dest="debugserver",
                      help="Instantiates a debug HTTP server which exposes an "
                           "interface using which parameters can be modified "
                           "at run-time. Currently supported parameters: "
                           "/cvu?inc=<integer> to increase the number of "
                           "CVUs, /cvu?dec=<integer> to decrease the number "
                           "of CVUs, /getcvu returns number of CVUs ")
    parser.add_option("--debug-server-port",
                      type="string",
                      dest="debugport",
                      help="Port at which debug server should run during the "
                           "test")
    parser.add_option("--distribute",
                      action="store_true",
                      dest="distribute",
                      help="Distributes the CVUs over a group of worker "
                           "machines that are defined in the workers section")
    parser.add_option("--distribute-workers",
                      type="string",
                      dest="workerlist",
                      help="This parameter will  over-ride the list of "
                           "workers defined in the config file. expected "
                           "notation is uname@host,uname:pwd@host or just "
                           "host...")
    parser.add_option("--distribute-python",
                      type="string",
                      dest="python_bin",
                      help="When running in distributed mode, this Python "
                           "binary will be used across all hosts.")
    parser.add_option("--is-distributed",
                      action="store_true",
                      dest="is_distributed",
                      help="This parameter is for internal use only. it "
                           "signals to a worker node that it is in "
                           "distributed mode and shouldn't perform certain "
                           "actions.")
    parser.add_option("--distributed-packages",
                      type="string",
                      dest="distributed_packages",
                      help="Additional packages to be passed to easy_install "
                           "on remote machines when being run in distributed "
                           "mode.")
    parser.add_option("--distributed-log-path",
                      type="string",
                      dest="distributed_log_path",
                      help="Path where all the logs will be stored when "
                           "running a distributed test")

    # XXX What exactly is this checking for here??
    cmd_args = " ".join([k for k in args
                           if k.find('--distribute') < 0])

    options, args = parser.parse_args(args)

    if len(args) != 2:
        parser.error("incorrect number of arguments")

    if not args[1].count('.'):
        parser.error("invalid argument; should be [class].[method]")

    if options.as_fast_as_possible:
        options.bench_sleep_time_min = '0'
        options.bench_sleep_time_max = '0'
        options.bench_sleep_time = '0'

    if os.path.exists(args[0]):
        # We were passed a file for the first argument
        module_name = os.path.basename(os.path.splitext(args[0])[0])
    else:
        # We were passed a module name
        module_name = args[0]

    # registering signals
    signal.signal(signal.SIGTERM, shutdown)
    signal.signal(signal.SIGINT, shutdown)
    signal.signal(signal.SIGQUIT, shutdown)

    klass, method = args[1].split('.')
    if options.distribute:
        from Distributed import DistributionMgr
        ret = None
        global _manager

        try:
            distmgr = DistributionMgr(
                module_name, klass, method, options, cmd_args)
            _manager = distmgr
        except UserWarning, error:
            trace(red_str("Distribution failed with:%s \n" % (error)))

        try:
            try:
                distmgr.prepare_workers(allow_errors=True)
                ret = distmgr.run()
                distmgr.final_collect()
            except KeyboardInterrupt:
                trace("* ^C received *")
        finally:
            # in any case we want to stop the workers at the end
            distmgr.abort()

        _manager = None
        return ret
Beispiel #18
0
 def write(self, arg):
     if arg in ['OK', 'Ok', 'ok', '.']:
         arg = green_str(arg)
     elif arg in ['ERROR', 'E', 'FAILED', 'FAIL', 'F']:
         arg = red_str(arg)
     sys.stderr.write(arg)
Beispiel #19
0
def main():
    """Default main."""
    # enable to load module in the current path
    cur_path = os.path.abspath(os.path.curdir)
    sys.path.insert(0, cur_path)

    parser = OptionParser(USAGE, formatter=TitledHelpFormatter(),
                          version="FunkLoad %s" % get_version())
    parser.add_option("-u", "--url", type="string", dest="main_url",
                      help="Base URL to bench.")
    parser.add_option("-c", "--cycles", type="string", dest="bench_cycles",
                      help="Cycles to bench, this is a list of number of "
                      "virtual concurrent users, "
                      "to run a bench with 3 cycles with 5, 10 and 20 "
                      "users use: -c 2:10:20")
    parser.add_option("-D", "--duration", type="string", dest="bench_duration",
                      help="Duration of a cycle in seconds.")
    parser.add_option("-m", "--sleep-time-min", type="string",
                      dest="bench_sleep_time_min",
                      help="Minimum sleep time between requests.")
    parser.add_option("-M", "--sleep-time-max", type="string",
                      dest="bench_sleep_time_max",
                      help="Maximum sleep time between requests.")
    parser.add_option("-t", "--test-sleep-time", type="string",
                      dest="bench_sleep_time",
                      help="Sleep time between tests.")
    parser.add_option("-s", "--startup-delay", type="string",
                      dest="bench_startup_delay",
                      help="Startup delay between thread.")
    parser.add_option("-f", "--as-fast-as-possible", action="store_true",
                      help="Remove sleep times between requests and"
                      " between tests, shortcut for -m0 -M0 -t0")
    parser.add_option("", "--no-color", action="store_true",
                      help="Monochrome output.")
    parser.add_option("", "--accept-invalid-links", action="store_true",
                      help="Do not fail if css/image links are "
                      "not reachable.")
    parser.add_option("", "--simple-fetch", action="store_true",
                      dest="bench_simple_fetch",
                      help="Don't load additional links like css "
                      "or images when fetching an html page.")
    parser.add_option("-l", "--label", type="string",
                      help="Add a label to this bench run "
                      "for easier identification (it will be appended to the directory name "
                      "for reports generated from it).")
    parser.add_option("", "--enable-debug-server", action="store_true", dest="debugserver",
                      help="Instantiates a debug HTTP server which exposes an "
                      "interface using which parameters can be modified at "
                      "run-time. Currently supported parameters: "
                      "/cvu?inc=<integer> to increase the number of CVUs, "
                      "/cvu?dec=<integer> to decrease the number of CVUs, "
                      "/getcvu returns number of CVUs ")
    parser.add_option("", "--debug-server-port", type="string", dest="debugport",
                      help="Port at which debug server should run during the test")
    
    parser.add_option("","--distribute", action="store_true", dest="distribute",
                      help="Distributes the CVUs over a group of worker machines "
                      "that are defined in the section [workers]")
    parser.add_option("","--distribute-workers", type="string", dest="workerlist",
                      help="This parameter will  over-ride the list of workers defined "
                      "in the config file. expected notation is uname@host,uname:pwd@host or just host...") 
    parser.add_option("","--is-distributed", action="store_true", dest="is_distributed",
                      help="This parameter is for internal use only. it signals to a "
                      "worker node that it is in distributed mode and shouldn't "
                      "perform certain actions.")

    options, args = parser.parse_args()
    cmd_args = " ".join([k for k in sys.argv[1:] if k.find('--distribute')<0])
    if len(args) != 2:
        parser.error("incorrect number of arguments")
    if not args[1].count('.'):
        parser.error("invalid argument should be class.method")
    if options.as_fast_as_possible:
        options.bench_sleep_time_min = '0'
        options.bench_sleep_time_max = '0'
        options.bench_sleep_time = '0'
    klass, method = args[1].split('.')
    if options.distribute:
        from Distributed import DistributionMgr
        ret = None
        try:
            distmgr = DistributionMgr( args[0] , klass, method, options, cmd_args )     
            try:
                distmgr.prepare_workers(allow_errors = True)
                ret = distmgr.run()
                distmgr.final_collect()
            except KeyboardInterrupt:
                trace("* ^C received *")
                distmgr.abort()
        except UserWarning,error:
            trace(red_str("Distribution failed with:%s \n" % (error)))
        sys.exit(ret)
Beispiel #20
0
 def printErrorList(self, flavour, errors):
     flavour = red_str(flavour)
     super(_ColoredTextTestResult, self).printErrorList(flavour, errors)
Beispiel #21
0
 def write(self, arg):
     if arg in ['OK', 'Ok', 'ok', '.']:
         arg = green_str(arg)
     elif arg in ['ERROR', 'E', 'FAILED', 'FAIL', 'F']:
         arg = red_str(arg)
     sys.stderr.write(arg)
Beispiel #22
0
 def printErrorList(self, flavour, errors):
     flavour = red_str(flavour)
     super(_ColoredTextTestResult, self).printErrorList(flavour, errors)
Beispiel #23
0
 def addFailure(self, test, err):
     unittest.TestResult.addFailure(self, test, err)
     if self.showAll:
         self.stream.writeln(red_str("FAIL"))
     elif self.dots:
         self.stream.write(red_str("F"))
Beispiel #24
0
 def addError(self, test, err):
     unittest.TestResult.addError(self, test, err)
     if self.showAll:
         self.stream.writeln(red_str("ERROR"))
     elif self.dots:
         self.stream.write(red_str("E"))
Beispiel #25
0
def main():
    """Default main."""
    # enable to load module in the current path
    cur_path = os.path.abspath(os.path.curdir)
    sys.path.insert(0, cur_path)

    parser = OptionParser(USAGE,
                          formatter=TitledHelpFormatter(),
                          version="FunkLoad %s" % get_version())
    parser.add_option("-u",
                      "--url",
                      type="string",
                      dest="main_url",
                      help="Base URL to bench.")
    parser.add_option("-c",
                      "--cycles",
                      type="string",
                      dest="bench_cycles",
                      help="Cycles to bench, this is a list of number of "
                      "virtual concurrent users, to run a bench with 3"
                      "cycles with 5, 10 and 20 users use: -c 2:10:20")
    parser.add_option("-D",
                      "--duration",
                      type="string",
                      dest="bench_duration",
                      help="Duration of a cycle in seconds.")
    parser.add_option("-m",
                      "--sleep-time-min",
                      type="string",
                      dest="bench_sleep_time_min",
                      help="Minimum sleep time between requests.")
    parser.add_option("-M",
                      "--sleep-time-max",
                      type="string",
                      dest="bench_sleep_time_max",
                      help="Maximum sleep time between requests.")
    parser.add_option("-t",
                      "--test-sleep-time",
                      type="string",
                      dest="bench_sleep_time",
                      help="Sleep time between tests.")
    parser.add_option("-s",
                      "--startup-delay",
                      type="string",
                      dest="bench_startup_delay",
                      help="Startup delay between thread.")
    parser.add_option("-f",
                      "--as-fast-as-possible",
                      action="store_true",
                      help="Remove sleep times between requests and between "
                      "tests, shortcut for -m0 -M0 -t0")
    parser.add_option("",
                      "--no-color",
                      action="store_true",
                      help="Monochrome output.")
    parser.add_option("",
                      "--accept-invalid-links",
                      action="store_true",
                      help="Do not fail if css/image links are not reachable.")
    parser.add_option("",
                      "--simple-fetch",
                      action="store_true",
                      dest="bench_simple_fetch",
                      help="Don't load additional links like css or images "
                      "when fetching an html page.")
    parser.add_option("-l",
                      "--label",
                      type="string",
                      help="Add a label to this bench run for easier "
                      "identification (it will be appended to the "
                      "directory name for reports generated from it).")
    parser.add_option("--enable-debug-server",
                      action="store_true",
                      dest="debugserver",
                      help="Instantiates a debug HTTP server which exposes an "
                      "interface using which parameters can be modified "
                      "at run-time. Currently supported parameters: "
                      "/cvu?inc=<integer> to increase the number of "
                      "CVUs, /cvu?dec=<integer> to decrease the number "
                      "of CVUs, /getcvu returns number of CVUs ")
    parser.add_option("--debug-server-port",
                      type="string",
                      dest="debugport",
                      help="Port at which debug server should run during the "
                      "test")
    parser.add_option("--distribute",
                      action="store_true",
                      dest="distribute",
                      help="Distributes the CVUs over a group of worker "
                      "machines that are defined in the workers section")
    parser.add_option("--distribute-workers",
                      type="string",
                      dest="workerlist",
                      help="This parameter will  over-ride the list of "
                      "workers defined in the config file. expected "
                      "notation is uname@host,uname:pwd@host or just "
                      "host...")
    parser.add_option("--distribute-python",
                      type="string",
                      dest="python_bin",
                      help="When running in distributed mode, this Python "
                      "binary will be used across all hosts.")
    parser.add_option("--is-distributed",
                      action="store_true",
                      dest="is_distributed",
                      help="This parameter is for internal use only. it "
                      "signals to a worker node that it is in "
                      "distributed mode and shouldn't perform certain "
                      "actions.")
    parser.add_option("--distributed-packages",
                      type="string",
                      dest="distributed_packages",
                      help="Additional packages to be passed to easy_install "
                      "on remote machines when being run in distributed "
                      "mode.")

    options, args = parser.parse_args()
    # XXX What exactly is this checking for here??
    cmd_args = " ".join(
        [k for k in sys.argv[1:] if k.find('--distribute') < 0])

    if len(args) != 2:
        parser.error("incorrect number of arguments")

    if not args[1].count('.'):
        parser.error("invalid argument; should be [class].[method]")

    if options.as_fast_as_possible:
        options.bench_sleep_time_min = '0'
        options.bench_sleep_time_max = '0'
        options.bench_sleep_time = '0'

    klass, method = args[1].split('.')
    if options.distribute:
        from Distributed import DistributionMgr
        ret = None
        try:
            distmgr = DistributionMgr(args[0], klass, method, options,
                                      cmd_args)
        except UserWarning, error:
            trace(red_str("Distribution failed with:%s \n" % (error)))

        try:
            distmgr.prepare_workers(allow_errors=True)
            ret = distmgr.run()
            distmgr.final_collect()
        except KeyboardInterrupt:
            trace("* ^C received *")
            distmgr.abort()

        sys.exit(ret)
Beispiel #26
0
 def addFailure(self, test, err):
     unittest.TestResult.addFailure(self, test, err)
     if self.showAll:
         self.stream.writeln(red_str("FAIL"))
     elif self.dots:
         self.stream.write(red_str('F'))