From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
To: "Aníbal Limón" <anibal.limon@linux.intel.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 07/30] oeqa/core/threaded: Add support to run into a thread at end of execution
Date: Wed, 12 Jul 2017 09:22:26 -0500 [thread overview]
Message-ID: <1499869346.5349.39.camel@linux.intel.com> (raw)
In-Reply-To: <c98e2413ca74b935b701d8e576089c78fc4f0df7.1499803885.git.anibal.limon@linux.intel.com>
On Tue, 2017-07-11 at 15:23 -0500, Aníbal Limón wrote:
> Some test cases aren't allowed to run into a multi-thread environment so
> add the posibility to run those tests at end of execution.
>
Hi Anibal,
which is the reason these need to run at the end?
> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
> ---
> meta/lib/oeqa/core/threaded.py | 102 +++++++++++++++++++++++++++++++----------
> 1 file changed, 78 insertions(+), 24 deletions(-)
>
> diff --git a/meta/lib/oeqa/core/threaded.py b/meta/lib/oeqa/core/threaded.py
> index 34217f1a8b8..a7dc0aed401 100644
> --- a/meta/lib/oeqa/core/threaded.py
> +++ b/meta/lib/oeqa/core/threaded.py
> @@ -30,18 +30,35 @@ class OETestLoaderThreaded(OETestLoader):
> suites = {}
> suites['main'] = self.suiteClass()
> suites['pool'] = []
> + suites['end'] = self.suiteClass()
> for _ in range(self.process_num - 1):
> suites['pool'].append(self.suiteClass())
>
> + def _add_by_module_or_dep(suite, case, depends):
> + """
> + A test case that needs to run into the same thread
> + because is on the same module or for dependency
> + reasons.
> + """
> +
> + for c in suite._tests:
> + if case.__module__ == c.__module__:
> + suite.addTest(case)
> + return True
> +
> + if case.id() in depends:
> + case_depends = depends[case.id()]
> + for c in suite._tests:
> + if c.id() in case_depends:
> + suite.addTest(case)
> + return True
> +
> + return False
> +
> def _add_to_main_thread(main_suite, case, depends):
> """
> Some test cases needs to be run into the main
> - thread for several resons.
> -
> - A test case that needs to run in the main thread
> - can be for specific set via test class _main_thread
> - attr or because is on the same module or for a dependency
> - reason.
> + thread by request.
> """
>
> if hasattr(case.__class__, '_main_thread') and \
> @@ -50,19 +67,20 @@ class OETestLoaderThreaded(OETestLoader):
> main_suite.addTest(case)
> return True
>
> - for c in main_suite._tests:
> - if case.__module__ == c.__module__:
> - main_suite.addTest(case)
> - return True
> + return _add_by_module_or_dep(main_suite, case, depends)
>
> - if case.id() in depends:
> - case_depends = depends[case.id()]
> - for c in main_suite._tests:
> - if c.id() in case_depends:
> - main_suite.addTest(case)
> - return True
> + def _add_to_end_thread(end_suite, case, depends):
> + """
> + Some test cases needs to be run into at end of
> + execution into the main by request.
> + """
> + if hasattr(case.__class__, '_end_thread') and \
> + case.__class__._end_thread or \
> + self.process_num == 1:
> + end_suite.addTest(case)
> + return True
>
> - return False
> + return _add_by_module_or_dep(end_suite, case, depends)
>
> def _search_for_module_idx(suites, case):
> """
> @@ -112,6 +130,9 @@ class OETestLoaderThreaded(OETestLoader):
> if 'depends' in self.tc._registry:
> depends = self.tc._registry['depends']
>
> + if _add_to_end_thread(suites['end'], case, depends):
> + continue
> +
> if _add_to_main_thread(suites['main'], case, depends):
> continue
>
> @@ -135,7 +156,7 @@ class OETestLoaderThreaded(OETestLoader):
>
> # if the main suite doesn't have test cases
> # use the first element of the suites pool
> - if not len(suites['main']._tests):
> + if not len(suites['main']._tests) and len(suites['pool']):
> suites['main'] = suites['pool'].pop(0)
>
> return suites
> @@ -268,6 +289,12 @@ class _ThreadedPool:
> self.tasks = queue.Queue(num_tasks)
> self.workers = []
>
> + self.stream = stream
> + self.result = result
> +
> + self.end_task = None
> + self.end_worker = None
> +
> for _ in range(num_workers):
> worker = _Worker(self.tasks, result, stream)
> self.workers.append(worker)
> @@ -280,12 +307,25 @@ class _ThreadedPool:
> """Add a task to the queue"""
> self.tasks.put((func, args, kargs))
>
> + def add_end_task(self, func, *args, **kwargs):
> + """Add a task to be executed at end"""
> +
> + self.end_task = queue.Queue(1)
> + self.end_task.put((func, args, kwargs))
> + self.end_worker = _Worker(self.end_task, self.result,
> + self.stream)
> +
> def wait_completion(self):
> """Wait for completion of all the tasks in the queue"""
> self.tasks.join()
> for worker in self.workers:
> worker.join()
>
> + if self.end_task:
> + self.end_worker.start()
> + self.end_task.join()
> + self.end_worker.join()
> +
> class OETestRunnerThreaded(OETestRunner):
> streamLoggerClass = OEStreamLoggerThreaded
>
> @@ -293,32 +333,46 @@ class OETestRunnerThreaded(OETestRunner):
> super(OETestRunnerThreaded, self).__init__(tc, *args, **kwargs)
> self.resultclass = OETestResultThreadedInternal # XXX: XML reporting overrides at __init__
>
> + def _run_main_thread(self, suite, result):
> + if len(suite._tests):
> + run_start_time = time.time()
> + rc = super(OETestRunnerThreaded, self).run(suite)
> + run_end_time = time.time()
> + result.addResult(rc, run_start_time, run_end_time)
> + self.stream.finish()
> +
> def run(self, suites):
> result = OETestResultThreaded(self.tc)
>
> pool = None
> +
> if suites['pool']:
> thread_no = len(suites['pool'])
> pool = _ThreadedPool(thread_no, thread_no, stream=self.stream,
> result=result)
> for s in suites['pool']:
> pool.add_task(super(OETestRunnerThreaded, self).run, s)
> - pool.start()
>
> - run_start_time = time.time()
> - rc = super(OETestRunnerThreaded, self).run(suites['main'])
> - run_end_time = time.time()
> - result.addResult(rc, run_start_time, run_end_time)
> - self.stream.finish()
> + if len(suites['end']._tests):
> + if not pool:
> + pool = _ThreadedPool(0, 0, stream=self.stream,
> + result=result)
> + pool.add_end_task(super(OETestRunnerThreaded, self).run,
> + suites['end'])
>
> if pool:
> + pool.start()
> + self._run_main_thread(suites['main'], result)
> + if pool:
> pool.wait_completion()
> +
> result._fill_tc_results()
>
> return result
>
> def list_tests(self, suite, display_type):
> suite['pool'].insert(0, suite['main'])
> + suite['pool'].append(suite['end'])
>
> return super(OETestRunnerThreaded, self).list_tests(
> suite['pool'], display_type)
next prev parent reply other threads:[~2017-07-12 14:12 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-11 20:23 [PATCH 00/30] oeqa core and oe-selftest threaded enablement Aníbal Limón
2017-07-11 20:23 ` [PATCH 01/30] oeqa/core/loader: Switch method definition for _make_failed_test Aníbal Limón
2017-07-14 9:52 ` Patrick Ohly
2017-07-14 15:27 ` Aníbal Limón
2017-07-17 19:14 ` Patrick Ohly
2017-07-17 19:41 ` Aníbal Limón
2017-07-17 20:03 ` Patrick Ohly
2017-07-11 20:23 ` [PATCH 02/30] oeqa/selftest/{context, case}: Handle KeyboardInterrupt/SIGINT and SIGTERM Aníbal Limón
2017-07-12 14:18 ` Leonardo Sandoval
2017-07-12 14:53 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 03/30] selftest/cases/package: Call parent setUpClass method Aníbal Limón
2017-07-12 6:51 ` Patrick Ohly
2017-07-12 15:44 ` Aníbal Limón
2017-07-12 17:14 ` Patrick Ohly
2017-07-11 20:23 ` [PATCH 04/30] bb/tinfoil: run_command handle busy status in bitbake server Aníbal Limón
2017-07-11 20:23 ` [PATCH 05/30] oe/copy_buildsystem: check_sstate_task_list also pop BBPATH from env Aníbal Limón
2017-07-11 20:23 ` [PATCH 06/30] oeqa/core/threaded: Enable support to use the main thread Aníbal Limón
2017-07-11 20:23 ` [PATCH 07/30] oeqa/core/threaded: Add support to run into a thread at end of execution Aníbal Limón
2017-07-12 14:22 ` Leonardo Sandoval [this message]
2017-07-12 14:54 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 08/30] oeqa/core/threaded: logSummary add skipped tests info Aníbal Limón
2017-07-11 20:23 ` [PATCH 09/30] oeqa/core/tests: Update test_loader threaded to cover main thread usage Aníbal Limón
2017-07-11 20:23 ` [PATCH 10/30] oeqa/selftest/{case, context}: Add builddir by test class and context Aníbal Limón
2017-07-11 20:23 ` [PATCH 11/30] oeqa/selftest/case: Add wrappers to utils.commands modules Aníbal Limón
2017-07-11 20:23 ` [PATCH 12/30] oeqa/selftest/case: Creates meta-selftest layer per class Aníbal Limón
2017-07-11 20:23 ` [PATCH 13/30] oeqa/selftest/case: tearDown extra commands print what actually fails Aníbal Limón
2017-07-11 20:23 ` [PATCH 14/30] oeqa/selftest/case: Support bitbake memres mode in per build directory Aníbal Limón
2017-07-11 20:23 ` [PATCH 15/30] oeqa/selftest/cases: Use testlayer_path instead of call get_test_layer() Aníbal Limón
2017-07-11 20:23 ` [PATCH 16/30] oeqa/selftest/cases: Use builddir from class instead of get from environment Aníbal Limón
2017-07-11 20:23 ` [PATCH 17/30] oeqa/selftest/cases: Use wrapper methods from OESelfTestCase class Aníbal Limón
2017-07-11 20:23 ` [PATCH 18/30] oeqa/selftest/cases: tinfoil to run in the main thread Aníbal Limón
2017-07-12 6:56 ` Patrick Ohly
2017-07-12 14:55 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 19/30] oeqa/selftest/cases: imagefeatures enable threaded runs Aníbal Limón
2017-07-11 20:23 ` [PATCH 20/30] oeqa/selftest/cases: runqemu enable thraded runs Aníbal Limón
2017-07-12 7:15 ` Patrick Ohly
2017-07-12 15:01 ` Aníbal Limón
2017-07-14 9:35 ` Patrick Ohly
2017-07-14 15:27 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 21/30] oeqa/selftest/cases: runtime enable threaded runs Aníbal Limón
2017-07-11 20:23 ` [PATCH 22/30] oeqa/selftest/cases: eSDK " Aníbal Limón
2017-07-11 20:23 ` [PATCH 23/30] oeqa/selftest/cases: devtool " Aníbal Limón
2017-07-11 20:23 ` [PATCH 24/30] oeqa/selftest/cases: recipetool enable for " Aníbal Limón
2017-07-11 20:23 ` [PATCH 25/30] oeqa/selftest/cases: Move devtool deploy test case to own module Aníbal Limón
2017-07-11 20:23 ` [PATCH 26/30] selftest/cases/devtool{, end}: Move update/finish_modify tests to its " Aníbal Limón
2017-07-11 20:23 ` [PATCH 27/30] seltest/cases/devtool: Build dbus on test_devtool_add_git_local Aníbal Limón
2017-07-11 20:23 ` [PATCH 28/30] argparse_oe: Add int_positive type Aníbal Limón
2017-07-12 14:33 ` Leonardo Sandoval
2017-07-12 14:56 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 29/30] oeqa/selftest/context: Enable support for threaded runs Aníbal Limón
2017-07-11 20:23 ` [PATCH 30/30] oeqa/selftest/cases: systemd_boot enable " Aníbal Limón
2017-07-11 20:31 ` ✗ patchtest: failure for oeqa core and oe-selftest threaded enablement Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499869346.5349.39.camel@linux.intel.com \
--to=leonardo.sandoval.gonzalez@linux.intel.com \
--cc=anibal.limon@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox