Пример #1
0
 def test_add_hosting_vnf(self, mock_monitor_run):
     test_device_dict = MOCK_VNF_DEVICE
     test_boot_wait = 30
     test_vnfmonitor = VNFMonitor(test_boot_wait)
     test_vnfmonitor.add_hosting_vnf(test_device_dict)
     test_device_id = test_vnfmonitor._hosting_vnfs.keys()[0]
     self.assertEqual(test_device_id, MOCK_DEVICE_ID)
Пример #2
0
 def test_run_monitor(self, mock_monitor_run):
     test_hosting_vnf = MOCK_VNF_DEVICE
     test_hosting_vnf['device'] = {}
     test_boot_wait = 30
     mock_kwargs = {
         'count': 1,
         'monitoring_delay': 0,
         'interval': 0,
         'mgmt_ip': 'a.b.c.d',
         'timeout': 2
     }
     test_vnfmonitor = VNFMonitor(test_boot_wait)
     self.mock_monitor_manager.invoke = mock.MagicMock()
     test_vnfmonitor._monitor_manager = self.mock_monitor_manager
     test_vnfmonitor.run_monitor(test_hosting_vnf)
     self.mock_monitor_manager\
         .invoke.assert_called_once_with('ping', 'monitor_call', device={},
                                         kwargs=mock_kwargs)
Пример #3
0
 def test_to_hosting_vnf(self):
     test_device_dict = {
         'id': MOCK_DEVICE_ID,
         'mgmt_url': '{"vdu1": "a.b.c.d"}',
         'attributes': {
             'monitoring_policy':
             json.dumps(MOCK_VNF_DEVICE['monitoring_policy'])
         }
     }
     action_cb = mock.MagicMock()
     expected_output = {
         'id': MOCK_DEVICE_ID,
         'action_cb': action_cb,
         'management_ip_addresses': {
             'vdu1': 'a.b.c.d'
         },
         'device': test_device_dict,
         'monitoring_policy': MOCK_VNF_DEVICE['monitoring_policy']
     }
     output_dict = VNFMonitor.to_hosting_vnf(test_device_dict, action_cb)
     self.assertDictEqual(expected_output, output_dict)
Пример #4
0
 def test_to_hosting_vnf(self):
     test_device_dict = {
         'id': MOCK_DEVICE_ID,
         'mgmt_url': '{"vdu1": "a.b.c.d"}',
         'attributes': {
             'monitoring_policy': json.dumps(
                     MOCK_VNF_DEVICE['monitoring_policy'])
         }
     }
     action_cb = mock.MagicMock()
     expected_output = {
         'id': MOCK_DEVICE_ID,
         'action_cb': action_cb,
         'management_ip_addresses': {
             'vdu1': 'a.b.c.d'
         },
         'device': test_device_dict,
         'monitoring_policy': MOCK_VNF_DEVICE['monitoring_policy']
     }
     output_dict = VNFMonitor.to_hosting_vnf(test_device_dict,
                                             action_cb)
     self.assertDictEqual(expected_output, output_dict)