예제 #1
0
    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)
            resultsdir = replay.get_resultsdir(logdir, args.replay_jobid)

        if resultsdir is None:
            log.error("Can't find job results directory in '%s'", logdir)
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        sourcejob = replay.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 = replay.retrieve_args(resultsdir)
        whitelist = ['loaders',
                     'external_runner',
                     'external_runner_testdir',
                     'external_runner_chdir']
        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:
                    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 = replay.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 = replay.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 = replay.retrieve_replay_map(resultsdir,
                                                    args.replay_teststatus)
            setattr(args, 'replay_map', replay_map)

        # Use the original directory to discover test urls properly
        pwd = replay.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)
예제 #2
0
파일: replay.py 프로젝트: dsarrut/avocado
    def run(self, args):
        if getattr(args, 'replay_jobid', None) is None:
            return

        view = output.View()

        if args.remote_hostname is not None:
            msg = "Currently we don't replay jobs in remote hosts."
            view.notify(event='error', msg=(msg))
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        if args.replay_datadir is not None:
            resultsdir = args.replay_datadir
        else:
            logs_dir = settings.get_value('datadir.paths', 'logs_dir',
                                          default=None)
            self.logdir = os.path.expanduser(logs_dir)
            resultsdir = replay.get_resultsdir(self.logdir, args.replay_jobid)

        if resultsdir is None:
            msg = "can't find job results directory in '%s'" % self.logdir
            view.notify(event='error', msg=(msg))
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        sourcejob = replay.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)
            view.notify(event='error', msg=(msg))
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        setattr(args, 'replay_sourcejob', sourcejob)

        if getattr(args, 'url', None):
            msg = 'Overriding the replay urls with urls provided in '\
                  'command line.'
            view.notify(event='warning', msg=(msg))
        else:
            urls = replay.retrieve_urls(resultsdir)
            if urls is None:
                msg = 'Source job urls data not found. Aborting.'
                view.notify(event='error', msg=(msg))
                sys.exit(exit_codes.AVOCADO_JOB_FAIL)
            else:
                setattr(args, 'url', urls)

        if args.replay_ignore and 'config' in args.replay_ignore:
            msg = "Ignoring configuration from source job with " \
                  "--replay-ignore."
            view.notify(event='warning', msg=(msg))
        else:
            self.load_config(resultsdir)

        if args.replay_ignore and 'mux' in args.replay_ignore:
            msg = "Ignoring multiplex from source job with --replay-ignore."
            view.notify(event='warning', msg=(msg))
        else:
            if getattr(args, 'multiplex_files', None) is not None:
                msg = 'Overriding the replay multiplex with '\
                      '--multiplex-file.'
                view.notify(event='warning', msg=(msg))
            else:
                mux = replay.retrieve_mux(resultsdir)
                if mux is None:
                    msg = 'Source job multiplex data not found. Aborting.'
                    view.notify(event='error', msg=(msg))
                    sys.exit(exit_codes.AVOCADO_JOB_FAIL)
                else:
                    setattr(args, 'replay_mux', mux)

        if args.replay_teststatus:
            replay_map = replay.retrieve_replay_map(resultsdir,
                                                    args.replay_teststatus)
            setattr(args, 'replay_map', replay_map)

        pwd = replay.retrieve_pwd(resultsdir)
        if pwd is not None:
            setattr(args, 'replay_path', pwd)
예제 #3
0
파일: replay.py 프로젝트: chloerh/avocado
    def run(self, args):
        if getattr(args, 'replay_jobid', None) is None:
            return

        view = output.View()

        err = None
        if args.replay_teststatus and args.multiplex_files:
            err = "Option --replay-test-status is incompatible with "\
                  "--multiplex-files."
        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:
            view.notify(event="error", msg=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)
            self.logdir = os.path.expanduser(logs_dir)
            resultsdir = replay.get_resultsdir(self.logdir, args.replay_jobid)

        if resultsdir is None:
            msg = "Can't find job results directory in '%s'" % self.logdir
            view.notify(event='error', msg=(msg))
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        sourcejob = replay.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)
            view.notify(event='error', msg=(msg))
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        setattr(args, 'replay_sourcejob', sourcejob)

        if getattr(args, 'url', None):
            msg = 'Overriding the replay urls with urls provided in '\
                  'command line.'
            view.notify(event='warning', msg=(msg))
        else:
            urls = replay.retrieve_urls(resultsdir)
            if urls is None:
                msg = 'Source job urls data not found. Aborting.'
                view.notify(event='error', msg=(msg))
                sys.exit(exit_codes.AVOCADO_JOB_FAIL)
            else:
                setattr(args, 'url', urls)

        if args.replay_ignore and 'config' in args.replay_ignore:
            msg = "Ignoring configuration from source job with " \
                  "--replay-ignore."
            view.notify(event='warning', msg=(msg))
        else:
            self.load_config(resultsdir)

        if args.replay_ignore and 'mux' in args.replay_ignore:
            msg = "Ignoring multiplex from source job with --replay-ignore."
            view.notify(event='warning', msg=(msg))
        else:
            if getattr(args, 'multiplex_files', None) is not None:
                msg = 'Overriding the replay multiplex with '\
                      '--multiplex-files.'
                view.notify(event='warning', msg=(msg))
                # Use absolute paths to avoid problems with os.chdir
                args.multiplex_files = [os.path.abspath(_)
                                        for _ in args.multiplex_files]
            else:
                mux = replay.retrieve_mux(resultsdir)
                if mux is None:
                    msg = 'Source job multiplex data not found. Aborting.'
                    view.notify(event='error', msg=(msg))
                    sys.exit(exit_codes.AVOCADO_JOB_FAIL)
                else:
                    setattr(args, "multiplex_files", mux)

        if args.replay_teststatus:
            replay_map = replay.retrieve_replay_map(resultsdir,
                                                    args.replay_teststatus)
            setattr(args, 'replay_map', replay_map)

        # Use the original directory to discover test urls properly
        pwd = replay.retrieve_pwd(resultsdir)
        if pwd is not None:
            if os.path.exists(pwd):
                os.chdir(pwd)
            else:
                view.notify(event="warning", msg="Directory used in the replay"
                            " source job '%s' does not exist, using '.' "
                            "instead" % pwd)
예제 #4
0
    def run(self, args):
        if getattr(args, 'replay_jobid', None) is None:
            return

        view = output.View()

        if args.remote_hostname is not None:
            msg = "Currently we don't replay jobs in remote hosts."
            view.notify(event='error', msg=(msg))
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        if args.replay_datadir is not None:
            resultsdir = args.replay_datadir
        else:
            logs_dir = settings.get_value('datadir.paths', 'logs_dir',
                                          default=None)
            self.logdir = os.path.expanduser(logs_dir)
            resultsdir = replay.get_resultsdir(self.logdir, args.replay_jobid)

        if resultsdir is None:
            msg = "can't find job results directory in '%s'" % self.logdir
            view.notify(event='error', msg=(msg))
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        sourcejob = replay.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)
            view.notify(event='error', msg=(msg))
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        setattr(args, 'replay_sourcejob', sourcejob)

        if getattr(args, 'url', None):
            msg = 'Overriding the replay urls with urls provided in '\
                  'command line.'
            view.notify(event='warning', msg=(msg))
        else:
            urls = replay.retrieve_urls(resultsdir)
            if urls is None:
                msg = 'Source job urls data not found. Aborting.'
                view.notify(event='error', msg=(msg))
                sys.exit(exit_codes.AVOCADO_JOB_FAIL)
            else:
                setattr(args, 'url', urls)

        if args.replay_ignore and 'config' in args.replay_ignore:
            msg = "Ignoring configuration from source job with " \
                  "--replay-ignore."
            view.notify(event='warning', msg=(msg))
        else:
            self.load_config(resultsdir)

        if args.replay_ignore and 'mux' in args.replay_ignore:
            msg = "Ignoring multiplex from source job with --replay-ignore."
            view.notify(event='warning', msg=(msg))
        else:
            if getattr(args, 'multiplex_files', None) is not None:
                msg = 'Overriding the replay multiplex with '\
                      '--multiplex-file.'
                view.notify(event='warning', msg=(msg))
                # Use absolute paths to avoid problems with os.chdir
                args.multiplex_files = [os.path.abspath(_)
                                        for _ in args.multiplex_files]
            else:
                mux = replay.retrieve_mux(resultsdir)
                if mux is None:
                    msg = 'Source job multiplex data not found. Aborting.'
                    view.notify(event='error', msg=(msg))
                    sys.exit(exit_codes.AVOCADO_JOB_FAIL)
                else:
                    setattr(args, "multiplex_files", mux)

        if args.replay_teststatus:
            replay_map = replay.retrieve_replay_map(resultsdir,
                                                    args.replay_teststatus)
            setattr(args, 'replay_map', replay_map)

        # Use the original directory to discover test urls properly
        pwd = replay.retrieve_pwd(resultsdir)
        if pwd is not None:
            if os.path.exists(pwd):
                os.chdir(pwd)
            else:
                view.notify(event="warning", msg="Directory used in the replay"
                            " source job '%s' does not exist, using '.' "
                            "instead" % pwd)