3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
13 from functest.core import vnf
14 from functest.opnfv_tests.vnf.ims import cloudify_ims
17 class CloudifyImsTesting(unittest.TestCase):
21 self.tenant = 'cloudify_ims'
22 self.creds = {'username': 'user',
24 self.orchestrator = {'name': 'cloudify',
27 'requirements': {'flavor': {'name': 'm1.medium',
29 'os_image': 'manager_4.0'}}
31 self.vnf = {'name': 'clearwater',
32 'descriptor': {'version': '108',
33 'file_name': 'openstack-blueprint.yaml',
34 'name': 'clearwater-opnfv',
36 'requirements': {'flavor':
40 with mock.patch('functest.opnfv_tests.vnf.ims.cloudify_ims.'
42 mock.patch('functest.opnfv_tests.vnf.ims.cloudify_ims.'
43 'get_config', return_value={
44 'tenant_images': 'foo',
45 'orchestrator': self.orchestrator,
48 'version': 'whatever'}):
50 self.ims_vnf = cloudify_ims.CloudifyIms()
52 self.images = {'image1': 'url1',
54 self.details = {'orchestrator': {'status': 'PASS', 'duration': 120},
58 @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
60 @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
62 @mock.patch('functest.core.vnf.os_utils.get_or_create_user_for_vnf',
64 @mock.patch('functest.core.vnf.os_utils.get_credentials',
65 return_value={'auth_url': 'test/v1'})
66 @mock.patch('snaps.openstack.create_image.OpenStackImage.create')
67 def test_prepare_default(self, *args):
68 self.assertIsNone(self.ims_vnf.prepare())
69 args[4].assert_called_once_with()
71 @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
73 @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
75 @mock.patch('functest.core.vnf.os_utils.get_or_create_user_for_vnf',
77 @mock.patch('functest.core.vnf.os_utils.get_credentials',
78 return_value={'auth_url': 'test/no_v'})
79 @mock.patch('snaps.openstack.create_image.OpenStackImage.create')
80 def test_prepare_bad_auth_url(self, *args):
81 with self.assertRaises(Exception):
82 self.ims_vnf.prepare()
83 args[0].assert_not_called()
85 def test_prepare_missing_param(self):
86 with self.assertRaises(vnf.VnfPreparationException):
87 self.ims_vnf.prepare()
89 @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
90 side_effect=Exception)
91 def test_prepare_keystone_exception(self, *args):
92 with self.assertRaises(vnf.VnfPreparationException):
93 self.ims_vnf.prepare()
94 args[0].assert_called_once_with()
96 @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
98 @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
99 side_effect=Exception)
100 def test_prepare_tenant_exception(self, *args):
101 with self.assertRaises(vnf.VnfPreparationException):
102 self.ims_vnf.prepare()
103 args[1].assert_called_once_with()
105 @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
107 @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
109 @mock.patch('functest.core.vnf.os_utils.get_or_create_user_for_vnf',
110 side_effect=Exception)
111 def test_prepare_user_exception(self, *args):
112 with self.assertRaises(vnf.VnfPreparationException):
113 self.ims_vnf.prepare()
114 args[2].assert_called_once_with()
116 @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
118 @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
120 @mock.patch('functest.core.vnf.os_utils.get_or_create_user_for_vnf',
122 @mock.patch('functest.core.vnf.os_utils.get_credentials',
123 side_effect=Exception)
124 def test_prepare_credentials_exception(self, *args):
125 with self.assertRaises(vnf.VnfPreparationException):
126 self.ims_vnf.prepare()
127 args[0].assert_called_once_with()
129 # @mock.patch('snaps.openstack.create_keypairs.OpenStackKeypair',
130 # side_effect=Exception)
131 # def test_deploy_orchestrator_keypair_exception(self, *args):
132 # with self.assertRaises(vnf.OrchestratorDeploymentException):
133 # self.ims_vnf.deploy_orchestrator()
135 # def test_deploy_orchestrator_network_creation_fail(self):
136 # def test_deploy_orchestrator_floatting_ip_creation_fail(self):
137 # def test_deploy_orchestrator_flavor_fail(self):
138 # def test_deploy_orchestrator_get_image_id_fail(self):
139 # def test_deploy_orchestrator_create_instance_fail(self):
140 # def test_deploy_orchestrator_secgroup_fail(self):
141 # def test_deploy_orchestrator_add_floating_ip_fail(self):
142 # def test_deploy_orchestrator_get_endpoint_fail(self):
143 # def test_deploy_orchestrator_initiate CloudifyClient_fail(self):
144 # def test_deploy_orchestrator_get_status_fail(self):
147 # def test_deploy_vnf(self):
148 # def test_deploy_vnf_publish_fail(self):
149 # def test_deploy_vnf_get_flavor_fail(self):
150 # def test_deploy_vnf_get_external_net_fail(self):
151 # def test_deploy_vnf_deployment_create_fail(self):
152 # def test_deploy_vnf_start_fail(self):
154 # def test_test_vnf(self):
155 # def test_test_vnf_deployment_get_fail(self):
156 # def test_test_vnf_run_live_test_fail(self):
158 # def test_clean(self):
159 # def test_clean_execution_start_fail(self):
160 # def test_clean_deployment_delete_fail(self):
161 # def test_clean_blueprint_delete_fail(self):
164 if __name__ == "__main__":
165 logging.disable(logging.CRITICAL)
166 unittest.main(verbosity=2)