Пример #1
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)
Пример #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.
  """
    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)

    if FLAGS.run_uri is None:
        if stages.PROVISION in FLAGS.run_stage:
            FLAGS.run_uri = str(uuid.uuid4())[-8:]
        else:
            # Attempt to get the last modified run directory.
            run_uri = vm_util.GetLastRunUri()
            if run_uri:
                FLAGS.run_uri = run_uri
                logging.warning(
                    'No run_uri specified. Attempting to run the following stages with '
                    '--run_uri=%s: %s', FLAGS.run_uri,
                    ', '.join(FLAGS.run_stage))
            else:
                raise errors.Setup.NoRunURIError(
                    'No run_uri specified. Could not run the following stages: %s'
                    % ', '.join(FLAGS.run_stage))
    elif not FLAGS.run_uri.isalnum() or len(
            FLAGS.run_uri) > MAX_RUN_URI_LENGTH:
        raise errors.Setup.BadRunURIError(
            'run_uri must be alphanumeric and less '
            'than or equal to 8 characters in '
            'length.')

    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)

    vm_util.SSHKeyGen()

    events.initialization_complete.send(parsed_flags=FLAGS)
Пример #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)
 def testAllRequirementsFulfilled(self):
   requirements.CheckBasicRequirements()