Commit ab6e825b authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: test upgrade Instance Node

parent a918262b
...@@ -46,10 +46,18 @@ if len(root_instance_list) != 0: ...@@ -46,10 +46,18 @@ if len(root_instance_list) != 0:
if partition is not None: if partition is not None:
compute_node = partition.getParentValue() compute_node = partition.getParentValue()
if (root_instance.getPortalType() == 'Slave Instance') and \ if (root_instance.getPortalType() == 'Slave Instance'):
(compute_node.getPortalType() != 'Remote Node'): if (compute_node.getPortalType() == 'Compute Node'):
return # Search the instance node linked to this partition
soft_instance = partition.getAggregateRelatedValue(portal_type='Software Instance')
if soft_instance is None:
return
instance_node = soft_instance.getSpecialiseRelatedValue(portal_type='Instance Node')
if instance_node is None:
return
compute_node = instance_node
elif (compute_node.getPortalType() != 'Remote Node'):
return
person = context.getDestinationSectionValue() person = context.getDestinationSectionValue()
if person is None: if person is None:
......
...@@ -23,6 +23,10 @@ from erp5.component.test.testSlapOSPDMSkins import TestSlapOSPDMMixinSkins ...@@ -23,6 +23,10 @@ from erp5.component.test.testSlapOSPDMSkins import TestSlapOSPDMMixinSkins
class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
def afterSetUp(self):
self.portal.testromain()
TestSlapOSPDMMixinSkins.afterSetUp(self)
def test_createUpgradeDecision_destroyed_instance(self): def test_createUpgradeDecision_destroyed_instance(self):
instance_tree = self.portal.instance_tree_module.newContent( instance_tree = self.portal.instance_tree_module.newContent(
portal_type="Instance Tree" portal_type="Instance Tree"
...@@ -81,9 +85,23 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -81,9 +85,23 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
instance_tree = self.portal.REQUEST.get('request_instance_tree') instance_tree = self.portal.REQUEST.get('request_instance_tree')
if is_allocated: if is_allocated:
if node == "instance": if (node == "instance") and (shared):
real_compute_node = self.portal.compute_node_module.newContent(
portal_type="Compute Node",
follow_up_value=project
)
partition = real_compute_node.newContent(portal_type='Compute Partition')
software_instance = self.portal.software_instance_module.newContent(
portal_type="Software Instance",
follow_up_value=project,
aggregate_value=partition
)
compute_node.edit(specialise_value=software_instance)
elif (node == "instance") and (not shared):
raise NotImplementedError('can not allocate on instance node') raise NotImplementedError('can not allocate on instance node')
partition = compute_node.newContent(portal_type='Compute Partition') else:
partition = compute_node.newContent(portal_type='Compute Partition')
instance = instance_tree.getSuccessorValue() instance = instance_tree.getSuccessorValue()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
...@@ -387,3 +405,31 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -387,3 +405,31 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision()) self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
##########################################################################
# Shared allocated on Instance Node
##########################################################################
def test_createUpgradeDecision_slaveAllocatedOnInstanceNode_newReleaseOnInstanceNode(self):
software_product, _, type_variation, compute_node, instance_tree = self.bootstrapAllocableInstanceTree(is_allocated=True, shared=True, node="instance")
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_slaveAllocatedOnInstanceNode_newReleaseOnAnotherInstanceNode(self):
software_product, _, type_variation, _, instance_tree = self.bootstrapAllocableInstanceTree(is_allocated=True, shared=True, node="instance")
project = instance_tree.getFollowUpValue()
instance_node2 = self.portal.compute_node_module.newContent(
portal_type="Instance Node",
follow_up_value=project
)
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node", instance_node2, software_product,
new_release_variation, type_variation)
self.tic()
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
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