Skip to content

Commit

Permalink
Merge pull request #168 from hautof/dev-3.0.0
Browse files Browse the repository at this point in the history
fix #167
  • Loading branch information
tsbxmw authored May 13, 2019
2 parents c5b3f05 + f514d9e commit 107ab71
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 26 deletions.
2 changes: 2 additions & 0 deletions haf/asserthelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion haf/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion haf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -133,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}"

Expand Down
17 changes: 9 additions & 8 deletions haf/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions haf/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 3 additions & 4 deletions haf/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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()
Expand Down
30 changes: 20 additions & 10 deletions haf/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,35 +305,43 @@ 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):
'''
check case is in the filter
: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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 107ab71

Please sign in to comment.