From c61ca832c89b57908decf2735270b7d6cf7340b0 Mon Sep 17 00:00:00 2001 From: xudan Date: Mon, 10 Oct 2016 01:50:57 +0000 Subject: Add yardstick crawler and checker for the results of testcase JIRA: DOVETAIL-18 Change-Id: Idaad0ee4f8e6304f18fa478f1cded6e256cb12fd Signed-off-by: xudan --- scripts/report.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'scripts/report.py') diff --git a/scripts/report.py b/scripts/report.py index 42ec0df0..5dfa5890 100644 --- a/scripts/report.py +++ b/scripts/report.py @@ -157,6 +157,30 @@ class YardstickCrawler: self.type = 'yardstick' def crawl(self, testcase=None): + store_type = dovetail_config[self.type]['result']['store_type'] + if store_type == 'file': + return self.crawl_from_file(testcase) + + if store_type == 'url': + return self.crawl_from_url(testcase) + + def crawl_from_file(self, testcase=None): + file_path = os.path.join(dovetail_config['result_dir'], testcase+'.out') + if not os.path.exists(file_path): + logger.info('result file not found: %s' % file_path) + return None + try: + with open(file_path, 'r') as myfile: + output = myfile.read() + criteria = 'PASS' + json_results = {'criteria':criteria} + logger.debug('Results: %s' % str(json_results)) + return json_results + except Exception as e: + logger.error('Cannot read content from the file: %s, exception: %s' % (file_path, e)) + return None + + def crawl_from_url(self, testcase=None): return None class CheckerFactory: @@ -208,6 +232,8 @@ class FunctestChecker: class YardstickChecker: def check(cls, testcase, result): - return 'PASS' - - + if not result: + testcase.passed(False) + else: + testcase.passed(result['criteria'] == 'PASS') + return -- cgit 1.2.3-korg