Commit 38e9d877 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: fixup slapos_stop_collect_instance tests

parent 0bea52ec
...@@ -599,95 +599,70 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin): ...@@ -599,95 +599,70 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
#################################################################
def afterSetUp(self): # slapos_stop_collect_instance
SlapOSTestCaseMixin.afterSetUp(self) #################################################################
self.project = self.addProject() def test_SoftwareInstance_tryToStopCollect_alarm(self):
instance_tree = self.addInstanceTree()
def createInstance(self, project): software_instance = instance_tree.getSuccessorValue()
instance_tree = self.portal.instance_tree_module\ self._test_alarm(
.template_instance_tree.Base_createCloneDocument(batch_mode=1) self.portal.portal_alarms.slapos_stop_collect_instance,
instance_tree.edit( software_instance,
follow_up_value=project 'SoftwareInstance_tryToStopCollect'
)
instance_tree.validate()
instance_tree.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTHS-%s" % self.generateNewId(),
)
request_kw = dict(
software_release=\
self.generateNewSoftwareReleaseUrl(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=instance_tree.getTitle(),
state='started',
project_reference=project.getReference()
) )
instance_tree.requestStart(**request_kw)
instance_tree.requestInstance(**request_kw)
instance = instance_tree.getSuccessorValue() def test_SoftwareInstance_tryToStopCollect_alarm_invalidated(self):
self.tic() instance_tree = self.addInstanceTree()
return instance software_instance = instance_tree.getSuccessorValue()
software_instance.invalidate()
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_stop_collect_instance,
software_instance,
'SoftwareInstance_tryToStopCollect'
)
#################################################################
# SoftwareInstance_tryToStopCollect
#################################################################
def test_SoftwareInstance_tryToStopCollect_REQUEST_disallowed(self): def test_SoftwareInstance_tryToStopCollect_REQUEST_disallowed(self):
self.assertRaises( self.assertRaises(
Unauthorized, Unauthorized,
self.portal.SoftwareInstance_tryToStopCollect, self.portal.SoftwareInstance_tryToStopCollect,
REQUEST={}) REQUEST={})
def test_SoftwareInstance_tryToStopCollect_started_instance(self): def test_SoftwareInstance_tryToStopCollect_script_startedInstance(self):
instance = self.createInstance(self.project) instance_tree = self.addInstanceTree()
instance_tree = instance.getSpecialiseValue() software_instance = instance_tree.getSuccessorValue()
self.portal.portal_workflow._jumpToStateFor(instance_tree, self.portal.portal_workflow._jumpToStateFor(instance_tree,
'stop_requested') 'stop_requested')
self.assertEqual('start_requested', instance.getSlapState()) self.assertEqual('start_requested', software_instance.getSlapState())
instance.SoftwareInstance_tryToStopCollect() software_instance.SoftwareInstance_tryToStopCollect()
self.assertEqual('stop_requested', instance.getSlapState()) self.assertEqual('stop_requested', software_instance.getSlapState())
def test_SoftwareInstance_tryToStopCollect_destroyed_instance(self): def test_SoftwareInstance_tryToStopCollect_script_destroyedInstance(self):
instance = self.createInstance(self.project) instance_tree = self.addInstanceTree()
instance_tree = instance.getSpecialiseValue() software_instance = instance_tree.getSuccessorValue()
self.portal.portal_workflow._jumpToStateFor(instance_tree, self.portal.portal_workflow._jumpToStateFor(instance_tree,
'stop_requested') 'stop_requested')
self.portal.portal_workflow._jumpToStateFor(instance, self.portal.portal_workflow._jumpToStateFor(software_instance,
'destroy_requested') 'destroy_requested')
instance.SoftwareInstance_tryToStopCollect() software_instance.SoftwareInstance_tryToStopCollect()
self.assertEqual('destroy_requested', instance.getSlapState()) self.assertEqual('destroy_requested', software_instance.getSlapState())
def test_SoftwareInstance_tryToStopCollect_started_subscription(self): def test_SoftwareInstance_tryToStopCollect_script_startedInstanceTree(self):
instance = self.createInstance(self.project) instance_tree = self.addInstanceTree()
instance_tree = instance.getSpecialiseValue() software_instance = instance_tree.getSuccessorValue()
self.assertEqual('start_requested', instance_tree.getSlapState()) self.assertEqual('start_requested', instance_tree.getSlapState())
self.assertEqual('start_requested', instance.getSlapState()) self.assertEqual('start_requested', software_instance.getSlapState())
instance.SoftwareInstance_tryToStopCollect()
self.assertEqual('start_requested', instance.getSlapState())
def test_alarm(self): software_instance.SoftwareInstance_tryToStopCollect()
instance = self.createInstance(self.project) self.assertEqual('start_requested', software_instance.getSlapState())
self._test_alarm(
self.portal.portal_alarms.slapos_stop_collect_instance,
instance,
'SoftwareInstance_tryToStopCollect'
)
def test_alarm_invalidated(self):
instance = self.createInstance(self.project)
instance.invalidate()
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_stop_collect_instance,
instance,
'SoftwareInstance_tryToStopCollect'
)
class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(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