示例#1
0
def call_main(args):
    # Get output directory.
    try:
        if args.output_dir is not None:
            runtime.set_output_dir(args.output_dir)
    except ValueError as e:
        print str(e)
        raise

    # Set up logging.
    setup_logging(runtime.get_output_dir(), args.log_level, args.console_level)
    logger = logging.getLogger("zopkio")
    logger.info("Starting zopkio")

    try:
        utils.check_file_with_exception(args.testfile)
        utils.check_testfile_dir_structure(args.testfile)
        machines = utils.make_machine_mapping(args.machine_list)
        config_overrides = utils.parse_config_list(args.config_overrides)
    except ValueError as e:
        logger.error(str(e))
        print("Error in processing command line arguments:\n {0}".format(
            traceback.format_exc()))
        raise

    runtime.set_machines(machines)
    if args.user is not None:
        user = args.user
    else:
        user = getpass.getuser()
    if args.nopassword:
        password = ""
    else:
        password = getpass.getpass()
    runtime.set_user(user, password)

    try:
        testmodule = utils.load_module(args.testfile)
        ztestsuites = [
            getattr(testmodule, attr) for attr in dir(testmodule)
            if isinstance(getattr(testmodule, attr), ZTestSuite)
        ]
        if len(
                ztestsuites
        ) > 0:  #TODO(jehrlich) intelligently handle multiple test suites
            test_runner = TestRunner(ztestsuite=ztestsuites[0],
                                     testlist=args.test_list,
                                     config_overrides=config_overrides)
        else:
            test_runner = TestRunner(args.testfile, args.test_list,
                                     config_overrides)
    except BaseException as e:
        print("Error setting up testrunner:\n%s" % traceback.format_exc())
        raise ValueError(e.message)

    test_runner.run()

    logger.info("Exiting zopkio")
    return test_runner.success_count(), test_runner.fail_count()
示例#2
0
def call_main(args):
  # Get output directory.
  try:
    if args.output_dir is not None:
      runtime.set_output_dir(args.output_dir)
  except ValueError as e:
    print str(e)
    raise

  # Set up logging.
  setup_logging(runtime.get_output_dir(), args.log_level, args.console_level)
  logger = logging.getLogger("zopkio")
  logger.info("Starting zopkio")

  try:
    utils.check_file_with_exception(args.testfile)
    utils.check_testfile_dir_structure(args.testfile)
    machines = utils.make_machine_mapping(args.machine_list)
    config_overrides = utils.parse_config_list(args.config_overrides)
  except ValueError as e:
    logger.error(str(e))
    print("Error in processing command line arguments:\n {0}".format(traceback.format_exc()))
    raise

  runtime.set_machines(machines)
  if args.user is not None:
    user = args.user
  else:
    user = getpass.getuser()
  if args.nopassword:
    password = ""
  else:
    password = getpass.getpass()
  runtime.set_user(user, password)

  try:
    testmodule = utils.load_module(args.testfile)
    ztestsuites = [getattr(testmodule, attr)
               for attr in dir(testmodule)
               if isinstance(getattr(testmodule, attr), ZTestSuite)]
    if len(ztestsuites) > 0: #TODO(jehrlich) intelligently handle multiple test suites
      test_runner = TestRunner(ztestsuite=ztestsuites[0], testlist=args.test_list, config_overrides=config_overrides)
    else:
      test_runner = TestRunner(args.testfile, args.test_list, config_overrides)
  except BaseException as e:
    print("Error setting up testrunner:\n%s" % traceback.format_exc())
    raise ValueError(e.message)

  test_runner.run()

  logger.info("Exiting zopkio")
  return test_runner.success_count(), test_runner.fail_count()
示例#3
0
def main():
  """
  Parse command line arguments and then run the test suite
  """
  parser = argparse.ArgumentParser(description='A distributed test framework')
  parser.add_argument('testfile',
      help='The file that is used to determine the test suite run')
  parser.add_argument('--test-only',
      nargs='*',
      dest='test_list',
      help='run only the named tests to help debug broken tests')
  parser.add_argument('--machine-list',
      nargs='*',
      dest='machine_list',
      help='''mapping of logical host names to physical names allowing the same
              test suite to run on different hardware, each argument is a pair
              of logical name and physical name separated by a =''')
  parser.add_argument('--config-overrides',
      nargs='*',
      dest='config_overrides',
      help='''config overrides at execution time, each argument is a config with
              its value separated by a =. This has the highest priority of all
              configs''')
  parser.add_argument('-d', '--output-dir',
      dest='output_dir',
      help='''Directory to write output files and logs. Defaults to the current
              directory.''')
  parser.add_argument("--log-level", dest="log_level", help="Log level (default INFO)", default="INFO")
  parser.add_argument("--console-log-level", dest="console_level", help="Console Log level (default ERROR)",
                      default="ERROR")
  parser.add_argument("--nopassword", action='store_true', dest="nopassword", help="Disable password prompt")
  parser.add_argument("--user", dest="user", help="user to run the test as (defaults to current user)")
  args = parser.parse_args()

  # Get output directory.
  try:
    if args.output_dir is not None:
      runtime.set_output_dir(args.output_dir)
  except ValueError as e:
    print str(e)
    sys.exit(1)

  # Set up logging.
  setup_logging(runtime.get_output_dir(), args.log_level, args.console_level)
  logger = logging.getLogger("zopkio")
  logger.info("Starting zopkio")

  try:
    utils.check_file_with_exception(args.testfile)
    utils.check_testfile_dir_structure(args.testfile)
    machines = utils.make_machine_mapping(args.machine_list)
    config_overrides = utils.parse_config_list(args.config_overrides)
  except ValueError as e:
    logger.error(str(e))
    print("Error in processing command line arguments:\n {0}".format(traceback.format_exc()))
    sys.exit(1)

  runtime.set_machines(machines)
  if args.user is not None:
    user = args.user
  else:
    user = getpass.getuser()
  if args.nopassword:
    password = ""
  else:
    password = getpass.getpass()
  runtime.set_user(user, password)

  try:
    testmodule = utils.load_module(args.testfile)
    ztestsuites = [getattr(testmodule, attr)
               for attr in dir(testmodule)
               if isinstance(getattr(testmodule, attr), ZTestSuite)]
    if len(ztestsuites) > 0: #TODO(jehrlich) intelligently handle multiple test suites
      test_runner = TestRunner(ztestsuite=ztestsuites[0], testlist=args.test_list, config_overrides=config_overrides)
    else:
      test_runner = TestRunner(args.testfile, args.test_list, config_overrides)
  except BaseException as e:
    print("Error setting up testrunner:\n%s" % traceback.format_exc())
    sys.exit(1)

  test_runner.run()

  logger.info("Exiting zopkio")
示例#4
0
def main():
    """
  Parse command line arguments and then run the test suite
  """
    parser = argparse.ArgumentParser(
        description='A distributed test framework')
    parser.add_argument(
        'testfile',
        help='The file that is used to determine the test suite run')
    parser.add_argument(
        '--test-only',
        nargs='*',
        dest='test_list',
        help='run only the named tests to help debug broken tests')
    parser.add_argument(
        '--machine-list',
        nargs='*',
        dest='machine_list',
        help='''mapping of logical host names to physical names allowing the same
              test suite to run on different hardware, each argument is a pair
              of logical name and physical name separated by a =''')
    parser.add_argument(
        '--config-overrides',
        nargs='*',
        dest='config_overrides',
        help=
        '''config overrides at execution time, each argument is a config with
              its value separated by a =. This has the highest priority of all
              configs''')
    parser.add_argument(
        '-d',
        '--output-dir',
        dest='output_dir',
        help='''Directory to write output files and logs. Defaults to the current
              directory.''')
    parser.add_argument("--log-level",
                        dest="log_level",
                        help="Log level (default INFO)",
                        default="INFO")
    parser.add_argument("--console-log-level",
                        dest="console_level",
                        help="Console Log level (default ERROR)",
                        default="ERROR")
    parser.add_argument("--nopassword",
                        action='store_true',
                        dest="nopassword",
                        help="Disable password prompt")
    args = parser.parse_args()

    # Get output directory.
    try:
        if args.output_dir is not None:
            runtime.set_output_dir(args.output_dir)
    except ValueError as e:
        print str(e)
        sys.exit(1)

    # Set up logging.
    runtime.set_init_time(time.time())
    setup_logging(runtime.get_output_dir(), args.log_level, args.console_level)
    logger = logging.getLogger("zopkio")
    logger.info("Starting zopkio")

    try:
        utils.check_file_with_exception(args.testfile)
        machines = utils.make_machine_mapping(args.machine_list)
        config_overrides = utils.parse_config_list(args.config_overrides)
    except ValueError as e:
        print("Error in processing command line arguments:\n %s".format(
            traceback.format_exc()))
        sys.exit(1)

    runtime.set_machines(machines)
    user = getpass.getuser()
    if args.nopassword:
        password = ""
    else:
        password = getpass.getpass()
    runtime.set_user(user, password)

    try:
        test_runner = TestRunner(args.testfile, args.test_list,
                                 config_overrides)
    except BaseException as e:
        print("Error setting up testrunner:\n%s" % traceback.format_exc())
        sys.exit(1)

    test_runner.run()

    logger.info("Exiting zopkio")
示例#5
0
文件: __main__.py 项目: bzero/Zopkio
def main():
  """
  Parse command line arguments and then run the test suite
  """
  parser = argparse.ArgumentParser(description='A distributed test framework')
  parser.add_argument('testfile',
      help='The file that is used to determine the test suite run')
  parser.add_argument('--test-only',
      nargs='*',
      dest='test_list',
      help='run only the named tests to help debug broken tests')
  parser.add_argument('--machine-list',
      nargs='*',
      dest='machine_list',
      help='''mapping of logical host names to physical names allowing the same
              test suite to run on different hardware, each argument is a pair
              of logical name and physical name separated by a =''')
  parser.add_argument('--config-overrides',
      nargs='*',
      dest='config_overrides',
      help='''config overrides at execution time, each argument is a config with
              its value separated by a =. This has the highest priority of all
              configs''')
  parser.add_argument('-d', '--output-dir',
      dest='output_dir',
      help='''Directory to write output files and logs. Defaults to the current
              directory.''')
  args = parser.parse_args()

  # Get output directory.
  try:
    if args.output_dir is not None:
      runtime.set_output_dir(args.output_dir)
  except ValueError as e:
    print str(e)
    sys.exit(1)

  # Set up logging.
  runtime.set_init_time(time.time())
  setup_logging(runtime.get_output_dir())
  logger = logging.getLogger("zopkio")
  logger.info("Starting zopkio")

  try:
    utils.check_file_with_exception(args.testfile)
    machines = utils.make_machine_mapping(args.machine_list)
    config_overrides = utils.parse_config_list(args.config_overrides)
  except ValueError as e:
    print("Error in processing command line arguments:\n %s" %
          traceback.format_exc())
    sys.exit(1)

  runtime.set_machines(machines)
  user = getpass.getuser()
  password = getpass.getpass()
  runtime.set_user(user, password)

  try:
    test_runner = TestRunner(args.testfile, args.test_list, config_overrides)
  except BaseException as e:
    print("Error setting up testrunner:\n%s" % traceback.format_exc())
    sys.exit(1)

  test_runner.run()

  logger.info("Exiting zopkio")
示例#6
0
文件: __main__.py 项目: pubnub/Zopkio
def main():
    """
  Parse command line arguments and then run the test suite
  """
    parser = argparse.ArgumentParser(
        description='A distributed test framework')
    parser.add_argument(
        'testfile',
        help='The file that is used to determine the test suite run')
    parser.add_argument(
        '--test-only',
        nargs='*',
        dest='test_list',
        help='run only the named tests to help debug broken tests')
    parser.add_argument(
        '--machine-list',
        nargs='*',
        dest='machine_list',
        help='''mapping of logical host names to physical names allowing the same
              test suite to run on different hardware, each argument is a pair
              of logical name and physical name separated by a =''')
    parser.add_argument(
        '--config-overrides',
        nargs='*',
        dest='config_overrides',
        help=
        '''config overrides at execution time, each argument is a config with
              its value separated by a =. This has the highest priority of all
              configs''')
    parser.add_argument(
        '-d',
        '--output-dir',
        dest='output_dir',
        help='''Directory to write output files and logs. Defaults to the current
              directory.''')
    parser.add_argument("--log-level",
                        dest="log_level",
                        help="Log level (default INFO)",
                        default="INFO")
    parser.add_argument("--console-log-level",
                        dest="console_level",
                        help="Console Log level (default ERROR)",
                        default="ERROR")
    parser.add_argument("--nopassword",
                        action='store_true',
                        dest="nopassword",
                        help="Disable password prompt")
    parser.add_argument(
        "--user",
        dest="user",
        help="user to run the test as (defaults to current user)")
    parser.add_argument(
        "--reporter",
        dest="reporter",
        help="reporter type that will be use to generate report)")
    args = parser.parse_args()

    # Get output directory.
    try:
        if args.output_dir is not None:
            runtime.set_output_dir(args.output_dir)
    except ValueError as e:
        print str(e)
        sys.exit(1)

    # Set up logging.
    setup_logging(runtime.get_output_dir(), args.log_level, args.console_level)
    logger = logging.getLogger("zopkio")
    logger.info("Starting zopkio")

    try:
        utils.check_file_with_exception(args.testfile)
        utils.check_testfile_dir_structure(args.testfile)
        machines = utils.make_machine_mapping(args.machine_list)
        config_overrides = utils.parse_config_list(args.config_overrides)
    except ValueError as e:
        logger.error(str(e))
        print("Error in processing command line arguments:\n {0}".format(
            traceback.format_exc()))
        sys.exit(1)

    runtime.set_machines(machines)
    if args.user is not None:
        user = args.user
    else:
        user = getpass.getuser()
    if args.nopassword:
        password = ""
    else:
        password = getpass.getpass()
    runtime.set_user(user, password)

    try:
        testmodule = utils.load_module(args.testfile)
        ztestsuites = [
            getattr(testmodule, attr) for attr in dir(testmodule)
            if isinstance(getattr(testmodule, attr), ZTestSuite)
        ]
        # reporter_type = runtime.get_active_config('zopkio_reporter')
        reporter_type = None
        if args.reporter is not None:
            reporter_type = args.reporter
        if len(
                ztestsuites
        ) > 0:  #TODO(jehrlich) intelligently handle multiple test suites
            test_runner = TestRunner(ztestsuite=ztestsuites[0],
                                     testlist=args.test_list,
                                     config_overrides=config_overrides,
                                     reporter_type=reporter_type)
        else:
            test_runner = TestRunner(args.testfile,
                                     args.test_list,
                                     config_overrides,
                                     reporter_type=reporter_type)

    except BaseException as e:
        print("Error setting up testrunner:\n%s" % traceback.format_exc())
        sys.exit(1)
    print "CONFIG_OVERRIDE: %s" % (config_overrides, )
    test_runner.run()

    logger.info("Exiting zopkio")