def run_suite(self, job, test_suite): summary = set() test_suite.tests, _ = nrunner.check_runnables_runner_requirements( test_suite.tests) job.result.tests_total = test_suite.variants.get_number_of_tests( test_suite.tests) listen = test_suite.config.get('nrunner.status_server_listen') self._start_status_server(listen) # pylint: disable=W0201 self.runtime_tasks = self._get_all_runtime_tasks(test_suite) if test_suite.config.get('nrunner.shuffle'): random.shuffle(self.runtime_tasks) test_ids = [ rt.task.identifier for rt in self.runtime_tasks if rt.task.category == 'test' ] tsm = TaskStateMachine(self.runtime_tasks, self.status_repo) spawner_name = test_suite.config.get('nrunner.spawner') spawner = SpawnerDispatcher(test_suite.config)[spawner_name].obj max_running = min(test_suite.config.get('nrunner.max_parallel_tasks'), len(self.runtime_tasks)) timeout = test_suite.config.get('task.timeout.running') workers = [ Worker(state_machine=tsm, spawner=spawner, max_running=max_running, task_timeout=timeout).run() for _ in range(max_running) ] asyncio.ensure_future(self._update_status(job)) loop = asyncio.get_event_loop() try: loop.run_until_complete( asyncio.wait_for(asyncio.gather(*workers), job.timeout or None)) except (KeyboardInterrupt, asyncio.TimeoutError, TestFailFast) as ex: LOG_JOB.info(str(ex)) job.interrupted_reason = str(ex) summary.add("INTERRUPTED") # Wait until all messages may have been processed by the # status_updater. This should be replaced by a mechanism # that only waits if there are missing status messages to # be processed, and, only for a given amount of time. # Tests with non received status will always show as SKIP # because of result reconciliation. loop.run_until_complete(asyncio.sleep(0.05)) job.result.end_tests() self.status_server.close() # Update the overall summary with found test statuses, which will # determine the Avocado command line exit status summary.update([ status.upper() for status in self.status_repo.get_result_set_for_tasks(test_ids) ]) return summary
def run_suite(self, job, test_suite): # pylint: disable=W0201 self.summary = set() test_suite.tests, _ = nrunner.check_tasks_requirements( test_suite.tests) job.result.tests_total = test_suite.size # no support for variants yet listen = test_suite.config.get('nrunner.status_server_listen') self._start_status_server(listen) # pylint: disable=W0201 self.tasks = self._get_all_runtime_tasks(test_suite) if test_suite.config.get('nrunner.shuffle'): random.shuffle(self.tasks) tsm = TaskStateMachine(self.tasks) spawner_name = test_suite.config.get('nrunner.spawner') spawner = SpawnerDispatcher(test_suite.config)[spawner_name].obj max_running = min(test_suite.config.get('nrunner.max_parallel_tasks'), len(self.tasks)) timeout = test_suite.config.get('task.timeout.running') workers = [ Worker(state_machine=tsm, spawner=spawner, max_running=max_running, task_timeout=timeout).run() for _ in range(max_running) ] asyncio.ensure_future(self._update_status(job)) loop = asyncio.get_event_loop() try: loop.run_until_complete( asyncio.wait_for(asyncio.gather(*workers), job.timeout or None)) except (KeyboardInterrupt, asyncio.TimeoutError): self.summary.add("INTERRUPTED") # Wait until all messages may have been processed by the # status_updater. This should be replaced by a mechanism # that only waits if there are missing status messages to # be processed, and, only for a given amount of time. # Tests with non received status will always show as SKIP # because of result reconciliation. loop.run_until_complete(asyncio.sleep(0.05)) job.result.end_tests() self.status_server.close() return self.summary
def set_environment(self, job, env_id): """ Set the environment for executing the test node. :param job: job that includes the test suite :type job: :py:class:`avocado.core.job.Job` :param str env_id: name or ID to uniquely identiy the environment This isolating environment could be a container, a virtual machine, or a less-isolated process and is managed by a specialized spawner. """ spawner_name = job.config.get('nrunner.spawner', 'lxc') # TODO: move cid in constructor in the upstream PR self.spawner = SpawnerDispatcher(job.config)[spawner_name].obj self.spawner.cid = env_id hostname = self.params["hostname"] # prepend affected test parameters for key, value in self.params.items(): if isinstance(value, str): self.params[key] = value.replace(hostname, hostname + env_id) self.params["hostname"] = env_id if env_id else hostname
def run_suite(self, job, test_suite): summary = set() if not test_suite.enabled: job.interrupted_reason = f"Suite {test_suite.name} is disabled." return summary test_suite.tests, missing_requirements = check_runnables_runner_requirements( test_suite.tests) self._update_avocado_configuration_used_on_runnables( test_suite.tests, test_suite.config) self._abort_if_missing_runners(missing_requirements) job.result.tests_total = test_suite.variants.get_number_of_tests( test_suite.tests) self._create_status_server(test_suite, job) graph = RuntimeTaskGraph( test_suite.get_test_variants(), test_suite.name, self.status_server.uri, job.unique_id, ) # pylint: disable=W0201 self.runtime_tasks = graph.get_tasks_in_topological_order() # Start the status server asyncio.ensure_future(self.status_server.serve_forever()) if test_suite.config.get("nrunner.shuffle"): random.shuffle(self.runtime_tasks) test_ids = [ rt.task.identifier for rt in self.runtime_tasks if rt.task.category == "test" ] tsm = TaskStateMachine(self.runtime_tasks, self.status_repo) spawner_name = test_suite.config.get("nrunner.spawner") spawner = SpawnerDispatcher(test_suite.config, job)[spawner_name].obj max_running = min(test_suite.config.get("nrunner.max_parallel_tasks"), len(self.runtime_tasks)) timeout = test_suite.config.get("task.timeout.running") failfast = test_suite.config.get("run.failfast") workers = [ Worker( state_machine=tsm, spawner=spawner, max_running=max_running, task_timeout=timeout, failfast=failfast, ).run() for _ in range(max_running) ] asyncio.ensure_future(self._update_status(job)) loop = asyncio.get_event_loop() try: loop.run_until_complete( asyncio.wait_for(asyncio.gather(*workers), job.timeout or None)) except (KeyboardInterrupt, asyncio.TimeoutError, TestFailFast) as ex: LOG_JOB.info(str(ex)) job.interrupted_reason = str(ex) summary.add("INTERRUPTED") # Wait until all messages may have been processed by the # status_updater. This should be replaced by a mechanism # that only waits if there are missing status messages to # be processed, and, only for a given amount of time. # Tests with non received status will always show as SKIP # because of result reconciliation. loop.run_until_complete(asyncio.sleep(0.05)) job.result.end_tests() self.status_server.close() if self.status_server_dir is not None: self.status_server_dir.cleanup() # Update the overall summary with found test statuses, which will # determine the Avocado command line exit status summary.update([ status.upper() for status in self.status_repo.get_result_set_for_tasks(test_ids) ]) return summary