diff options
author | hongbo tian <hongbo.tianhongbo@huawei.com> | 2016-10-12 09:08:19 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2016-10-12 09:08:19 +0000 |
commit | 47bd76a388cb6a5b3e023fc6239584b59e19b336 (patch) | |
tree | 87122de871a95e13d30801dfb9897fbc61b3f4a1 | |
parent | afe86e71d491d7e7acb3b58035d4fc8b1a0f4513 (diff) | |
parent | c61ca832c89b57908decf2735270b7d6cf7340b0 (diff) |
Merge "Add yardstick crawler and checker for the results of testcase"
-rw-r--r-- | scripts/report.py | 32 |
1 files changed, 29 insertions, 3 deletions
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 |