Esempio n. 1
0
    def run(self, config):
        resolutions = resolver.resolve(config.get('references'))
        tasks = self.resolutions_to_tasks(resolutions, config)
        self.pending_tasks = self.check_tasks_requirements(tasks)  # pylint: disable=W0201

        if not self.pending_tasks:
            LOG_UI.error('No test to be executed, exiting...')
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        if not config.get('disable_task_randomization'):
            random.shuffle(self.pending_tasks)

        self.spawned_tasks = []  # pylint: disable=W0201

        try:
            loop = asyncio.get_event_loop()
            self.status_server = nrunner.StatusServer(
                config.get('status_server'),  # pylint: disable=W0201
                [t.identifier for t in self.pending_tasks])
            self.status_server.start()
            loop.run_until_complete(self.spawn_tasks())
            loop.run_until_complete(self.status_server.wait())
            print(self.status_server.status)
            exit_code = exit_codes.AVOCADO_ALL_OK
            if self.status_server.status.get('fail') is not None:
                exit_code |= exit_codes.AVOCADO_TESTS_FAIL
            elif self.status_server.status.get('error') is not None:
                exit_code |= exit_codes.AVOCADO_TESTS_FAIL
            return exit_code
        except Exception as e:
            LOG_UI.error(e)
            return exit_codes.AVOCADO_FAIL
Esempio n. 2
0
 def run(self, config):
     references = config.get('references', [])
     resolutions = resolver.resolve(references)
     matrix, stats, tag_stats, resolution_matrix = self._get_resolution_matrix(
         config, resolutions)
     self._display(matrix, stats, tag_stats, resolution_matrix,
                   config.get('verbose'))
Esempio n. 3
0
    def run(self, config):
        hint_filepath = '.avocado.hint'
        hint = None
        if os.path.exists(hint_filepath):
            hint = HintParser(hint_filepath)
        resolutions = resolver.resolve(config.get('nrun.references'), hint)
        tasks = job.resolutions_to_tasks(resolutions, config)
        # pylint: disable=W0201
        self.pending_tasks, missing_requirements = nrunner.check_tasks_requirements(
            tasks)
        if missing_requirements:
            missing_tasks_msg = "\n".join(
                [str(t) for t in missing_requirements])
            LOG_UI.warning(
                'Tasks will not be run due to missing requirements: %s',
                missing_tasks_msg)

        if not self.pending_tasks:
            LOG_UI.error('No test to be executed, exiting...')
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        if not config.get('nrun.disable_task_randomization'):
            random.shuffle(self.pending_tasks)

        self.spawned_tasks = []  # pylint: disable=W0201

        try:
            if config.get('nrun.spawners.podman.enabled'):
                if not os.path.exists(PodmanSpawner.PODMAN_BIN):
                    msg = ('Podman Spawner selected, but podman binary "%s" '
                           'is not available on the system.  Please install '
                           'podman before attempting to use this feature.')
                    msg %= PodmanSpawner.PODMAN_BIN
                    LOG_UI.error(msg)
                    sys.exit(exit_codes.AVOCADO_JOB_FAIL)
                self.spawner = PodmanSpawner()  # pylint: disable=W0201
            else:
                self.spawner = ProcessSpawner()  # pylint: disable=W0201
            listen = config.get('nrun.status_server.listen')
            verbose = config.get('core.verbose')
            self.status_server = nrunner.StatusServer(
                listen,  # pylint: disable=W0201
                [t.identifier for t in self.pending_tasks],
                verbose)
            self.status_server.start()
            parallel_tasks = config.get('nrun.parallel_tasks')
            loop = asyncio.get_event_loop()
            loop.run_until_complete(self.spawn_tasks(parallel_tasks))
            loop.run_until_complete(self.status_server.wait())
            self.report_results()
            exit_code = exit_codes.AVOCADO_ALL_OK
            if self.status_server.result.get('fail') is not None:
                exit_code |= exit_codes.AVOCADO_TESTS_FAIL
            elif self.status_server.result.get('error') is not None:
                exit_code |= exit_codes.AVOCADO_TESTS_FAIL
            return exit_code
        except Exception as e:  # pylint: disable=W0703
            LOG_UI.error(e)
            return exit_codes.AVOCADO_FAIL
Esempio n. 4
0
 def run(self, config):
     references = config.get('references', [])
     resolutions = resolver.resolve(references)
     matrix, stats, tag_stats, resolution_matrix = self._get_resolution_matrix(
         config, resolutions)
     self._display(matrix, stats, tag_stats, resolution_matrix,
                   config.get('verbose'))
     recipes_directory = config.get('write_recipes_to_directory')
     if recipes_directory is not None:
         fmt = '%%0%uu.json' % len(str(len(matrix)))
         index = 1
         for resolution in resolutions:
             if resolution.result == resolver.ReferenceResolutionResult.SUCCESS:
                 for res in resolution.resolutions:
                     res.write_json(
                         os.path.join(recipes_directory, fmt % index))
                     index += 1
Esempio n. 5
0
    def _from_config_with_resolver(cls, config, name=None):
        ignore_missing = config.get("run.ignore_missing_references")
        references = config.get("resolver.references")
        try:
            hint = None
            hint_filepath = ".avocado.hint"
            if os.path.exists(hint_filepath):
                hint = HintParser(hint_filepath)
            resolutions = resolve(
                references, hint=hint, ignore_missing=ignore_missing, config=config
            )
        except JobTestSuiteReferenceResolutionError as details:
            raise TestSuiteError(details)

        runnables = resolutions_to_runnables(resolutions, config)

        if name is None:
            name = str(uuid4())
        return cls(name=name, config=config, tests=runnables, resolutions=resolutions)
Esempio n. 6
0
 def run(self, config):
     references = config.get('nlist.references')
     verbose = config.get('nlist.verbose')
     hint = None
     hint_filepath = '.avocado.hint'
     if os.path.exists(hint_filepath):
         hint = HintParser(hint_filepath)
     resolutions = resolver.resolve(references, hint)
     matrix, stats, tag_stats, resolution_matrix = self._get_resolution_matrix(
         config, resolutions, verbose)
     self._display(matrix, stats, tag_stats, resolution_matrix, verbose)
     recipes_directory = config.get('nlist.recipes.write_to_directory')
     if recipes_directory is not None:
         fmt = '%%0%uu.json' % len(str(len(matrix)))
         index = 1
         for resolution in resolutions:
             if resolution.result == resolver.ReferenceResolutionResult.SUCCESS:
                 for res in resolution.resolutions:
                     res.write_json(
                         os.path.join(recipes_directory, fmt % index))
                     index += 1