Commit ab54c13a authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: allow to force upgrade to a specific release

parent fc74fe8b
......@@ -6,6 +6,13 @@ instance_tree = context
if instance_tree.getSlapState() == "destroy_requested":
return
if (target_software_release is not None) or (target_software_type is not None):
# Those parameters will be use to force an upgrade decision
# to a specific release / type
# used by Remote Node for example
assert target_software_release is not None
assert target_software_type is not None
if portal.portal_catalog.getResultValue(
portal_type='Upgrade Decision',
aggregate__uid=instance_tree.getUid(),
......@@ -59,8 +66,8 @@ if person is None:
# XXX search only for the main node
allocation_cell_list = software_product.getFollowUpValue().Project_getSoftwareProductPredicateList(
software_product=software_product,
software_product_type=software_type,
#software_product_release=software_release,
software_product_type=target_software_type or software_type,
software_product_release=target_software_release,
destination_value=person,
node_value=compute_node,
predicate_portal_type='Allocation Supply Cell'
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>target_software_release=None, target_software_type=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -311,6 +311,39 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(SlapOSTestCaseMixin):
instance_tree, software_product, new_release_variation, type_variation
)
def test_createUpgradeDecision_allocatedOnComputeNode_newReleaseOnComputeNodeAndCorrectTarget(self):
software_product, _, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.tic()
self.checkCreatedUpgradeDecision(
instance_tree.InstanceTree_createUpgradeDecision(
target_software_release=new_release_variation,
target_software_type=type_variation
),
instance_tree, software_product, new_release_variation, type_variation
)
def test_createUpgradeDecision_allocatedOnComputeNode_newReleaseOnComputeNodeAndIncorrectTarget(self):
software_product, _, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
new_release_variation = self._makeSoftwareRelease(software_product)
incorrect_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.tic()
self.assertEqual(
None,
instance_tree.InstanceTree_createUpgradeDecision(
target_software_release=incorrect_release_variation,
target_software_type=type_variation
)
)
def test_createUpgradeDecision_allocatedOnComputeNode_twoRelease(self):
software_product, release_variation, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
self.tic()
......@@ -325,6 +358,47 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(SlapOSTestCaseMixin):
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
def test_createUpgradeDecision_allocatedOnComputeNode_twoReleaseAndCorrectTarget(self):
software_product, release_variation, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
self.tic()
self.addAllocationSupply(
"for compute node", compute_node, software_product,
release_variation, type_variation, disable_alarm=True)
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node 2", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.tic()
self.checkCreatedUpgradeDecision(
instance_tree.InstanceTree_createUpgradeDecision(
target_software_release=new_release_variation,
target_software_type=type_variation
),
instance_tree, software_product, new_release_variation, type_variation
)
def test_createUpgradeDecision_allocatedOnComputeNode_twoReleaseAndIncorrectTarget(self):
software_product, release_variation, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree(allocation_state='allocated')
self.tic()
self.addAllocationSupply(
"for compute node", compute_node, software_product,
release_variation, type_variation, disable_alarm=True)
new_release_variation = self._makeSoftwareRelease(software_product)
incorrect_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node 2", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.tic()
self.assertEqual(
instance_tree.InstanceTree_createUpgradeDecision(
target_software_release=incorrect_release_variation,
target_software_type=type_variation
),
None
)
##########################################################################
# Shared allocated on Compute Node
##########################################################################
......
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