def _get_variants(resultsdir): results = [] mux = jobdata.retrieve_mux(resultsdir) if mux is not None: env = set() for (index, tpl) in enumerate(mux.variants): paths = ', '.join([x.path for x in tpl]) results.append('Variant %s: %s\n' % (index + 1, paths)) for node in tpl: for key, value in node.environment.iteritems(): origin = node.environment_origin[key].path env.add(("%s:%s" % (origin, key), str(value))) if not env: continue fmt = ' %%-%ds => %%s\n' % max([len(_[0]) for _ in env]) for record in sorted(env): results.append(fmt % record) else: results.append('Not found\n') return results
def run(self, args): if getattr(args, 'replay_jobid', None) is None: return log = logging.getLogger("avocado.app") err = None if args.replay_teststatus and 'mux' in args.replay_ignore: err = ("Option `--replay-test-status` is incompatible with " "`--replay-ignore mux`.") elif args.replay_teststatus and args.reference: err = ("Option --replay-test-status is incompatible with " "test references given on the command line.") elif args.remote_hostname: err = "Currently we don't replay jobs in remote hosts." if err is not None: log.error(err) sys.exit(exit_codes.AVOCADO_FAIL) if args.replay_datadir is not None: resultsdir = args.replay_datadir else: logdir = settings.get_value(section='datadir.paths', key='logs_dir', key_type='path', default=None) try: resultsdir = jobdata.get_resultsdir(logdir, args.replay_jobid) except ValueError as exception: log.error(exception.message) sys.exit(exit_codes.AVOCADO_JOB_FAIL) if resultsdir is None: log.error("Can't find job results directory in '%s'", logdir) sys.exit(exit_codes.AVOCADO_JOB_FAIL) sourcejob = jobdata.get_id(os.path.join(resultsdir, 'id'), args.replay_jobid) if sourcejob is None: msg = ("Can't find matching job id '%s' in '%s' directory." % (args.replay_jobid, resultsdir)) log.error(msg) sys.exit(exit_codes.AVOCADO_JOB_FAIL) setattr(args, 'replay_sourcejob', sourcejob) replay_args = jobdata.retrieve_args(resultsdir) whitelist = ['loaders', 'external_runner', 'external_runner_testdir', 'external_runner_chdir', 'failfast'] if replay_args is None: log.warn('Source job args data not found. These options will not ' 'be loaded in this replay job: %s', ', '.join(whitelist)) else: for option in whitelist: optvalue = getattr(args, option, None) if optvalue is not None: log.warn("Overriding the replay %s with the --%s value " "given on the command line.", option.replace('_', '-'), option.replace('_', '-')) else: setattr(args, option, replay_args[option]) # Keeping this for compatibility. # TODO: Use replay_args['reference'] at some point in the future. if getattr(args, 'reference', None): log.warn('Overriding the replay test references with test ' 'references given in the command line.') else: references = jobdata.retrieve_references(resultsdir) if references is None: log.error('Source job test references data not found. Aborting.') sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: setattr(args, 'reference', references) if 'config' in args.replay_ignore: log.warn("Ignoring configuration from source job with " "--replay-ignore.") else: self.load_config(resultsdir) if 'mux' in args.replay_ignore: log.warn("Ignoring multiplex from source job with " "--replay-ignore.") else: mux = jobdata.retrieve_mux(resultsdir) if mux is None: log.error('Source job multiplex data not found. Aborting.') sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: # Ignore data manipulation. This is necessary, because # we replaced the unparsed object with parsed one. There # are other plugins running before/after this which might # want to alter the mux object. if len(args.mux.data) or args.mux.data.environment: log.warning("Using src job Mux data only, use `--replay-" "ignore mux` to override them.") setattr(args, "mux", mux) mux.data_merge = ignore_call mux.data_inject = ignore_call if args.replay_teststatus: replay_map = self._create_replay_map(resultsdir, args.replay_teststatus) setattr(args, 'replay_map', replay_map) # Use the original directory to resolve test references properly pwd = jobdata.retrieve_pwd(resultsdir) if pwd is not None: if os.path.exists(pwd): os.chdir(pwd) else: log.warn("Directory used in the replay source job '%s' does " "not exist, using '.' instead", pwd)
def run(self, args): if getattr(args, "replay_jobid", None) is None: return log = logging.getLogger("avocado.app") err = None if args.replay_teststatus and args.multiplex_files: err = "Option --replay-test-status is incompatible with " "--multiplex." elif args.replay_teststatus and args.url: err = "Option --replay-test-status is incompatible with " "test URLs given on the command line." elif args.remote_hostname: err = "Currently we don't replay jobs in remote hosts." if err is not None: log.error(err) sys.exit(exit_codes.AVOCADO_FAIL) if args.replay_datadir is not None: resultsdir = args.replay_datadir else: logs_dir = settings.get_value("datadir.paths", "logs_dir", default=None) logdir = os.path.expanduser(logs_dir) try: resultsdir = jobdata.get_resultsdir(logdir, args.replay_jobid) except ValueError as exception: log.error(exception.message) sys.exit(exit_codes.AVOCADO_JOB_FAIL) if resultsdir is None: log.error("Can't find job results directory in '%s'", logdir) sys.exit(exit_codes.AVOCADO_JOB_FAIL) sourcejob = jobdata.get_id(os.path.join(resultsdir, "id"), args.replay_jobid) if sourcejob is None: msg = "Can't find matching job id '%s' in '%s' directory." % (args.replay_jobid, resultsdir) log.error(msg) sys.exit(exit_codes.AVOCADO_JOB_FAIL) setattr(args, "replay_sourcejob", sourcejob) replay_args = jobdata.retrieve_args(resultsdir) whitelist = ["loaders", "external_runner", "external_runner_testdir", "external_runner_chdir", "failfast"] if replay_args is None: log.warn( "Source job args data not found. These options will not " "be loaded in this replay job: %s", ", ".join(whitelist), ) else: for option in whitelist: optvalue = getattr(args, option, None) if optvalue is not None: log.warn( "Overriding the replay %s with the --%s value " "given on the command line.", option.replace("_", "-"), option.replace("_", "-"), ) else: setattr(args, option, replay_args[option]) # Keeping this for compatibility. # TODO: Use replay_args['url'] at some point in the future. if getattr(args, "url", None): log.warn("Overriding the replay urls with urls provided in " "command line.") else: urls = jobdata.retrieve_urls(resultsdir) if urls is None: log.error("Source job urls data not found. Aborting.") sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: setattr(args, "url", urls) if args.replay_ignore and "config" in args.replay_ignore: log.warn("Ignoring configuration from source job with " "--replay-ignore.") else: self.load_config(resultsdir) if args.replay_ignore and "mux" in args.replay_ignore: log.warn("Ignoring multiplex from source job with " "--replay-ignore.") else: if getattr(args, "multiplex_files", None) is not None: log.warn("Overriding the replay multiplex with " "--multiplex-file.") # Use absolute paths to avoid problems with os.chdir args.multiplex_files = [os.path.abspath(_) for _ in args.multiplex_files] else: mux = jobdata.retrieve_mux(resultsdir) if mux is None: log.error("Source job multiplex data not found. Aborting.") sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: setattr(args, "multiplex_files", mux) if args.replay_teststatus: replay_map = self._create_replay_map(resultsdir, args.replay_teststatus) setattr(args, "replay_map", replay_map) # Use the original directory to discover test urls properly pwd = jobdata.retrieve_pwd(resultsdir) if pwd is not None: if os.path.exists(pwd): os.chdir(pwd) else: log.warn("Directory used in the replay source job '%s' does " "not exist, using '.' instead", pwd)
def run(self, args): if getattr(args, 'replay_jobid', None) is None: return log = logging.getLogger("avocado.app") err = None if args.replay_teststatus and 'mux' in args.replay_ignore: err = ("Option `--replay-test-status` is incompatible with " "`--replay-ignore mux`.") elif args.replay_teststatus and args.reference: err = ("Option --replay-test-status is incompatible with " "test references given on the command line.") elif args.remote_hostname: err = "Currently we don't replay jobs in remote hosts." if err is not None: log.error(err) sys.exit(exit_codes.AVOCADO_FAIL) if getattr(args, 'logdir', None) is not None: logdir = args.logdir else: logdir = settings.get_value(section='datadir.paths', key='logs_dir', key_type='path', default=None) try: resultsdir = jobdata.get_resultsdir(logdir, args.replay_jobid) except ValueError as exception: log.error(exception.message) sys.exit(exit_codes.AVOCADO_JOB_FAIL) if resultsdir is None: log.error("Can't find job results directory in '%s'", logdir) sys.exit(exit_codes.AVOCADO_JOB_FAIL) sourcejob = jobdata.get_id(os.path.join(resultsdir, 'id'), args.replay_jobid) if sourcejob is None: msg = ("Can't find matching job id '%s' in '%s' directory." % (args.replay_jobid, resultsdir)) log.error(msg) sys.exit(exit_codes.AVOCADO_JOB_FAIL) setattr(args, 'replay_sourcejob', sourcejob) replay_args = jobdata.retrieve_args(resultsdir) whitelist = ['loaders', 'external_runner', 'external_runner_testdir', 'external_runner_chdir', 'failfast'] if replay_args is None: log.warn('Source job args data not found. These options will not ' 'be loaded in this replay job: %s', ', '.join(whitelist)) else: for option in whitelist: optvalue = getattr(args, option, None) if optvalue is not None: log.warn("Overriding the replay %s with the --%s value " "given on the command line.", option.replace('_', '-'), option.replace('_', '-')) else: setattr(args, option, replay_args[option]) # Keeping this for compatibility. # TODO: Use replay_args['reference'] at some point in the future. if getattr(args, 'reference', None): log.warn('Overriding the replay test references with test ' 'references given in the command line.') else: references = jobdata.retrieve_references(resultsdir) if references is None: log.error('Source job test references data not found. Aborting.') sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: setattr(args, 'reference', references) if 'config' in args.replay_ignore: log.warn("Ignoring configuration from source job with " "--replay-ignore.") else: self.load_config(resultsdir) if 'mux' in args.replay_ignore: log.warn("Ignoring multiplex from source job with " "--replay-ignore.") else: mux = jobdata.retrieve_mux(resultsdir) if mux is None: log.error('Source job multiplex data not found. Aborting.') sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: # Ignore data manipulation. This is necessary, because # we replaced the unparsed object with parsed one. There # are other plugins running before/after this which might # want to alter the mux object. if len(args.mux.data) or args.mux.data.environment: log.warning("Using src job Mux data only, use `--replay-" "ignore mux` to override them.") setattr(args, "mux", mux) mux.data_merge = ignore_call mux.data_inject = ignore_call if args.replay_teststatus: replay_map = self._create_replay_map(resultsdir, args.replay_teststatus) setattr(args, 'replay_map', replay_map) # Use the original directory to resolve test references properly pwd = jobdata.retrieve_pwd(resultsdir) if pwd is not None: if os.path.exists(pwd): os.chdir(pwd) else: log.warn("Directory used in the replay source job '%s' does " "not exist, using '.' instead", pwd)