예제 #1
0
파일: __main__.py 프로젝트: vickkyy/Zopkio
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 setup_suite():
    print "==> Starting tests for PYHK."

    runtime.set_user('root', '')

    global pyhk_deployer
    global tcp_server

    #  Set the server deployer.
    tcp_server = adhoc_deployer.SSHDeployer(
        "server",
        {'executable': runtime.get_active_config('pyhk_exec'),
         'extract': True,
         'start_command': runtime.get_active_config('tcp_server_cmd'),
         'stop_command': "ps ax | grep '[p]ython server' | awk '{print $1}' | xargs kill -9"})
    runtime.set_deployer("server", tcp_server)

    #  Provisioning the server.
    tcp_server.install("server1",
        {"hostname": "10.0.1.23",
         "install_path": runtime.get_active_config('pyhk_install')})

    #  Set the client deployer
    tcp_client = adhoc_deployer.SSHDeployer(
        "client",
        {'executable': runtime.get_active_config('pyhk_exec'),
         'extract': True,
         'start_command': runtime.get_active_config('tcp_client_cmd')})
    runtime.set_deployer("client", tcp_client)

    #  Provisioning the client.
    tcp_client.install("client1",
        {"hostname": "10.0.1.24",
         "install_path": runtime.get_active_config('pyhk_install')})

    #  Set general deployer.
    pyhk_deployer = adhoc_deployer.SSHDeployer(
        "pyhk",
        {'executable': runtime.get_active_config('pyhk_exec'),
         'extract': True,
         'start_command': runtime.get_active_config('pyhk_cmd')})
    runtime.set_deployer("pyhk", pyhk_deployer)

    #  Hostname 1
    pyhk_deployer.install(
        "machine1",
        {"hostname": runtime.get_active_config('pyhk_hostname1'),
         "install_path": runtime.get_active_config('pyhk_install')})

    #  Hostname 2
    pyhk_deployer.install(
        "machine2",
        {"hostname": runtime.get_active_config('pyhk_hostname2'),
         "install_path": runtime.get_active_config('pyhk_install')})
예제 #3
0
파일: __main__.py 프로젝트: JahanviB/Zopkio
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()
예제 #4
0
def setup_suite():
    # Set up authentication
    username = runtime.get_active_config("username")
    password = runtime.get_active_config("password")
    runtime.set_user(username, password)

    # Set up the target directories and properties
    userdir = os.path.join("/home", username)
    riaps_app_path = os.path.join(userdir,
                                  runtime.get_active_config("riaps_apps_path"))
    test_app_path = os.path.join(riaps_app_path,
                                 runtime.get_active_config('app_dir'))

    start_actor_path = "/opt/riaps/armhf/bin/"

    env = {
        "PATH": "/usr/local/bin/:" + start_actor_path + ":$PATH",
        "RIAPSHOME": "/usr/local/riaps",
        "RIAPSAPPS": "$HOME/riaps_apps",
        "LD_LIBRARY_PATH": "/opt/riaps/armhf/lib:" + test_app_path
    }

    #start_riaps_lang = "riaps_lang " + runtime.get_active_config('model_file')

    # Set up the sources
    model_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                              runtime.get_active_config('app_dir'),
                              runtime.get_active_config('model_file'))

    # Script to check discovery service
    discoCheckScript = "checkDiscoveryService.py"
    discoCheckScriptPath = "../../test_common"

    # Script to start the discovery
    discoStartScript = "startDiscovery.py"
    discoStartScriptPath = "../../test_common"

    # Script to stop the discovery
    discoStopScript = "stopDiscovery.py"
    discoStopScriptPath = "../../test_common"

    killRiapsScript = "killRiaps.py"
    killRiapsScriptPath = "../../test_common"

    # Deploy the riaps killer script
    for target in runtime.get_active_config('targets'):
        deployerId = "killer_" + target["host"]
        killscriptpath = os.path.abspath(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         killRiapsScriptPath, killRiapsScript))

        killDeployer = adhoc_deployer.SSHDeployer(
            deployerId, {
                'executable':
                killscriptpath,
                'install_path':
                riaps_app_path,
                'env':
                env,
                'hostname':
                target["host"],
                "start_command":
                "python3 " + os.path.join(riaps_app_path, killRiapsScript)
            })
        runtime.set_deployer(deployerId, killDeployer)
        killDeployer.install(deployerId)

        # Deploy the discovery starter script
    for target in runtime.get_active_config('targets'):
        deployerId = "discostart_" + target["host"]
        startscriptpath = os.path.abspath(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         discoStartScriptPath, discoStartScript))

        startDiscoveryDeployer = adhoc_deployer.SSHDeployer(
            deployerId, {
                'executable':
                startscriptpath,
                'install_path':
                riaps_app_path,
                'env':
                env,
                'hostname':
                target["host"],
                "start_command":
                "python3 " + os.path.join(riaps_app_path, discoStartScript)
            })
        runtime.set_deployer(deployerId, startDiscoveryDeployer)
        startDiscoveryDeployer.install(deployerId)

        # Deploy the discovery stop script
    for target in runtime.get_active_config('targets'):
        deployerId = "discostop_" + target["host"]
        stopscriptpath = os.path.abspath(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         discoStopScriptPath, discoStopScript))

        stopDiscoveryDeployer = adhoc_deployer.SSHDeployer(
            deployerId, {
                'executable':
                stopscriptpath,
                'install_path':
                riaps_app_path,
                'env':
                env,
                'hostname':
                target["host"],
                "start_command":
                "python3 " + os.path.join(riaps_app_path, discoStopScript)
            })
        runtime.set_deployer(deployerId, stopDiscoveryDeployer)
        stopDiscoveryDeployer.install(deployerId)

    # Deploy the riaps-disco checker script
    for target in runtime.get_active_config('targets'):
        deployerId = "disco" + target["host"]
        checkscriptpath = os.path.abspath(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         discoCheckScriptPath, discoCheckScript))

        checkDiscoDeployer = adhoc_deployer.SSHDeployer(
            deployerId, {
                'executable':
                checkscriptpath,
                'install_path':
                riaps_app_path,
                'env':
                env,
                'hostname':
                target["host"],
                "start_command":
                "python3 " +
                os.path.join(riaps_app_path, "checkDiscoveryService.py")
            })
        runtime.set_deployer(deployerId, checkDiscoDeployer)
        checkDiscoDeployer.install(deployerId)

    # Deploy the riaps-components/model file
    local_riaps_lang = "riaps_lang " + model_path
    local_test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                  runtime.get_active_config('app_dir'))

    subprocess.call(local_riaps_lang, shell=True)

    move_cmd = "mv " + runtime.get_active_config(
        'app_dir') + '.json ' + local_test_dir
    subprocess.call(move_cmd, shell=True)

    local_model_json = os.path.join(
        local_test_dir,
        runtime.get_active_config('app_dir') + '.json')

    for target in runtime.get_active_config('targets'):
        model_deployer = adhoc_deployer.SSHDeployer(
            target["actor"],
            {
                'executable': local_model_json,
                'install_path': test_app_path,
                'hostname': target["host"],
                #'start_command': os.path.join(start_actor_path, "start_actor"),
                'start_command': "start_actor",

                #'args': [os.path.join(test_app_path, runtime.get_active_config('app_dir') + '.json'),
                #         target["actor"]],
                'env': env
                #'terminate_only': False,
                #'pid_keyword': model_path,
            })
        runtime.set_deployer(target["actor"], model_deployer)

        # Add test cases
        testcases = [
            "pubfirst_" + target["actor"], "subfirst_" + target["actor"]
        ]

        for testcase in testcases:
            model_deployer.install(
                testcase, {
                    'args': [
                        os.path.join(
                            test_app_path,
                            runtime.get_active_config('app_dir') + '.json'),
                        target["actor"], '--logfile="' + testcase + '.log"'
                    ]
                })

        for component in runtime.get_active_config('components_so'):
            localPath = os.path.join(
                os.path.dirname(os.path.abspath(__file__)),
                runtime.get_active_config('app_dir'), component)
            #localPath = os.path.join(os.path.dirname(os.path.abspath(__file__)),
            #                         runtime.get_active_config('app_dir'),
            #                         "lib",
            #                         component)

            #targetPath = target_path#os.path.join(riaps_app_path, runtime.get_active_config('app_dir'))
            component_deployer = adhoc_deployer.SSHDeployer(
                component,
                {
                    'executable': localPath,
                    'install_path': test_app_path,
                    'hostname': target["host"],
                    #'start_command': "start_actor",  #os.path.join(target_path, "start_actor"),
                    #'args': [runtime.get_active_config('app_dir'),
                    #         runtime.get_active_config('app_dir') + '.json',
                    #         target["actor"]],
                    'env': env,
                    #'terminate_only': True,
                    #'pid_keyword': component,
                })
            runtime.set_deployer(component, component_deployer)
            component_deployer.install(component)

    print("Deployment done.")
예제 #5
0
파일: __main__.py 프로젝트: alshopov/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)")
  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")
예제 #6
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")
예제 #7
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")
예제 #8
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")