Add ONAP VVP Heat Template validation tests 19/66619/6
authorStamatis Katsaounis <mokats@intracom-telecom.com>
Thu, 24 Jan 2019 13:46:09 +0000 (15:46 +0200)
committerStamatis Katsaounis <mokats@intracom-telecom.com>
Fri, 1 Feb 2019 07:38:35 +0000 (07:38 +0000)
Change-Id: I9a3d56932ce41191901381831013768d1c57a749
Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
18 files changed:
dovetail/container.py
dovetail/report.py
dovetail/run.py
dovetail/test_runner.py
dovetail/testcase.py
dovetail/tests/unit/test_container.py
dovetail/tests/unit/test_report.py
dovetail/tests/unit/test_test_runner.py
dovetail/tests/unit/test_testcase.py
etc/conf/bottlenecks_config.yml
etc/conf/functest-k8s_config.yml
etc/conf/functest_config.yml
etc/conf/onap-vtp_config.yml
etc/conf/onap-vvp_config.yml [new file with mode: 0644]
etc/conf/vnftest_config.yml
etc/conf/yardstick_config.yml
etc/testcase/onap-vvp.validate.heat.yml [new file with mode: 0644]
etc/userconfig/env_config.sh.onap.sample

index d44035c..43ecf41 100644 (file)
@@ -70,6 +70,9 @@ class Container(object):
         project_cfg = dovetail_config[self.valid_type]
 
         opts = dt_utils.get_value_from_dict('opts', project_cfg)
+        shell = dt_utils.get_value_from_dict('shell', project_cfg)
+        if not shell:
+            return None
         envs = dt_utils.get_value_from_dict('envs', project_cfg)
         volumes_list = dt_utils.get_value_from_dict('volumes', project_cfg)
         opts = ' ' if not opts else opts
@@ -91,7 +94,7 @@ class Container(object):
             return None
 
         cmd = 'sudo docker run {opts} {envs} {volumes} {config} ' \
-              '{hosts_config} {docker_image} /bin/bash'.format(**locals())
+              '{hosts_config} {docker_image} {shell}'.format(**locals())
         ret, container_id = dt_utils.exec_cmd(cmd, self.logger)
         if ret != 0:
             return None
@@ -179,8 +182,13 @@ class Container(object):
     def exec_cmd(self, sub_cmd, exit_on_error=False):
         if sub_cmd == "":
             return (1, 'sub_cmd is empty')
-        cmd = 'sudo docker exec {} /bin/bash -c "{}"'.format(self.container_id,
-                                                             sub_cmd)
+        dovetail_config = dt_cfg.dovetail_config
+        project_cfg = dovetail_config[self.valid_type]
+        shell = dt_utils.get_value_from_dict('shell', project_cfg)
+        if not shell:
+            return (1, 'shell is empty')
+        cmd = 'sudo docker exec {} {} -c "{}"'.format(self.container_id, shell,
+                                                      sub_cmd)
         return dt_utils.exec_cmd(cmd, self.logger, exit_on_error)
 
     def copy_file(self, src_path, dest_path, exit_on_error=False):
index ce88ed1..0918e42 100644 (file)
@@ -29,7 +29,8 @@ from testcase import Testcase
 class Report(object):
 
     results = {'functest': {}, 'yardstick': {}, 'functest-k8s': {},
-               'bottlenecks': {}, 'shell': {}, 'vnftest': {}, 'onap-vtp': {}}
+               'bottlenecks': {}, 'shell': {}, 'vnftest': {}, 'onap-vtp': {},
+               'onap-vvp': {}}
 
     logger = None
 
@@ -488,15 +489,52 @@ class OnapVtpCrawler(Crawler):
         return json_results
 
 
+class OnapVvpCrawler(Crawler):
+
+    logger = None
+
+    def __init__(self):
+        self.type = 'onap-vvp'
+        self.logger.debug('Create crawler: {}'.format(self.type))
+
+    @classmethod
+    def create_log(cls):
+        cls.logger = dt_logger.Logger(__name__ + '.OnapVvpCrawler').getLogger()
+
+    def crawl(self, testcase, file_path):
+        return self.crawl_from_file(testcase, file_path)
+
+    def crawl_from_file(self, testcase, file_path):
+        if not os.path.exists(file_path):
+            self.logger.error('Result file not found: {}'.format(file_path))
+            return None
+        criteria = 'FAIL'
+        with open(file_path, 'r') as f:
+            try:
+                data = json.load(f)
+                criteria = data['outcome']
+            except KeyError as e:
+                self.logger.exception('Outcome field not found {}'.format(e))
+            except ValueError:
+                self.logger.exception('Result file has invalid format')
+        json_results = {'criteria': criteria}
+
+        testcase.set_results(json_results)
+        return json_results
+
+
 class CrawlerFactory(object):
 
-    CRAWLER_MAP = {'functest': FunctestCrawler,
-                   'yardstick': YardstickCrawler,
-                   'bottlenecks': BottlenecksCrawler,
-                   'vnftest': VnftestCrawler,
-                   'shell': ShellCrawler,
-                   'functest-k8s': FunctestK8sCrawler,
-                   'onap-vtp': OnapVtpCrawler}
+    CRAWLER_MAP = {
+        'functest': FunctestCrawler,
+        'yardstick': YardstickCrawler,
+        'bottlenecks': BottlenecksCrawler,
+        'vnftest': VnftestCrawler,
+        'shell': ShellCrawler,
+        'functest-k8s': FunctestK8sCrawler,
+        'onap-vtp': OnapVtpCrawler,
+        'onap-vvp': OnapVvpCrawler
+    }
 
     @classmethod
     def create(cls, type):
@@ -667,15 +705,35 @@ class OnapVtpChecker(object):
         return
 
 
+class OnapVvpChecker(object):
+
+    logger = None
+
+    @classmethod
+    def create_log(cls):
+        cls.logger = dt_logger.Logger(__name__ + '.OnapVvpChecker').getLogger()
+
+    @staticmethod
+    def check(testcase, result):
+        if not result:
+            testcase.passed('FAIL')
+        else:
+            testcase.passed(result['criteria'])
+        return
+
+
 class CheckerFactory(object):
 
-    CHECKER_MAP = {'functest': FunctestChecker,
-                   'yardstick': YardstickChecker,
-                   'bottlenecks': BottlenecksChecker,
-                   'shell': ShellChecker,
-                   'vnftest': VnftestChecker,
-                   'functest-k8s': FunctestK8sChecker,
-                   'onap-vtp': OnapVtpChecker}
+    CHECKER_MAP = {
+        'functest': FunctestChecker,
+        'yardstick': YardstickChecker,
+        'bottlenecks': BottlenecksChecker,
+        'shell': ShellChecker,
+        'vnftest': VnftestChecker,
+        'functest-k8s': FunctestK8sChecker,
+        'onap-vtp': OnapVtpChecker,
+        'onap-vvp': OnapVvpChecker
+    }
 
     @classmethod
     def create(cls, type):
index 7bb707f..04df912 100755 (executable)
@@ -112,12 +112,14 @@ def create_logs():
     dt_report.VnftestCrawler.create_log()
     dt_report.BottlenecksCrawler.create_log()
     dt_report.OnapVtpCrawler.create_log()
+    dt_report.OnapVvpCrawler.create_log()
     dt_report.FunctestChecker.create_log()
     dt_report.FunctestK8sChecker.create_log()
     dt_report.YardstickChecker.create_log()
     dt_report.VnftestChecker.create_log()
     dt_report.BottlenecksChecker.create_log()
     dt_report.OnapVtpChecker.create_log()
+    dt_report.OnapVvpChecker.create_log()
     dt_testcase.Testcase.create_log()
     dt_testcase.Testsuite.create_log()
     dt_test_runner.DockerRunner.create_log()
index 228432a..9745597 100644 (file)
@@ -132,6 +132,7 @@ class DockerRunner(Runner):
         config_item['cacert'] = os.getenv('OS_CACERT')
         config_item['host_url'] = os.getenv('HOST_URL')
         config_item['csar_file'] = os.getenv('CSAR_FILE')
+        config_item['heat_templates_dir'] = os.getenv('VNF_DIRECTORY')
         return config_item
 
     def _update_config(self, testcase, update_pod=True):
@@ -292,6 +293,22 @@ class OnapVtpRunner(DockerRunner):
         self._update_config(testcase, update_pod=False)
 
 
+class OnapVvpRunner(DockerRunner):
+
+    config_file_name = 'onap-vvp_config.yml'
+
+    def __init__(self, testcase):
+        self.type = 'onap-vvp'
+        super(OnapVvpRunner, self).__init__(testcase)
+        env_file = os.path.join(dt_cfg.dovetail_config['config_dir'],
+                                dt_cfg.dovetail_config['env_file'])
+        if not os.path.isfile(env_file):
+            self.logger.error('File {} does not exist.'.format(env_file))
+            return
+        dt_utils.source_env(env_file)
+        self._update_config(testcase, update_pod=False)
+
+
 class TestRunnerFactory(object):
 
     TEST_RUNNER_MAP = {
@@ -301,7 +318,8 @@ class TestRunnerFactory(object):
         "shell": ShellRunner,
         "vnftest": VnftestRunner,
         "functest-k8s": FunctestK8sRunner,
-        "onap-vtp": OnapVtpRunner
+        "onap-vtp": OnapVtpRunner,
+        "onap-vvp": OnapVvpRunner
     }
 
     @classmethod
index 04d95ca..93aa607 100644 (file)
@@ -358,6 +358,15 @@ class OnapVtpTestcase(Testcase):
         self.type = 'onap-vtp'
 
 
+class OnapVvpTestcase(Testcase):
+
+    validate_testcase_list = {}
+
+    def __init__(self, testcase_yaml):
+        super(OnapVvpTestcase, self).__init__(testcase_yaml)
+        self.type = 'onap-vvp'
+
+
 class TestcaseFactory(object):
     TESTCASE_TYPE_MAP = {
         'functest': FunctestTestcase,
@@ -366,7 +375,8 @@ class TestcaseFactory(object):
         'shell': ShellTestcase,
         'vnftest': VnftestTestcase,
         'functest-k8s': FunctestK8sTestcase,
-        'onap-vtp': OnapVtpTestcase
+        'onap-vtp': OnapVtpTestcase,
+        'onap-vvp': OnapVvpTestcase
     }
 
     @classmethod
index 25509a7..803566b 100644 (file)
@@ -126,14 +126,28 @@ class ContainerTesting(unittest.TestCase):
 
         self.assertEqual(expected, result)
 
+    @patch('dovetail.container.dt_cfg')
     @patch('dovetail.container.dt_utils')
-    def test_exec_cmd(self, mock_utils):
+    def test_exec_cmd(self, mock_utils, mock_config):
         expected = (0, 'success')
         mock_utils.exec_cmd.return_value = expected
+        mock_utils.get_value_from_dict.return_value = 'shell'
+        mock_config.dovetail_config = {'bottlenecks': 'value'}
         result = self.container.exec_cmd('command')
 
         mock_utils.exec_cmd.assert_called_once_with(
-            'sudo docker exec None /bin/bash -c "command"', self.logger, False)
+            'sudo docker exec None shell -c "command"', self.logger, False)
+        self.assertEqual(expected, result)
+
+    @patch('dovetail.container.dt_cfg')
+    @patch('dovetail.container.dt_utils')
+    def test_exec_cmd_no_shell(self, mock_utils, mock_config):
+        expected = (1, 'shell is empty')
+        mock_utils.exec_cmd.return_value = expected
+        mock_utils.get_value_from_dict.return_value = None
+        mock_config.dovetail_config = {'bottlenecks': 'value'}
+        result = self.container.exec_cmd('command')
+
         self.assertEqual(expected, result)
 
     @patch('dovetail.container.dt_cfg')
@@ -455,7 +469,7 @@ class ContainerTesting(unittest.TestCase):
         docker_image = 'docker_image'
         container_id = 'container_id'
         mock_utils.get_value_from_dict.side_effect = [
-            'opts', 'envs', ['volume_one', 'volume_two']]
+            'opts', 'shell', 'envs', ['volume_one', 'volume_two']]
         mock_utils.get_hosts_info.return_value = 'host_info'
         mock_utils.exec_cmd.return_value = (0, container_id)
         project_config = {}
@@ -466,21 +480,37 @@ class ContainerTesting(unittest.TestCase):
 
         mock_utils.get_value_from_dict.assert_has_calls([
             call('opts', project_config),
+            call('shell', project_config),
             call('envs', project_config),
             call('volumes', project_config)])
         mock_utils.get_hosts_info.assert_called_once_with(self.logger)
         mock_utils.exec_cmd.assert_called_once_with(
             'sudo docker run opts envs volume_one volume_two   host_info '
-            'docker_image /bin/bash', self.logger)
+            'docker_image shell', self.logger)
         self.assertEquals(expected, result)
 
+    @patch('dovetail.container.dt_utils')
+    @patch('dovetail.container.dt_cfg')
+    def test_create_no_shell(self, mock_config, mock_utils):
+        docker_image = 'docker_image'
+        mock_config.dovetail_config = {'bottlenecks': 'value'}
+        mock_utils.get_value_from_dict.side_effect = ['opts', None]
+        mock_utils.get_hosts_info.return_value = 'host_info'
+
+        result = self.container.create(docker_image)
+
+        mock_utils.get_value_from_dict.assert_has_calls([
+            call('opts', 'value'),
+            call('shell', 'value')])
+        self.assertEquals(None, result)
+
     @patch('dovetail.container.dt_utils')
     @patch('dovetail.container.dt_cfg')
     @patch('dovetail.container.os.getenv')
     def test_create_error(self, mock_getenv, mock_config, mock_utils):
         docker_image = 'docker_image'
         mock_utils.get_value_from_dict.side_effect = [
-            'opts', 'envs', ['volume_one']]
+            'opts', 'shell', 'envs', ['volume_one']]
         mock_getenv.side_effect = ['True', 'dovetail_home', None, 'True']
         mock_utils.get_hosts_info.return_value = 'host_info'
         mock_utils.check_https_enabled.return_value = True
@@ -491,12 +521,13 @@ class ContainerTesting(unittest.TestCase):
 
         mock_utils.get_value_from_dict.assert_has_calls([
             call('opts', project_config),
+            call('shell', project_config),
             call('envs', project_config),
             call('volumes', project_config)])
         mock_utils.get_hosts_info.assert_called_once_with(self.logger)
         mock_utils.exec_cmd.assert_called_once_with(
             'sudo docker run opts envs volume_one   host_info '
-            'docker_image /bin/bash', self.logger)
+            'docker_image shell', self.logger)
         self.assertEquals(None, result)
 
     @patch('dovetail.container.dt_utils')
@@ -509,7 +540,7 @@ class ContainerTesting(unittest.TestCase):
         docker_image = 'docker_image'
         container_id = 'container_id'
         mock_utils.get_value_from_dict.side_effect = [
-            'opts', 'envs', ['volume_one']]
+            'opts', 'shell', 'envs', ['volume_one']]
         mock_getenv.side_effect = ['False', 'dovetail_home', 'cacert', 'True']
         mock_setvnfconf.return_value = 'vnftest_config'
         mock_utils.get_hosts_info.return_value = 'host_info'
@@ -524,6 +555,7 @@ class ContainerTesting(unittest.TestCase):
 
         mock_utils.get_value_from_dict.assert_has_calls([
             call('opts', project_config),
+            call('shell', project_config),
             call('envs', project_config),
             call('volumes', project_config)])
         mock_utils.get_hosts_info.assert_called_once_with(self.logger)
@@ -531,7 +563,7 @@ class ContainerTesting(unittest.TestCase):
         mock_setvnffile.assert_called_once_with(container_id)
         mock_utils.exec_cmd.assert_called_once_with(
             'sudo docker run opts envs volume_one vnftest_config host_info '
-            'docker_image /bin/bash',
+            'docker_image shell',
             self.logger)
         self.assertEquals(expected, result)
 
@@ -543,7 +575,7 @@ class ContainerTesting(unittest.TestCase):
                                   mock_getenv, mock_config, mock_utils):
         docker_image = 'docker_image'
         mock_utils.get_value_from_dict.side_effect = [
-            'opts', 'envs', ['volume_one']]
+            'opts', 'shell', 'envs', ['volume_one']]
         mock_getenv.return_value = 'True'
         mock_setvnfconf.return_value = None
         mock_config.dovetail_config = {
@@ -556,6 +588,7 @@ class ContainerTesting(unittest.TestCase):
 
         mock_utils.get_value_from_dict.assert_has_calls([
             call('opts', 'value'),
+            call('shell', 'value'),
             call('envs', 'value'),
             call('volumes', 'value')])
         mock_utils.get_hosts_info.assert_called_once_with(self.logger)
index 9f5369e..8cf2e02 100644 (file)
@@ -8,6 +8,7 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##
 
+import json
 import os
 import unittest
 import yaml
@@ -35,16 +36,19 @@ class ReportTesting(unittest.TestCase):
         dt_report.BottlenecksCrawler.logger = None
         dt_report.VnftestCrawler.logger = None
         dt_report.OnapVtpCrawler.logger = None
+        dt_report.OnapVvpCrawler.logger = None
         dt_report.FunctestChecker.logger = None
         dt_report.FunctestK8sChecker.logger = None
         dt_report.YardstickChecker.logger = None
         dt_report.BottlenecksChecker.logger = None
         dt_report.VnftestChecker.logger = None
         dt_report.OnapVtpChecker.logger = None
+        dt_report.OnapVvpChecker.logger = None
         dt_report.Report.logger = None
         dt_report.Report.results = {
             'functest': {}, 'yardstick': {}, 'functest-k8s': {},
-            'bottlenecks': {}, 'shell': {}, 'vnftest': {}, 'onap-vtp': {}}
+            'bottlenecks': {}, 'shell': {}, 'vnftest': {}, 'onap-vtp': {},
+            'onap-vvp': {}}
 
     def _produce_report_initial_text(self, report_data):
         report_txt = ''
@@ -960,6 +964,17 @@ class ReportTesting(unittest.TestCase):
 
         self.assertEquals(getlogger_obj, dt_report.OnapVtpCrawler.logger)
 
+    @patch('dovetail.report.dt_logger')
+    def test_onapvvp_crawler_create_log(self, mock_logger):
+        getlogger_obj = Mock()
+        logger_obj = Mock()
+        logger_obj.getLogger.return_value = getlogger_obj
+        mock_logger.Logger.return_value = logger_obj
+
+        dt_report.OnapVvpCrawler.create_log()
+
+        self.assertEquals(getlogger_obj, dt_report.OnapVvpCrawler.logger)
+
     @patch('dovetail.report.os.path')
     def test_onapvtp_crawler_crawl_not_exists(self, mock_path):
         logger_obj = Mock()
@@ -975,6 +990,113 @@ class ReportTesting(unittest.TestCase):
             'Result file not found: {}'.format(file_path))
         self.assertEquals(None, result)
 
+    @patch('dovetail.report.os.path')
+    def test_onapvvp_crawler_crawl_not_exists(self, mock_path):
+        logger_obj = Mock()
+        dt_report.OnapVvpCrawler.logger = logger_obj
+        mock_path.exists.return_value = False
+        file_path = 'file_path'
+
+        crawler = dt_report.OnapVvpCrawler()
+        result = crawler.crawl(None, file_path)
+
+        mock_path.exists.assert_called_once_with(file_path)
+        logger_obj.error.assert_called_once_with(
+            'Result file not found: {}'.format(file_path))
+        self.assertEquals(None, result)
+
+    @patch('__builtin__.open')
+    @patch('dovetail.report.os.path')
+    def test_onapvvp_crawler_crawl_pass(self, mock_path,
+                                        mock_open):
+        dt_report.OnapVvpCrawler.logger = Mock()
+        mock_path.exists.return_value = True
+        file_path = 'file_path'
+        testcase_obj = Mock()
+        file_obj = Mock()
+        file_obj.read.return_value = json.dumps({'outcome': 'PASS'})
+        mock_open.return_value.__enter__.return_value = file_obj
+
+        crawler = dt_report.OnapVvpCrawler()
+        result = crawler.crawl(testcase_obj, file_path)
+        expected = {'criteria': 'PASS'}
+
+        mock_path.exists.assert_called_once_with(file_path)
+        mock_open.assert_called_once_with(file_path, 'r')
+        file_obj.read.assert_called_once_with()
+        testcase_obj.set_results.assert_called_once_with(expected)
+        self.assertEquals(expected, result)
+
+    @patch('__builtin__.open')
+    @patch('dovetail.report.os.path')
+    def test_onapvvp_crawler_crawl_fail(self, mock_path,
+                                        mock_open):
+        dt_report.OnapVvpCrawler.logger = Mock()
+        mock_path.exists.return_value = True
+        file_path = 'file_path'
+        testcase_obj = Mock()
+        file_obj = Mock()
+        file_obj.read.return_value = json.dumps({'outcome': 'FAIL'})
+        mock_open.return_value.__enter__.return_value = file_obj
+
+        crawler = dt_report.OnapVvpCrawler()
+        result = crawler.crawl(testcase_obj, file_path)
+        expected = {'criteria': 'FAIL'}
+
+        mock_path.exists.assert_called_once_with(file_path)
+        mock_open.assert_called_once_with(file_path, 'r')
+        file_obj.read.assert_called_once_with()
+        testcase_obj.set_results.assert_called_once_with(expected)
+        self.assertEquals(expected, result)
+
+    @patch('__builtin__.open')
+    @patch('dovetail.report.os.path')
+    def test_onapvvp_crawler_crawl_value_exception(self, mock_path,
+                                                   mock_open):
+        dt_report.OnapVvpCrawler.logger = Mock()
+        mock_path.exists.return_value = True
+        file_path = 'file_path'
+        testcase_obj = Mock()
+        file_obj = Mock()
+        file_obj.read.return_value = 'error'
+        mock_open.return_value.__enter__.return_value = file_obj
+
+        crawler = dt_report.OnapVvpCrawler()
+        result = crawler.crawl(testcase_obj, file_path)
+        expected = {'criteria': 'FAIL'}
+
+        mock_path.exists.assert_called_once_with(file_path)
+        mock_open.assert_called_once_with(file_path, 'r')
+        file_obj.read.assert_called_once_with()
+        dt_report.OnapVvpCrawler.logger.exception.assert_called_once_with(
+            'Result file has invalid format')
+        testcase_obj.set_results.assert_called_once_with(expected)
+        self.assertEquals(expected, result)
+
+    @patch('__builtin__.open')
+    @patch('dovetail.report.os.path')
+    def test_onapvvp_crawler_crawl_key_exception(self, mock_path,
+                                                 mock_open):
+        dt_report.OnapVvpCrawler.logger = Mock()
+        mock_path.exists.return_value = True
+        file_path = 'file_path'
+        testcase_obj = Mock()
+        file_obj = Mock()
+        file_obj.read.return_value = json.dumps({'key': 'value'})
+        mock_open.return_value.__enter__.return_value = file_obj
+
+        crawler = dt_report.OnapVvpCrawler()
+        result = crawler.crawl(testcase_obj, file_path)
+        expected = {'criteria': 'FAIL'}
+
+        mock_path.exists.assert_called_once_with(file_path)
+        mock_open.assert_called_once_with(file_path, 'r')
+        file_obj.read.assert_called_once_with()
+        dt_report.OnapVvpCrawler.logger.exception.assert_called_once_with(
+            "Outcome field not found 'outcome'")
+        testcase_obj.set_results.assert_called_once_with(expected)
+        self.assertEquals(expected, result)
+
     @patch('__builtin__.open')
     @patch('dovetail.report.json.loads')
     @patch('dovetail.report.os.path')
@@ -1359,3 +1481,30 @@ class ReportTesting(unittest.TestCase):
         dt_report.OnapVtpChecker.check(testcase_obj, result)
 
         testcase_obj.passed.assert_called_once_with('PASS')
+
+    @patch('dovetail.report.dt_logger')
+    def test_onapvvp_checker_create_log(self, mock_logger):
+        getlogger_obj = Mock()
+        logger_obj = Mock()
+        logger_obj.getLogger.return_value = getlogger_obj
+        mock_logger.Logger.return_value = logger_obj
+
+        dt_report.OnapVvpChecker.create_log()
+
+        self.assertEquals(getlogger_obj, dt_report.OnapVvpChecker.logger)
+
+    def test_onapvvp_check_result_none(self):
+        testcase_obj = Mock()
+        result = {}
+
+        dt_report.OnapVvpChecker.check(testcase_obj, result)
+
+        testcase_obj.passed.assert_called_once_with('FAIL')
+
+    def test_onapvvp_check_result(self):
+        testcase_obj = Mock()
+        result = {'criteria': 'PASS'}
+
+        dt_report.OnapVvpChecker.check(testcase_obj, result)
+
+        testcase_obj.passed.assert_called_once_with('PASS')
index 4b5c00b..0eb1213 100644 (file)
@@ -323,7 +323,8 @@ class TestRunnerTesting(unittest.TestCase):
     @patch('dovetail.test_runner.os')
     def test_add_testcase_info(self, mock_os, mock_config):
         mock_os.getenv.side_effect = ['os_insecure', 'dovetail_home', 'debug',
-                                      'os_cacert', 'host_url', 'csar_file']
+                                      'os_cacert', 'host_url', 'csar_file',
+                                      'heat_templates_dir']
         mock_os.environ = {'DEPLOY_SCENARIO': 'deploy_scenario'}
         mock_config.dovetail_config = {'build_tag': 'build_tag'}
 
@@ -333,14 +334,17 @@ class TestRunnerTesting(unittest.TestCase):
             'deploy_scenario': 'deploy_scenario',
             'dovetail_home': 'dovetail_home', 'debug': 'debug',
             'build_tag': 'build_tag', 'cacert': 'os_cacert',
-            'host_url': 'host_url', 'csar_file': 'csar_file'}
+            'host_url': 'host_url', 'csar_file': 'csar_file',
+            'heat_templates_dir': 'heat_templates_dir'
+        }
         result = t_runner.FunctestRunner._add_testcase_info(self.testcase)
 
         self.testcase.validate_testcase.assert_called_once_with()
         self.testcase.name.assert_called_once_with()
         mock_os.getenv.assert_has_calls([
             call('OS_INSECURE'), call('DOVETAIL_HOME'), call('DEBUG'),
-            call('OS_CACERT')])
+            call('OS_CACERT'), call('HOST_URL'), call('CSAR_FILE'),
+            call('VNF_DIRECTORY')])
         self.assertEquals(expected, result)
 
     @patch('dovetail.test_runner.dt_utils')
@@ -672,3 +676,35 @@ class TestRunnerTesting(unittest.TestCase):
         mock_path.join.assert_has_calls([call('one', 'two')])
         mock_path.isfile.assert_called_once()
         mock_utils.source_env.assert_called_once_with('env_file')
+
+    @patch('dovetail.test_runner.dt_utils')
+    @patch('dovetail.test_runner.os.path')
+    @patch('dovetail.test_runner.dt_cfg')
+    def test_init_onapvvprunner_no_env_file(self, mock_config, mock_path,
+                                            mock_utils):
+        t_runner.OnapVvpRunner.create_log()
+        mock_path.join.side_effect = ['env_file']
+        mock_config.dovetail_config = {'config_dir': 'one', 'env_file': 'two'}
+        mock_path.isfile.return_value = False
+
+        docker_runner = t_runner.OnapVvpRunner(self.testcase)
+
+        mock_path.join.assert_has_calls([call('one', 'two')])
+        mock_path.isfile.assert_called_once()
+        docker_runner.logger.error.assert_called_once_with(
+            'File env_file does not exist.')
+
+    @patch('dovetail.test_runner.dt_utils')
+    @patch('dovetail.test_runner.os.path')
+    @patch('dovetail.test_runner.dt_cfg')
+    def test_init_onapvvprunner(self, mock_config, mock_path, mock_utils):
+        t_runner.OnapVvpRunner.create_log()
+        mock_path.join.side_effect = ['env_file']
+        mock_config.dovetail_config = {'config_dir': 'one', 'env_file': 'two'}
+        mock_path.isfile.return_value = True
+
+        t_runner.OnapVvpRunner(self.testcase)
+
+        mock_path.join.assert_has_calls([call('one', 'two')])
+        mock_path.isfile.assert_called_once()
+        mock_utils.source_env.assert_called_once_with('env_file')
index 7224c1a..b224a13 100644 (file)
@@ -120,7 +120,7 @@ class TestcaseTesting(unittest.TestCase):
         self.assertEquals(testcase.testcase, result)
 
     def test_objective(self):
-        testcase = tcase.Testcase(self.testcase_yaml)
+        testcase = tcase.OnapVvpTestcase(self.testcase_yaml)
         testcase.testcase['objective'] = 'objective'
 
         result = testcase.objective()
index 266fb2b..8a0a39b 100644 (file)
@@ -20,6 +20,7 @@ bottlenecks:
   image_name: opnfv/bottlenecks
   docker_tag: latest
   opts: '-id --privileged=true'
+  shell: '/bin/bash'
   envs: '-e DEPLOY_SCENARIO={{deploy_scenario}} -e Yardstick_TAG=stable
          -e OUTPUT_FILE={{testcase}}.out -e CI_DEBUG={{debug}}
          -e BUILD_TAG={{build_tag}}-{{testcase}}'
index 927af1d..b5ad12b 100644 (file)
@@ -13,6 +13,7 @@ functest-k8s:
   image_name: opnfv/functest-kubernetes-healthcheck
   docker_tag: gambia
   opts: '-id'
+  shell: '/bin/bash'
   envs: '-e INSTALLER_TYPE=unknown -e DEPLOY_SCENARIO=k8-deploy -e NODE_NAME=unknown
          -e TEST_DB_URL=file:///home/opnfv/functest/results/functest_results.txt
          -e CI_DEBUG={{debug}} -e BUILD_TAG={{build_tag}}-{{testcase}}'
index a7b00e6..bf63754 100644 (file)
@@ -25,6 +25,7 @@ functest:
   image_name: opnfv/functest-smoke
   docker_tag: gambia
   opts: '-id --privileged=true'
+  shell: '/bin/bash'
   envs: '{{os_verify}} -e INSTALLER_TYPE=unknown -e DEPLOY_SCENARIO={{deploy_scenario}} -e NODE_NAME=unknown
          -e TEST_DB_URL=file://{{result_dir}}/functest_results.txt
          -e CI_DEBUG={{debug}} -e BUILD_TAG={{build_tag}}-{{testcase}}'
index 85944c3..72ebeab 100644 (file)
@@ -11,6 +11,7 @@ onap-vtp:
   image_name: nexus3.onap.org:10001/onap/cli
   docker_tag: 2.0.5
   opts: '-td '
+  shell: '/bin/bash'
   envs: '-e OPEN_CLI_MODE=daemon -e BUILD_TAG={{build_tag}}-{{testcase}}
          -e OPEN_CLI_PRODUCT_IN_USE=onap-vtp'
   volumes:
diff --git a/etc/conf/onap-vvp_config.yml b/etc/conf/onap-vvp_config.yml
new file mode 100644 (file)
index 0000000..a7d08ea
--- /dev/null
@@ -0,0 +1,20 @@
+---
+
+{% set build_tag = build_tag or '' %}
+{% set heat_templates_dir = heat_templates_dir or '' %}
+{% set result_dir = '/reports' %}
+
+onap-vvp:
+  image_name: nexus3.onap.org:10001/onap/vvp/validation-scripts
+  docker_tag: latest
+  opts: '-td --entrypoint=""'
+  shell: '/bin/ash'
+  volumes:
+    - '-v {{heat_templates_dir}}:/template'
+    - '-v {{dovetail_home}}/results:{{result_dir}}'
+  pre_condition:
+    - 'echo this is pre_condition'
+  cmds:
+    - 'pytest --template-directory=/template --output-directory=/reports --report-format=json --continue-on-failure'
+  post_condition:
+    - 'echo this is post_condition'
index 82e068b..4104d76 100644 (file)
@@ -3,6 +3,7 @@ vnftest:
   image_name: onap/vnfsdk/vnftest
   docker_tag: latest
   opts: '-id --privileged=true'
+  shell: '/bin/bash'
   config:
     dir: '/home/onap/userconfig'
   pre_condition:
index 8f3db55..e43989e 100644 (file)
@@ -24,6 +24,7 @@ yardstick:
   image_name: opnfv/yardstick
   docker_tag: latest
   opts: '-id --privileged=true'
+  shell: '/bin/bash'
   envs: "{{os_verify}} -e YARDSTICK_BRANCH=fraser -e CI_DEBUG={{debug}}
          -e BUILD_TAG={{build_tag}}-{{testcase}}"
   volumes:
diff --git a/etc/testcase/onap-vvp.validate.heat.yml b/etc/testcase/onap-vvp.validate.heat.yml
new file mode 100644 (file)
index 0000000..a4ca9ab
--- /dev/null
@@ -0,0 +1,16 @@
+---
+onap-vvp.validate.heat:
+  name: onap-vvp.validate.heat
+  objective: onap heat template validation
+  validate:
+    type: onap-vvp
+    testcase: ice_validator
+  report:
+    source_archive_files:
+      - failures
+      - report.json
+    dest_archive_files:
+      - onap-vvp_logs/failures
+      - onap-vvp_logs/report.json
+    check_results_file: onap-vvp_logs/report.json
+    sub_testcase_list:
index d983b46..5f7a2e6 100644 (file)
@@ -1,4 +1,12 @@
+## Special environment parameters for TOSCA validation tests.
+
+# The url under which the VNF SDK container is accessible through the host.
 export HOST_URL="http://<docker host ip>:8702"
 
 # Absolute path of CSAR file, and should be copied to vtp container.
 export CSAR_FILE="/opt/test.csar"
+
+## Special environment parameters for Heat validation tests.
+
+# The VNF directory should be put at $DOVETAIL_HOME/pre_config.
+export VNF_DIRECTORY="/path/to/pre_config/vnf_dir"