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):
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):
SlapOSTestCaseMixin.afterSetUp(self)
self.project = self.addProject()
self._makeTree(self.project)
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()
instance_tree.archive()
self._test_alarm(
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
software_instance,
'SoftwareInstance_tryToGarbageCollect'
)
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect()
self.tic()
self.assertEqual('destroy_requested',
self.requested_software_instance.getSlapState())
self.assertEqual('validated',
self.requested_software_instance.getValidationState())
def test_SoftwareInstance_tryToGarbageCollect_alarm_sharedAndArchived(self):
instance_tree = self.addInstanceTree(shared=True)
software_instance = instance_tree.getSuccessorValue()
def test_SoftwareInstance_tryToGarbageCollect_not_destroy_requested(self):
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect()
self.tic()
self.assertEqual('start_requested',
self.requested_software_instance.getSlapState())
self.assertEqual('validated',
self.requested_software_instance.getValidationState())
instance_tree.archive()
self._test_alarm(
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
software_instance,
'SoftwareInstance_tryToGarbageCollect'
)
def test_SoftwareInstance_tryToGarbageCollect_not_archived(self):
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.tic()
def test_SoftwareInstance_tryToGarbageCollect_alarm_invalidated(self):
instance_tree = self.addInstanceTree()
software_instance = instance_tree.getSuccessorValue()
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect()
self.tic()
self.assertEqual('start_requested',
self.requested_software_instance.getSlapState())
self.assertEqual('validated',
self.requested_software_instance.getValidationState())
instance_tree.archive()
software_instance.invalidate()
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
software_instance,
'SoftwareInstance_tryToGarbageCollect'
)
def test_SoftwareInstance_tryToGarbageCollect_only_instance_destroy_requested(self):
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.tic()
def test_SoftwareInstance_tryToGarbageCollect_alarm_notArchived(self):
instance_tree = self.addInstanceTree()
software_instance = instance_tree.getSuccessorValue()
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()
self.assertEqual('start_requested',
self.requested_software_instance.getSlapState())
self.assertEqual('validated',
self.requested_software_instance.getValidationState())
#################################################################
# SoftwareInstance_tryToGarbageCollect
#################################################################
def test_SoftwareInstance_tryToGarbageCollect_script_destroyed(self):
instance_tree = self.addInstanceTree()
software_instance = instance_tree.getSuccessorValue()
def test_SoftwareInstance_tryToGarbageCollect_unlinked_successor(self):
self.requested_software_instance.edit(successor_list=[])
self.instance_tree.archive()
self.portal.portal_workflow._jumpToStateFor(self.instance_tree,
'destroy_requested')
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
instance_tree.archive()
self.portal.portal_workflow._jumpToStateFor(instance_tree,
'destroy_requested')
self.tic()
self.assertEqual('validated',
software_instance.getValidationState())
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect()
self.tic()
software_instance.SoftwareInstance_tryToGarbageCollect()
self.assertEqual('destroy_requested',
self.requested_software_instance.getSlapState())
software_instance.getSlapState())
self.assertEqual('validated',
self.requested_software_instance.getValidationState())
software_instance.getValidationState())
def test_SoftwareInstance_tryToGarbageCollect_destroy_unlinked_with_child(self):
instance_kw = dict(software_release=self.generateNewSoftwareReleaseUrl(),
software_type=self.generateNewSoftwareType(),
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)
def test_SoftwareInstance_tryToGarbageCollect_script_archived(self):
instance_tree = self.addInstanceTree()
software_instance = instance_tree.getSuccessorValue()
self.requested_software_instance.edit(successor_list=[])
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()
instance_tree.archive()
self.requested_software_instance.SoftwareInstance_tryToGarbageCollect()
self.tic()
software_instance.SoftwareInstance_tryToGarbageCollect()
self.assertEqual('destroy_requested',
self.requested_software_instance.getSlapState())
self.assertEqual('start_requested',
software_instance.getSlapState())
self.assertEqual('validated',
self.requested_software_instance.getValidationState())
software_instance.getValidationState())
self.assertEqual(self.requested_software_instance.getSuccessorValue(),
None)
self.assertEqual(sub_instance.getSlapState(), 'start_requested')
def test_SoftwareInstance_tryToGarbageCollect_script_notArchived(self):
instance_tree = self.addInstanceTree()
software_instance = instance_tree.getSuccessorValue()
self.portal.portal_workflow._jumpToStateFor(instance_tree,
'destroy_requested')
sub_instance.SoftwareInstance_tryToGarbageCollect()
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')
self.assertEqual(sub_instance.getValidationState(), 'validated')
def test_SoftwareInstance_tryToGarbageCollect_script_unlinkedSuccessor(self):
instance_tree = self.addInstanceTree()
software_instance = instance_tree.getSuccessorValue()
def test_alarm(self):
self.instance_tree.archive()
self._test_alarm(
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
self.software_instance,
'SoftwareInstance_tryToGarbageCollect'
)
instance_tree.edit(successor_list=[])
instance_tree.archive()
self.portal.portal_workflow._jumpToStateFor(instance_tree,
'destroy_requested')
def test_alarm_invalidated(self):
self.instance_tree.archive()
self.software_instance.invalidate()
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
self.software_instance,
'SoftwareInstance_tryToGarbageCollect'
)
self.tic()
software_instance.SoftwareInstance_tryToGarbageCollect()
def test_alarm_not_archived(self):
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
self.software_instance,
'SoftwareInstance_tryToGarbageCollect'
)
self.assertEqual('destroy_requested',
software_instance.getSlapState())
self.assertEqual('validated',
software_instance.getValidationState())
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