summaryrefslogtreecommitdiffstats
path: root/dovetail/tests/unit
diff options
context:
space:
mode:
authorPanagiotis Karalis <pkaralis@intracom-telecom.com>2019-04-11 13:28:21 +0300
committerDan Xu <xudan16@huawei.com>2019-04-17 12:55:54 +0000
commit73febf900b85dae4d953389696f3a78cf8267816 (patch)
tree41b45803fa0a7c3368a3f1553f58b96b671f3ef6 /dovetail/tests/unit
parentf170bf4205fd75db96b84a685b931904f4dbab93 (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>
Diffstat (limited to 'dovetail/tests/unit')
-rw-r--r--dovetail/tests/unit/test_report.py118
-rw-r--r--dovetail/tests/unit/test_testcase.py7
-rw-r--r--dovetail/tests/unit/test_testcase.yaml1
3 files changed, 125 insertions, 1 deletions
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