summaryrefslogtreecommitdiffstats
path: root/dovetail
diff options
context:
space:
mode:
authorStamatis Katsaounis <mokats@intracom-telecom.com>2019-02-01 16:43:28 +0200
committerDan Xu <xudan16@huawei.com>2019-03-08 09:21:49 +0000
commit03610129690840704fdcdbf28188c695a263e46e (patch)
treea683ff6363125915a9b3abddbaa6dbdd8b5fdf24 /dovetail
parentea480f97ea68b741a7b62ff07a38808871b568de (diff)
Add Functest Rally test cases
This patch adds all Rally testcases of Functest to Dovetail. Change-Id: I8b20bce9966e924fd5aac41bde5a30442394db05 Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
Diffstat (limited to 'dovetail')
-rw-r--r--dovetail/report.py38
-rw-r--r--dovetail/tests/unit/test_report.py55
2 files changed, 81 insertions, 12 deletions
diff --git a/dovetail/report.py b/dovetail/report.py
index 8e75c26..86f941d 100644
--- a/dovetail/report.py
+++ b/dovetail/report.py
@@ -270,7 +270,10 @@ class FunctestCrawler(Crawler):
duration = dt_utils.get_duration(timestart, timestop,
self.logger)
if complex_testcase:
- details = self.get_details(data)
+ if testcase_name == 'rally_full':
+ details = self.get_rally_details(data)
+ else:
+ details = self.get_details(data)
except KeyError as e:
self.logger.exception(
"Result data don't have key {}.".format(e))
@@ -285,17 +288,28 @@ class FunctestCrawler(Crawler):
testcase.set_results(json_results)
return json_results
- def get_details(self, data):
- tests = data['details']['tests_number']
- failed_num = data['details']['failures_number']
- success_case = data['details']['success']
- error_case = data['details']['failures']
- skipped_case = data['details']['skipped']
- details = {'tests': tests,
- 'failures': failed_num,
- 'success': success_case,
- 'errors': error_case,
- 'skipped': skipped_case}
+ @staticmethod
+ def get_details(data):
+ t_details = data['details']
+ details = {
+ 'tests': t_details['tests_number'],
+ 'failures': t_details['failures_number'],
+ 'success': t_details['success'],
+ 'errors': t_details['failures'],
+ 'skipped': t_details['skipped']
+ }
+ return details
+
+ @staticmethod
+ def get_rally_details(data):
+ t_details = data['details'][0]['details']
+ details = {
+ 'tests': len(t_details['success']) + len(t_details['failures']),
+ 'failures': len(t_details['failures']),
+ 'success': t_details['success'],
+ 'errors': t_details['failures'],
+ 'skipped': []
+ }
return details
diff --git a/dovetail/tests/unit/test_report.py b/dovetail/tests/unit/test_report.py
index 4e1214e..be56e15 100644
--- a/dovetail/tests/unit/test_report.py
+++ b/dovetail/tests/unit/test_report.py
@@ -558,6 +558,61 @@ class ReportTesting(unittest.TestCase):
self.assertEquals(expected, result)
@patch('__builtin__.open')
+ @patch('dovetail.report.json')
+ @patch('dovetail.report.dt_cfg')
+ @patch('dovetail.report.dt_utils')
+ @patch('dovetail.report.os.path')
+ def test_functest_rally_crawler_crawl(self, mock_path, mock_utils,
+ mock_config, mock_json, mock_open):
+ logger_obj = Mock()
+ mock_config.dovetail_config = {'build_tag': 'tag'}
+ dt_report.FunctestCrawler.logger = logger_obj
+ mock_path.exists.return_value = True
+ file_path = 'file_path'
+ testcase_obj = Mock()
+ testcase_obj.validate_testcase.return_value = 'rally_full'
+ testcase_obj.name.return_value = 'name'
+ testcase_obj.sub_testcase.return_value = ['subt_a', 'subt_b', 'subt_c']
+ file_obj = Mock()
+ mock_open.return_value.__enter__.side_effect = [[file_obj], file_obj]
+ data_dict = {
+ 'case_name': 'rally_full',
+ 'build_tag': 'tag-name',
+ 'criteria': 'criteria',
+ 'start_date': 'start_date',
+ 'stop_date': 'stop_date',
+ 'details': [{
+ 'details': {
+ 'success': ['subt_a'],
+ 'failures': ['subt_b', 'subt_c']
+ }
+ }]
+ }
+
+ mock_json.loads.return_value = data_dict
+ mock_utils.get_duration.return_value = 'duration'
+
+ crawler = dt_report.FunctestCrawler()
+ result = crawler.crawl(testcase_obj, [file_path, file_path])
+ expected = {'criteria': 'criteria', 'timestart': 'start_date',
+ 'timestop': 'stop_date', 'duration': 'duration',
+ 'details': {
+ 'tests': 3, 'failures': 2,
+ 'success': ['subt_a'], 'errors': ['subt_b', 'subt_c'],
+ 'skipped': []}}
+
+ mock_path.exists.assert_called_once_with(file_path)
+ mock_open.assert_called_with(file_path, 'r')
+ mock_json.loads.assert_called_with(file_obj)
+ mock_utils.get_duration.assert_called_once_with(
+ 'start_date', 'stop_date', logger_obj)
+ testcase_obj.set_results.assert_called_with(expected)
+ testcase_obj.validate_testcase.assert_called_once_with()
+ testcase_obj.sub_testcase.assert_called_once_with()
+ testcase_obj.name.assert_called_once_with()
+ self.assertEquals(expected, result)
+
+ @patch('__builtin__.open')
@patch('dovetail.report.json.loads')
@patch('dovetail.report.dt_cfg')
@patch('dovetail.report.dt_utils')