diff options
author | Panagiotis Karalis <pkaralis@intracom-telecom.com> | 2019-04-11 13:28:21 +0300 |
---|---|---|
committer | Dan Xu <xudan16@huawei.com> | 2019-04-17 12:55:54 +0000 |
commit | 73febf900b85dae4d953389696f3a78cf8267816 (patch) | |
tree | 41b45803fa0a7c3368a3f1553f58b96b671f3ef6 | |
parent | f170bf4205fd75db96b84a685b931904f4dbab93 (diff) |
Failed to upload results to ONAP portal
The results.json file generated by running
'dovetail run --testsuite xxx' is different from the one
generated by running 'dovetail run --testcase xxx'.
The former can be uploaded to ONAP portal successfully
but the latter one can't.
The main reason is that the latter one lacking of 'vnf_type'.
Keep the results.json with the same format for both running
one test suite or several test cases.
JIRA: DOVETAIL-769
Change-Id: I46af84f9f229f9e601439f68c9ed9df9477d002b
Signed-off-by: Panagiotis Karalis <pkaralis@intracom-telecom.com>
-rw-r--r-- | dovetail/report.py | 7 | ||||
-rw-r--r-- | dovetail/testcase.py | 3 | ||||
-rw-r--r-- | dovetail/tests/unit/test_report.py | 118 | ||||
-rw-r--r-- | dovetail/tests/unit/test_testcase.py | 7 | ||||
-rw-r--r-- | dovetail/tests/unit/test_testcase.yaml | 1 | ||||
-rw-r--r-- | etc/testcase/onap-vtp.validate.csar.yml | 1 | ||||
-rw-r--r-- | etc/testcase/onap-vvp.validate.heat.yml | 1 |
7 files changed, 137 insertions, 1 deletions
diff --git a/dovetail/report.py b/dovetail/report.py index 36a33a49..06ef4159 100644 --- a/dovetail/report.py +++ b/dovetail/report.py @@ -122,6 +122,13 @@ class Report(object): testcase_inreport['result'] = testcase.passed() testcase_inreport['objective'] = testcase.objective() + try: + vnf_type = testcase.vnf_type() + except Exception: + vnf_type = None + if vnf_type: + report_obj['vnf_type'] = vnf_type + report_obj['vnf_checksum'] = self.get_checksum(vnf_type) testcase_inreport['mandatory'] = testcase.is_mandatory testcase_inreport['sub_testcase'] = [] if testcase.sub_testcase() is not None: diff --git a/dovetail/testcase.py b/dovetail/testcase.py index e40ec4db..b6f54fa7 100644 --- a/dovetail/testcase.py +++ b/dovetail/testcase.py @@ -85,6 +85,9 @@ class Testcase(object): def validate_type(self): return self.testcase['validate']['type'] + def vnf_type(self): + return self.testcase['vnf_type'] + def validate_testcase(self): return self.testcase['validate']['testcase'] diff --git a/dovetail/tests/unit/test_report.py b/dovetail/tests/unit/test_report.py index 53b06cb9..2dcb44e4 100644 --- a/dovetail/tests/unit/test_report.py +++ b/dovetail/tests/unit/test_report.py @@ -170,10 +170,125 @@ class ReportTesting(unittest.TestCase): mock_factory.create.assert_called_once_with('type') checker_obj.check.assert_called_once_with(testcase_obj, None) + @patch.object(dt_report.Report, 'get_checksum') + @patch('dovetail.report.Testcase') + @patch('dovetail.report.datetime.datetime') + @patch('dovetail.report.dt_cfg') + def test_generate_json(self, mock_config, mock_datetime, mock_testcase, + mock_checksum): + logger_obj = Mock() + report = dt_report.Report() + report.logger = logger_obj + testcase_list = ['ta.tb.tc', 'td.te.tf'] + duration = 42 + mock_config.dovetail_config = { + 'build_tag': 'build_tag', + 'version': '2018.09' + } + utc_obj = Mock() + utc_obj.strftime.return_value = '2018-01-13 13:13:13 UTC' + mock_datetime.utcnow.return_value = utc_obj + testcase_obj = Mock() + testcase_obj.passed.return_value = 'PASS' + testcase_obj.objective.return_value = 'objective' + mock_checksum.return_value = 'da39a3ee5e6b4b0d3255bfef95601890afd80709' + testcase_obj.is_mandatory = True + testcase_obj.vnf_type.return_value = 'tosca' + testcase_obj.sub_testcase.return_value = ['subt_a'] + testcase_obj.sub_testcase_passed.return_value = 'PASS' + mock_testcase.get.side_effect = [testcase_obj, None] + + result = report.generate_json(testcase_list, duration) + expected = { + 'version': '2018.09', + 'build_tag': 'build_tag', + 'vnf_type': 'tosca', + 'vnf_checksum': 'da39a3ee5e6b4b0d3255bfef95601890afd80709', + 'test_date': '2018-01-13 13:13:13 UTC', + 'duration': duration, + 'testcases_list': [ + { + 'name': 'ta.tb.tc', + 'result': 'PASS', + 'objective': 'objective', + 'mandatory': True, + 'sub_testcase': [{ + 'name': 'subt_a', + 'result': 'PASS' + }] + }, + { + 'name': 'td.te.tf', + 'result': 'Undefined', + 'objective': '', + 'mandatory': False, + 'sub_testcase': [] + } + ] + } + + self.assertEquals(expected, result) + + @patch('dovetail.report.Testcase') + @patch('dovetail.report.datetime.datetime') + @patch('dovetail.report.dt_cfg') + def test_generate_json_noVNF(self, mock_config, mock_datetime, + mock_testcase): + logger_obj = Mock() + report = dt_report.Report() + report.logger = logger_obj + testcase_list = ['ta.tb.tc', 'td.te.tf'] + duration = 42 + mock_config.dovetail_config = { + 'build_tag': 'build_tag', + 'version': '2018.09' + } + utc_obj = Mock() + utc_obj.strftime.return_value = '2018-01-13 13:13:13 UTC' + mock_datetime.utcnow.return_value = utc_obj + testcase_obj = Mock() + testcase_obj.passed.return_value = 'PASS' + testcase_obj.objective.return_value = 'objective' + testcase_obj.is_mandatory = True + testcase_obj.vnf_type.return_value = None + testcase_obj.sub_testcase.return_value = ['subt_a'] + testcase_obj.sub_testcase_passed.return_value = 'PASS' + mock_testcase.get.side_effect = [testcase_obj, None] + + result = report.generate_json(testcase_list, duration) + expected = { + 'version': '2018.09', + 'build_tag': 'build_tag', + 'test_date': '2018-01-13 13:13:13 UTC', + 'duration': duration, + 'testcases_list': [ + { + 'name': 'ta.tb.tc', + 'result': 'PASS', + 'objective': 'objective', + 'mandatory': True, + 'sub_testcase': [{ + 'name': 'subt_a', + 'result': 'PASS' + }] + }, + { + 'name': 'td.te.tf', + 'result': 'Undefined', + 'objective': '', + 'mandatory': False, + 'sub_testcase': [] + } + ] + } + + self.assertEquals(expected, result) + @patch('dovetail.report.Testcase') @patch('dovetail.report.datetime.datetime') @patch('dovetail.report.dt_cfg') - def test_generate_json(self, mock_config, mock_datetime, mock_testcase): + def test_generate_json_noVNF_inTestCase(self, mock_config, mock_datetime, + mock_testcase): logger_obj = Mock() report = dt_report.Report() report.logger = logger_obj @@ -190,6 +305,7 @@ class ReportTesting(unittest.TestCase): testcase_obj.passed.return_value = 'PASS' testcase_obj.objective.return_value = 'objective' testcase_obj.is_mandatory = True + testcase_obj.vnf_type.side_effect = Exception() testcase_obj.sub_testcase.return_value = ['subt_a'] testcase_obj.sub_testcase_passed.return_value = 'PASS' mock_testcase.get.side_effect = [testcase_obj, None] diff --git a/dovetail/tests/unit/test_testcase.py b/dovetail/tests/unit/test_testcase.py index e3f2a64c..b915556c 100644 --- a/dovetail/tests/unit/test_testcase.py +++ b/dovetail/tests/unit/test_testcase.py @@ -163,6 +163,13 @@ class TestcaseTesting(unittest.TestCase): self.assertEquals('tempest_smoke_serial', result) + def test_vnf_type(self): + testcase = tcase.OnapVtpTestcase(self.testcase_yaml) + + result = testcase.vnf_type() + + self.assertEquals('tosca', result) + def test_passed(self): testcase = tcase.Testcase(self.testcase_yaml) diff --git a/dovetail/tests/unit/test_testcase.yaml b/dovetail/tests/unit/test_testcase.yaml index cb947cd9..d1406127 100644 --- a/dovetail/tests/unit/test_testcase.yaml +++ b/dovetail/tests/unit/test_testcase.yaml @@ -2,6 +2,7 @@ dovetail.ipv6.tc001: name: dovetail.ipv6.tc001 objective: VIM ipv6 operations, to create/delete network, port and subnet in bulk operation + vnf_type: tosca validate: type: functest testcase: tempest_smoke_serial diff --git a/etc/testcase/onap-vtp.validate.csar.yml b/etc/testcase/onap-vtp.validate.csar.yml index d544b6c5..da64c6ef 100644 --- a/etc/testcase/onap-vtp.validate.csar.yml +++ b/etc/testcase/onap-vtp.validate.csar.yml @@ -2,6 +2,7 @@ onap-vtp.validate.csar: name: onap-vtp.validate.csar objective: onap csar validation + vnf_type: tosca validate: type: onap-vtp testcase: csar-validate diff --git a/etc/testcase/onap-vvp.validate.heat.yml b/etc/testcase/onap-vvp.validate.heat.yml index 2cdab7cc..c6071e6a 100644 --- a/etc/testcase/onap-vvp.validate.heat.yml +++ b/etc/testcase/onap-vvp.validate.heat.yml @@ -2,6 +2,7 @@ onap-vvp.validate.heat: name: onap-vvp.validate.heat objective: onap heat template validation + vnf_type: heat validate: type: onap-vvp testcase: ice_validator |