Commit 338d5585 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: project needed in compute node / instance

parent 7be88836
...@@ -269,11 +269,10 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -269,11 +269,10 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
instance_xml=self.generateSafeXml(), instance_xml=self.generateSafeXml(),
sla_xml=self.generateEmptyXml(), sla_xml=self.generateEmptyXml(),
shared=False, shared=False,
state="started" state="started",
project_reference=project.getReference()
) )
self.person_user = self.makePerson(project, new_id=new_id, index=False)
self.commit()
# prepare part of tree # prepare part of tree
self.instance_tree = self.portal.instance_tree_module\ self.instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1) .template_instance_tree.Base_createCloneDocument(batch_mode=1)
...@@ -289,7 +288,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -289,7 +288,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
sla_xml=self.request_kw['sla_xml'], sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'], root_slave=self.request_kw['shared'],
successor=self.software_instance.getRelativeUrl(), successor=self.software_instance.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl() follow_up_value=project
) )
self.instance_tree.validate() self.instance_tree.validate()
self.portal.portal_workflow._jumpToStateFor(self.instance_tree, 'start_requested') self.portal.portal_workflow._jumpToStateFor(self.instance_tree, 'start_requested')
...@@ -304,7 +303,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -304,7 +303,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
text_content=self.request_kw['instance_xml'], text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'], sla_xml=self.request_kw['sla_xml'],
specialise=self.instance_tree.getRelativeUrl(), specialise=self.instance_tree.getRelativeUrl(),
successor=self.requested_software_instance.getRelativeUrl() successor=self.requested_software_instance.getRelativeUrl(),
follow_up_value=project
) )
self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested') self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested')
self.software_instance.validate() self.software_instance.validate()
...@@ -318,6 +318,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -318,6 +318,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
text_content=self.request_kw['instance_xml'], text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'], sla_xml=self.request_kw['sla_xml'],
specialise=self.instance_tree.getRelativeUrl(), specialise=self.instance_tree.getRelativeUrl(),
follow_up_value=project
) )
self.portal.portal_workflow._jumpToStateFor(self.requested_software_instance, 'start_requested') self.portal.portal_workflow._jumpToStateFor(self.requested_software_instance, 'start_requested')
self.requested_software_instance.validate() self.requested_software_instance.validate()
......
...@@ -11,7 +11,8 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -11,7 +11,8 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree() self.project = self.addProject()
self._makeTree(self.project)
def test_InstanceTree_assertSuccessor(self): def test_InstanceTree_assertSuccessor(self):
self.software_instance.rename(new_name=self.generateNewSoftwareTitle()) self.software_instance.rename(new_name=self.generateNewSoftwareTitle())
...@@ -86,10 +87,11 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -86,10 +87,11 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree() self.project = self.addProject()
self._makeTree(self.project)
def test_SoftwareInstance_tryToUnallocatePartition(self): def test_SoftwareInstance_tryToUnallocatePartition(self):
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy() self.partition.markBusy()
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
...@@ -102,7 +104,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -102,7 +104,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
self.assertEqual('free', self.partition.getSlapState()) self.assertEqual('free', self.partition.getSlapState())
def test_SoftwareInstance_tryToUnallocatePartition_concurrency(self): def test_SoftwareInstance_tryToUnallocatePartition_concurrency(self):
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy() self.partition.markBusy()
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
...@@ -122,7 +124,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -122,7 +124,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
software_instance = self.portal.software_instance_module\ software_instance = self.portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1) .template_software_instance.Base_createCloneDocument(batch_mode=1)
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
software_instance.setAggregate(self.partition.getRelativeUrl()) software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy() self.partition.markBusy()
...@@ -137,7 +139,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -137,7 +139,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
self.assertEqual(self.partition.getRelativeUrl(), software_instance.getAggregate()) self.assertEqual(self.partition.getRelativeUrl(), software_instance.getAggregate())
def test_alarm_allocated(self): def test_alarm_allocated(self):
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy() self.partition.markBusy()
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
...@@ -151,7 +153,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -151,7 +153,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
) )
def test_alarm_unallocated(self): def test_alarm_unallocated(self):
self._makeComputeNode() self._makeComputeNode(self.project)
self.partition.markBusy() self.partition.markBusy()
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested') 'destroy_requested')
...@@ -164,7 +166,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -164,7 +166,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
) )
def test_alarm_validated(self): def test_alarm_validated(self):
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy() self.partition.markBusy()
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
...@@ -177,7 +179,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -177,7 +179,7 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
) )
def test_alarm_start_requested(self): def test_alarm_start_requested(self):
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy() self.partition.markBusy()
...@@ -190,10 +192,12 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -190,10 +192,12 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
class TestSlapOSFreeComputePartitionAlarmWithSlave(SlapOSTestCaseMixin): class TestSlapOSFreeComputePartitionAlarmWithSlave(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree(requested_template_id='template_slave_instance') self.project = self.addProject()
self._makeTree(self.project,
requested_template_id='template_slave_instance')
def test_SoftwareInstance_tryToUnallocatePartition(self): def test_SoftwareInstance_tryToUnallocatePartition(self):
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy() self.partition.markBusy()
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
...@@ -206,7 +210,7 @@ class TestSlapOSFreeComputePartitionAlarmWithSlave(SlapOSTestCaseMixin): ...@@ -206,7 +210,7 @@ class TestSlapOSFreeComputePartitionAlarmWithSlave(SlapOSTestCaseMixin):
self.assertEqual('free', self.partition.getSlapState()) self.assertEqual('free', self.partition.getSlapState())
def test_SoftwareInstance_tryToUnallocatePartition_nonDestroyed(self): def test_SoftwareInstance_tryToUnallocatePartition_nonDestroyed(self):
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy() self.partition.markBusy()
self.tic() self.tic()
...@@ -222,7 +226,8 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -222,7 +226,8 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self._makeTree() self.project = self.addProject()
self._makeTree(self.project)
def test_SoftwareInstance_tryToGarbageCollect(self): def test_SoftwareInstance_tryToGarbageCollect(self):
self.instance_tree.archive() self.instance_tree.archive()
...@@ -355,15 +360,17 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -355,15 +360,17 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin): class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin):
allocation_scope_to_test = 'open/public' allocation_scope_to_test = 'open'
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self.project = self.addProject()
self.compute_node = self.portal.compute_node_module.template_compute_node\ self.compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
self.compute_node.edit( self.compute_node.edit(
allocation_scope=self.allocation_scope_to_test, allocation_scope=self.allocation_scope_to_test,
reference='TESTC-%s' % self.generateNewId(), reference='TESTC-%s' % self.generateNewId(),
follow_up_value=self.project
) )
self.compute_node.edit(capacity_scope='open') self.compute_node.edit(capacity_scope='open')
self.compute_node.validate() self.compute_node.validate()
...@@ -404,7 +411,7 @@ class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin): ...@@ -404,7 +411,7 @@ class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin):
self.compute_node.getCapacityQuantity()) self.compute_node.getCapacityQuantity())
def test_ComputeNode_checkAndUpdateCapacityScope_model_no_capacity(self): def test_ComputeNode_checkAndUpdateCapacityScope_model_no_capacity(self):
self._makeTree() self._makeTree(self.project)
computer_model = self._newComputerModel(1) computer_model = self._newComputerModel(1)
self.compute_node.edit(specialise_value=computer_model, self.compute_node.edit(specialise_value=computer_model,
...@@ -421,7 +428,7 @@ class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin): ...@@ -421,7 +428,7 @@ class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin):
def test_ComputeNode_checkAndUpdateCapacityScope_model_has_capacity(self): def test_ComputeNode_checkAndUpdateCapacityScope_model_has_capacity(self):
# If capacity is set on compute_node, model value is ignored. # If capacity is set on compute_node, model value is ignored.
self._makeTree() self._makeTree(self.project)
computer_model = self._newComputerModel(1) computer_model = self._newComputerModel(1)
self.compute_node.edit(specialise_value=computer_model, self.compute_node.edit(specialise_value=computer_model,
...@@ -447,7 +454,7 @@ class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin): ...@@ -447,7 +454,7 @@ class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin):
self.compute_node.workflow_history['edit_workflow'][-1]['comment']) self.compute_node.workflow_history['edit_workflow'][-1]['comment'])
def test_ComputeNode_checkAndUpdateCapacityScope_no_capacity_quantity(self): def test_ComputeNode_checkAndUpdateCapacityScope_no_capacity_quantity(self):
self._makeTree() self._makeTree(self.project)
self.compute_node.edit(capacity_quantity=1) self.compute_node.edit(capacity_quantity=1)
self._addPartitionToComputeNode() self._addPartitionToComputeNode()
self.compute_node.ComputeNode_checkAndUpdateCapacityScope() self.compute_node.ComputeNode_checkAndUpdateCapacityScope()
...@@ -474,14 +481,6 @@ class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin): ...@@ -474,14 +481,6 @@ class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin):
self.assertEqual("Compute Node reported an error", self.assertEqual("Compute Node reported an error",
self.compute_node.workflow_history['edit_workflow'][-1]['comment']) self.compute_node.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSComputeNode_checkAndUpdateCapacityScopeSubscription(TestSlapOSComputeNode_checkAndUpdateCapacityScope):
allocation_scope_to_test = 'open/subscription'
class TestSlapOSComputeNode_checkAndUpdateCapacityScopePersonal(TestSlapOSComputeNode_checkAndUpdateCapacityScope):
allocation_scope_to_test = 'open/personal'
class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
self.compute_node = self.portal.compute_node_module.template_compute_node\ self.compute_node = self.portal.compute_node_module.template_compute_node\
...@@ -502,12 +501,8 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin): ...@@ -502,12 +501,8 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
'ComputeNode_checkAndUpdateCapacityScope' 'ComputeNode_checkAndUpdateCapacityScope'
) )
def test_alarm_subscription(self): def test_alarm_open(self):
self.compute_node.edit(allocation_scope='open/subscription') self.compute_node.edit(allocation_scope='open')
self.test_alarm()
def test_alarm_personal(self):
self.compute_node.edit(allocation_scope='open/personal')
self.test_alarm() self.test_alarm()
def test_alarm_non_public(self): def test_alarm_non_public(self):
...@@ -528,10 +523,15 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin): ...@@ -528,10 +523,15 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
def createInstance(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.project = self.addProject()
def createInstance(self, project):
instance_tree = self.portal.instance_tree_module\ instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1) .template_instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree.edit( instance_tree.edit(
follow_up_value=project
) )
instance_tree.validate() instance_tree.validate()
instance_tree.edit( instance_tree.edit(
...@@ -546,7 +546,8 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -546,7 +546,8 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
sla_xml=self.generateSafeXml(), sla_xml=self.generateSafeXml(),
shared=False, shared=False,
software_title=instance_tree.getTitle(), software_title=instance_tree.getTitle(),
state='started' state='started',
project_reference=project.getReference()
) )
instance_tree.requestStart(**request_kw) instance_tree.requestStart(**request_kw)
instance_tree.requestInstance(**request_kw) instance_tree.requestInstance(**request_kw)
...@@ -562,7 +563,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -562,7 +563,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
REQUEST={}) REQUEST={})
def test_SoftwareInstance_tryToStopCollect_started_instance(self): def test_SoftwareInstance_tryToStopCollect_started_instance(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance_tree = instance.getSpecialiseValue() instance_tree = instance.getSpecialiseValue()
self.portal.portal_workflow._jumpToStateFor(instance_tree, self.portal.portal_workflow._jumpToStateFor(instance_tree,
...@@ -573,7 +574,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -573,7 +574,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('stop_requested', instance.getSlapState()) self.assertEqual('stop_requested', instance.getSlapState())
def test_SoftwareInstance_tryToStopCollect_destroyed_instance(self): def test_SoftwareInstance_tryToStopCollect_destroyed_instance(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance_tree = instance.getSpecialiseValue() instance_tree = instance.getSpecialiseValue()
self.portal.portal_workflow._jumpToStateFor(instance_tree, self.portal.portal_workflow._jumpToStateFor(instance_tree,
...@@ -585,7 +586,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -585,7 +586,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('destroy_requested', instance.getSlapState()) self.assertEqual('destroy_requested', instance.getSlapState())
def test_SoftwareInstance_tryToStopCollect_started_subscription(self): def test_SoftwareInstance_tryToStopCollect_started_subscription(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance_tree = instance.getSpecialiseValue() instance_tree = instance.getSpecialiseValue()
self.assertEqual('start_requested', instance_tree.getSlapState()) self.assertEqual('start_requested', instance_tree.getSlapState())
...@@ -603,7 +604,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -603,7 +604,7 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
) )
def test_alarm_invalidated(self): def test_alarm_invalidated(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance.invalidate() instance.invalidate()
self._test_alarm_not_visited( self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_stop_collect_instance, self.portal.portal_alarms.slapos_stop_collect_instance,
...@@ -613,9 +614,16 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -613,9 +614,16 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
def createInstance(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.project = self.addProject()
def createInstance(self, project):
instance_tree = self.portal.instance_tree_module\ instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1) .template_instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree.edit(
follow_up_value=project
)
instance_tree.validate() instance_tree.validate()
instance_tree.edit( instance_tree.edit(
title=self.generateNewSoftwareTitle(), title=self.generateNewSoftwareTitle(),
...@@ -629,7 +637,8 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -629,7 +637,8 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
sla_xml=self.generateSafeXml(), sla_xml=self.generateSafeXml(),
shared=False, shared=False,
software_title=instance_tree.getTitle(), software_title=instance_tree.getTitle(),
state='started' state='started',
project_reference=project
) )
instance_tree.requestStart(**request_kw) instance_tree.requestStart(**request_kw)
instance_tree.requestInstance(**request_kw) instance_tree.requestInstance(**request_kw)
...@@ -655,7 +664,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -655,7 +664,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
REQUEST={}) REQUEST={})
def test_tryToGarbageCollect_invalidated_instance(self): def test_tryToGarbageCollect_invalidated_instance(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance.invalidate() instance.invalidate()
self.tic() self.tic()
...@@ -665,7 +674,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -665,7 +674,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('start_requested', instance_tree.getSlapState()) self.assertEqual('start_requested', instance_tree.getSlapState())
def test_tryToGarbageCollect_destroyed_instance(self): def test_tryToGarbageCollect_destroyed_instance(self):
instance = self.createInstance() instance = self.createInstance(self.project)
self.portal.portal_workflow._jumpToStateFor(instance, 'destroy_requested') self.portal.portal_workflow._jumpToStateFor(instance, 'destroy_requested')
self.tic() self.tic()
...@@ -675,7 +684,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -675,7 +684,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('start_requested', instance_tree.getSlapState()) self.assertEqual('start_requested', instance_tree.getSlapState())
def test_tryToGarbageCollect_allocated_instance(self): def test_tryToGarbageCollect_allocated_instance(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self.tic()
...@@ -686,7 +695,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -686,7 +695,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('start_requested', instance_tree.getSlapState()) self.assertEqual('start_requested', instance_tree.getSlapState())
def test_tryToGarbageCollect_no_allocation_try_found(self): def test_tryToGarbageCollect_no_allocation_try_found(self):
instance = self.createInstance() instance = self.createInstance(self.project)
self.tic() self.tic()
instance.SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree() instance.SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree()
...@@ -695,7 +704,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -695,7 +704,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('start_requested', instance_tree.getSlapState()) self.assertEqual('start_requested', instance_tree.getSlapState())
def test_tryToGarbageCollect_recent_allocation_try_found(self): def test_tryToGarbageCollect_recent_allocation_try_found(self):
instance = self.createInstance() instance = self.createInstance(self.project)
self.tic() self.tic()
instance.workflow_history['edit_workflow'].append({ instance.workflow_history['edit_workflow'].append({
'comment':'Allocation failed: no free Compute Partition', 'comment':'Allocation failed: no free Compute Partition',
...@@ -713,7 +722,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -713,7 +722,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
def test_tryToGarbageCollect_recent_allocation_try_found_allocation_disallowed(self): def test_tryToGarbageCollect_recent_allocation_try_found_allocation_disallowed(self):
instance = self.createInstance() instance = self.createInstance(self.project)
self.tic() self.tic()
instance.workflow_history['edit_workflow'].append({ instance.workflow_history['edit_workflow'].append({
'comment':'Allocation failed: Allocation disallowed', 'comment':'Allocation failed: Allocation disallowed',
...@@ -730,7 +739,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -730,7 +739,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('start_requested', instance_tree.getSlapState()) self.assertEqual('start_requested', instance_tree.getSlapState())
def test_tryToGarbageCollect_complex_tree(self): def test_tryToGarbageCollect_complex_tree(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance_tree = instance.getSpecialiseValue() instance_tree = instance.getSpecialiseValue()
request_kw = dict( request_kw = dict(
software_release=\ software_release=\
...@@ -758,7 +767,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -758,7 +767,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('start_requested', instance_tree.getSlapState()) self.assertEqual('start_requested', instance_tree.getSlapState())
def test_tryToGarbageCollect_complex_tree_allocation_disallowed(self): def test_tryToGarbageCollect_complex_tree_allocation_disallowed(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance_tree = instance.getSpecialiseValue() instance_tree = instance.getSpecialiseValue()
request_kw = dict( request_kw = dict(
software_release=\ software_release=\
...@@ -786,7 +795,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -786,7 +795,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual('start_requested', instance_tree.getSlapState()) self.assertEqual('start_requested', instance_tree.getSlapState())
def test_tryToGarbageCollect_old_allocation_try_found(self): def test_tryToGarbageCollect_old_allocation_try_found(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance_tree = instance.getSpecialiseValue() instance_tree = instance.getSpecialiseValue()
self.tic() self.tic()
instance.workflow_history['edit_workflow'].append({ instance.workflow_history['edit_workflow'].append({
...@@ -804,7 +813,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -804,7 +813,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
def test_tryToGarbageCollect_old_allocation_try_found_allocation_disallowed(self): def test_tryToGarbageCollect_old_allocation_try_found_allocation_disallowed(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance_tree = instance.getSpecialiseValue() instance_tree = instance.getSpecialiseValue()
self.tic() self.tic()
instance.workflow_history['edit_workflow'].append({ instance.workflow_history['edit_workflow'].append({
...@@ -829,7 +838,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -829,7 +838,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
) )
def test_alarm_invalidated(self): def test_alarm_invalidated(self):
instance = self.createInstance() instance = self.createInstance(self.project)
instance.invalidate() instance.invalidate()
self._test_alarm_not_visited( self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_garbage_collect_non_allocated_root_tree, self.portal.portal_alarms.slapos_garbage_collect_non_allocated_root_tree,
...@@ -838,7 +847,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -838,7 +847,7 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
) )
def test_alarm_allocated(self): def test_alarm_allocated(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self._test_alarm_not_visited( self._test_alarm_not_visited(
...@@ -850,9 +859,16 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -850,9 +859,16 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
def createInstance(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.project = self.addProject()
def createInstance(self, project):
instance_tree = self.portal.instance_tree_module\ instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1) .template_instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree.edit(
follow_up_value=project
)
instance_tree.validate() instance_tree.validate()
instance_tree.edit( instance_tree.edit(
title=self.generateNewSoftwareTitle(), title=self.generateNewSoftwareTitle(),
...@@ -866,7 +882,8 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -866,7 +882,8 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
sla_xml=self.generateSafeXml(), sla_xml=self.generateSafeXml(),
shared=False, shared=False,
software_title=instance_tree.getTitle(), software_title=instance_tree.getTitle(),
state='started' state='started',
project_reference=project.getReference()
) )
instance_tree.requestStart(**request_kw) instance_tree.requestStart(**request_kw)
instance_tree.requestInstance(**request_kw) instance_tree.requestInstance(**request_kw)
...@@ -906,7 +923,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -906,7 +923,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
return sub_instance return sub_instance
def test_SoftwareInstance_tryToGarbageUnlinkedInstance(self): def test_SoftwareInstance_tryToGarbageUnlinkedInstance(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self.tic()
...@@ -922,7 +939,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -922,7 +939,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
self.assertEqual(instance0.getSlapState(), 'destroy_requested') self.assertEqual(instance0.getSlapState(), 'destroy_requested')
def test_SoftwareInstance_tryToGarbageUnlinkedInstance_hosting_destroyed(self): def test_SoftwareInstance_tryToGarbageUnlinkedInstance_hosting_destroyed(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self.tic()
...@@ -942,7 +959,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -942,7 +959,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
self.assertEqual(instance0.getSlapState(), 'start_requested') self.assertEqual(instance0.getSlapState(), 'start_requested')
def test_SoftwareInstance_tryToGarbageUnlinkedInstance_will_unlink_children(self): def test_SoftwareInstance_tryToGarbageUnlinkedInstance_will_unlink_children(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self.tic()
...@@ -962,7 +979,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -962,7 +979,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
self.assertEqual(instance_instance0.getSuccessorRelatedTitle(), None) self.assertEqual(instance_instance0.getSuccessorRelatedTitle(), None)
def test_SoftwareInstance_tryToGarbageUnlinkedInstance_will_delay(self): def test_SoftwareInstance_tryToGarbageUnlinkedInstance_will_delay(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self.tic()
...@@ -991,7 +1008,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -991,7 +1008,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
self.assertEqual(instance_instance0.getSuccessorRelatedTitle(), None) self.assertEqual(instance_instance0.getSuccessorRelatedTitle(), None)
def test_SoftwareInstance_tryToGarbageUnlinkedInstance_unlinked_root(self): def test_SoftwareInstance_tryToGarbageUnlinkedInstance_unlinked_root(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self.tic()
...@@ -1011,7 +1028,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -1011,7 +1028,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
self.assertEqual(instance.getSlapState(), 'start_requested') self.assertEqual(instance.getSlapState(), 'start_requested')
def test_SoftwareInstance_tryToGarbageUnlinkedInstance_not_unlinked(self): def test_SoftwareInstance_tryToGarbageUnlinkedInstance_not_unlinked(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self.tic()
...@@ -1027,7 +1044,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -1027,7 +1044,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
self.assertEqual(instance_instance0.getSlapState(), 'start_requested') self.assertEqual(instance_instance0.getSlapState(), 'start_requested')
def test_alarm_search_inlinked_instance(self): def test_alarm_search_inlinked_instance(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self.tic()
...@@ -1049,7 +1066,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -1049,7 +1066,7 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
) )
def test_alarm_search_inlinked_instance_slave(self): def test_alarm_search_inlinked_instance_slave(self):
instance = self.createInstance() instance = self.createInstance(self.project)
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self.tic()
...@@ -1071,6 +1088,10 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -1071,6 +1088,10 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin): class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
self.project = self.addProject()
def createSoftwareInstance(self): def createSoftwareInstance(self):
new_id = self.generateNewId() new_id = self.generateNewId()
return self.portal.software_instance_module.newContent( return self.portal.software_instance_module.newContent(
......
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