示例#1
0
def Main(argv=sys.argv):
    logging.basicConfig(level=logging.INFO)

    # TODO: Verify if there is other way of appending additional help
    # message.
    # Inject more help documentation
    # The following appends descriptions of the benchmarks and descriptions of
    # the benchmark sets to the help text.
    benchmark_sets_list = [
        '%s:  %s' %
        (set_name, benchmark_sets.BENCHMARK_SETS[set_name]['message'])
        for set_name in benchmark_sets.BENCHMARK_SETS
    ]
    sys.modules['__main__'].__doc__ = (
        'PerfKitBenchmarker version: {version}\n\n{doc}\n'
        'Benchmarks (default requirements):\n'
        '\t{benchmark_doc}').format(
            version=version.VERSION,
            doc=__doc__,
            benchmark_doc=_GenerateBenchmarkDocumentation())
    sys.modules['__main__'].__doc__ += ('\n\nBenchmark Sets:\n\t%s' %
                                        '\n\t'.join(benchmark_sets_list))

    try:
        argv = FLAGS(argv)  # parse flags
    except flags.FlagsError as e:
        logging.error('%s\nUsage: %s ARGS\n%s', e, sys.argv[0], FLAGS)
        sys.exit(1)

    disk.WarnAndTranslateDiskFlags()

    SetUpPKB()

    return RunBenchmarks()
示例#2
0
def SetUpPKB():
    """Set globals and environment variables for PKB.

  After SetUpPKB() returns, it should be possible to call PKB
  functions, like benchmark_spec.Prepare() or benchmark_spec.Run().

  SetUpPKB() also modifies the local file system by creating a temp
  directory and storing new SSH keys.
  """
    try:
        _InitializeRunUri()
    except errors.Error as e:
        logging.error(e)
        sys.exit(1)

    # Initialize logging.
    vm_util.GenTempDir()
    if FLAGS.use_pkb_logging:
        log_util.ConfigureLogging(
            stderr_log_level=log_util.LOG_LEVELS[FLAGS.log_level],
            log_path=vm_util.PrependTempDir(LOG_FILE_NAME),
            run_uri=FLAGS.run_uri,
            file_log_level=log_util.LOG_LEVELS[FLAGS.file_log_level])
    logging.info('PerfKitBenchmarker version: %s', version.VERSION)

    # Translate deprecated flags and log all provided flag values.
    disk.WarnAndTranslateDiskFlags()
    _LogCommandLineFlags()

    # Register skip pending runs functionality.
    RegisterSkipPendingRunsCheck(_SkipPendingRunsFile)

    # Check environment.
    if not FLAGS.ignore_package_requirements:
        requirements.CheckBasicRequirements()

    for executable in REQUIRED_EXECUTABLES:
        if not vm_util.ExecutableOnPath(executable):
            raise errors.Setup.MissingExecutableError(
                'Could not find required executable "%s"', executable)

    # Check mutually exclusive flags
    if FLAGS.run_stage_iterations > 1 and FLAGS.run_stage_time > 0:
        raise errors.Setup.InvalidFlagConfigurationError(
            'Flags run_stage_iterations and run_stage_time are mutually exclusive'
        )

    vm_util.SSHKeyGen()

    if FLAGS.static_vm_file:
        with open(FLAGS.static_vm_file) as fp:
            static_virtual_machine.StaticVirtualMachine.ReadStaticVirtualMachineFile(
                fp)

    events.initialization_complete.send(parsed_flags=FLAGS)

    benchmark_lookup.SetBenchmarkModuleFunction(benchmark_sets.BenchmarkModule)
    package_lookup.SetPackageModuleFunction(benchmark_sets.PackageModule)
示例#3
0
def SetUpPKB():
    """Set globals and environment variables for PKB.

  After SetUpPKB() returns, it should be possible to call PKB
  functions, like benchmark_spec.Prepare() or benchmark_spec.Run().

  SetUpPKB() also modifies the local file system by creating a temp
  directory and storing new SSH keys.
  """
    try:
        _InitializeRunUri()
    except errors.Error as e:
        logging.error(e)
        sys.exit(1)

    # Initialize logging.
    vm_util.GenTempDir()
    log_util.ConfigureLogging(
        stderr_log_level=log_util.LOG_LEVELS[FLAGS.log_level],
        log_path=vm_util.PrependTempDir(LOG_FILE_NAME),
        run_uri=FLAGS.run_uri,
        file_log_level=log_util.LOG_LEVELS[FLAGS.file_log_level])
    logging.info('PerfKitBenchmarker version: %s', version.VERSION)

    # Translate deprecated flags and log all provided flag values.
    disk.WarnAndTranslateDiskFlags()
    _LogCommandLineFlags()

    # Check environment.
    if not FLAGS.ignore_package_requirements:
        requirements.CheckBasicRequirements()

    if FLAGS.os_type == os_types.WINDOWS and not vm_util.RunningOnWindows():
        logging.error('In order to run benchmarks on Windows VMs, you must be '
                      'running on Windows.')
        sys.exit(1)

    for executable in REQUIRED_EXECUTABLES:
        if not vm_util.ExecutableOnPath(executable):
            raise errors.Setup.MissingExecutableError(
                'Could not find required executable "%s"', executable)

    vm_util.SSHKeyGen()

    if FLAGS.static_vm_file:
        with open(FLAGS.static_vm_file) as fp:
            static_virtual_machine.StaticVirtualMachine.ReadStaticVirtualMachineFile(
                fp)

    events.initialization_complete.send(parsed_flags=FLAGS)