Пример #1
0
 def _command_line(self):
     return autoserv_utils.autoserv_run_job_command(
         autoserv_utils.autoserv_directory,
         self.host.hostname,
         results_directory=drone_manager.WORKING_DIRECTORY,
         extra_args=self._extra_command_args,
         queue_entry=self.queue_entry,
         in_lab=True,
     )
Пример #2
0
 def _command_line(self):
     # If we give queue_entry to autoserv_run_job_command, then it will
     # append -c for this invocation if the queue_entry is a client side
     # test. We don't want that, as it messes with provisioning, so we just
     # drop it from the arguments here.
     # Note that we also don't verify job_repo_url as provisioining tasks are
     # required to stage whatever content we need, and the job itself will
     # force autotest to be staged if it isn't already.
     return autoserv_utils.autoserv_run_job_command(
             autoserv_utils.autoserv_directory,
             self.host.hostname,
             results_directory=drone_manager.WORKING_DIRECTORY,
             extra_args=self._extra_command_args,
             in_lab=True,
     )
Пример #3
0
def run_provisioning_job(provision_label,
                         host,
                         autotest_path,
                         results_directory,
                         fast_mode,
                         ssh_verbosity=0,
                         ssh_options=None,
                         pretend=False,
                         autoserv_verbose=False):
    """Shell out to autoserv to run provisioning job.

    @param provision_label: Label to provision the machine to.
    @param host: Hostname of DUT.
    @param autotest_path: Absolute path of autotest directory.
    @param results_directory: Absolute path of directory to store results in.
                              (results will be stored in subdirectory of this).
    @param fast_mode: bool to use fast mode (disables slow autotest features).
    @param ssh_verbosity: SSH verbosity level, passed along to autoserv_utils
    @param ssh_options: Additional ssh options to be passed to autoserv_utils
    @param pretend: If True, will print out autoserv commands rather than
                    running them.
    @param autoserv_verbose: If true, pass the --verbose flag to autoserv.

    @returns: Absolute path of directory where results were stored.

    """
    # TODO(fdeng): When running against a local DUT, autoserv
    # is still hitting the AFE in the lab.
    # provision_AutoUpdate checks the current build of DUT by
    # retrieving build info from AFE. crosbug.com/295178
    results_directory = os.path.join(results_directory, 'results-provision')
    command = autoserv_utils.autoserv_run_job_command(
        os.path.join(autotest_path, 'server'),
        machines=host,
        job=None,
        verbose=autoserv_verbose,
        results_directory=results_directory,
        fast_mode=fast_mode,
        ssh_verbosity=ssh_verbosity,
        ssh_options=ssh_options,
        extra_args=['--provision', '--job-labels', provision_label],
        no_console_prefix=True)
    if _run_autoserv(command, pretend) != 0:
        raise TestThatProvisioningError('Command returns non-zero code: %s ' %
                                        command)
    return results_directory
Пример #4
0
def run_job(job,
            host,
            autotest_path,
            results_directory,
            fast_mode,
            id_digits=1,
            ssh_verbosity=0,
            ssh_options=None,
            args=None,
            pretend=False,
            autoserv_verbose=False,
            host_attributes={}):
    """
    Shell out to autoserv to run an individual test job.

    @param job: A Job object containing the control file contents and other
                relevent metadata for this test.
    @param host: Hostname of DUT to run test against.
    @param autotest_path: Absolute path of autotest directory.
    @param results_directory: Absolute path of directory to store results in.
                              (results will be stored in subdirectory of this).
    @param fast_mode: bool to use fast mode (disables slow autotest features).
    @param id_digits: The minimum number of digits that job ids should be
                      0-padded to when formatting as a string for results
                      directory.
    @param ssh_verbosity: SSH verbosity level, passed along to autoserv_utils
    @param ssh_options: Additional ssh options to be passed to autoserv_utils
    @param args: String that should be passed as args parameter to autoserv,
                 and then ultimitely to test itself.
    @param pretend: If True, will print out autoserv commands rather than
                    running them.
    @param autoserv_verbose: If true, pass the --verbose flag to autoserv.
    @param host_attributes: Dict of host attributes to pass into autoserv.

    @returns: a tuple, return code of the job and absolute path of directory
              where results were stored.
    """
    with tempfile.NamedTemporaryFile() as temp_file:
        temp_file.write(job.control_file)
        temp_file.flush()
        name_tail = job.name.split('/')[-1]
        results_directory = os.path.join(
            results_directory,
            'results-%0*d-%s' % (id_digits, job.id, name_tail))
        # Drop experimental keyval in the keval file in the job result folder.
        os.makedirs(results_directory)
        utils.write_keyval(
            results_directory, {
                constants.JOB_EXPERIMENTAL_KEY:
                job.keyvals[constants.JOB_EXPERIMENTAL_KEY]
            })
        extra_args = [temp_file.name]
        if args:
            extra_args.extend(['--args', args])

        command = autoserv_utils.autoserv_run_job_command(
            os.path.join(autotest_path, 'server'),
            machines=host,
            job=job,
            verbose=autoserv_verbose,
            results_directory=results_directory,
            fast_mode=fast_mode,
            ssh_verbosity=ssh_verbosity,
            ssh_options=ssh_options,
            extra_args=extra_args,
            no_console_prefix=True,
            use_packaging=False,
            host_attributes=host_attributes)

        code = _run_autoserv(command, pretend)
        return code, results_directory