From 9574db77342d4957db3bfd8b1ca5344993beac9f Mon Sep 17 00:00:00 2001 From: tsbxmw <1050636648@qq.com> Date: Fri, 10 May 2019 19:10:09 +0800 Subject: [PATCH 1/2] fix some bugs of output ... --- haf/asserthelper.py | 2 ++ haf/config.py | 11 +++++++++++ haf/program.py | 4 ++-- haf/runner.py | 30 ++++++++++++++++++++---------- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/haf/asserthelper.py b/haf/asserthelper.py index 11e01e9..aa762bf 100644 --- a/haf/asserthelper.py +++ b/haf/asserthelper.py @@ -34,6 +34,8 @@ def assert_that(real, expect, **kwargs): result = True for temp in real.keys(): result = result and AssertHelper.assert_that(real.get(temp), expect.get(temp)) + for temp in expect.keys(): + result = result and AssertHelper.assert_that(real.get(temp), expect.get(temp)) return result elif isinstance(real, list) and isinstance(expect, list): result = True diff --git a/haf/config.py b/haf/config.py index a422803..ddc1f2b 100644 --- a/haf/config.py +++ b/haf/config.py @@ -42,6 +42,17 @@ SIGNAL_BUS_END = 25 SIGNAL_LOGGER_END = 26 +# SIGNAL GROUP +SIGNAL_GROUP = { + SIGNAL_START: "signal start", + SIGNAL_STOP: "signal stop", + SIGNAL_CASE_END: "signal case end", + SIGNAL_RESULT_END: "signal result end", + SIGNAL_RECORD_END: "signal record end", + SIGNAL_BUS_END: "signal bus end", + SIGNAL_LOGGER_END: "signal logger end" +} + # api method [get, post, put, delete] CASE_HTTP_API_METHOD_GET = 30 CASE_HTTP_API_METHOD_POST = 31 diff --git a/haf/program.py b/haf/program.py index 4dbd583..cf1e801 100644 --- a/haf/program.py +++ b/haf/program.py @@ -213,16 +213,16 @@ def wait_end_signal(self, args): if not args.console: if not system_signal.empty(): self.signal = system_signal.get() - logger.info(f"program signal {self.signal}") signal = self.signal.signal if isinstance(self.signal, Signal) else None + logger.info(f"program signal {SIGNAL_GROUP.get(signal) if signal in [x for x in range(20, 30)] else None}") # check the end signal from recorder to main if signal == SIGNAL_RECORD_END or signal == SIGNAL_STOP: if not args.local_logger: while True: if not system_signal.empty(): signal_logger = system_signal.get() - logger.info(f"program signal {signal_logger}") signal_logger = signal_logger.signal if isinstance(signal_logger, Signal) else None + logger.info(f"program signal {SIGNAL_GROUP.get(signal_logger) if signal_logger in [x for x in range(20, 30)] else None}") # check the logger signal from logger to main if signal_logger == SIGNAL_LOGGER_END: logger.info("main -- stop") diff --git a/haf/runner.py b/haf/runner.py index 061e06c..3c61111 100644 --- a/haf/runner.py +++ b/haf/runner.py @@ -305,20 +305,26 @@ def check_case_run_here(self, case): :param case: :return: ''' - logger.debug(f"Base Runner check case run here {case.dependent}", __name__) + logger.debug(f"check_case_run_here Base Runner check case run here {case.dependent}", __name__) + check_case_run_here_result = False if not case.dependent or len(case.dependent) == 0: - return True + check_case_run_here_result = True + return check_case_run_here_result elif isinstance(case.dependent, list) and case.dependent==['None']: - return True + check_case_run_here_result = True + return check_case_run_here_result try: for dependence in case.dependent: if dependence not in self.bench.cases.keys(): - return False + check_case_run_here_result = False + return check_case_run_here_result if isinstance(case, HttpApiCase): self.get_dependent_var(case) - return True + check_case_run_here_result = True + return check_case_run_here_result except Exception: - return False + check_case_run_here_result = False + return check_case_run_here_result def check_case_filter(self, case): ''' @@ -326,14 +332,16 @@ def check_case_filter(self, case): :param case: :return: ''' - logger.debug(f"case <{case.ids.name}> check in [{self.bench.args.filter_case}]", __name__) filter_cases = self.bench.args.filter_case + check_case_filter_result = False if filter_cases is None or filter_cases=='None': - return True + check_case_filter_result = True elif isinstance(filter_cases, list): - return case.ids.name in filter_cases + check_case_filter_result = case.ids.name in filter_cases else: - return True + check_case_filter_result = True + logger.debug(f"check_case_filter case <{case.ids.name}> check in [{self.bench.args.filter_case}], result is {check_case_filter_result}", __name__) + return check_case_filter_result def check_case_run(self, case): # if skip, return False if self.check_case_filter(case): @@ -473,9 +481,11 @@ async def run(self, case:PyCase): result.on_case_begin() if not self.check_case_run_here(case) : + logger.debug(f"PyRunner check_case_run_here : Dependent not found ! get False", __name__) result.on_case_end() return [CASE_CAN_NOT_RUN_HERE, result] if not self.check_case_run(case): # not False is skip + logger.debug(f"PyRunner check_case_run False", __name__) result.case = case result.on_case_end() result.result = RESULT_SKIP From f514d9ed6ada3b554f15e7a7952a395e1ee6801c Mon Sep 17 00:00:00 2001 From: tsbxmw <1050636648@qq.com> Date: Mon, 13 May 2019 16:09:41 +0800 Subject: [PATCH 2/2] fix #167 --- haf/bus.py | 2 +- haf/config.py | 2 +- haf/loader.py | 17 +++++++++-------- haf/recorder.py | 7 +++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/haf/bus.py b/haf/bus.py index ebd7773..b2064cf 100644 --- a/haf/bus.py +++ b/haf/bus.py @@ -57,7 +57,7 @@ def start_manager_server(self): # runner queue to web server publish_runner = Queue(maxsize=1) # case count queue - case_count = Queue(maxsize=1) + case_count = Queue(maxsize=-1) # case result summary main queue case_result_main = Queue(maxsize=1) # logger end queue diff --git a/haf/config.py b/haf/config.py index ddc1f2b..f944ac8 100644 --- a/haf/config.py +++ b/haf/config.py @@ -144,7 +144,7 @@ # version define MAIN_VERSION = 2 SUB_VERSION = 9 -FIX_VERSION = 2 +FIX_VERSION = 3 VERSION_TYPE = "haf" PLATFORM_VERSION = f"{VERSION_TYPE}-{MAIN_VERSION}.{SUB_VERSION}.{FIX_VERSION}" diff --git a/haf/loader.py b/haf/loader.py index 09bb986..31b8cad 100644 --- a/haf/loader.py +++ b/haf/loader.py @@ -82,14 +82,15 @@ def run(self): self.put_case("case", None, self.case_back_queue.get()) if self.case_queue.empty() and self.case_back_queue.empty(): - if complete_case_count not in show_count: - logger.debug(f"complete case count check here {complete_case_count} == {self.true_case_count}", __name__) - show_count.append(complete_case_count) - if complete_case_count==self.true_case_count: - if self.args.nout: - cb.finish() - self.end_handler() - return + with new_locker(self.bus_client, self.key, self.lock): + if complete_case_count not in show_count: + logger.debug(f"complete case count check here {complete_case_count} == {self.true_case_count}", __name__) + show_count.append(complete_case_count) + if complete_case_count==self.true_case_count: + if self.args.nout: + cb.finish() + self.end_handler() + return time.sleep(0.01) elif temp is None: time.sleep(0.01) diff --git a/haf/recorder.py b/haf/recorder.py index 6893504..35a1b82 100644 --- a/haf/recorder.py +++ b/haf/recorder.py @@ -9,7 +9,7 @@ from haf.common.log import Log from haf.result import HttpApiResult, EndResult, Detail, Summary, AppResult, WebResult from haf.config import * -from haf.mark import locker +from haf.mark import locker, new_locker from haf.pluginmanager import plugin_manager from haf.utils import Utils from haf.signal import Signal @@ -205,6 +205,7 @@ def add_result_to_suite(self, result): suite.cases.append(result) self.results.details[result.case.bench_name] = suite + @locker def count_case(self, key: str, lock: m_lock=None): ''' put case's commplete count to loader, from recorder to loader @@ -213,8 +214,6 @@ def count_case(self, key: str, lock: m_lock=None): :return: ''' logger.debug(f"put case count {self.complete_case_count}", __name__) - if not self.case_count.empty(): - self.case_count.get() self.case_count.put(self.complete_case_count) def result_handler(self, result): @@ -223,7 +222,7 @@ def result_handler(self, result): :param result: :return: ''' - self.count_case("case_count", self.lock) + self.count_case(self.recorder_key, self.lock) self.add_result_to_suite(result) self.check_case_result(result) self.publish_results()