summaryrefslogtreecommitdiffstats
path: root/dovetail
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
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')
-rw-r--r--dovetail/report.py7
-rw-r--r--dovetail/testcase.py3
-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
5 files changed, 135 insertions, 1 deletions
diff --git a/dovetail/report.py b/dovetail/report.py
index 36a33a4..06ef415 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 e40ec4d..b6f54fa 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 53b06cb..2dcb44e 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 e3f2a64..b915556 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 cb947cd..d140612 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