def _get_variants(resultsdir): results = [] variants = jobdata.retrieve_variants(resultsdir) if variants is not None: results.extend(variants.to_str(variants=2).splitlines()) else: results.append('Not found\n') return results
def _get_variants(resultsdir): results = [] variants = jobdata.retrieve_variants(resultsdir) if variants is not None: results.extend(variants.to_str(variants=2).splitlines()) else: results.append('Not found\n') return results
def _get_variants(resultsdir): results = [] variants = jobdata.retrieve_variants(resultsdir) if variants is not None: env = set() for (index, tpl) in enumerate(variants.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 _get_variants(resultsdir): results = [] variants = jobdata.retrieve_variants(resultsdir) if variants is not None: env = set() for (index, tpl) in enumerate(variants.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 'variants' in args.replay_ignore: err = ("Option `--replay-test-status` is incompatible with " "`--replay-ignore variants`.") 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 'variants' in args.replay_ignore: log.warn("Ignoring variants from source job with " "--replay-ignore.") else: variants = jobdata.retrieve_variants(resultsdir) if variants is None: log.error('Source job variants 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 variants object. if (len(args.avocado_variants.data) or args.avocado_variants.data.environment): log.warning("Using src job Mux data only, use `--replay-" "ignore variants` to override them.") setattr(args, "avocado_variants", variants) variants.ignore_new_data = True 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 _check_results(self, dirname): pth = os.path.join(BASEDIR, "selftests", ".data", dirname) # pwd self.assertEqual(jobdata.retrieve_pwd(pth), "/home/user/avocado", "pwd mismatch") # references self.assertEqual(jobdata.retrieve_references(pth), ["yes", "no"], "references mismatch") # variants try: variants = jobdata.retrieve_variants(pth) except Exception as details: self.fail("variants: Unable to retrieve: %s" % details) act = variants.to_str(0, 99) self.assertTrue(act) exp = ("\nVariant first-febe: /run/first\n" " /run/first:variable_one => 1\n\n" "Variant second-bafe: /run/second\n" " /run/second:variable_two => 2") self.assertIn(exp, act, "variants mismatch") # args try: args = jobdata.retrieve_args(pth) except Exception as details: self.fail("args: Unable to retrieve: %s" % details) self.assertTrue(isinstance(args, dict), "args: Invalid args: %s" % args) for scenario in [["loaders", [u"external:/bin/echo"]], ["external_runner", u"/bin/echo"], ["failfast", False, None], ["ignore_missing_references", False, None], ["execution_order", "variants-per-test", None]]: act = args.get(scenario[0]) self.assertIn(act, scenario[1:], "args: Invalid value '%s' of key '%s' '%s'" % ( act, scenario[0], scenario[1:])) # config conf_path = jobdata.retrieve_config(pth) self.assertTrue(os.path.exists(conf_path), "config: Retrieved path '%s' does not exists" % conf_path) exp = "[avocado.selftest]\njobdata = yes" with open(conf_path, "r") as conf: act = conf.read() self.assertIn(exp, act, "config: Expected string\n%s\n\nNot in:\n%s" % ( exp, act)) # cmdline act = jobdata.retrieve_cmdline(pth) exp = ['/usr/local/bin/avocado', 'run', '--external-runner', '/bin/echo', '-m', 'examples/yaml_to_mux/simple_vars.yaml', '--', 'yes', 'no'] self.assertEqual(exp, act, "cmdline: Invalid cmdline '%s' (%s)" % (act, exp))
def run(self, config): job_id = config.get('run.replay.job_id') if job_id is None: return err = None replay_ignore = config.get('run.replay.ignore') test_status = config.get('run.replay.test_status') if test_status and 'variants' in replay_ignore: err = ("Option `--replay-test-status` is incompatible with " "`--replay-ignore variants`.") elif test_status and config.get('run.references'): err = ("Option --replay-test-status is incompatible with " "test references given on the command line.") elif config.get("remote_hostname", False): err = "Currently we don't replay jobs in remote hosts." if err is not None: LOG_UI.error(err) sys.exit(exit_codes.AVOCADO_FAIL) resultsdir = data_dir.get_job_results_dir( job_id, config.get('run.results_dir')) if resultsdir is None: LOG_UI.error("Can't find job results directory for '%s'", job_id) sys.exit(exit_codes.AVOCADO_FAIL) with open(os.path.join(resultsdir, 'id'), 'r') as id_file: config['replay_sourcejob'] = id_file.read().strip() replay_config = jobdata.retrieve_job_config(resultsdir) whitelist = [ 'loaders', 'external_runner', 'external_runner_testdir', 'external_runner_chdir', 'failfast', 'ignore_missing_references', 'execution_order' ] if replay_config is None: LOG_UI.warn( 'Source job config data not found. These options will ' 'not be loaded in this replay job: %s', ', '.join(whitelist)) else: for option in whitelist: optvalue = config.get(option, None) # Temporary, this will be removed soon if option in [ 'failfast', 'ignore_missing_references', 'execution_order', 'loaders', 'external_runner', 'external_runner_chdir', 'external_runner_testdir' ]: optvalue = config.get('run.{}'.format(option)) if optvalue is not None: LOG_UI.warn( "Overriding the replay %s with the --%s value " "given on the command line.", option.replace('_', '-'), option.replace('_', '-')) elif option in replay_config: config[option] = replay_config[option] if config.get('run.references'): LOG_UI.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_UI.error('Source job test references data not found. ' 'Aborting.') sys.exit(exit_codes.AVOCADO_FAIL) else: config['run.references'] = references if 'config' in replay_ignore: LOG_UI.warn("Ignoring configuration from source job with " "--replay-ignore.") else: self.load_config(resultsdir) if 'variants' in replay_ignore: LOG_UI.warn("Ignoring variants from source job with " "--replay-ignore.") else: variants = jobdata.retrieve_variants(resultsdir) if variants is None: LOG_UI.error('Source job variants data not found. Aborting.') sys.exit(exit_codes.AVOCADO_FAIL) else: LOG_UI.warning("Using src job Mux data only, use " "`--replay-ignore variants` to override " "them.") config["avocado_variants"] = variants # Extend "replay_test_status" of "INTERRUPTED" when --replay-resume # supplied. if config.get('run.replay.resume'): if not test_status: config['replay_teststatus'] = ["INTERRUPTED"] elif "INTERRUPTED" not in test_status: config['replay_teststatus'].append("INTERRUPTED") if test_status: replay_map = self._create_replay_map(resultsdir, test_status) config['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_UI.warn( "Directory used in the replay source job '%s' does" " not exist, using '.' instead", pwd)
def _check_results(self, dirname): pth = os.path.join(BASEDIR, "selftests", ".data", dirname) # pwd self.assertEqual(jobdata.retrieve_pwd(pth), "/home/user/avocado", "pwd mismatch") # references self.assertEqual(jobdata.retrieve_references(pth), ["yes", "no"], "references mismatch") # variants try: variants = jobdata.retrieve_variants(pth) except Exception as details: self.fail("variants: Unable to retrieve: %s" % details) act = variants.to_str(0, 99) self.assertTrue(act) exp = ("\nVariant first-febe: /run/first\n" " /run/first:variable_one => 1\n\n" "Variant second-bafe: /run/second\n" " /run/second:variable_two => 2") self.assertIn(exp, act, "variants mismatch") # args try: args = jobdata.retrieve_args(pth) except Exception as details: self.fail("args: Unable to retrieve: %s" % details) self.assertTrue(isinstance(args, dict), "args: Invalid args: %s" % args) for scenario in [["loaders", [u"external:/bin/echo"]], ["external_runner", u"/bin/echo"], ["failfast", False, None], ["ignore_missing_references", False, None], ["execution_order", "variants-per-test", None]]: act = args.get(scenario[0]) self.assertIn( act, scenario[1:], "args: Invalid value '%s' of key '%s' '%s'" % (act, scenario[0], scenario[1:])) # config conf_path = jobdata.retrieve_config(pth) self.assertTrue( os.path.exists(conf_path), "config: Retrieved path '%s' does not exists" % conf_path) exp = "[avocado.selftest]\njobdata = yes" with open(conf_path, "r") as conf: act = conf.read() self.assertIn( exp, act, "config: Expected string\n%s\n\nNot in:\n%s" % (exp, act)) # cmdline act = jobdata.retrieve_cmdline(pth) exp = [ '/usr/local/bin/avocado', 'run', '--external-runner', '/bin/echo', '-m', 'examples/yaml_to_mux/simple_vars.yaml', '--', 'yes', 'no' ] self.assertEqual(exp, act, "cmdline: Invalid cmdline '%s' (%s)" % (act, exp))
def run(self, args): if getattr(args, 'replay_jobid', None) is None: return err = None if args.replay_teststatus and 'variants' in args.replay_ignore: err = ("Option `--replay-test-status` is incompatible with " "`--replay-ignore variants`.") 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_UI.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_UI.error(exception.message) sys.exit(exit_codes.AVOCADO_FAIL) if resultsdir is None: LOG_UI.error("Can't find job results directory in '%s'", logdir) sys.exit(exit_codes.AVOCADO_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_UI.error(msg) sys.exit(exit_codes.AVOCADO_FAIL) setattr(args, 'replay_sourcejob', sourcejob) replay_args = jobdata.retrieve_args(resultsdir) whitelist = [ 'loaders', 'external_runner', 'external_runner_testdir', 'external_runner_chdir', 'failfast', 'ignore_missing_references' ] if replay_args is None: LOG_UI.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_UI.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_UI.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_UI.error('Source job test references data not found. ' 'Aborting.') sys.exit(exit_codes.AVOCADO_FAIL) else: setattr(args, 'reference', references) if 'config' in args.replay_ignore: LOG_UI.warn("Ignoring configuration from source job with " "--replay-ignore.") else: self.load_config(resultsdir) if 'variants' in args.replay_ignore: LOG_UI.warn("Ignoring variants from source job with " "--replay-ignore.") else: variants = jobdata.retrieve_variants(resultsdir) if variants is None: LOG_UI.error('Source job variants data not found. Aborting.') sys.exit(exit_codes.AVOCADO_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 variants object. if args.avocado_variants.is_parsed(): LOG_UI.warning("Using src job Mux data only, use " "`--replay-ignore variants` to override " "them.") setattr(args, "avocado_variants", variants) # Extend "replay_test_status" of "INTERRUPTED" when --replay-resume # supplied. if args.replay_resume: if not args.replay_teststatus: args.replay_teststatus = ["INTERRUPTED"] elif "INTERRUPTED" not in args.replay_teststatus: args.replay_teststatus.append("INTERRUPTED") 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_UI.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 err = None if args.replay_teststatus and 'variants' in args.replay_ignore: err = ("Option `--replay-test-status` is incompatible with " "`--replay-ignore variants`.") elif args.replay_teststatus and args.reference: err = ("Option --replay-test-status is incompatible with " "test references given on the command line.") elif getattr(args, "remote_hostname", False): err = "Currently we don't replay jobs in remote hosts." if err is not None: LOG_UI.error(err) sys.exit(exit_codes.AVOCADO_FAIL) base_logdir = getattr(args, 'base_logdir', None) if base_logdir is None: base_logdir = settings.get_value(section='datadir.paths', key='logs_dir', key_type='path', default=None) try: resultsdir = jobdata.get_resultsdir(base_logdir, args.replay_jobid) except ValueError as exception: LOG_UI.error(exception.message) sys.exit(exit_codes.AVOCADO_FAIL) if resultsdir is None: LOG_UI.error("Can't find job results directory in '%s'", base_logdir) sys.exit(exit_codes.AVOCADO_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_UI.error(msg) sys.exit(exit_codes.AVOCADO_FAIL) setattr(args, 'replay_sourcejob', sourcejob) replay_args = jobdata.retrieve_args(resultsdir) whitelist = ['loaders', 'external_runner', 'external_runner_testdir', 'external_runner_chdir', 'failfast', 'ignore_missing_references', 'execution_order'] if replay_args is None: LOG_UI.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_UI.warn("Overriding the replay %s with the --%s value " "given on the command line.", option.replace('_', '-'), option.replace('_', '-')) elif option in replay_args: setattr(args, option, replay_args[option]) if getattr(args, 'reference', None): LOG_UI.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_UI.error('Source job test references data not found. ' 'Aborting.') sys.exit(exit_codes.AVOCADO_FAIL) else: setattr(args, 'reference', references) if 'config' in args.replay_ignore: LOG_UI.warn("Ignoring configuration from source job with " "--replay-ignore.") else: self.load_config(resultsdir) if 'variants' in args.replay_ignore: LOG_UI.warn("Ignoring variants from source job with " "--replay-ignore.") else: variants = jobdata.retrieve_variants(resultsdir) if variants is None: LOG_UI.error('Source job variants data not found. Aborting.') sys.exit(exit_codes.AVOCADO_FAIL) else: LOG_UI.warning("Using src job Mux data only, use " "`--replay-ignore variants` to override " "them.") setattr(args, "avocado_variants", variants) # Extend "replay_test_status" of "INTERRUPTED" when --replay-resume # supplied. if args.replay_resume: if not args.replay_teststatus: args.replay_teststatus = ["INTERRUPTED"] elif "INTERRUPTED" not in args.replay_teststatus: args.replay_teststatus.append("INTERRUPTED") 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_UI.warn("Directory used in the replay source job '%s' does" " not exist, using '.' instead", pwd)
def _check_results(pth): msg = "Retrieved %s is not '%s' (%s)" errs = [] # pwd exp = "/home/medic/Work/Projekty/avocado/avocado" act = jobdata.retrieve_pwd(pth) if act != exp: errs.append("pwd: '%s' '%s'" % (exp, act)) # references exp = ["yes", "no"] act = jobdata.retrieve_references(pth) if act != exp: errs.append("references: '%s' '%s'" % (exp, act)) # variants try: variants = jobdata.retrieve_variants(pth) act = variants.to_str(0, 99) except Exception as details: errs.append("variants: Unable to retrieve: %s" % details) else: exp = ("\nVariant variant1-6ec4: /run/variant1\n" " /run/variant1:foo => bar\n\n" "Variant variant2-a6fe: /run/variant2\n" " /run/variant2:foo => baz") if not act or exp not in act: errs.append("variants:\n%s\n\n%s" % (exp, act)) # args try: args = jobdata.retrieve_args(pth) except Exception as details: errs.append("args: Unable to retrieve: %s" % details) else: if isinstance(args, dict): for scenario in [["loaders", [u"external:/bin/echo"]], ["external_runner", u"/bin/echo"], ["failfast", False, None], ["ignore_missing_references", False, None], ["execution_order", "variants-per-test", None]]: act = args.get(scenario[0]) for exp in scenario[1:]: if act == exp: break else: errs.append("args: Invalid value '%s' of key '%s' " "%s" % (act, scenario[0], scenario[1:])) else: errs.append("args: Invalid args: %s" % args) # config conf_path = jobdata.retrieve_config(pth) if os.path.exists(conf_path): exp = "[avocado.selftest]\njobdata = yes" with open(conf_path, "r") as conf: act = conf.read() if exp not in act: errs.append("config: Expected string\n%s\n\nNot in:\n%s" % (exp, act)) else: errs.append("config: Retrieved path '%s' does not exists" % conf_path) # cmdline act = jobdata.retrieve_cmdline(pth) exp = ['/usr/local/bin/avocado', 'run', '--external-runner', '/bin/echo', '-m', 'examples/mux-0.yaml', '--', 'yes', 'no'] if exp != act: errs.append("cmdline: Invalid cmdline '%s' (%s)" % (act, exp)) return errs
def _check_results(pth): msg = "Retrieved %s is not '%s' (%s)" errs = [] # pwd exp = "/home/medic/Work/Projekty/avocado/avocado" act = jobdata.retrieve_pwd(pth) if act != exp: errs.append("pwd: '%s' '%s'" % (exp, act)) # references exp = ["yes", "no"] act = jobdata.retrieve_references(pth) if act != exp: errs.append("references: '%s' '%s'" % (exp, act)) # variants try: variants = jobdata.retrieve_variants(pth) act = variants.to_str(0, 99) except Exception as details: errs.append("variants: Unable to retrieve: %s" % details) else: exp = ("\nVariant variant1-6ec4: /run/variant1\n" " /run/variant1:foo => bar\n\n" "Variant variant2-a6fe: /run/variant2\n" " /run/variant2:foo => baz") if not act or exp not in act: errs.append("variants:\n%s\n\n%s" % (exp, act)) # args try: args = jobdata.retrieve_args(pth) except Exception as details: errs.append("args: Unable to retrieve: %s" % details) else: if isinstance(args, dict): for scenario in [["loaders", [u"external:/bin/echo"]], ["external_runner", u"/bin/echo"], ["failfast", False, None], ["ignore_missing_references", False, None], [ "execution_order", "variants-per-test", None ]]: act = args.get(scenario[0]) for exp in scenario[1:]: if act == exp: break else: errs.append("args: Invalid value '%s' of key '%s' " "%s" % (act, scenario[0], scenario[1:])) else: errs.append("args: Invalid args: %s" % args) # config conf_path = jobdata.retrieve_config(pth) if os.path.exists(conf_path): exp = "[avocado.selftest]\njobdata = yes" with open(conf_path, "r") as conf: act = conf.read() if exp not in act: errs.append("config: Expected string\n%s\n\nNot in:\n%s" % (exp, act)) else: errs.append("config: Retrieved path '%s' does not exists" % conf_path) # cmdline act = jobdata.retrieve_cmdline(pth) exp = [ '/usr/local/bin/avocado', 'run', '--external-runner', '/bin/echo', '-m', 'examples/mux-0.yaml', '--', 'yes', 'no' ] if exp != act: errs.append("cmdline: Invalid cmdline '%s' (%s)" % (act, exp)) return errs
def run(self, config): if config.get('replay_jobid', None) is None: return err = None if config.get('replay_teststatus') and 'variants' in config.get( 'replay_ignore'): err = ("Option `--replay-test-status` is incompatible with " "`--replay-ignore variants`.") elif config.get('replay_teststatus') and config.get('references'): err = ("Option --replay-test-status is incompatible with " "test references given on the command line.") elif config.get("remote_hostname", False): err = "Currently we don't replay jobs in remote hosts." if err is not None: LOG_UI.error(err) sys.exit(exit_codes.AVOCADO_FAIL) base_logdir = config.get('base_logdir', None) if base_logdir is None: base_logdir = settings.get_value(section='datadir.paths', key='logs_dir', key_type='path', default=None) try: resultsdir = jobdata.get_resultsdir(base_logdir, config.get('replay_jobid')) except ValueError as exception: LOG_UI.error(exception) sys.exit(exit_codes.AVOCADO_FAIL) if resultsdir is None: LOG_UI.error("Can't find job results directory in '%s'", base_logdir) sys.exit(exit_codes.AVOCADO_FAIL) sourcejob = jobdata.get_id(os.path.join(resultsdir, 'id'), config.get('replay_jobid')) if sourcejob is None: msg = ("Can't find matching job id '%s' in '%s' directory." % (config.get('replay_jobid'), resultsdir)) LOG_UI.error(msg) sys.exit(exit_codes.AVOCADO_FAIL) config['replay_sourcejob'] = sourcejob replay_config = jobdata.retrieve_job_config(resultsdir) whitelist = [ 'loaders', 'external_runner', 'external_runner_testdir', 'external_runner_chdir', 'failfast', 'ignore_missing_references', 'execution_order' ] if replay_config is None: LOG_UI.warn( 'Source job config data not found. These options will ' 'not be loaded in this replay job: %s', ', '.join(whitelist)) else: for option in whitelist: optvalue = config.get(option, None) if optvalue is not None: LOG_UI.warn( "Overriding the replay %s with the --%s value " "given on the command line.", option.replace('_', '-'), option.replace('_', '-')) elif option in replay_config: config[option] = replay_config[option] if config.get('references', None): LOG_UI.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_UI.error('Source job test references data not found. ' 'Aborting.') sys.exit(exit_codes.AVOCADO_FAIL) else: config['references'] = references if 'config' in config.get('replay_ignore'): LOG_UI.warn("Ignoring configuration from source job with " "--replay-ignore.") else: self.load_config(resultsdir) if 'variants' in config.get('replay_ignore'): LOG_UI.warn("Ignoring variants from source job with " "--replay-ignore.") else: variants = jobdata.retrieve_variants(resultsdir) if variants is None: LOG_UI.error('Source job variants data not found. Aborting.') sys.exit(exit_codes.AVOCADO_FAIL) else: LOG_UI.warning("Using src job Mux data only, use " "`--replay-ignore variants` to override " "them.") config["avocado_variants"] = variants # Extend "replay_test_status" of "INTERRUPTED" when --replay-resume # supplied. if config.get('replay_resume'): if not config.get('replay_teststatus'): config['replay_teststatus'] = ["INTERRUPTED"] elif "INTERRUPTED" not in config.get('replay_teststatus'): config['replay_teststatus'].append("INTERRUPTED") if config.get('replay_teststatus'): replay_map = self._create_replay_map( resultsdir, config.get('replay_teststatus')) config['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_UI.warn( "Directory used in the replay source job '%s' does" " not exist, using '.' instead", pwd)