Commit 0f7c72df authored by Rafael Monnerat's avatar Rafael Monnerat

Reduce allocation scope usage

See merge request !486
parents 06a27d31 8955cfe7
Pipeline #26466 failed with stage
in 0 seconds
...@@ -1276,6 +1276,7 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin): ...@@ -1276,6 +1276,7 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
open_order = self.createOpenOrder() open_order = self.createOpenOrder()
open_order.OpenSaleOrder_updatePeriod() open_order.OpenSaleOrder_updatePeriod()
@simulateByEditWorkflowMark('Person_storeOpenSaleOrderJournal')
def test_updatePeriod_validated(self): def test_updatePeriod_validated(self):
open_order = self.createOpenOrder() open_order = self.createOpenOrder()
person = self.portal.person_module.template_member\ person = self.portal.person_module.template_member\
...@@ -1284,14 +1285,12 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin): ...@@ -1284,14 +1285,12 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
destination_decision_value=person, destination_decision_value=person,
) )
script_name = "Person_storeOpenSaleOrderJournal" open_order.OpenSaleOrder_updatePeriod()
self._simulateScript(script_name) self.assertEqual(
try: 'Visited by Person_storeOpenSaleOrderJournal',
open_order.OpenSaleOrder_updatePeriod() person.workflow_history['edit_workflow'][-1]['comment'])
finally:
self._dropScript(script_name)
self.assertScriptVisited(person, script_name)
@simulateByEditWorkflowMark('Person_storeOpenSaleOrderJournal')
def test_updatePeriod_invalidated(self): def test_updatePeriod_invalidated(self):
open_order = self.createOpenOrder() open_order = self.createOpenOrder()
person = self.portal.person_module.template_member\ person = self.portal.person_module.template_member\
...@@ -1300,14 +1299,11 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin): ...@@ -1300,14 +1299,11 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
destination_decision_value=person, destination_decision_value=person,
) )
open_order.invalidate() open_order.invalidate()
open_order.OpenSaleOrder_updatePeriod()
script_name = "Person_storeOpenSaleOrderJournal" self.assertNotEqual(
self._simulateScript(script_name) 'Visited by Person_storeOpenSaleOrderJournal',
try: person.workflow_history['edit_workflow'][-1]['comment'])
open_order.OpenSaleOrder_updatePeriod()
finally:
self._dropScript(script_name)
self.assertScriptNotVisited(person, script_name)
def test_alarm(self): def test_alarm(self):
open_order = self.createOpenOrder() open_order = self.createOpenOrder()
...@@ -1351,39 +1347,46 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin): ...@@ -1351,39 +1347,46 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
) )
return open_order return open_order
def _simulateScript(self, script_name, fake_return="False"):
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'uid=None,*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
document = context.portal_catalog.getResultValue(uid=uid)
portal_workflow.doActionFor(document, action='edit_action', comment='Visited by %s') """ % script_name )
transaction.commit()
def test_alarm(self): def test_alarm(self):
open_order = self.createOpenOrder() open_order = self.createOpenOrder()
self.tic() self.tic()
# Jut wait a bit so the line has a different timestamp > 1 sec. # Jut wait a bit so the line has a different timestamp > 1 sec.
time.sleep(1) time.sleep(1)
open_order.newContent(portal_type="Open Sale Order Line") open_order_line = open_order.newContent(portal_type="Open Sale Order Line")
self.tic() self.tic()
script_name = "OpenSaleOrder_reindexIfIndexedBeforeLine"
alarm = self.portal.portal_alarms.slapos_reindex_open_sale_order order = self.portal.portal_catalog(
uid=open_order.getUid(),
self._test_alarm( select_dict={'indexation_timestamp': None})[0]
alarm, open_order, script_name)
line = self.portal.portal_catalog(
uid=open_order_line.getUid(),
select_dict={'indexation_timestamp': None})[0]
self.assertTrue(order.indexation_timestamp < line.indexation_timestamp)
self.portal.portal_alarms.slapos_reindex_open_sale_order.activeSense()
self.tic()
order = self.portal.portal_catalog(
uid=open_order.getUid(),
select_dict={'indexation_timestamp': None})[0]
line = self.portal.portal_catalog(
uid=open_order_line.getUid(),
select_dict={'indexation_timestamp': None})[0]
self.assertTrue(order.indexation_timestamp > line.indexation_timestamp,
"%s %s" % (order.indexation_timestamp, line.indexation_timestamp))
def test_alarm_no_line(self): def test_alarm_no_line(self):
open_order = self.createOpenOrder() open_order = self.createOpenOrder()
self.tic() self.tic()
script_name = "OpenSaleOrder_reindexIfIndexedBeforeLine" # Rather them test the alarm with fake script, directly
alarm = self.portal.portal_alarms.slapos_reindex_open_sale_order # test the ERP5Site_zGetOpenOrderWithModifiedLineUid code.
open_order_with_modified_line_uid_list = [i.uid for i in \
self._test_alarm_not_visited( self.portal.ERP5Site_zGetOpenOrderWithModifiedLineUid()]
alarm, open_order, script_name)
self.assertNotIn(open_order.getUid(), open_order_with_modified_line_uid_list)
class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin): class TestSlapOSGeneratePackingListFromTioXML(SlapOSTestCaseMixin):
......
...@@ -147,6 +147,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -147,6 +147,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server.edit( server.edit(
allocation_scope='open/public') allocation_scope='open/public')
self.assertEqual('open/public', server.getAllocationScope()) self.assertEqual('open/public', server.getAllocationScope())
# Called by alarm
server.ComputeNode_checkAndUpdateCapacityScope()
self.assertEqual('open', server.getCapacityScope()) self.assertEqual('open', server.getCapacityScope())
self.tic() self.tic()
...@@ -155,6 +157,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -155,6 +157,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server.edit( server.edit(
allocation_scope='open/subscription') allocation_scope='open/subscription')
self.assertEqual('open/subscription', server.getAllocationScope()) self.assertEqual('open/subscription', server.getAllocationScope())
# Called by alarm
server.ComputeNode_checkAndUpdateCapacityScope()
self.assertEqual('open', server.getCapacityScope()) self.assertEqual('open', server.getCapacityScope())
self.tic() self.tic()
...@@ -163,6 +167,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -163,6 +167,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server.edit( server.edit(
allocation_scope='open/personal', subject_list=[]) allocation_scope='open/personal', subject_list=[])
self.assertEqual('open/personal', server.getAllocationScope()) self.assertEqual('open/personal', server.getAllocationScope())
# Called by alarm
server.ComputeNode_checkAndUpdateCapacityScope()
self.assertEqual('open', server.getCapacityScope()) self.assertEqual('open', server.getCapacityScope())
self.tic() self.tic()
...@@ -173,6 +179,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -173,6 +179,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server.edit( server.edit(
allocation_scope='open/friend', subject_list=friend_list) allocation_scope='open/friend', subject_list=friend_list)
self.assertEqual('open/friend', server.getAllocationScope()) self.assertEqual('open/friend', server.getAllocationScope())
# Called by alarm
server.ComputeNode_checkAndUpdateCapacityScope()
self.assertEqual('open', server.getCapacityScope()) self.assertEqual('open', server.getCapacityScope())
self.assertSameSet(friend_list, server.getSubjectList()) self.assertSameSet(friend_list, server.getSubjectList())
self.tic() self.tic()
......
...@@ -78,6 +78,40 @@ def withAbort(func): ...@@ -78,6 +78,40 @@ def withAbort(func):
self.abort() self.abort()
return wrapped return wrapped
class TemporaryAlarmScript(object):
"""
Context manager for temporary python scripts
"""
def __init__(self, portal, script_name, fake_return="", attribute=None):
self.script_name = script_name
self.portal = portal
self.fake_return = fake_return
self.attribute = attribute
def __enter__(self):
if self.script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % self.script_name)
if self.attribute is None:
content = """portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by %s')
return %s""" % (self.script_name, self.fake_return)
else:
content = """portal_workflow = context.portal_workflow
context.edit(%s='Visited by %s')
return %s""" % (self.attribute, self.script_name, self.fake_return)
createZODBPythonScript(self.portal.portal_skins.custom,
self.script_name,
'*args, **kwargs',
'# Script body\n' + content)
transaction.commit()
def __exit__(self, exc_type, exc_value, traceback):
if self.script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(self.script_name)
transaction.commit()
class SlapOSTestCaseMixin(testSlapOSMixin): class SlapOSTestCaseMixin(testSlapOSMixin):
expected_html_payzen_redirect_page = None expected_html_payzen_redirect_page = None
...@@ -620,53 +654,31 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -620,53 +654,31 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
resource='foo/bar', resource='foo/bar',
) )
# Set of methods to help test alarms and to see if the script was called def _test_alarm(self, alarm, document, script_name, attribute=None):
def _simulateScript(self, script_name, fake_return=""):
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by %s')
return %s""" % (script_name, fake_return ))
transaction.commit()
def _dropScript(self, script_name):
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def assertScriptVisited(self, document, script_name):
self.assertEqual(
'Visited by %s' % script_name,
document.workflow_history['edit_workflow'][-1]['comment'])
def assertScriptNotVisited(self, document, script_name):
self.assertNotEqual(
'Visited by %s' % script_name,
document.workflow_history['edit_workflow'][-1]['comment'])
def _test_alarm(self, alarm, document, script_name):
self.tic() self.tic()
self._simulateScript(script_name) with TemporaryAlarmScript(self.portal, script_name, attribute=attribute):
try:
alarm.activeSense() alarm.activeSense()
self.tic() self.tic()
finally: if attribute is None:
self._dropScript(script_name) content = document.workflow_history['edit_workflow'][-1]['comment']
self.assertScriptVisited(document, script_name) else:
content = document.getProperty(attribute)
self.assertEqual(
'Visited by %s' % script_name,
content)
def _test_alarm_not_visited(self, alarm, document, script_name): def _test_alarm_not_visited(self, alarm, document, script_name, attribute=None):
self.tic() self.tic()
self._simulateScript(script_name) with TemporaryAlarmScript(self.portal, script_name, attribute=attribute):
try:
alarm.activeSense() alarm.activeSense()
self.tic() self.tic()
finally: if attribute is None:
self._dropScript(script_name) content = document.workflow_history['edit_workflow'][-1]['comment']
self.assertScriptNotVisited(document, script_name) else:
content = document.getProperty(attribute)
self.assertNotEqual(
'Visited by %s' % script_name,
content)
def restoreAccountingTemplatesOnPreferences(self): def restoreAccountingTemplatesOnPreferences(self):
self.login() self.login()
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript
import time import time
from zExceptions import Unauthorized from zExceptions import Unauthorized
from DateTime import DateTime from DateTime import DateTime
...@@ -67,47 +66,21 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -67,47 +66,21 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self.assertFalse(self.instance_tree.getTitle() in self.assertFalse(self.instance_tree.getTitle() in
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
def _simulateInstanceTree_assertSuccessor(self):
script_name = 'InstanceTree_assertSuccessor'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by InstanceTree_assertSuccessor') """ )
transaction.commit()
def _dropInstanceTree_assertSuccessor(self):
script_name = 'InstanceTree_assertSuccessor'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_renamed(self): def test_alarm_renamed(self):
self.software_instance.edit(title=self.generateNewSoftwareTitle()) self.software_instance.edit(title=self.generateNewSoftwareTitle())
self.tic() self._test_alarm(
self._simulateInstanceTree_assertSuccessor() self.portal.portal_alarms.slapos_assert_instance_tree_successor,
try: self.instance_tree,
self.portal.portal_alarms.slapos_assert_instance_tree_successor.activeSense() 'InstanceTree_assertSuccessor'
self.tic() )
finally:
self._dropInstanceTree_assertSuccessor()
self.assertEqual(
'Visited by InstanceTree_assertSuccessor',
self.instance_tree.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_renamed(self): def test_alarm_not_renamed(self):
self._simulateInstanceTree_assertSuccessor() self._test_alarm_not_visited(
try: self.portal.portal_alarms.slapos_assert_instance_tree_successor,
self.portal.portal_alarms.slapos_assert_instance_tree_successor.activeSense() self.instance_tree,
self.tic() 'InstanceTree_assertSuccessor'
finally: )
self._dropInstanceTree_assertSuccessor()
self.assertNotEqual(
'Visited by InstanceTree_assertSuccessor',
self.instance_tree.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
...@@ -170,16 +143,12 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -170,16 +143,12 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested') 'destroy_requested')
self.software_instance.invalidate() self.software_instance.invalidate()
self.tic()
self._simulateScript('SoftwareInstance_tryToUnallocatePartition') self._test_alarm(
try: self.portal.portal_alarms.slapos_free_compute_partition,
self.portal.portal_alarms.slapos_free_compute_partition.activeSense() self.software_instance,
self.tic() 'SoftwareInstance_tryToUnallocatePartition'
finally: )
self._dropScript('SoftwareInstance_tryToUnallocatePartition')
self.assertEqual(
'Visited by SoftwareInstance_tryToUnallocatePartition',
self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_unallocated(self): def test_alarm_unallocated(self):
self._makeComputeNode() self._makeComputeNode()
...@@ -187,16 +156,12 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -187,16 +156,12 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested') 'destroy_requested')
self.software_instance.invalidate() self.software_instance.invalidate()
self.tic()
self._simulateScript('SoftwareInstance_tryToUnallocatePartition') self._test_alarm_not_visited(
try: self.portal.portal_alarms.slapos_free_compute_partition,
self.portal.portal_alarms.slapos_free_compute_partition.activeSense() self.software_instance,
self.tic() 'SoftwareInstance_tryToUnallocatePartition'
finally: )
self._dropScript('SoftwareInstance_tryToUnallocatePartition')
self.assertNotEqual(
'Visited by SoftwareInstance_tryToUnallocatePartition',
self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_validated(self): def test_alarm_validated(self):
self._makeComputeNode() self._makeComputeNode()
...@@ -204,31 +169,23 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin): ...@@ -204,31 +169,23 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
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')
self.tic()
self._simulateScript('SoftwareInstance_tryToUnallocatePartition') self._test_alarm_not_visited(
try: self.portal.portal_alarms.slapos_free_compute_partition,
self.portal.portal_alarms.slapos_free_compute_partition.activeSense() self.software_instance,
self.tic() 'SoftwareInstance_tryToUnallocatePartition'
finally: )
self._dropScript('SoftwareInstance_tryToUnallocatePartition')
self.assertNotEqual(
'Visited by SoftwareInstance_tryToUnallocatePartition',
self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_start_requested(self): def test_alarm_start_requested(self):
self._makeComputeNode() self._makeComputeNode()
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy() self.partition.markBusy()
self.tic()
self._simulateScript('SoftwareInstance_tryToUnallocatePartition') self._test_alarm_not_visited(
try: self.portal.portal_alarms.slapos_free_compute_partition,
self.portal.portal_alarms.slapos_free_compute_partition.activeSense() self.software_instance,
self.tic() 'SoftwareInstance_tryToUnallocatePartition'
finally: )
self._dropScript('SoftwareInstance_tryToUnallocatePartition')
self.assertNotEqual(
'Visited by SoftwareInstance_tryToUnallocatePartition',
self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSFreeComputePartitionAlarmWithSlave(SlapOSTestCaseMixin): class TestSlapOSFreeComputePartitionAlarmWithSlave(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
...@@ -372,62 +329,30 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -372,62 +329,30 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
self.assertEqual(sub_instance.getSlapState(), 'destroy_requested') self.assertEqual(sub_instance.getSlapState(), 'destroy_requested')
self.assertEqual(sub_instance.getValidationState(), 'validated') self.assertEqual(sub_instance.getValidationState(), 'validated')
def _simulateSoftwareInstance_tryToGarbageCollect(self):
script_name = 'SoftwareInstance_tryToGarbageCollect'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by SoftwareInstance_tryToGarbageCollect') """ )
transaction.commit()
def _dropSoftwareInstance_tryToGarbageCollect(self):
script_name = 'SoftwareInstance_tryToGarbageCollect'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm(self): def test_alarm(self):
self.instance_tree.archive() self.instance_tree.archive()
self.tic() self._test_alarm(
self._simulateScript('SoftwareInstance_tryToGarbageCollect') self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
try: self.software_instance,
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree.activeSense() 'SoftwareInstance_tryToGarbageCollect'
self.tic() )
finally:
self._dropScript('SoftwareInstance_tryToGarbageCollect')
self.assertEqual(
'Visited by SoftwareInstance_tryToGarbageCollect',
self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_invalidated(self): def test_alarm_invalidated(self):
self.instance_tree.archive() self.instance_tree.archive()
self.software_instance.invalidate() self.software_instance.invalidate()
self.tic() self._test_alarm_not_visited(
self._simulateScript('SoftwareInstance_tryToGarbageCollect') self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
try: self.software_instance,
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree.activeSense() 'SoftwareInstance_tryToGarbageCollect'
self.tic() )
finally:
self._dropScript('SoftwareInstance_tryToGarbageCollect')
self.assertNotEqual(
'Visited by SoftwareInstance_tryToGarbageCollect',
self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_not_archived(self): def test_alarm_not_archived(self):
self.tic() self._test_alarm_not_visited(
self._simulateScript('SoftwareInstance_tryToGarbageCollect') self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree,
try: self.software_instance,
self.portal.portal_alarms.slapos_garbage_collect_destroyed_root_tree.activeSense() 'SoftwareInstance_tryToGarbageCollect'
self.tic() )
finally:
self._dropScript('SoftwareInstance_tryToGarbageCollect')
self.assertNotEqual(
'Visited by SoftwareInstance_tryToGarbageCollect',
self.software_instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin): class TestSlapOSComputeNode_checkAndUpdateCapacityScope(SlapOSTestCaseMixin):
allocation_scope_to_test = 'open/public' allocation_scope_to_test = 'open/public'
...@@ -573,35 +498,12 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin): ...@@ -573,35 +498,12 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
self.compute_node.setAccessStatus("#access ok") self.compute_node.setAccessStatus("#access ok")
transaction.commit() transaction.commit()
def _simulateComputeNode_checkAndUpdateCapacityScope(self):
script_name = 'ComputeNode_checkAndUpdateCapacityScope'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by ComputeNode_checkAndUpdateCapacityScope') """ )
transaction.commit()
def _dropComputeNode_checkAndUpdateCapacityScope(self):
script_name = 'ComputeNode_checkAndUpdateCapacityScope'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm(self): def test_alarm(self):
self.tic() self._test_alarm(
self._simulateComputeNode_checkAndUpdateCapacityScope() self.portal.portal_alarms.slapos_update_compute_node_capacity_scope,
try: self.compute_node,
self.portal.portal_alarms.slapos_update_compute_node_capacity_scope.activeSense() 'ComputeNode_checkAndUpdateCapacityScope'
self.tic() )
finally:
self._dropComputeNode_checkAndUpdateCapacityScope()
self.assertEqual(
'Visited by ComputeNode_checkAndUpdateCapacityScope',
self.compute_node.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_subscription(self): def test_alarm_subscription(self):
self.compute_node.edit(allocation_scope='open/subscription') self.compute_node.edit(allocation_scope='open/subscription')
...@@ -615,31 +517,21 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C ...@@ -615,31 +517,21 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self.compute_node.edit(allocation_scope='open/friend') self.compute_node.edit(allocation_scope='open/friend')
self.test_alarm() self.test_alarm()
def test_alarm_closed(self): def test_alarm_non_public(self):
self.compute_node.edit(allocation_scope='close/outdated') self.compute_node.edit(allocation_scope='close')
self.tic() self._test_alarm_not_visited(
self._simulateComputeNode_checkAndUpdateCapacityScope() self.portal.portal_alarms.slapos_update_compute_node_capacity_scope,
try: self.compute_node,
self.portal.portal_alarms.slapos_update_compute_node_capacity_scope.activeSense() 'ComputeNode_checkAndUpdateCapacityScope'
self.tic() )
finally:
self._dropComputeNode_checkAndUpdateCapacityScope()
self.assertNotEqual(
'Visited by ComputeNode_checkAndUpdateCapacityScope',
self.compute_node.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_invalidated(self): def test_alarm_invalidated(self):
self.compute_node.invalidate() self.compute_node.invalidate()
self.tic() self._test_alarm_not_visited(
self._simulateComputeNode_checkAndUpdateCapacityScope() self.portal.portal_alarms.slapos_update_compute_node_capacity_scope,
try: self.compute_node,
self.portal.portal_alarms.slapos_update_compute_node_capacity_scope.activeSense() 'ComputeNode_checkAndUpdateCapacityScope'
self.tic() )
finally:
self._dropComputeNode_checkAndUpdateCapacityScope()
self.assertNotEqual(
'Visited by ComputeNode_checkAndUpdateCapacityScope',
self.compute_node.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
...@@ -711,29 +603,20 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -711,29 +603,20 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
def test_alarm(self): def test_alarm(self):
instance = self.createInstance() instance = self.createInstance()
self._simulateScript('SoftwareInstance_tryToStopCollect') self._test_alarm(
try: self.portal.portal_alarms.slapos_stop_collect_instance,
self.portal.portal_alarms.slapos_stop_collect_instance.activeSense() instance,
self.tic() 'SoftwareInstance_tryToStopCollect'
finally: )
self._dropScript('SoftwareInstance_tryToStopCollect')
self.assertEqual(
'Visited by SoftwareInstance_tryToStopCollect',
instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_invalidated(self): def test_alarm_invalidated(self):
instance = self.createInstance() instance = self.createInstance()
instance.invalidate() instance.invalidate()
self.tic() self._test_alarm_not_visited(
self._simulateScript('SoftwareInstance_tryToStopCollect') self.portal.portal_alarms.slapos_stop_collect_instance,
try: instance,
self.portal.portal_alarms.slapos_stop_collect_instance.activeSense() 'SoftwareInstance_tryToStopCollect'
self.tic() )
finally:
self._dropScript('SoftwareInstance_tryToStopCollect')
self.assertNotEqual(
'Visited by SoftwareInstance_tryToStopCollect',
instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
...@@ -946,45 +829,31 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin): ...@@ -946,45 +829,31 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
def test_alarm(self): def test_alarm(self):
instance = self.createInstance() instance = self.createInstance()
self.tic() self._test_alarm(
self._simulateScript("SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree") self.portal.portal_alarms.slapos_garbage_collect_non_allocated_root_tree,
try: instance,
self.portal.portal_alarms.slapos_garbage_collect_non_allocated_root_tree.activeSense() 'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
self.tic() )
finally:
self._dropScript('SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree')
self.assertEqual(
'Visited by SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree',
instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_invalidated(self): def test_alarm_invalidated(self):
instance = self.createInstance() instance = self.createInstance()
instance.invalidate() instance.invalidate()
self.tic() self._test_alarm_not_visited(
self._simulateScript("SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree") self.portal.portal_alarms.slapos_garbage_collect_non_allocated_root_tree,
try: instance,
self.portal.portal_alarms.slapos_garbage_collect_non_allocated_root_tree.activeSense() 'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
self.tic() )
finally:
self._dropScript('SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree')
self.assertNotEqual(
'Visited by SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree',
instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_allocated(self): def test_alarm_allocated(self):
instance = self.createInstance() instance = self.createInstance()
partition = self.createComputePartition() partition = self.createComputePartition()
instance.edit(aggregate_value=partition) instance.edit(aggregate_value=partition)
self.tic() self._test_alarm_not_visited(
self._simulateScript("SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree") self.portal.portal_alarms.slapos_garbage_collect_non_allocated_root_tree,
try: instance,
self.portal.portal_alarms.slapos_garbage_collect_non_allocated_root_tree.activeSense() 'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
self.tic() )
finally:
self._dropScript('SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree')
self.assertNotEqual(
'Visited by SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree',
instance.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
...@@ -1043,24 +912,6 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin): ...@@ -1043,24 +912,6 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
sub_instance.getSpecialise()) sub_instance.getSpecialise())
return sub_instance return sub_instance
def _simulateSoftwareInstance_tryToGarbageUnlinkedInstance(self):
script_name = 'SoftwareInstance_tryToGarbageUnlinkedInstance'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by SoftwareInstance_tryToGarbageUnlinkedInstance') """ )
transaction.commit()
def _dropSoftwareInstance_tryToGarbageUnlinkedInstance(self):
script_name = 'SoftwareInstance_tryToGarbageUnlinkedInstance'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_SoftwareInstance_tryToGarbageUnlinkedInstance(self): def test_SoftwareInstance_tryToGarbageUnlinkedInstance(self):
instance = self.createInstance() instance = self.createInstance()
partition = self.createComputePartition() partition = self.createComputePartition()
...@@ -1190,28 +1041,19 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -1190,28 +1041,19 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
instance0 = self.doRequestInstance(instance, 'instance0') instance0 = self.doRequestInstance(instance, 'instance0')
self.assertEqual(instance.getSuccessorReference(), self.assertEqual(instance.getSuccessorReference(),
instance0.getReference()) instance0.getReference())
self._simulateSoftwareInstance_tryToGarbageUnlinkedInstance() self._test_alarm_not_visited(
try: self.portal.portal_alarms.slapos_garbage_collect_destroy_unlinked_instance,
self.portal.portal_alarms.slapos_garbage_collect_destroy_unlinked_instance.activeSense() instance0,
self.tic() 'SoftwareInstance_tryToGarbageUnlinkedInstance'
finally: )
self._dropSoftwareInstance_tryToGarbageUnlinkedInstance()
self.assertNotEqual(
'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance',
instance0.workflow_history['edit_workflow'][-1]['comment'])
# Remove successor link # Remove successor link
instance.edit(successor_list=[]) instance.edit(successor_list=[])
self._simulateSoftwareInstance_tryToGarbageUnlinkedInstance() self._test_alarm(
self.tic() self.portal.portal_alarms.slapos_garbage_collect_destroy_unlinked_instance,
try: instance0,
self.portal.portal_alarms.slapos_garbage_collect_destroy_unlinked_instance.activeSense() 'SoftwareInstance_tryToGarbageUnlinkedInstance'
self.tic() )
finally:
self._dropSoftwareInstance_tryToGarbageUnlinkedInstance()
self.assertEqual(
'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance',
instance0.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_search_inlinked_instance_slave(self): def test_alarm_search_inlinked_instance_slave(self):
instance = self.createInstance() instance = self.createInstance()
...@@ -1220,17 +1062,19 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -1220,17 +1062,19 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.tic() self.tic()
slave_instance0 = self.doRequestInstance(instance, 'slaveInstance0', True) slave_instance0 = self.doRequestInstance(instance, 'slaveInstance0', True)
self.assertEqual(instance.getSuccessorTitle(), 'slaveInstance0') self.assertEqual(instance.getSuccessorTitle(), 'slaveInstance0')
self._simulateSoftwareInstance_tryToGarbageUnlinkedInstance() self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_garbage_collect_destroy_unlinked_instance,
slave_instance0,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
instance.edit(successor_list=[]) instance.edit(successor_list=[])
self.tic() self._test_alarm(
try: self.portal.portal_alarms.slapos_garbage_collect_destroy_unlinked_instance,
self.portal.portal_alarms.slapos_garbage_collect_destroy_unlinked_instance.activeSense() slave_instance0,
self.tic() 'SoftwareInstance_tryToGarbageUnlinkedInstance'
finally: )
self._dropSoftwareInstance_tryToGarbageUnlinkedInstance()
self.assertEqual(
'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance',
slave_instance0.workflow_history['edit_workflow'][-1]['comment'])
class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin): class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
...@@ -1301,24 +1145,6 @@ class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin): ...@@ -1301,24 +1145,6 @@ class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
self.assertEqual(instance.getValidationState(), "validated") self.assertEqual(instance.getValidationState(), "validated")
self.assertEqual(instance.getSlapState(), "destroy_requested") self.assertEqual(instance.getSlapState(), "destroy_requested")
def _simulateSoftwareInstance_tryToInvalidateIfDestroyed(self):
script_name = 'SoftwareInstance_tryToInvalidateIfDestroyed'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by SoftwareInstance_tryToInvalidateIfDestroyed') """ )
transaction.commit()
def _dropSoftwareInstance_tryToInvalidateIfDestroyed(self):
script_name = 'SoftwareInstance_tryToInvalidateIfDestroyed'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_alarm_software_instance_allocated(self): def test_alarm_software_instance_allocated(self):
instance = self.createSoftwareInstance() instance = self.createSoftwareInstance()
partition = self.createComputePartition() partition = self.createComputePartition()
...@@ -1327,16 +1153,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -1327,16 +1153,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.portal.portal_workflow._jumpToStateFor(instance, 'destroy_requested') self.portal.portal_workflow._jumpToStateFor(instance, 'destroy_requested')
self.tic() self.tic()
self._simulateSoftwareInstance_tryToInvalidateIfDestroyed() self._test_alarm_not_visited(
try: self.portal.portal_alarms.slapos_cloud_invalidate_destroyed_instance,
self.portal.portal_alarms.slapos_cloud_invalidate_destroyed_instance.\ instance,
activeSense() 'SoftwareInstance_tryToInvalidateIfDestroyed'
self.tic() )
finally:
self._dropSoftwareInstance_tryToInvalidateIfDestroyed()
self.assertNotEqual(
'Visited by SoftwareInstance_tryToInvalidateIfDestroyed',
instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_software_instance_invalidated(self): def test_alarm_software_instance_invalidated(self):
instance = self.createSoftwareInstance() instance = self.createSoftwareInstance()
...@@ -1345,16 +1166,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -1345,16 +1166,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.portal.portal_workflow._jumpToStateFor(instance, 'destroy_requested') self.portal.portal_workflow._jumpToStateFor(instance, 'destroy_requested')
self.tic() self.tic()
self._simulateSoftwareInstance_tryToInvalidateIfDestroyed() self._test_alarm_not_visited(
try: self.portal.portal_alarms.slapos_cloud_invalidate_destroyed_instance,
self.portal.portal_alarms.slapos_cloud_invalidate_destroyed_instance.\ instance,
activeSense() 'SoftwareInstance_tryToInvalidateIfDestroyed'
self.tic() )
finally:
self._dropSoftwareInstance_tryToInvalidateIfDestroyed()
self.assertNotEqual(
'Visited by SoftwareInstance_tryToInvalidateIfDestroyed',
instance.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_software_instance_matching(self): def test_alarm_software_instance_matching(self):
instance = self.createSoftwareInstance() instance = self.createSoftwareInstance()
...@@ -1363,13 +1179,8 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -1363,13 +1179,8 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self.portal.portal_workflow._jumpToStateFor(instance, 'destroy_requested') self.portal.portal_workflow._jumpToStateFor(instance, 'destroy_requested')
self.tic() self.tic()
self._simulateSoftwareInstance_tryToInvalidateIfDestroyed() self._test_alarm(
try: self.portal.portal_alarms.slapos_cloud_invalidate_destroyed_instance,
self.portal.portal_alarms.slapos_cloud_invalidate_destroyed_instance.\ instance,
activeSense() 'SoftwareInstance_tryToInvalidateIfDestroyed'
self.tic() )
finally:
self._dropSoftwareInstance_tryToInvalidateIfDestroyed()
self.assertEqual(
'Visited by SoftwareInstance_tryToInvalidateIfDestroyed',
instance.workflow_history['edit_workflow'][-1]['comment'])
...@@ -209,6 +209,10 @@ return True""" ) ...@@ -209,6 +209,10 @@ return True""" )
self.software_instance.getUrlString()) self.software_instance.getUrlString())
self.compute_node.edit(allocation_scope='open/personal', self.compute_node.edit(allocation_scope='open/personal',
source_administration=self.person_user.getRelativeUrl()) source_administration=self.person_user.getRelativeUrl())
self.compute_node.setAccessStatus("#access ok")
self.tic()
self.compute_node.ComputeNode_checkAndUpdateCapacityScope()
self.assertEqual(self.compute_node.getCapacityScope(), 'open')
self.tic() self.tic()
self.assertEqual(None, self.software_instance.getAggregateValue( self.assertEqual(None, self.software_instance.getAggregateValue(
...@@ -226,6 +230,10 @@ return True""" ) ...@@ -226,6 +230,10 @@ return True""" )
self.partition) self.partition)
self.compute_node.edit(allocation_scope='open/personal', self.compute_node.edit(allocation_scope='open/personal',
source_administration=self.person_user.getRelativeUrl()) source_administration=self.person_user.getRelativeUrl())
self.compute_node.setAccessStatus("#access ok")
self.tic()
self.compute_node.ComputeNode_checkAndUpdateCapacityScope()
self.assertEqual(self.compute_node.getCapacityScope(), 'open')
self.tic() self.tic()
self.assertEqual(None, self.software_instance.getAggregateValue( self.assertEqual(None, self.software_instance.getAggregateValue(
...@@ -259,6 +267,10 @@ return True""" ) ...@@ -259,6 +267,10 @@ return True""" )
source_administration=person_user.getRelativeUrl(), source_administration=person_user.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl(), destination_section=self.person_user.getRelativeUrl(),
allocation_scope='open/friend') allocation_scope='open/friend')
self.compute_node.setAccessStatus("#access ok")
self.tic()
self.compute_node.ComputeNode_checkAndUpdateCapacityScope()
self.assertEqual(self.compute_node.getCapacityScope(), 'open')
self.tic() self.tic()
self.assertEqual(None, self.software_instance.getAggregateValue( self.assertEqual(None, self.software_instance.getAggregateValue(
...@@ -292,6 +304,10 @@ return True""" ) ...@@ -292,6 +304,10 @@ return True""" )
source_administration=person_user.getRelativeUrl(), source_administration=person_user.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl(), destination_section=self.person_user.getRelativeUrl(),
allocation_scope='open/friend') allocation_scope='open/friend')
self.compute_node.setAccessStatus("#access ok")
self.tic()
self.compute_node.ComputeNode_checkAndUpdateCapacityScope()
self.assertEqual(self.compute_node.getCapacityScope(), 'open')
self.tic() self.tic()
self.assertEqual(None, self.software_instance.getAggregateValue( self.assertEqual(None, self.software_instance.getAggregateValue(
......
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudAllocationAlarm</string> </value> <value> <string>testSlapOSCloudAllocationAlarm</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -641,7 +641,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin): ...@@ -641,7 +641,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference()) self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference())
self.assertEqual('validated', compute_node.getValidationState()) self.assertEqual('validated', compute_node.getValidationState())
self.assertEqual('open/personal', compute_node.getAllocationScope()) self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual('open', compute_node.getCapacityScope()) self.assertEqual('close', compute_node.getCapacityScope())
def test_request_notReindexedCompute(self): def test_request_notReindexedCompute(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue() person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
...@@ -682,7 +682,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin): ...@@ -682,7 +682,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference()) self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference())
self.assertEqual('validated', compute_node.getValidationState()) self.assertEqual('validated', compute_node.getValidationState())
self.assertEqual('open/personal', compute_node.getAllocationScope()) self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual('open', compute_node.getCapacityScope()) self.assertEqual('close', compute_node.getCapacityScope())
self.tic() self.tic()
...@@ -708,7 +708,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin): ...@@ -708,7 +708,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference()) self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference())
self.assertEqual('validated', compute_node.getValidationState()) self.assertEqual('validated', compute_node.getValidationState())
self.assertEqual('open/personal', compute_node.getAllocationScope()) self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual('open', compute_node.getCapacityScope()) self.assertEqual('close', compute_node.getCapacityScope())
# and now another one # and now another one
person.requestComputeNode(compute_node_title=compute_node_title2) person.requestComputeNode(compute_node_title=compute_node_title2)
...@@ -735,7 +735,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin): ...@@ -735,7 +735,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
self.assertEqual('COMP-%s' % (previous_id + 2), compute_node2.getReference()) self.assertEqual('COMP-%s' % (previous_id + 2), compute_node2.getReference())
self.assertEqual('validated', compute_node2.getValidationState()) self.assertEqual('validated', compute_node2.getValidationState())
self.assertEqual('open/personal', compute_node2.getAllocationScope()) self.assertEqual('open/personal', compute_node2.getAllocationScope())
self.assertEqual('open', compute_node2.getCapacityScope()) self.assertEqual('close', compute_node2.getCapacityScope())
def test_request_duplicatedComputeNode(self): def test_request_duplicatedComputeNode(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue() person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
......
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudPersonSlapInterfaceWorkflow</string> </value> <value> <string>testSlapOSCloudPersonSlapInterfaceWorkflow</string> </value>
...@@ -61,28 +55,13 @@ ...@@ -61,28 +55,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -95,7 +74,7 @@ ...@@ -95,7 +74,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -104,7 +83,7 @@ ...@@ -104,7 +83,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -7,10 +7,6 @@ if not person or \ ...@@ -7,10 +7,6 @@ if not person or \
portal.ERP5Site_isSupportRequestCreationClosed(): portal.ERP5Site_isSupportRequestCreationClosed():
return return
if context.getAllocationScope("open").startswith("close"):
context.setMonitorScope("disabled")
return
reference = context.getReference() reference = context.getReference()
compute_node_title = context.getTitle() compute_node_title = context.getTitle()
......
#
# XXX This ticket contains dupplicated coded found arround SlapOS
# It is required to rewrite this in a generic way.
# See also: InstanceTree_checkSoftwareInstanceState
# See also: ComputeNode_checkState
#
from DateTime import DateTime from DateTime import DateTime
if context.getSimulationState() == "invalidated": if context.getSimulationState() == "invalidated":
...@@ -103,17 +96,11 @@ if aggregate_portal_type == "Instance Tree": ...@@ -103,17 +96,11 @@ if aggregate_portal_type == "Instance Tree":
if instance.getAggregate() is not None: if instance.getAggregate() is not None:
compute_node = instance.getAggregateValue().getParentValue() compute_node = instance.getAggregateValue().getParentValue()
if instance.getPortalType() == "Software Instance" and \ if instance.getPortalType() == "Software Instance" and \
compute_node.getAllocationScope() in ["open/public", "open/friend", "open/subscription"] and \
instance.getSlapState() == "start_requested" and \ instance.getSlapState() == "start_requested" and \
instance.SoftwareInstance_hasReportedError(): instance.SoftwareInstance_hasReportedError():
message_list.append("%s has error (%s, %s at %s scope %s)" % (instance.getReference(), instance.getTitle(), message_list.append("%s has error (%s, %s at %s scope %s)" % (instance.getReference(), instance.getTitle(),
instance.getUrlString(), compute_node.getReference(), instance.getUrlString(), compute_node.getReference(),
compute_node.getAllocationScope())) compute_node.getAllocationScope()))
if instance.getPortalType() == "Software Instance" and \
compute_node.getAllocationScope() in ["closed/outdated", "open/personal"] and \
instance.getSlapState() == "start_requested" and \
instance.SoftwareInstance_hasReportedError():
message_list.append("%s on a %s compute_node" % (instance.getReference(), compute_node.getAllocationScope()) )
else: else:
message_list.append("%s is not allocated" % instance.getReference()) message_list.append("%s is not allocated" % instance.getReference())
return ",".join(message_list) return ",".join(message_list)
......
...@@ -502,6 +502,19 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort) ...@@ -502,6 +502,19 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
slapos_crm_check_compute_node_state slapos_crm_check_compute_node_state
self._test_alarm(alarm, self.compute_node, "ComputeNode_checkState") self._test_alarm(alarm, self.compute_node, "ComputeNode_checkState")
def _test_alarm_check_compute_node_state_selected(self, allocation_scope,
monitor_scope=None):
self._makeComputeNode()
self.compute_node.edit(allocation_scope=allocation_scope)
self.tic()
if monitor_scope is not None:
self.compute_node.edit(monitor_scope=monitor_scope)
self.tic()
alarm = self.portal.portal_alarms.\
slapos_crm_check_compute_node_state
self._test_alarm(alarm, self.compute_node, "ComputeNode_checkState")
def _test_alarm_check_compute_node_state_not_selected(self, allocation_scope, def _test_alarm_check_compute_node_state_not_selected(self, allocation_scope,
monitor_scope=None): monitor_scope=None):
self._makeComputeNode() self._makeComputeNode()
...@@ -532,15 +545,15 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort) ...@@ -532,15 +545,15 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
def test_alarm_check_compute_node_state_closed_forever_compute_node(self): def test_alarm_check_compute_node_state_closed_forever_compute_node(self):
self._test_alarm_check_compute_node_state_not_selected( self._test_alarm_check_compute_node_state_not_selected(
allocation_scope='closed/forever') allocation_scope='close/forever')
def test_alarm_check_compute_node_state_closed_mantainence_compute_node(self): def test_alarm_check_compute_node_state_closed_mantainence_compute_node(self):
self._test_alarm_check_compute_node_state_not_selected( self._test_alarm_check_compute_node_state_selected(
allocation_scope='closed/maintenance') allocation_scope='close/maintenance')
def test_alarm_check_compute_node_state_closed_termination_compute_node(self): def test_alarm_check_compute_node_state_closed_termination_compute_node(self):
self._test_alarm_check_compute_node_state_not_selected( self._test_alarm_check_compute_node_state_selected(
allocation_scope='closed/termination') allocation_scope='close/termination')
class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCaseMixinWithAbort): class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCaseMixinWithAbort):
...@@ -601,25 +614,48 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase ...@@ -601,25 +614,48 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
slapos_crm_check_software_installation_state slapos_crm_check_software_installation_state
self._test_alarm_not_visited(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState") self._test_alarm_not_visited(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState")
def _test_alarm_not_run_on_close(self, allocation_scope): def _test_alarm_not_run_on_close(self, allocation_scope, monitor_scope=None):
self._makeComputeNode() self._makeComputeNode()
self.compute_node.edit(allocation_scope=allocation_scope) self.compute_node.edit(allocation_scope=allocation_scope)
self.tic() self.tic()
if monitor_scope is not None:
self.compute_node.edit(monitor_scope=monitor_scope)
self.tic()
alarm = self.portal.portal_alarms.\ alarm = self.portal.portal_alarms.\
slapos_crm_check_software_installation_state slapos_crm_check_software_installation_state
self._test_alarm_not_visited(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState") self._test_alarm_not_visited(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState")
def _test_alarm_run_on_close(self, allocation_scope,):
self._makeComputeNode()
self.compute_node.edit(allocation_scope=allocation_scope)
self.tic()
alarm = self.portal.portal_alarms.\
slapos_crm_check_software_installation_state
self._test_alarm(alarm, self.compute_node, "ComputeNode_checkSoftwareInstallationState")
def test_alarm_not_run_on_close_forever(self): def test_alarm_not_run_on_close_forever(self):
self._test_alarm_not_run_on_close('close/forever') self._test_alarm_not_run_on_close('close/forever')
def test_alarm_not_run_on_close_maintainence(self): def test_alarm_not_run_on_close_maintainence(self):
self._test_alarm_not_run_on_close('close/maintenence') self._test_alarm_not_run_on_close('close/maintenence', monitor_scope="disabled")
def test_alarm_not_run_on_close_outdated(self): def test_alarm_not_run_on_close_outdated(self):
self._test_alarm_not_run_on_close('close/outdated') self._test_alarm_not_run_on_close('close/outdated', monitor_scope="disabled")
def test_alarm_not_run_on_close_termination(self): def test_alarm_not_run_on_close_termination(self):
self._test_alarm_not_run_on_close('close/termination') self._test_alarm_not_run_on_close('close/termination', monitor_scope="disabled")
def test_alarm_run_on_close_maintainence(self):
self._test_alarm_run_on_close('close/maintenence')
def test_alarm_run_on_close_outdated(self):
self._test_alarm_run_on_close('close/outdated')
def test_alarm_run_on_close_termination(self):
self._test_alarm_run_on_close('close/termination')
class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort): class TestSlapOSCrmMonitoringCheckInstanceInError(SlapOSTestCaseMixinWithAbort):
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import transaction
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixinWithAbort
from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime from DateTime import DateTime
from zExceptions import Unauthorized from zExceptions import Unauthorized
class TestSlapOSERP5CleanupActiveProcess(SlapOSTestCaseMixinWithAbort): class TestSlapOSERP5CleanupActiveProcess(SlapOSTestCaseMixinWithAbort):
def _simulateActiveProcess_deleteSelf(self): def check_cleanup_active_process_alarm(self, date, test_method):
script_name = 'ActiveProcess_deleteSelf'
if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom,
script_name,
'*args, **kwargs',
'# Script body\n'
"""description = '%s\\nVisited by ActiveProcess_deleteSelf' % context.getDescription()
context.edit(description=description)""")
transaction.commit()
def _dropActiveProcess_deleteSelf(self):
script_name = 'ActiveProcess_deleteSelf'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def check_cleanup_active_process_alarm(self, date, assert_method):
def verify_getCreationDate_call(*args, **kwargs): def verify_getCreationDate_call(*args, **kwargs):
return date return date
ActiveProcessClass = self.portal.portal_types.getPortalTypeClass( ActiveProcessClass = self.portal.portal_types.getPortalTypeClass(
...@@ -44,6 +24,13 @@ context.edit(description=description)""") ...@@ -44,6 +24,13 @@ context.edit(description=description)""")
) )
self.assertEqual(active_process.getCreationDate(), date) self.assertEqual(active_process.getCreationDate(), date)
test_method(
self.portal.portal_alarms.slapos_erp5_cleanup_active_process,
active_process,
'ActiveProcess_deleteSelf',
attribute='description'
)
"""
self.tic() self.tic()
self._simulateActiveProcess_deleteSelf() self._simulateActiveProcess_deleteSelf()
try: try:
...@@ -56,13 +43,13 @@ context.edit(description=description)""") ...@@ -56,13 +43,13 @@ context.edit(description=description)""")
assert_method(active_process.getDescription('').\ assert_method(active_process.getDescription('').\
endswith("Visited by ActiveProcess_deleteSelf"), endswith("Visited by ActiveProcess_deleteSelf"),
active_process.getDescription('')) active_process.getDescription(''))"""
def test_alarm_old_active_process(self): def test_alarm_old_active_process(self):
self.check_cleanup_active_process_alarm(DateTime() - 22, self.assertTrue) self.check_cleanup_active_process_alarm(DateTime() - 22, self._test_alarm)
def test_alarm_new_active_process(self): def test_alarm_new_active_process(self):
self.check_cleanup_active_process_alarm(DateTime() - 20, self.assertFalse) self.check_cleanup_active_process_alarm(DateTime() - 20, self._test_alarm_not_visited)
class TestSlapOSERP5ActiveProcess_deleteSelf(SlapOSTestCaseMixinWithAbort): class TestSlapOSERP5ActiveProcess_deleteSelf(SlapOSTestCaseMixinWithAbort):
......
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSERP5Alarm</string> </value> <value> <string>testSlapOSERP5Alarm</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -47,7 +47,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -47,7 +47,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node.edit(allocation_scope=allocation_scope) compute_node.edit(allocation_scope=allocation_scope)
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'open') self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'enabled') self.assertEqual(compute_node.getMonitorScope(), 'enabled')
return compute_node return compute_node
...@@ -96,7 +96,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -96,7 +96,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close') self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'disabled') self.assertEqual(compute_node.getMonitorScope(), 'enabled')
self.commit() self.commit()
compute_node.edit(allocation_scope=None) compute_node.edit(allocation_scope=None)
self.commit() self.commit()
...@@ -107,8 +107,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -107,8 +107,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node.edit(allocation_scope='open/personal') compute_node.edit(allocation_scope='open/personal')
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'open') self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'disabled') self.assertEqual(compute_node.getMonitorScope(), 'enabled')
return compute_node return compute_node
def test_ComputeNode_setAllocationScope_personal(self): def test_ComputeNode_setAllocationScope_personal(self):
...@@ -169,7 +169,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -169,7 +169,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node.edit(allocation_scope='open/friend') compute_node.edit(allocation_scope='open/friend')
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'open') self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'enabled') self.assertEqual(compute_node.getMonitorScope(), 'enabled')
return compute_node return compute_node
...@@ -205,7 +205,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -205,7 +205,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
def _test_ComputeNode_setAllocationScope_closed(self, def _test_ComputeNode_setAllocationScope_closed(self,
source_administration=None, source_administration=None,
allocation_scope="close/forever", allocation_scope="close/forever",
subject_list=None): subject_list=None,
monitor_scope='enabled'):
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node', compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node',
capacity_scope=None, capacity_scope=None,
monitor_scope=None, monitor_scope=None,
...@@ -217,7 +218,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -217,7 +218,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close') self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'disabled') self.assertEqual(compute_node.getMonitorScope(), monitor_scope)
self.commit() self.commit()
compute_node.edit(allocation_scope=None) compute_node.edit(allocation_scope=None)
...@@ -230,12 +231,12 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -230,12 +231,12 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.commit() self.commit()
self.assertEqual(compute_node.getCapacityScope(), 'close') self.assertEqual(compute_node.getCapacityScope(), 'close')
self.assertEqual(compute_node.getMonitorScope(), 'disabled') self.assertEqual(compute_node.getMonitorScope(), monitor_scope)
return compute_node return compute_node
def test_ComputeNode_setAllocationScope_closed_forever_no_source_adm(self): def test_ComputeNode_setAllocationScope_closed_forever_no_source_adm(self):
self._test_ComputeNode_setAllocationScope_closed() self._test_ComputeNode_setAllocationScope_closed(monitor_scope='disabled')
def test_ComputeNode_setAllocationScope_closed_forever_with_source_adm(self): def test_ComputeNode_setAllocationScope_closed_forever_with_source_adm(self):
person = self.makePerson() person = self.makePerson()
...@@ -243,7 +244,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope( ...@@ -243,7 +244,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""]) self.assertNotIn(person.getDefaultEmailCoordinateText(), [None, ""])
compute_node = self._test_ComputeNode_setAllocationScope_closed( compute_node = self._test_ComputeNode_setAllocationScope_closed(
source_administration=person.getRelativeUrl()) source_administration=person.getRelativeUrl(), monitor_scope='disabled')
self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()]) self.assertEqual(compute_node.getSubjectList(), [person.getDefaultEmailCoordinateText()])
self.assertEqual(compute_node.getDestinationSectionList(), self.assertEqual(compute_node.getDestinationSectionList(),
......
...@@ -3,18 +3,17 @@ allocation_scope = compute_node.getAllocationScope() ...@@ -3,18 +3,17 @@ allocation_scope = compute_node.getAllocationScope()
edit_kw = {} edit_kw = {}
if compute_node.getCapacityScope() is None: # Automatically close the capacity whenever the allocation scope
# changes, and let the alarm update it later, whenever the
# allocation scope is open.
if compute_node.getCapacityScope() != "close":
edit_kw['capacity_scope'] = 'close' edit_kw['capacity_scope'] = 'close'
if allocation_scope in ['open/public', 'open/subscription', 'open/friend']: if compute_node.getMonitorScope() is None:
monitor_scope = 'enabled' edit_kw['monitor_scope'] = 'enabled'
elif allocation_scope == 'open/personal':
monitor_scope = compute_node.getMonitorScope("disabled")
else:
monitor_scope = 'disabled'
edit_kw['capacity_scope'] = 'close'
edit_kw['monitor_scope'] = monitor_scope if allocation_scope == "close/forever":
edit_kw['monitor_scope'] = 'disabled'
self_person = compute_node.getSourceAdministrationValue(portal_type="Person") self_person = compute_node.getSourceAdministrationValue(portal_type="Person")
if self_person is None: if self_person is None:
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>update_allocation_scope</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>0.8</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Update Allocation Scope</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/ComputeNode_viewAllocationScopeUpdateDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>update_category</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>0.81</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Update Compute Node Categories</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/ComputeNode_viewCategoryAsWeb</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -6,8 +6,6 @@ Compute Node | new_ticket ...@@ -6,8 +6,6 @@ Compute Node | new_ticket
Compute Node | request_certificate_action Compute Node | request_certificate_action
Compute Node | revoke_certificate Compute Node | revoke_certificate
Compute Node | slaposjs_view Compute Node | slaposjs_view
Compute Node | update_allocation_scope
Compute Node | update_category
Computer Network Module | slaposjs_view Computer Network Module | slaposjs_view
Computer Network | slaposjs_view Computer Network | slaposjs_view
ERP5 Login | slaposjs_view ERP5 Login | slaposjs_view
......
portal = context.getPortalObject() portal = context.getPortalObject()
default_allocation_scope_uid = [category.getUid() \ default_upgrade_scope_uid = [
for category in portal.portal_categories.allocation_scope.open.objectValues()] portal.portal_categories.upgrade_scope.auto.getUid(),
portal.portal_categories.upgrade_scope.confirmation.getUid()
]
if default_upgrade_scope_uid:
if default_allocation_scope_uid:
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type='Compute Node', portal_type='Compute Node',
validation_state = 'validated', validation_state = 'validated',
default_allocation_scope_uid=default_allocation_scope_uid, default_upgrade_scope_uid=default_upgrade_scope_uid,
method_id = 'ComputeNode_checkAndCreateUpgradeDecision', method_id = 'ComputeNode_checkAndCreateUpgradeDecision',
activate_kw = {'tag':tag} activate_kw = {'tag':tag}
) )
......
...@@ -40,9 +40,6 @@ if slave_upgrade: ...@@ -40,9 +40,6 @@ if slave_upgrade:
if url_string != instance_tree.getUrlString(): if url_string != instance_tree.getUrlString():
newer_release = context.portal_catalog.getResultValue(portal_type='Software Release', url_string=url_string) newer_release = context.portal_catalog.getResultValue(portal_type='Software Release', url_string=url_string)
else: else:
if not partition.getParentValue().getAllocationScopeUid() in [category.getUid() \
for category in portal.portal_categories.allocation_scope.open.objectValues()]:
return
newer_release = instance_tree.\ newer_release = instance_tree.\
InstanceTree_getUpgradableSoftwareRelease() InstanceTree_getUpgradableSoftwareRelease()
if newer_release is None: if newer_release is None:
......
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved. # -*- coding:utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin): class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
...@@ -32,132 +51,83 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin): ...@@ -32,132 +51,83 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.start() upgrade_decision.start()
self.tic() self.tic()
self._test_alarm(
self._simulateScript('UpgradeDecision_processUpgrade', 'True') self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_started,
try: upgrade_decision,
self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_started.activeSense() 'UpgradeDecision_processUpgrade')
self.tic()
finally:
self._dropScript('UpgradeDecision_processUpgrade')
self.assertEqual(
'Visited by UpgradeDecision_processUpgrade',
upgrade_decision.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_upgrade_decision_process_planned(self): def test_alarm_upgrade_decision_process_planned(self):
upgrade_decision = self._makeUpgradeDecision(confirm=0) upgrade_decision = self._makeUpgradeDecision(confirm=0)
upgrade_decision.plan() upgrade_decision.plan()
self.tic() self._test_alarm(
self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_planned,
self._simulateScript('UpgradeDecision_notify', 'True') upgrade_decision,
try: 'UpgradeDecision_notify')
self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_planned.\
activeSense()
self.tic()
finally:
self._dropScript('UpgradeDecision_notify')
self.assertEqual('Visited by UpgradeDecision_notify',
upgrade_decision.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_upgrade_decision_process_stopped(self): def test_alarm_upgrade_decision_process_stopped(self):
upgrade_decision = self._makeUpgradeDecision() upgrade_decision = self._makeUpgradeDecision()
upgrade_decision.start() upgrade_decision.start()
upgrade_decision.stop() upgrade_decision.stop()
self.tic() self.tic()
self._test_alarm(
self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_stopped,
upgrade_decision,
'UpgradeDecision_notifyDelivered')
def _test_alarm_compute_node_create_upgrade_decision(self, allocation_scope, upgrade_scope):
compute_node = self._makeComputeNode(allocation_scope=allocation_scope)[0]
compute_node.setUpgradeScope(upgrade_scope)
self._test_alarm(
self.portal.portal_alarms.slapos_pdm_compute_node_create_upgrade_decision,
compute_node,
'ComputeNode_checkAndCreateUpgradeDecision')
def _test_alarm_compute_node_create_upgrade_decision_not_visited(self, allocation_scope, upgrade_scope):
compute_node = self._makeComputeNode(allocation_scope=allocation_scope)[0]
compute_node.setUpgradeScope(upgrade_scope)
self._test_alarm_not_visited(
self.portal.portal_alarms.slapos_pdm_compute_node_create_upgrade_decision,
compute_node,
'ComputeNode_checkAndCreateUpgradeDecision')
def test_alarm_compute_node_create_upgrade_decision_auto(self):
self._test_alarm_compute_node_create_upgrade_decision('open/public', 'auto')
self._test_alarm_compute_node_create_upgrade_decision('open/personal', 'auto')
self._test_alarm_compute_node_create_upgrade_decision('open/friend', 'auto')
self._test_alarm_compute_node_create_upgrade_decision('open/subscription', 'auto')
self._test_alarm_compute_node_create_upgrade_decision('close/outdated', 'auto')
self._test_alarm_compute_node_create_upgrade_decision('close/maintanance', 'auto')
self._test_alarm_compute_node_create_upgrade_decision('close/termination', 'auto')
def test_alarm_compute_node_create_upgrade_decision_ask_confirmation(self):
self._test_alarm_compute_node_create_upgrade_decision('open/public', 'confirmation')
self._test_alarm_compute_node_create_upgrade_decision('open/personal', 'confirmation')
self._test_alarm_compute_node_create_upgrade_decision('open/friend', 'confirmation')
self._test_alarm_compute_node_create_upgrade_decision('open/subscription', 'confirmation')
self._test_alarm_compute_node_create_upgrade_decision('close/outdated', 'confirmation')
self._test_alarm_compute_node_create_upgrade_decision('close/maintanance', 'confirmation')
self._test_alarm_compute_node_create_upgrade_decision('close/termination', 'confirmation')
def test_alarm_compute_node_create_upgrade_decision_never(self):
self._test_alarm_compute_node_create_upgrade_decision_not_visited('open/public', 'never')
self._test_alarm_compute_node_create_upgrade_decision_not_visited('open/personal', 'never')
self._test_alarm_compute_node_create_upgrade_decision_not_visited('open/friend', 'never')
self._test_alarm_compute_node_create_upgrade_decision_not_visited('open/subscription', 'never')
self._test_alarm_compute_node_create_upgrade_decision_not_visited('close/outdated', 'never')
self._test_alarm_compute_node_create_upgrade_decision_not_visited('close/maintanance', 'never')
self._test_alarm_compute_node_create_upgrade_decision_not_visited('close/termination', 'never')
self._simulateScript('UpgradeDecision_notifyDelivered', 'True')
try:
self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_stopped.\
activeSense()
self.tic()
finally:
self._dropScript('UpgradeDecision_notifyDelivered')
self.assertEqual('Visited by UpgradeDecision_notifyDelivered',
upgrade_decision.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_compute_node_create_upgrade_decision(self):
compute_node = self._makeComputeNode(allocation_scope = 'open/public')[0]
compute_node2 = self._makeComputeNode(allocation_scope = 'open/personal')[0]
compute_node3 = self._makeComputeNode(allocation_scope = 'open/friend')[0]
self.tic()
self._simulateScript('ComputeNode_checkAndCreateUpgradeDecision', 'True')
try:
self.portal.portal_alarms.slapos_pdm_compute_node_create_upgrade_decision.\
activeSense()
self.tic()
finally:
self._dropScript('ComputeNode_checkAndCreateUpgradeDecision')
self.assertEqual('Visited by ComputeNode_checkAndCreateUpgradeDecision',
compute_node.workflow_history['edit_workflow'][-1]['comment'])
self.assertEqual('Visited by ComputeNode_checkAndCreateUpgradeDecision',
compute_node2.workflow_history['edit_workflow'][-1]['comment'])
self.assertEqual('Visited by ComputeNode_checkAndCreateUpgradeDecision',
compute_node3.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_instance_tree_create_upgrade_decision(self): def test_alarm_instance_tree_create_upgrade_decision(self):
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
instance_tree2 = self._makeInstanceTree() self._test_alarm(
instance_tree3 = self._makeInstanceTree() self.portal.portal_alarms.slapos_pdm_instance_tree_create_upgrade_decision,
instance_tree,
self.tic() 'InstanceTree_createUpgradeDecision')
self._simulateScript('InstanceTree_createUpgradeDecision', 'True')
try:
self.portal.portal_alarms.slapos_pdm_instance_tree_create_upgrade_decision.\
activeSense()
self.tic()
finally:
self._dropScript('InstanceTree_createUpgradeDecision')
self.assertEqual('Visited by InstanceTree_createUpgradeDecision',
instance_tree.workflow_history['edit_workflow'][-1]['comment'])
self.assertEqual('Visited by InstanceTree_createUpgradeDecision',
instance_tree2.workflow_history['edit_workflow'][-1]['comment'])
self.assertEqual('Visited by InstanceTree_createUpgradeDecision',
instance_tree3.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_create_upgrade_decision_destroyed_instance_tree(self): def test_alarm_create_upgrade_decision_destroyed_instance_tree(self):
instance_tree = self._makeInstanceTree(slap_state="destroy_requested") instance_tree = self._makeInstanceTree(slap_state="destroy_requested")
instance_tree2 = self._makeInstanceTree(slap_state="destroy_requested") self._test_alarm_not_visited(
self.tic() self.portal.portal_alarms.slapos_pdm_instance_tree_create_upgrade_decision,
instance_tree,
self._simulateScript('InstanceTree_createUpgradeDecision', 'True') 'InstanceTree_createUpgradeDecision')
try:
self.portal.portal_alarms.slapos_pdm_instance_tree_create_upgrade_decision.\
activeSense()
self.tic()
finally:
self._dropScript('InstanceTree_createUpgradeDecision')
self.assertNotEqual('Visited by InstanceTree_createUpgradeDecision',
instance_tree.workflow_history['edit_workflow'][-1]['comment'])
self.assertNotEqual('Visited by InstanceTree_createUpgradeDecision',
instance_tree2.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_create_upgrade_decision_closed_compute_node(self):
compute_node = self._makeComputeNode(allocation_scope='close/oudtated')[0]
compute_node2 = self._makeComputeNode(allocation_scope='close/maintenance')[0]
self.tic()
self._simulateScript('ComputeNode_checkAndCreateUpgradeDecision', 'True')
try:
self.portal.portal_alarms.slapos_pdm_compute_node_create_upgrade_decision.\
activeSense()
self.tic()
finally:
self._dropScript('ComputeNode_checkAndCreateUpgradeDecision')
self.assertNotEqual('Visited by ComputeNode_checkAndCreateUpgradeDecision',
compute_node.workflow_history['edit_workflow'][-1]['comment'])
self.assertNotEqual('Visited by ComputeNode_checkAndCreateUpgradeDecision',
compute_node2.workflow_history['edit_workflow'][-1]['comment'])
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSPDMAlarm</string> </value> <value> <string>testSlapOSPDMAlarm</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -219,7 +219,15 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins): ...@@ -219,7 +219,15 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self.tic() self.tic()
up_decision = instance_tree.InstanceTree_createUpgradeDecision() up_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(up_decision, None) self.assertNotEqual(up_decision, None)
self.assertEqual(up_decision.getSimulationState(), 'planned')
self.assertEqual(up_decision.UpgradeDecision_getAggregateValue("Instance Tree").\
getReference(), instance_tree.getReference())
self.assertEqual(software_release2.getUrlString(),
up_decision.UpgradeDecision_getAggregateValue("Software Release").\
getUrlString())
def testInstanceTree_createUpgradeDecision_create_once_transaction(self): def testInstanceTree_createUpgradeDecision_create_once_transaction(self):
person = self._makePerson() person = self._makePerson()
......
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSPDMCreateUpgradeDecisionSkins</string> </value> <value> <string>testSlapOSPDMCreateUpgradeDecisionSkins</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
...@@ -31,11 +31,11 @@ if instance_tree is not None: ...@@ -31,11 +31,11 @@ if instance_tree is not None:
compute_node = upgrade_decision.UpgradeDecision_getAggregateValue("Compute Node") compute_node = upgrade_decision.UpgradeDecision_getAggregateValue("Compute Node")
if compute_node is not None: if compute_node is not None:
if compute_node.getUpgradeScope() in ['never', 'disabled']: if compute_node.getUpgradeScope() in ['never', 'disabled']:
upgrade_decision.cancel("Upgrade scope was disabled on the related Instance Tree") upgrade_decision.cancel("Upgrade scope was disabled on the related Compute Node")
return return
elif compute_node.getAllocationScope() in ["closed/forever", "closed/termination"]: elif compute_node.getAllocationScope() == "close/forever":
upgrade_decision.cancel(comment="Compute Node is closed.") upgrade_decision.cancel(comment="Compute Node is close forever.")
return return
already_deployed = len(portal.portal_catalog(limit=1, already_deployed = len(portal.portal_catalog(limit=1,
......
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