Commit e57cfcd4 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: alarm must visit allocated Slave Instance to invalidate them

parent d10490cf
portal = context.getPortalObject() portal = context.getPortalObject()
select_dict= {'default_aggregate_uid': None}
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type=('Slave Instance', 'Software Instance'), portal_type=('Slave Instance', 'Software Instance'),
validation_state='validated', validation_state='validated',
default_aggregate_uid=None,
select_dict=select_dict,
left_join_list=select_dict.keys(),
method_id='SoftwareInstance_tryToInvalidateIfDestroyed', method_id='SoftwareInstance_tryToInvalidateIfDestroyed',
activate_kw={'tag': tag}, activate_kw={'tag': tag},
**{"slapos_item.slap_state": "destroy_requested"} **{"slapos_item.slap_state": "destroy_requested"}
......
...@@ -1126,6 +1126,8 @@ class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin): ...@@ -1126,6 +1126,8 @@ class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
) )
def test_tryToInvalidateIfDestroyed_alarm_softwareInstanceAllocated(self): def test_tryToInvalidateIfDestroyed_alarm_softwareInstanceAllocated(self):
# This use case is not needed by the alarm
# But it keeps alarm search way simpler
instance_tree = self.addInstanceTree() instance_tree = self.addInstanceTree()
software_instance = instance_tree.getSuccessorValue() software_instance = instance_tree.getSuccessorValue()
...@@ -1137,7 +1139,25 @@ class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin): ...@@ -1137,7 +1139,25 @@ class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
self.portal.portal_workflow._jumpToStateFor(software_instance, 'destroy_requested') self.portal.portal_workflow._jumpToStateFor(software_instance, 'destroy_requested')
self.tic() self.tic()
self._test_alarm_not_visited( self._test_alarm(
self.portal.portal_alarms.slapos_cloud_invalidate_destroyed_instance,
software_instance,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
def test_tryToInvalidateIfDestroyed_alarm_slaveInstanceAllocated(self):
instance_tree = self.addInstanceTree(shared=True)
software_instance = instance_tree.getSuccessorValue()
_, partition = self.addComputeNodeAndPartition(project=instance_tree.getFollowUpValue())
software_instance.setAggregateValue(partition)
partition.markBusy()
self.portal.portal_workflow._jumpToStateFor(software_instance, 'validated')
self.portal.portal_workflow._jumpToStateFor(software_instance, 'destroy_requested')
self.tic()
self._test_alarm(
self.portal.portal_alarms.slapos_cloud_invalidate_destroyed_instance, self.portal.portal_alarms.slapos_cloud_invalidate_destroyed_instance,
software_instance, software_instance,
'SoftwareInstance_tryToInvalidateIfDestroyed' 'SoftwareInstance_tryToInvalidateIfDestroyed'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment