Commit 2f7f421d authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_pdm: Rename alarms and update test

Conflicts:
	master/bt5/slapos_pdm/bt/revision
parent 37712722
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>slapos_hosting_subscription_create_upgrade_decision</string> </value> <value> <string>slapos_pdm_hosting_subscription_create_upgrade_decision</string> </value>
</item> </item>
<item> <item>
<key> <string>periodicity_day_frequency</string> </key> <key> <string>periodicity_day_frequency</string> </key>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>slapos_upgrade_decision_process_planned</string> </value> <value> <string>slapos_pdm_upgrade_decision_process_planned</string> </value>
</item> </item>
<item> <item>
<key> <string>periodicity_day_frequency</string> </key> <key> <string>periodicity_day_frequency</string> </key>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>slapos_upgrade_decision_process_started</string> </value> <value> <string>slapos_pdm_upgrade_decision_process_started</string> </value>
</item> </item>
<item> <item>
<key> <string>periodicity_day_frequency</string> </key> <key> <string>periodicity_day_frequency</string> </key>
......
...@@ -13,11 +13,12 @@ class TestSlapOSUpgradeDecisionProcess(testSlapOSMixin): ...@@ -13,11 +13,12 @@ class TestSlapOSUpgradeDecisionProcess(testSlapOSMixin):
return "%sTEST" % self.portal.portal_ids.generateNewId( return "%sTEST" % self.portal.portal_ids.generateNewId(
id_group=('slapos_core_test')) id_group=('slapos_core_test'))
def _makeUpgradeDecision(self): def _makeUpgradeDecision(self, confirm=True):
upgrade_decision = self.portal.\ upgrade_decision = self.portal.\
upgrade_decision_module.newContent( upgrade_decision_module.newContent(
portal_type="Upgrade Decision", portal_type="Upgrade Decision",
title="TESTUPDE-%s" % self.new_id) title="TESTUPDE-%s" % self.new_id)
if confirm:
upgrade_decision.confirm() upgrade_decision.confirm()
return upgrade_decision return upgrade_decision
...@@ -36,13 +37,7 @@ class TestSlapOSUpgradeDecisionProcess(testSlapOSMixin): ...@@ -36,13 +37,7 @@ class TestSlapOSUpgradeDecisionProcess(testSlapOSMixin):
return computer return computer
def _simulateUpgradeDecision_upgradeHostingSubscription(self, fake_return="True"): def _simulateScript(self, script_name, fake_return='True'):
self._simulateScript('UpgradeDecision_upgradeHostingSubscription', fake_return)
def _simulateUpgradeDecision_upgradeComputer(self, fake_return="True"):
self._simulateScript('UpgradeDecision_upgradeComputer', fake_return)
def _simulateScript(self, script_name, fake_return):
if script_name in self.portal.portal_skins.custom.objectIds(): if script_name in self.portal.portal_skins.custom.objectIds():
raise ValueError('Precondition failed: %s exists in custom' % script_name) raise ValueError('Precondition failed: %s exists in custom' % script_name)
createZODBPythonScript(self.portal.portal_skins.custom, createZODBPythonScript(self.portal.portal_skins.custom,
...@@ -55,11 +50,6 @@ return %s ...@@ -55,11 +50,6 @@ return %s
""" % (script_name, fake_return )) """ % (script_name, fake_return ))
transaction.commit() transaction.commit()
def _dropUpgradeDecision_upgradeHostingSubscription(self):
self._dropScript('UpgradeDecision_upgradeHostingSubscription')
def _dropUpgradeDecision_upgradeComputer(self):
self._dropScript('UpgradeDecision_upgradeComputer')
def _dropScript(self, script_name): def _dropScript(self, script_name):
if script_name in self.portal.portal_skins.custom.objectIds(): if script_name in self.portal.portal_skins.custom.objectIds():
...@@ -71,12 +61,12 @@ return %s ...@@ -71,12 +61,12 @@ return %s
upgrade_decision.start() upgrade_decision.start()
self.tic() self.tic()
self._simulateUpgradeDecision_upgradeHostingSubscription() self._simulateScript('UpgradeDecision_upgradeHostingSubscription', 'True')
try: try:
self.portal.portal_alarms.slapos_upgrade_decision_process.activeSense() self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_started.activeSense()
self.tic() self.tic()
finally: finally:
self._dropUpgradeDecision_upgradeHostingSubscription() self._dropScript('UpgradeDecision_upgradeHostingSubscription')
self.assertEqual( self.assertEqual(
'Visited by UpgradeDecision_upgradeHostingSubscription', 'Visited by UpgradeDecision_upgradeHostingSubscription',
upgrade_decision.workflow_history['edit_workflow'][-1]['comment']) upgrade_decision.workflow_history['edit_workflow'][-1]['comment'])
...@@ -86,52 +76,48 @@ return %s ...@@ -86,52 +76,48 @@ return %s
upgrade_decision.start() upgrade_decision.start()
self.tic() self.tic()
self._simulateUpgradeDecision_upgradeHostingSubscription("False") self._simulateScript('UpgradeDecision_upgradeHostingSubscription', 'False')
self._simulateUpgradeDecision_upgradeComputer() self._simulateScript('UpgradeDecision_upgradeComputer', 'True')
try: try:
self.portal.portal_alarms.slapos_upgrade_decision_process.activeSense() self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_started.activeSense()
self.tic() self.tic()
finally: finally:
self._dropUpgradeDecision_upgradeHostingSubscription() self._dropScript('UpgradeDecision_upgradeHostingSubscription')
self._dropUpgradeDecision_upgradeComputer() self._dropScript('UpgradeDecision_upgradeComputer')
self.assertEqual( self.assertEqual(
'Visited by UpgradeDecision_upgradeComputer', 'Visited by UpgradeDecision_upgradeComputer',
upgrade_decision.workflow_history['edit_workflow'][-1]['comment']) upgrade_decision.workflow_history['edit_workflow'][-1]['comment'])
def test_alarm_upgrade_decision_process_planned(self):
upgrade_decision = self._makeUpgradeDecision(confirm=0)
upgrade_decision.plan()
self.tic()
def _simulateComputer_checkAndCreateUpgradeDecision(self): self._simulateScript('UpgradeDecision_notify')
script_name = 'Computer_checkAndCreateUpgradeDecision' try:
if script_name in self.portal.portal_skins.custom.objectIds(): self.portal.portal_alarms.slapos_pdm_upgrade_decision_process_planned.\
raise ValueError('Precondition failed: %s exists in custom' % script_name) activeSense()
createZODBPythonScript(self.portal.portal_skins.custom, self.tic()
script_name, finally:
'*args, **kw', self._dropScript('UpgradeDecision_notify')
'# Script body\n'
"""portal_workflow = context.portal_workflow self.assertEqual('Visited by UpgradeDecision_notify',
portal_workflow.doActionFor(context, action='edit_action', comment='%s') """ % \ upgrade_decision.workflow_history['edit_workflow'][-1]['comment'])
'Visited by Computer_checkAndCreateUpgradeDecision')
transaction.commit()
def _dropComputer_checkAndCreateUpgradeDecision(self):
script_name = 'Computer_checkAndCreateUpgradeDecision'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_Alarm_computerCheckUpgradeSoftwareRelease(self): def test_alarm_computer_create_upgrade_decision(self):
computer = self._makeComputer(self.new_id) computer = self._makeComputer(self.new_id)
computer.edit(allocation_scope = 'open/public') computer.edit(allocation_scope = 'open/public')
computer2 = self._makeComputer(self.generateNewId()) computer2 = self._makeComputer(self.generateNewId())
computer2.edit(allocation_scope = 'open/personal') computer2.edit(allocation_scope = 'open/personal')
self._simulateComputer_checkAndCreateUpgradeDecision() self._simulateScript('Computer_checkAndCreateUpgradeDecision')
try: try:
self.portal.portal_alarms.slapos_pdm_computer_create_upgrade_decision.\ self.portal.portal_alarms.slapos_pdm_computer_create_upgrade_decision.\
activeSense() activeSense()
self.tic() self.tic()
finally: finally:
self._dropComputer_checkAndCreateUpgradeDecision() self._dropScript('Computer_checkAndCreateUpgradeDecision')
self.assertEqual('Visited by Computer_checkAndCreateUpgradeDecision', self.assertEqual('Visited by Computer_checkAndCreateUpgradeDecision',
computer.workflow_history['edit_workflow'][-1]['comment']) computer.workflow_history['edit_workflow'][-1]['comment'])
...@@ -139,39 +125,20 @@ portal_workflow.doActionFor(context, action='edit_action', comment='%s') """ % \ ...@@ -139,39 +125,20 @@ portal_workflow.doActionFor(context, action='edit_action', comment='%s') """ % \
self.assertNotEqual('Visited by Computer_checkAndCreateUpgradeDecision', self.assertNotEqual('Visited by Computer_checkAndCreateUpgradeDecision',
computer2.workflow_history['edit_workflow'][-1]['comment']) computer2.workflow_history['edit_workflow'][-1]['comment'])
def _simulateComputer_hostingSubscriptionCreateUpgradeDecision(self): def test_alarm_hosting_subscription_create_upgrade_decision(self):
script_name = 'Computer_hostingSubscriptionCreateUpgradeDecision'
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, **kw',
'# Script body\n'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='%s') """ % \
'Visited by Computer_hostingSubscriptionCreateUpgradeDecision')
transaction.commit()
def _dropComputer_hostingSubscriptionCreateUpgradeDecision(self):
script_name = 'Computer_hostingSubscriptionCreateUpgradeDecision'
if script_name in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_name)
transaction.commit()
def test_Alarm_computerCheckUpgradeHostingSubscription(self):
computer = self._makeComputer(self.new_id) computer = self._makeComputer(self.new_id)
computer.edit(allocation_scope = 'open/public') computer.edit(allocation_scope = 'open/public')
computer2 = self._makeComputer(self.generateNewId()) computer2 = self._makeComputer(self.generateNewId())
computer2.edit(allocation_scope = 'open/personal') computer2.edit(allocation_scope = 'open/personal')
self._simulateComputer_hostingSubscriptionCreateUpgradeDecision() self._simulateScript('Computer_hostingSubscriptionCreateUpgradeDecision')
try: try:
self.portal.portal_alarms.slapos_hosting_subscription_create_upgrade_decision.\ self.portal.portal_alarms.slapos_pdm_hosting_subscription_create_upgrade_decision.\
activeSense() activeSense()
self.tic() self.tic()
finally: finally:
self._dropComputer_hostingSubscriptionCreateUpgradeDecision() self._dropScript('Computer_hostingSubscriptionCreateUpgradeDecision')
self.assertEqual('Visited by Computer_hostingSubscriptionCreateUpgradeDecision', self.assertEqual('Visited by Computer_hostingSubscriptionCreateUpgradeDecision',
computer.workflow_history['edit_workflow'][-1]['comment']) computer.workflow_history['edit_workflow'][-1]['comment'])
...@@ -179,4 +146,3 @@ portal_workflow.doActionFor(context, action='edit_action', comment='%s') """ % \ ...@@ -179,4 +146,3 @@ portal_workflow.doActionFor(context, action='edit_action', comment='%s') """ % \
self.assertNotEqual('Visited by Computer_hostingSubscriptionCreateUpgradeDecision', self.assertNotEqual('Visited by Computer_hostingSubscriptionCreateUpgradeDecision',
computer2.workflow_history['edit_workflow'][-1]['comment']) computer2.workflow_history['edit_workflow'][-1]['comment'])
\ No newline at end of file
portal_alarms/slapos_hosting_subscription_create_upgrade_decision
portal_alarms/slapos_manage_software_catalog portal_alarms/slapos_manage_software_catalog
portal_alarms/slapos_pdm_computer_create_upgrade_decision portal_alarms/slapos_pdm_computer_create_upgrade_decision
portal_alarms/slapos_upgrade_decision_process_planned portal_alarms/slapos_pdm_hosting_subscription_create_upgrade_decision
portal_alarms/slapos_upgrade_decision_process_started portal_alarms/slapos_pdm_upgrade_decision_process_planned
portal_alarms/slapos_pdm_upgrade_decision_process_started
software_product_module/template_software_product software_product_module/template_software_product
software_release_module/template_software_release software_release_module/template_software_release
\ No newline at end of file
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