Commit 51e8990f authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: fixup tests for slapos_garbage_collect_destroyed_root_tree

parent 826a52f6
...@@ -310,140 +310,116 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -310,140 +310,116 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin): class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
#################################################################
# slapos_garbage_collect_destroyed_root_tree
#################################################################
def test_SoftwareInstance_tryToGarbageCollect_alarm_archived(self):
instance_tree = self.addInstanceTree()
software_instance = instance_tree.getSuccessorValue()
def afterSetUp(self): instance_tree.archive()
SlapOSTestCaseMixin.afterSetUp(self) self._test_alarm(
self.project = self.addProject() self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
self._makeTree(self.project) software_instance,
'SoftwareInstance_tryToGarbageCollect'
def test_SoftwareInstance_tryToGarbageCollect(self): )
self.instance_tree.archive()
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.tic()
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect() def test_SoftwareInstance_tryToGarbageCollect_alarm_sharedAndArchived(self):
self.tic() instance_tree = self.addInstanceTree(shared=True)
self.assertEqual('destroy_requested', software_instance = instance_tree.getSuccessorValue()
self.requested_software_instance.getSlapState())
self.assertEqual('validated',
self.requested_software_instance.getValidationState())
def test_SoftwareInstance_tryToGarbageCollect_not_destroy_requested(self): instance_tree.archive()
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect() self._test_alarm(
self.tic() self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
self.assertEqual('start_requested', software_instance,
self.requested_software_instance.getSlapState()) 'SoftwareInstance_tryToGarbageCollect'
self.assertEqual('validated', )
self.requested_software_instance.getValidationState())
def test_SoftwareInstance_tryToGarbageCollect_not_archived(self): def test_SoftwareInstance_tryToGarbageCollect_alarm_invalidated(self):
self.portal.portal_workflow._jumpToStateFor(self.software_instance, instance_tree = self.addInstanceTree()
'destroy_requested') software_instance = instance_tree.getSuccessorValue()
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.tic()
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect() instance_tree.archive()
self.tic() software_instance.invalidate()
self.assertEqual('start_requested', self._test_alarm_not_visited(
self.requested_software_instance.getSlapState()) self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
self.assertEqual('validated', software_instance,
self.requested_software_instance.getValidationState()) 'SoftwareInstance_tryToGarbageCollect'
)
def test_SoftwareInstance_tryToGarbageCollect_only_instance_destroy_requested(self): def test_SoftwareInstance_tryToGarbageCollect_alarm_notArchived(self):
self.portal.portal_workflow._jumpToStateFor(self.software_instance, instance_tree = self.addInstanceTree()
'destroy_requested') software_instance = instance_tree.getSuccessorValue()
self.tic() self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
software_instance,
'SoftwareInstance_tryToGarbageCollect'
)
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect() #################################################################
self.tic() # SoftwareInstance_tryToGarbageCollect
self.assertEqual('start_requested', #################################################################
self.requested_software_instance.getSlapState()) def test_SoftwareInstance_tryToGarbageCollect_script_destroyed(self):
self.assertEqual('validated', instance_tree = self.addInstanceTree()
self.requested_software_instance.getValidationState()) software_instance = instance_tree.getSuccessorValue()
def test_SoftwareInstance_tryToGarbageCollect_unlinked_successor(self): instance_tree.archive()
self.requested_software_instance.edit(successor_list=[]) self.portal.portal_workflow._jumpToStateFor(instance_tree,
self.instance_tree.archive()
self.portal.portal_workflow._jumpToStateFor(self.instance_tree,
'destroy_requested')
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested') 'destroy_requested')
self.tic() self.assertEqual('validated',
software_instance.getValidationState())
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect()
self.tic() self.tic()
software_instance.SoftwareInstance_tryToGarbageCollect()
self.assertEqual('destroy_requested', self.assertEqual('destroy_requested',
self.requested_software_instance.getSlapState()) software_instance.getSlapState())
self.assertEqual('validated', self.assertEqual('validated',
self.requested_software_instance.getValidationState()) software_instance.getValidationState())
def test_SoftwareInstance_tryToGarbageCollect_destroy_unlinked_with_child(self): def test_SoftwareInstance_tryToGarbageCollect_script_archived(self):
instance_kw = dict(software_release=self.generateNewSoftwareReleaseUrl(), instance_tree = self.addInstanceTree()
software_type=self.generateNewSoftwareType(), software_instance = instance_tree.getSuccessorValue()
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title='Sub Instance',
state='started'
)
self.requested_software_instance.requestInstance(**instance_kw)
sub_instance = self.requested_software_instance.getSuccessorValue()
self.assertNotEqual(sub_instance, None)
self.requested_software_instance.edit(successor_list=[]) instance_tree.archive()
self.instance_tree.archive()
self.portal.portal_workflow._jumpToStateFor(self.instance_tree,
'destroy_requested')
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.tic()
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect()
self.tic() self.tic()
software_instance.SoftwareInstance_tryToGarbageCollect()
self.assertEqual('destroy_requested', self.assertEqual('start_requested',
self.requested_software_instance.getSlapState()) software_instance.getSlapState())
self.assertEqual('validated', self.assertEqual('validated',
self.requested_software_instance.getValidationState()) software_instance.getValidationState())
self.assertEqual(self.requested_software_instance.getSuccessorValue(), def test_SoftwareInstance_tryToGarbageCollect_script_notArchived(self):
None) instance_tree = self.addInstanceTree()
self.assertEqual(sub_instance.getSlapState(), 'start_requested') software_instance = instance_tree.getSuccessorValue()
self.portal.portal_workflow._jumpToStateFor(instance_tree,
'destroy_requested')
sub_instance.SoftwareInstance_tryToGarbageCollect()
self.tic() self.tic()
software_instance.SoftwareInstance_tryToGarbageCollect()
self.assertEqual('start_requested',
software_instance.getSlapState())
self.assertEqual('validated',
software_instance.getValidationState())
self.assertEqual(sub_instance.getSlapState(), 'destroy_requested') def test_SoftwareInstance_tryToGarbageCollect_script_unlinkedSuccessor(self):
self.assertEqual(sub_instance.getValidationState(), 'validated') instance_tree = self.addInstanceTree()
software_instance = instance_tree.getSuccessorValue()
def test_alarm(self): instance_tree.edit(successor_list=[])
self.instance_tree.archive() instance_tree.archive()
self._test_alarm( self.portal.portal_workflow._jumpToStateFor(instance_tree,
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree, 'destroy_requested')
self.software_instance,
'SoftwareInstance_tryToGarbageCollect'
)
def test_alarm_invalidated(self): self.tic()
self.instance_tree.archive() software_instance.SoftwareInstance_tryToGarbageCollect()
self.software_instance.invalidate()
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
self.software_instance,
'SoftwareInstance_tryToGarbageCollect'
)
def test_alarm_not_archived(self): self.assertEqual('destroy_requested',
self._test_alarm_not_visited( software_instance.getSlapState())
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree, self.assertEqual('validated',
self.software_instance, software_instance.getValidationState())
'SoftwareInstance_tryToGarbageCollect'
)
class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin): class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
......
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