Failed to upload results to ONAP portal 38/67538/8
authorPanagiotis Karalis <pkaralis@intracom-telecom.com>
Thu, 11 Apr 2019 10:28:21 +0000 (13:28 +0300)
committerDan Xu <xudan16@huawei.com>
Wed, 17 Apr 2019 12:55:54 +0000 (12:55 +0000)
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>
dovetail/report.py
dovetail/testcase.py
dovetail/tests/unit/test_report.py
dovetail/tests/unit/test_testcase.py
dovetail/tests/unit/test_testcase.yaml
etc/testcase/onap-vtp.validate.csar.yml
etc/testcase/onap-vvp.validate.heat.yml

index 36a33a4..06ef415 100644 (file)
@@ -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:
index e40ec4d..b6f54fa 100644 (file)
@@ -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']
 
index 53b06cb..2dcb44e 100644 (file)
@@ -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]
index e3f2a64..b915556 100644 (file)
@@ -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)
 
index cb947cd..d140612 100644 (file)
@@ -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
index d544b6c..da64c6e 100644 (file)
@@ -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
index 2cdab7c..c6071e6 100644 (file)
@@ -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