Device Refactor
Replacing device with vnf in test cases in continuation of [1]. [1]: https://review.openstack.org/#/c/352205/ Co-Authored-By: Dharmendra Kushwaha <dharmendra.kushwaha@india.nec.com> Change-Id: Iec9feafa657e82b1887d37f51df12bf694c274e7
This commit is contained in:
parent
e69896b9e2
commit
6812d2a2c6
|
@ -902,7 +902,7 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
|
||||||
self.assertEqual(400, res.status_int)
|
self.assertEqual(400, res.status_int)
|
||||||
|
|
||||||
def test_create_bulk_partial_body(self):
|
def test_create_bulk_partial_body(self):
|
||||||
data = {'ports': [{'device_id': 'device_1',
|
data = {'ports': [{'vnf_id': 'vnf_1',
|
||||||
'tenant_id': _uuid()},
|
'tenant_id': _uuid()},
|
||||||
{'tenant_id': _uuid()}]}
|
{'tenant_id': _uuid()}]}
|
||||||
res = self.api.post(_get_path('ports', fmt=self.fmt),
|
res = self.api.post(_get_path('ports', fmt=self.fmt),
|
||||||
|
@ -914,21 +914,21 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
|
||||||
def test_create_attr_not_specified(self):
|
def test_create_attr_not_specified(self):
|
||||||
net_id = _uuid()
|
net_id = _uuid()
|
||||||
tenant_id = _uuid()
|
tenant_id = _uuid()
|
||||||
device_id = _uuid()
|
vnf_id = _uuid()
|
||||||
initial_input = {'port': {'name': '', 'network_id': net_id,
|
initial_input = {'port': {'name': '', 'network_id': net_id,
|
||||||
'tenant_id': tenant_id,
|
'tenant_id': tenant_id,
|
||||||
'device_id': device_id,
|
'vnf_id': vnf_id,
|
||||||
'admin_state_up': True}}
|
'admin_state_up': True}}
|
||||||
full_input = {'port': {'admin_state_up': True,
|
full_input = {'port': {'admin_state_up': True,
|
||||||
'mac_address': attributes.ATTR_NOT_SPECIFIED,
|
'mac_address': attributes.ATTR_NOT_SPECIFIED,
|
||||||
'fixed_ips': attributes.ATTR_NOT_SPECIFIED,
|
'fixed_ips': attributes.ATTR_NOT_SPECIFIED,
|
||||||
'device_owner': ''}}
|
'vnf_owner': ''}}
|
||||||
full_input['port'].update(initial_input['port'])
|
full_input['port'].update(initial_input['port'])
|
||||||
return_value = {'id': _uuid(), 'status': 'ACTIVE',
|
return_value = {'id': _uuid(), 'status': 'ACTIVE',
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'mac_address': 'ca:fe:de:ad:be:ef',
|
'mac_address': 'ca:fe:de:ad:be:ef',
|
||||||
'device_id': device_id,
|
'vnf_id': vnf_id,
|
||||||
'device_owner': ''}
|
'vnf_owner': ''}
|
||||||
return_value.update(initial_input['port'])
|
return_value.update(initial_input['port'])
|
||||||
|
|
||||||
instance = self.plugin.return_value
|
instance = self.plugin.return_value
|
||||||
|
@ -1232,7 +1232,7 @@ class V2Views(base.BaseTestCase):
|
||||||
|
|
||||||
def test_port(self):
|
def test_port(self):
|
||||||
keys = ('id', 'network_id', 'mac_address', 'fixed_ips',
|
keys = ('id', 'network_id', 'mac_address', 'fixed_ips',
|
||||||
'device_id', 'admin_state_up', 'tenant_id', 'status')
|
'vnf_id', 'admin_state_up', 'tenant_id', 'status')
|
||||||
self._view(keys, 'ports', 'port')
|
self._view(keys, 'ports', 'port')
|
||||||
|
|
||||||
def test_subnet(self):
|
def test_subnet(self):
|
||||||
|
|
|
@ -114,7 +114,7 @@ def get_dummy_vnf_config_obj():
|
||||||
'config': {'firewall': 'dummy_firewall_values'}}}}}}}
|
'config': {'firewall': 'dummy_firewall_values'}}}}}}}
|
||||||
|
|
||||||
|
|
||||||
def get_dummy_device_obj():
|
def get_dummy_vnf():
|
||||||
return {'status': 'PENDING_CREATE', 'instance_id': None, 'name':
|
return {'status': 'PENDING_CREATE', 'instance_id': None, 'name':
|
||||||
u'test_openwrt', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
|
u'test_openwrt', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
|
||||||
'vnfd_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e',
|
'vnfd_id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e',
|
||||||
|
|
|
@ -244,7 +244,7 @@ class TestOpenStack(base.TestCase):
|
||||||
def _get_dummy_tosca_vnf(self, template, input_params=''):
|
def _get_dummy_tosca_vnf(self, template, input_params=''):
|
||||||
|
|
||||||
tosca_template = _get_template(template)
|
tosca_template = _get_template(template)
|
||||||
vnf = utils.get_dummy_device_obj()
|
vnf = utils.get_dummy_vnf()
|
||||||
dtemplate = self._get_expected_vnfd(tosca_template)
|
dtemplate = self._get_expected_vnfd(tosca_template)
|
||||||
|
|
||||||
vnf['vnfd'] = dtemplate
|
vnf['vnfd'] = dtemplate
|
||||||
|
|
|
@ -27,30 +27,30 @@ class TestVNFMonitorHTTPPing(testtools.TestCase):
|
||||||
|
|
||||||
@mock.patch('six.moves.urllib.request.urlopen')
|
@mock.patch('six.moves.urllib.request.urlopen')
|
||||||
def test_monitor_call_for_success(self, mock_urlopen):
|
def test_monitor_call_for_success(self, mock_urlopen):
|
||||||
test_device = {}
|
test_vnf = {}
|
||||||
test_kwargs = {
|
test_kwargs = {
|
||||||
'mgmt_ip': 'a.b.c.d'
|
'mgmt_ip': 'a.b.c.d'
|
||||||
}
|
}
|
||||||
self.monitor_http_ping.monitor_call(test_device,
|
self.monitor_http_ping.monitor_call(test_vnf,
|
||||||
test_kwargs)
|
test_kwargs)
|
||||||
mock_urlopen.assert_called_once_with('http://a.b.c.d:80', timeout=5)
|
mock_urlopen.assert_called_once_with('http://a.b.c.d:80', timeout=5)
|
||||||
|
|
||||||
@mock.patch('six.moves.urllib.request.urlopen')
|
@mock.patch('six.moves.urllib.request.urlopen')
|
||||||
def test_monitor_call_for_failure(self, mock_urlopen):
|
def test_monitor_call_for_failure(self, mock_urlopen):
|
||||||
mock_urlopen.side_effect = urlerr.URLError("MOCK Error")
|
mock_urlopen.side_effect = urlerr.URLError("MOCK Error")
|
||||||
test_device = {}
|
test_vnf = {}
|
||||||
test_kwargs = {
|
test_kwargs = {
|
||||||
'mgmt_ip': 'a.b.c.d'
|
'mgmt_ip': 'a.b.c.d'
|
||||||
}
|
}
|
||||||
monitor_return = self.monitor_http_ping.monitor_call(test_device,
|
monitor_return = self.monitor_http_ping.monitor_call(test_vnf,
|
||||||
test_kwargs)
|
test_kwargs)
|
||||||
self.assertEqual('failure', monitor_return)
|
self.assertEqual('failure', monitor_return)
|
||||||
|
|
||||||
def test_monitor_url(self):
|
def test_monitor_url(self):
|
||||||
test_device = {
|
test_vnf = {
|
||||||
'monitor_url': 'a.b.c.d'
|
'monitor_url': 'a.b.c.d'
|
||||||
}
|
}
|
||||||
test_monitor_url = self.monitor_http_ping.monitor_url(mock.ANY,
|
test_monitor_url = self.monitor_http_ping.monitor_url(mock.ANY,
|
||||||
mock.ANY,
|
mock.ANY,
|
||||||
test_device)
|
test_vnf)
|
||||||
self.assertEqual('a.b.c.d', test_monitor_url)
|
self.assertEqual('a.b.c.d', test_monitor_url)
|
||||||
|
|
|
@ -26,7 +26,7 @@ class TestVNFMonitorPing(testtools.TestCase):
|
||||||
|
|
||||||
@mock.patch('tacker.agent.linux.utils.execute')
|
@mock.patch('tacker.agent.linux.utils.execute')
|
||||||
def test_monitor_call_for_success(self, mock_utils_execute):
|
def test_monitor_call_for_success(self, mock_utils_execute):
|
||||||
test_device = {}
|
test_vnf = {}
|
||||||
test_kwargs = {
|
test_kwargs = {
|
||||||
'mgmt_ip': 'a.b.c.d'
|
'mgmt_ip': 'a.b.c.d'
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class TestVNFMonitorPing(testtools.TestCase):
|
||||||
'-W', 1,
|
'-W', 1,
|
||||||
'-i', '0.2',
|
'-i', '0.2',
|
||||||
'a.b.c.d']
|
'a.b.c.d']
|
||||||
self.monitor_ping.monitor_call(test_device,
|
self.monitor_ping.monitor_call(test_vnf,
|
||||||
test_kwargs)
|
test_kwargs)
|
||||||
mock_utils_execute.assert_called_once_with(mock_ping_cmd,
|
mock_utils_execute.assert_called_once_with(mock_ping_cmd,
|
||||||
check_exit_code=True)
|
check_exit_code=True)
|
||||||
|
@ -43,19 +43,19 @@ class TestVNFMonitorPing(testtools.TestCase):
|
||||||
@mock.patch('tacker.agent.linux.utils.execute')
|
@mock.patch('tacker.agent.linux.utils.execute')
|
||||||
def test_monitor_call_for_failure(self, mock_utils_execute):
|
def test_monitor_call_for_failure(self, mock_utils_execute):
|
||||||
mock_utils_execute.side_effect = RuntimeError()
|
mock_utils_execute.side_effect = RuntimeError()
|
||||||
test_device = {}
|
test_vnf = {}
|
||||||
test_kwargs = {
|
test_kwargs = {
|
||||||
'mgmt_ip': 'a.b.c.d'
|
'mgmt_ip': 'a.b.c.d'
|
||||||
}
|
}
|
||||||
monitor_return = self.monitor_ping.monitor_call(test_device,
|
monitor_return = self.monitor_ping.monitor_call(test_vnf,
|
||||||
test_kwargs)
|
test_kwargs)
|
||||||
self.assertEqual('failure', monitor_return)
|
self.assertEqual('failure', monitor_return)
|
||||||
|
|
||||||
def test_monitor_url(self):
|
def test_monitor_url(self):
|
||||||
test_device = {
|
test_vnf = {
|
||||||
'monitor_url': 'a.b.c.d'
|
'monitor_url': 'a.b.c.d'
|
||||||
}
|
}
|
||||||
test_monitor_url = self.monitor_ping.monitor_url(mock.ANY,
|
test_monitor_url = self.monitor_ping.monitor_url(mock.ANY,
|
||||||
mock.ANY,
|
mock.ANY,
|
||||||
test_device)
|
test_vnf)
|
||||||
self.assertEqual('a.b.c.d', test_monitor_url)
|
self.assertEqual('a.b.c.d', test_monitor_url)
|
||||||
|
|
|
@ -64,7 +64,7 @@ class TestVNFMonitor(testtools.TestCase):
|
||||||
self.addCleanup(p.stop)
|
self.addCleanup(p.stop)
|
||||||
|
|
||||||
def test_to_hosting_vnf(self):
|
def test_to_hosting_vnf(self):
|
||||||
test_device_dict = {
|
test_vnf_dict = {
|
||||||
'id': MOCK_DEVICE_ID,
|
'id': MOCK_DEVICE_ID,
|
||||||
'mgmt_url': '{"vdu1": "a.b.c.d"}',
|
'mgmt_url': '{"vdu1": "a.b.c.d"}',
|
||||||
'attributes': {
|
'attributes': {
|
||||||
|
@ -79,16 +79,16 @@ class TestVNFMonitor(testtools.TestCase):
|
||||||
'management_ip_addresses': {
|
'management_ip_addresses': {
|
||||||
'vdu1': 'a.b.c.d'
|
'vdu1': 'a.b.c.d'
|
||||||
},
|
},
|
||||||
'vnf': test_device_dict,
|
'vnf': test_vnf_dict,
|
||||||
'monitoring_policy': MOCK_VNF_DEVICE['monitoring_policy']
|
'monitoring_policy': MOCK_VNF_DEVICE['monitoring_policy']
|
||||||
}
|
}
|
||||||
output_dict = monitor.VNFMonitor.to_hosting_vnf(test_device_dict,
|
output_dict = monitor.VNFMonitor.to_hosting_vnf(test_vnf_dict,
|
||||||
action_cb)
|
action_cb)
|
||||||
self.assertEqual(expected_output, output_dict)
|
self.assertEqual(expected_output, output_dict)
|
||||||
|
|
||||||
@mock.patch('tacker.vnfm.monitor.VNFMonitor.__run__')
|
@mock.patch('tacker.vnfm.monitor.VNFMonitor.__run__')
|
||||||
def test_add_hosting_vnf(self, mock_monitor_run):
|
def test_add_hosting_vnf(self, mock_monitor_run):
|
||||||
test_device_dict = {
|
test_vnf_dict = {
|
||||||
'id': MOCK_DEVICE_ID,
|
'id': MOCK_DEVICE_ID,
|
||||||
'mgmt_url': '{"vdu1": "a.b.c.d"}',
|
'mgmt_url': '{"vdu1": "a.b.c.d"}',
|
||||||
'attributes': {
|
'attributes': {
|
||||||
|
@ -100,10 +100,10 @@ class TestVNFMonitor(testtools.TestCase):
|
||||||
action_cb = mock.MagicMock()
|
action_cb = mock.MagicMock()
|
||||||
test_boot_wait = 30
|
test_boot_wait = 30
|
||||||
test_vnfmonitor = monitor.VNFMonitor(test_boot_wait)
|
test_vnfmonitor = monitor.VNFMonitor(test_boot_wait)
|
||||||
new_dict = test_vnfmonitor.to_hosting_vnf(test_device_dict, action_cb)
|
new_dict = test_vnfmonitor.to_hosting_vnf(test_vnf_dict, action_cb)
|
||||||
test_vnfmonitor.add_hosting_vnf(new_dict)
|
test_vnfmonitor.add_hosting_vnf(new_dict)
|
||||||
test_device_id = list(test_vnfmonitor._hosting_vnfs.keys())[0]
|
test_vnf_id = list(test_vnfmonitor._hosting_vnfs.keys())[0]
|
||||||
self.assertEqual(MOCK_DEVICE_ID, test_device_id)
|
self.assertEqual(MOCK_DEVICE_ID, test_vnf_id)
|
||||||
self._cos_db_plugin.create_event.assert_called_with(
|
self._cos_db_plugin.create_event.assert_called_with(
|
||||||
mock.ANY, res_id=mock.ANY, res_type=constants.RES_TYPE_VNF,
|
mock.ANY, res_id=mock.ANY, res_type=constants.RES_TYPE_VNF,
|
||||||
res_state=mock.ANY, evt_type=constants.RES_EVT_MONITOR,
|
res_state=mock.ANY, evt_type=constants.RES_EVT_MONITOR,
|
||||||
|
|
|
@ -63,7 +63,7 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
self._mock_vim_client()
|
self._mock_vim_client()
|
||||||
self._stub_get_vim()
|
self._stub_get_vim()
|
||||||
self._mock_device_manager()
|
self._mock_vnf_manager()
|
||||||
self._mock_vnf_monitor()
|
self._mock_vnf_monitor()
|
||||||
self._mock_vnf_alarm_monitor()
|
self._mock_vnf_alarm_monitor()
|
||||||
self._mock_green_pool()
|
self._mock_green_pool()
|
||||||
|
@ -75,14 +75,14 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
self._cos_db_plugin =\
|
self._cos_db_plugin =\
|
||||||
common_services_db_plugin.CommonServicesPluginDb()
|
common_services_db_plugin.CommonServicesPluginDb()
|
||||||
|
|
||||||
def _mock_device_manager(self):
|
def _mock_vnf_manager(self):
|
||||||
self._device_manager = mock.Mock(wraps=FakeDriverManager())
|
self._vnf_manager = mock.Mock(wraps=FakeDriverManager())
|
||||||
self._device_manager.__contains__ = mock.Mock(
|
self._vnf_manager.__contains__ = mock.Mock(
|
||||||
return_value=True)
|
return_value=True)
|
||||||
fake_device_manager = mock.Mock()
|
fake_vnf_manager = mock.Mock()
|
||||||
fake_device_manager.return_value = self._device_manager
|
fake_vnf_manager.return_value = self._vnf_manager
|
||||||
self._mock(
|
self._mock(
|
||||||
'tacker.common.driver_manager.DriverManager', fake_device_manager)
|
'tacker.common.driver_manager.DriverManager', fake_vnf_manager)
|
||||||
|
|
||||||
def _mock_vim_client(self):
|
def _mock_vim_client(self):
|
||||||
self.vim_client = mock.Mock(wraps=FakeVimClient())
|
self.vim_client = mock.Mock(wraps=FakeVimClient())
|
||||||
|
@ -120,31 +120,31 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
self._mock(
|
self._mock(
|
||||||
'tacker.vnfm.monitor.VNFAlarmMonitor', fake_vnf_alarm_monitor)
|
'tacker.vnfm.monitor.VNFAlarmMonitor', fake_vnf_alarm_monitor)
|
||||||
|
|
||||||
def _insert_dummy_device_template(self):
|
def _insert_dummy_vnf_template(self):
|
||||||
session = self.context.session
|
session = self.context.session
|
||||||
device_template = vnfm_db.VNFD(
|
vnf_template = vnfm_db.VNFD(
|
||||||
id='eb094833-995e-49f0-a047-dfb56aaf7c4e',
|
id='eb094833-995e-49f0-a047-dfb56aaf7c4e',
|
||||||
tenant_id='ad7ebc56538745a08ef7c5e97f8bd437',
|
tenant_id='ad7ebc56538745a08ef7c5e97f8bd437',
|
||||||
name='fake_template',
|
name='fake_template',
|
||||||
description='fake_template_description',
|
description='fake_template_description',
|
||||||
template_source='onboarded',
|
template_source='onboarded',
|
||||||
deleted_at=datetime.min)
|
deleted_at=datetime.min)
|
||||||
session.add(device_template)
|
session.add(vnf_template)
|
||||||
session.flush()
|
session.flush()
|
||||||
return device_template
|
return vnf_template
|
||||||
|
|
||||||
def _insert_dummy_device_template_inline(self):
|
def _insert_dummy_vnf_template_inline(self):
|
||||||
session = self.context.session
|
session = self.context.session
|
||||||
device_template = vnfm_db.VNFD(
|
vnf_template = vnfm_db.VNFD(
|
||||||
id='d58bcc4e-d0cf-11e6-bf26-cec0c932ce01',
|
id='d58bcc4e-d0cf-11e6-bf26-cec0c932ce01',
|
||||||
tenant_id='ad7ebc56538745a08ef7c5e97f8bd437',
|
tenant_id='ad7ebc56538745a08ef7c5e97f8bd437',
|
||||||
name='tmpl-koeak4tqgoqo8cr4-dummy_inline_vnf',
|
name='tmpl-koeak4tqgoqo8cr4-dummy_inline_vnf',
|
||||||
description='inline_fake_template_description',
|
description='inline_fake_template_description',
|
||||||
deleted_at=datetime.min,
|
deleted_at=datetime.min,
|
||||||
template_source='inline')
|
template_source='inline')
|
||||||
session.add(device_template)
|
session.add(vnf_template)
|
||||||
session.flush()
|
session.flush()
|
||||||
return device_template
|
return vnf_template
|
||||||
|
|
||||||
def _insert_dummy_vnfd_attributes(self, template):
|
def _insert_dummy_vnfd_attributes(self, template):
|
||||||
session = self.context.session
|
session = self.context.session
|
||||||
|
@ -157,22 +157,22 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
session.flush()
|
session.flush()
|
||||||
return vnfd_attr
|
return vnfd_attr
|
||||||
|
|
||||||
def _insert_dummy_device(self):
|
def _insert_dummy_vnf(self):
|
||||||
session = self.context.session
|
session = self.context.session
|
||||||
device_db = vnfm_db.VNF(
|
vnf_db = vnfm_db.VNF(
|
||||||
id='6261579e-d6f3-49ad-8bc3-a9cb974778fe',
|
id='6261579e-d6f3-49ad-8bc3-a9cb974778fe',
|
||||||
tenant_id='ad7ebc56538745a08ef7c5e97f8bd437',
|
tenant_id='ad7ebc56538745a08ef7c5e97f8bd437',
|
||||||
name='fake_device',
|
name='fake_vnf',
|
||||||
description='fake_device_description',
|
description='fake_vnf_description',
|
||||||
instance_id='da85ea1a-4ec4-4201-bbb2-8d9249eca7ec',
|
instance_id='da85ea1a-4ec4-4201-bbb2-8d9249eca7ec',
|
||||||
vnfd_id='eb094833-995e-49f0-a047-dfb56aaf7c4e',
|
vnfd_id='eb094833-995e-49f0-a047-dfb56aaf7c4e',
|
||||||
vim_id='6261579e-d6f3-49ad-8bc3-a9cb974778ff',
|
vim_id='6261579e-d6f3-49ad-8bc3-a9cb974778ff',
|
||||||
placement_attr={'region': 'RegionOne'},
|
placement_attr={'region': 'RegionOne'},
|
||||||
status='ACTIVE',
|
status='ACTIVE',
|
||||||
deleted_at=datetime.min)
|
deleted_at=datetime.min)
|
||||||
session.add(device_db)
|
session.add(vnf_db)
|
||||||
session.flush()
|
session.flush()
|
||||||
return device_db
|
return vnf_db
|
||||||
|
|
||||||
def _insert_scaling_attributes_vnf(self):
|
def _insert_scaling_attributes_vnf(self):
|
||||||
session = self.context.session
|
session = self.context.session
|
||||||
|
@ -258,7 +258,7 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
self.context, vnfd_obj)
|
self.context, vnfd_obj)
|
||||||
|
|
||||||
def test_create_vnf_with_vnfd(self):
|
def test_create_vnf_with_vnfd(self):
|
||||||
self._insert_dummy_device_template()
|
self._insert_dummy_vnf_template()
|
||||||
vnf_obj = utils.get_dummy_vnf_obj()
|
vnf_obj = utils.get_dummy_vnf_obj()
|
||||||
result = self.vnfm_plugin.create_vnf(self.context, vnf_obj)
|
result = self.vnfm_plugin.create_vnf(self.context, vnf_obj)
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
@ -269,12 +269,12 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
self.assertIn('mgmt_url', result)
|
self.assertIn('mgmt_url', result)
|
||||||
self.assertIn('created_at', result)
|
self.assertIn('created_at', result)
|
||||||
self.assertIn('updated_at', result)
|
self.assertIn('updated_at', result)
|
||||||
self._device_manager.invoke.assert_called_with('test_vim',
|
self._vnf_manager.invoke.assert_called_with('test_vim',
|
||||||
'create',
|
'create',
|
||||||
plugin=mock.ANY,
|
plugin=mock.ANY,
|
||||||
context=mock.ANY,
|
context=mock.ANY,
|
||||||
vnf=mock.ANY,
|
vnf=mock.ANY,
|
||||||
auth_attr=mock.ANY)
|
auth_attr=mock.ANY)
|
||||||
self._pool.spawn_n.assert_called_once_with(mock.ANY)
|
self._pool.spawn_n.assert_called_once_with(mock.ANY)
|
||||||
self._cos_db_plugin.create_event.assert_called_with(
|
self._cos_db_plugin.create_event.assert_called_with(
|
||||||
self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY,
|
self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY,
|
||||||
|
@ -283,7 +283,7 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
|
|
||||||
@mock.patch('tacker.vnfm.plugin.VNFMPlugin.create_vnfd')
|
@mock.patch('tacker.vnfm.plugin.VNFMPlugin.create_vnfd')
|
||||||
def test_create_vnf_from_template(self, mock_create_vnfd):
|
def test_create_vnf_from_template(self, mock_create_vnfd):
|
||||||
self._insert_dummy_device_template_inline()
|
self._insert_dummy_vnf_template_inline()
|
||||||
mock_create_vnfd.return_value = {'id':
|
mock_create_vnfd.return_value = {'id':
|
||||||
'd58bcc4e-d0cf-11e6-bf26-cec0c932ce01'}
|
'd58bcc4e-d0cf-11e6-bf26-cec0c932ce01'}
|
||||||
vnf_obj = utils.get_dummy_inline_vnf_obj()
|
vnf_obj = utils.get_dummy_inline_vnf_obj()
|
||||||
|
@ -297,12 +297,12 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
self.assertIn('created_at', result)
|
self.assertIn('created_at', result)
|
||||||
self.assertIn('updated_at', result)
|
self.assertIn('updated_at', result)
|
||||||
mock_create_vnfd.assert_called_once_with(mock.ANY, mock.ANY)
|
mock_create_vnfd.assert_called_once_with(mock.ANY, mock.ANY)
|
||||||
self._device_manager.invoke.assert_called_with('test_vim',
|
self._vnf_manager.invoke.assert_called_with('test_vim',
|
||||||
'create',
|
'create',
|
||||||
plugin=mock.ANY,
|
plugin=mock.ANY,
|
||||||
context=mock.ANY,
|
context=mock.ANY,
|
||||||
vnf=mock.ANY,
|
vnf=mock.ANY,
|
||||||
auth_attr=mock.ANY)
|
auth_attr=mock.ANY)
|
||||||
self._pool.spawn_n.assert_called_once_with(mock.ANY)
|
self._pool.spawn_n.assert_called_once_with(mock.ANY)
|
||||||
self._cos_db_plugin.create_event.assert_called_with(
|
self._cos_db_plugin.create_event.assert_called_with(
|
||||||
self.context, evt_type=constants.RES_EVT_CREATE,
|
self.context, evt_type=constants.RES_EVT_CREATE,
|
||||||
|
@ -311,15 +311,15 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
tstamp=mock.ANY, details=mock.ANY)
|
tstamp=mock.ANY, details=mock.ANY)
|
||||||
|
|
||||||
def test_show_vnf_details_vnf_inactive(self):
|
def test_show_vnf_details_vnf_inactive(self):
|
||||||
self._insert_dummy_device_template()
|
self._insert_dummy_vnf_template()
|
||||||
vnf_obj = utils.get_dummy_vnf_obj()
|
vnf_obj = utils.get_dummy_vnf_obj()
|
||||||
result = self.vnfm_plugin.create_vnf(self.context, vnf_obj)
|
result = self.vnfm_plugin.create_vnf(self.context, vnf_obj)
|
||||||
self.assertRaises(vnfm.VNFInactive, self.vnfm_plugin.get_vnf_resources,
|
self.assertRaises(vnfm.VNFInactive, self.vnfm_plugin.get_vnf_resources,
|
||||||
self.context, result['id'])
|
self.context, result['id'])
|
||||||
|
|
||||||
def test_show_vnf_details_vnf_active(self):
|
def test_show_vnf_details_vnf_active(self):
|
||||||
self._insert_dummy_device_template()
|
self._insert_dummy_vnf_template()
|
||||||
active_vnf = self._insert_dummy_device()
|
active_vnf = self._insert_dummy_vnf()
|
||||||
resources = self.vnfm_plugin.get_vnf_resources(self.context,
|
resources = self.vnfm_plugin.get_vnf_resources(self.context,
|
||||||
active_vnf['id'])[0]
|
active_vnf['id'])[0]
|
||||||
self.assertIn('name', resources)
|
self.assertIn('name', resources)
|
||||||
|
@ -327,16 +327,16 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
self.assertIn('id', resources)
|
self.assertIn('id', resources)
|
||||||
|
|
||||||
def test_delete_vnf(self):
|
def test_delete_vnf(self):
|
||||||
self._insert_dummy_device_template()
|
self._insert_dummy_vnf_template()
|
||||||
dummy_device_obj = self._insert_dummy_device()
|
dummy_vnf_obj = self._insert_dummy_vnf()
|
||||||
self.vnfm_plugin.delete_vnf(self.context, dummy_device_obj[
|
self.vnfm_plugin.delete_vnf(self.context, dummy_vnf_obj[
|
||||||
'id'])
|
'id'])
|
||||||
self._device_manager.invoke.assert_called_with('test_vim', 'delete',
|
self._vnf_manager.invoke.assert_called_with('test_vim', 'delete',
|
||||||
plugin=mock.ANY,
|
plugin=mock.ANY,
|
||||||
context=mock.ANY,
|
context=mock.ANY,
|
||||||
vnf_id=mock.ANY,
|
vnf_id=mock.ANY,
|
||||||
auth_attr=mock.ANY,
|
auth_attr=mock.ANY,
|
||||||
region_name=mock.ANY)
|
region_name=mock.ANY)
|
||||||
self._vnf_monitor.delete_hosting_vnf.assert_called_with(mock.ANY)
|
self._vnf_monitor.delete_hosting_vnf.assert_called_with(mock.ANY)
|
||||||
self._pool.spawn_n.assert_called_once_with(mock.ANY, mock.ANY,
|
self._pool.spawn_n.assert_called_once_with(mock.ANY, mock.ANY,
|
||||||
mock.ANY, mock.ANY,
|
mock.ANY, mock.ANY,
|
||||||
|
@ -407,13 +407,13 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
self.context, '6261579e-d6f3-49ad-8bc3-a9cb974778fe')
|
self.context, '6261579e-d6f3-49ad-8bc3-a9cb974778fe')
|
||||||
|
|
||||||
def test_update_vnf(self):
|
def test_update_vnf(self):
|
||||||
self._insert_dummy_device_template()
|
self._insert_dummy_vnf_template()
|
||||||
dummy_device_obj = self._insert_dummy_device()
|
dummy_vnf_obj = self._insert_dummy_vnf()
|
||||||
vnf_config_obj = utils.get_dummy_vnf_config_obj()
|
vnf_config_obj = utils.get_dummy_vnf_config_obj()
|
||||||
result = self.vnfm_plugin.update_vnf(self.context, dummy_device_obj[
|
result = self.vnfm_plugin.update_vnf(self.context, dummy_vnf_obj[
|
||||||
'id'], vnf_config_obj)
|
'id'], vnf_config_obj)
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
self.assertEqual(dummy_device_obj['id'], result['id'])
|
self.assertEqual(dummy_vnf_obj['id'], result['id'])
|
||||||
self.assertIn('instance_id', result)
|
self.assertIn('instance_id', result)
|
||||||
self.assertIn('status', result)
|
self.assertIn('status', result)
|
||||||
self.assertIn('attributes', result)
|
self.assertIn('attributes', result)
|
||||||
|
@ -436,22 +436,22 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
|
|
||||||
def _test_scale_vnf(self, type, scale_state):
|
def _test_scale_vnf(self, type, scale_state):
|
||||||
# create vnfd
|
# create vnfd
|
||||||
self._insert_dummy_device_template()
|
self._insert_dummy_vnf_template()
|
||||||
self._insert_scaling_attributes_vnfd()
|
self._insert_scaling_attributes_vnfd()
|
||||||
|
|
||||||
# create vnf
|
# create vnf
|
||||||
dummy_device_obj = self._insert_dummy_device()
|
dummy_vnf_obj = self._insert_dummy_vnf()
|
||||||
self._insert_scaling_attributes_vnf()
|
self._insert_scaling_attributes_vnf()
|
||||||
|
|
||||||
# scale vnf
|
# scale vnf
|
||||||
vnf_scale = self._get_dummy_scaling_policy(type)
|
vnf_scale = self._get_dummy_scaling_policy(type)
|
||||||
self.vnfm_plugin.create_vnf_scale(
|
self.vnfm_plugin.create_vnf_scale(
|
||||||
self.context,
|
self.context,
|
||||||
dummy_device_obj['id'],
|
dummy_vnf_obj['id'],
|
||||||
vnf_scale)
|
vnf_scale)
|
||||||
|
|
||||||
# validate
|
# validate
|
||||||
self._device_manager.invoke.assert_called_once_with(
|
self._vnf_manager.invoke.assert_called_once_with(
|
||||||
mock.ANY,
|
mock.ANY,
|
||||||
'scale',
|
'scale',
|
||||||
plugin=mock.ANY,
|
plugin=mock.ANY,
|
||||||
|
@ -478,7 +478,7 @@ class TestVNFMPlugin(db_base.SqlTestCase):
|
||||||
self._test_scale_vnf('in', constants.PENDING_SCALE_IN)
|
self._test_scale_vnf('in', constants.PENDING_SCALE_IN)
|
||||||
|
|
||||||
def _get_dummy_active_vnf(self, vnfd_template):
|
def _get_dummy_active_vnf(self, vnfd_template):
|
||||||
dummy_vnf = utils.get_dummy_device_obj()
|
dummy_vnf = utils.get_dummy_vnf()
|
||||||
dummy_vnf['vnfd']['attributes']['vnfd'] = vnfd_template
|
dummy_vnf['vnfd']['attributes']['vnfd'] = vnfd_template
|
||||||
dummy_vnf['status'] = 'ACTIVE'
|
dummy_vnf['status'] = 'ACTIVE'
|
||||||
dummy_vnf['instance_id'] = '4c00108e-c69d-4624-842d-389c77311c1d'
|
dummy_vnf['instance_id'] = '4c00108e-c69d-4624-842d-389c77311c1d'
|
||||||
|
|
Loading…
Reference in New Issue