Commit a9020c91 authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: test Upgrade for allocated Software Instance

parent 26fe1a30
...@@ -70,6 +70,9 @@ if len(allocation_cell_list) == 1: ...@@ -70,6 +70,9 @@ if len(allocation_cell_list) == 1:
if (allocation_cell_list[0].getSoftwareReleaseValue().getUrlString() != instance_tree.getUrlString()): if (allocation_cell_list[0].getSoftwareReleaseValue().getUrlString() != instance_tree.getUrlString()):
# XXX Upgrade # XXX Upgrade
if compute_node is not None:
assert compute_node.getRelativeUrl() in allocation_cell_list[0].getParentValue().getParentValue().getAggregateList()
decision_title = 'A new upgrade is available for %s' % instance_tree.getTitle() decision_title = 'A new upgrade is available for %s' % instance_tree.getTitle()
upgrade_decision = portal.upgrade_decision_module.newContent( upgrade_decision = portal.upgrade_decision_module.newContent(
portal_type='Upgrade Decision', portal_type='Upgrade Decision',
......
...@@ -127,7 +127,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -127,7 +127,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
) )
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision()) self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
def bootstrapAllocableInstanceTree(self): def bootstrapAllocableInstanceTree(self, is_allocated=False):
project = self.addProject() project = self.addProject()
person = self._makePerson(project) person = self._makePerson(project)
software_product = self._makeSoftwareProduct(project) software_product = self._makeSoftwareProduct(project)
...@@ -144,16 +144,30 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -144,16 +144,30 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
) )
assert compute_node is not None assert compute_node is not None
instance_tree = self.portal.instance_tree_module.newContent( request_kw = dict(
portal_type="Instance Tree", software_release=release_variation.getUrlString(),
destination_section_value=person, software_type=type_variation.getTitle(),
url_string=release_variation.getUrlString(), instance_xml=self.generateSafeXml(),
source_reference=type_variation.getTitle(), sla_xml=self.generateSafeXml(),
follow_up_value=project, shared=False,
software_title='test tree',
state='started',
project_reference=project.getReference()
) )
person.requestSoftwareInstance(**request_kw)
instance_tree = self.portal.REQUEST.get('request_instance_tree')
if is_allocated:
partition = compute_node.newContent(portal_type='Compute Partition')
instance = instance_tree.getSuccessorValue()
instance.edit(aggregate_value=partition)
self.tic() self.tic()
return software_product, release_variation, type_variation, compute_node, instance_tree return software_product, release_variation, type_variation, compute_node, instance_tree
##########################################################################
# Not allocated
##########################################################################
def test_createUpgradeDecision_notAllocated_newRelease(self): def test_createUpgradeDecision_notAllocated_newRelease(self):
software_product, _, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree() software_product, _, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree()
...@@ -231,14 +245,58 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -231,14 +245,58 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
upgrade_decision2 = instance_tree.InstanceTree_createUpgradeDecision() upgrade_decision2 = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual('started', upgrade_decision2.getSimulationState()) self.assertEqual('started', upgrade_decision2.getSimulationState())
# not allocated 0 supply ##########################################################################
# not allocated 1 same supply # Allocated on Compute Node
# not allocated 1 different supply without existing decision ##########################################################################
# not allocated 1 different supply with existing decision def test_createUpgradeDecision_allocatedOnComputeNode_newReleaseOnAnotherComputeNode(self):
# not allocated 1 different supply with existing rejected decision software_product, _, type_variation, _, instance_tree = self.bootstrapAllocableInstanceTree(is_allocated=True)
project = instance_tree.getFollowUpValue()
person = instance_tree.getDestinationSectionValue()
person.requestComputeNode(compute_node_title='another test compute node',
project_reference=project.getReference())
self.tic()
compute_node2 = self.portal.portal_catalog.getResultValue(
portal_type='Compute Node',
reference=self.portal.REQUEST.get('compute_node_reference')
)
assert compute_node2 is not None
# 2 supplies new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node 2", compute_node2, software_product,
new_release_variation, type_variation)
self.tic()
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
def test_createUpgradeDecision_allocatedOnComputeNode_newReleaseOnComputeNode(self):
software_product, _, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree(is_allocated=True)
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node", compute_node, software_product,
new_release_variation, type_variation)
self.tic()
upgrade_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual('started', upgrade_decision.getSimulationState())
def test_createUpgradeDecision_allocatedOnComputeNode_twoRelease(self):
software_product, release_variation, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree(is_allocated=True)
self.addAllocationSupply(
"for compute node", compute_node, software_product,
release_variation, type_variation)
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node 2", compute_node, software_product,
new_release_variation, type_variation)
self.tic()
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
##########################################################################
# tocheck
##########################################################################
def test_tocheck_InstanceTree_createUpgradeDecision(self): def test_tocheck_InstanceTree_createUpgradeDecision(self):
upgrade_decision = self.instance_tree.InstanceTree_createUpgradeDecision() upgrade_decision = self.instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual('started', upgrade_decision.getSimulationState()) self.assertEqual('started', upgrade_decision.getSimulationState())
......
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