Exemplo n.º 1
0
 def _test_scale(self, resource_status):
     dummy_event = fd_utils.get_dummy_event(resource_status)
     self._responses_in_resource_event_list(dummy_event)
     self._response_in_resource_get(self.instance_uuid, res_name='G1')
     self._response_in_resource_get_list()
     self._response_in_resource_get(self.stack_id)
     self._response_in_resource_get(self.instance_uuid,
                                    res_name='SP1_group')
 def test_scale_wait_failed_with_exception(self, mock_log):
     self._exception_response()
     self.assertRaises(vnfm.VNFScaleWaitFailed,
                       self.openstack.scale_wait,
                       plugin=self, context=self.context, auth_attr=None,
                       policy=fd_utils.get_dummy_policy_dict(),
                       region_name=None,
                       last_event_id=fd_utils.get_dummy_event()['id'])
     mock_log.warning.assert_called_once()
 def test_scale_wait_with_same_last_event_id(self, resource_status):
     self._test_scale(resource_status)
     mgmt_ip = self.openstack.scale_wait(plugin=self,
                             context=self.context,
                             auth_attr=None,
                             policy=fd_utils.get_dummy_policy_dict(),
                             region_name=None,
                             last_event_id=fd_utils.get_dummy_event()['id'])
     self.assertEqual('{"vdu1": ["test1"]}', mgmt_ip)
 def test_scale_wait_without_resource_metadata(self):
     dummy_event = fd_utils.get_dummy_event("CREATE_IN_PROGRESS")
     self._responses_in_resource_event_list(dummy_event)
     self._response_in_resource_metadata()
     self._response_in_resource_get(self.instance_uuid, res_name='G1')
     self._response_in_resource_get_list()
     self._response_in_resource_get(self.stack_id)
     self._response_in_resource_get(self.instance_uuid,
                                    res_name='SP1_group')
     mgmt_ip = self.openstack.scale_wait(plugin=self, context=self.context,
                               auth_attr=None,
                               policy=fd_utils.get_dummy_policy_dict(),
                               region_name=None,
                               last_event_id=fd_utils.get_dummy_event()
                               ['id'])
     error_reason = ('When signal occurred within cool down '
                     'window, no events generated from heat, '
                     'so ignore it')
     self.mock_log.warning.assert_called_once_with(error_reason)
     self.assertEqual('{"vdu1": ["test1"]}', mgmt_ip)
 def test_scale_wait_failed_with_stack_retries_0(self):
     dummy_event = fd_utils.get_dummy_event("CREATE_IN_PROGRESS")
     self._responses_in_resource_event_list(dummy_event)
     self._response_in_resource_metadata(True)
     self.assertRaises(vnfm.VNFScaleWaitFailed,
                       self.openstack.scale_wait,
                       plugin=self, context=self.context, auth_attr=None,
                       policy=fd_utils.get_dummy_policy_dict(),
                       region_name=None,
                       last_event_id=dummy_event['id'])
     self.mock_log.warning.assert_called_once()
 def test_scale(self):
     dummy_event = fd_utils.get_dummy_event()
     self._responses_in_resource_event_list(dummy_event)
     # response for heat_client's resource_signal()
     url = self.url + '/stacks/' + self.instance_uuid + ('/myStack/60f83b5e'
                                          '/resources/SP1_scale_out/signal')
     self.requests_mock.register_uri('POST', url, json={},
                                     headers=self.json_headers)
     event_id = self.openstack.scale(plugin=self, context=self.context,
                                 auth_attr=None,
                                 policy=fd_utils.get_dummy_policy_dict(),
                                 region_name=None)
     self.assertEqual(dummy_event['id'], event_id)