Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
slapos.core
Commits
0f7c72df
Commit
0f7c72df
authored
Feb 07, 2023
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
Reduce allocation scope usage
See merge request
nexedi/slapos.core!486
parents
06a27d31
8955cfe7
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
443 additions
and
888 deletions
+443
-888
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
.../portal_components/test.erp5.testSlapOSAccountingAlarm.py
+40
-37
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
...omponents/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
+8
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
...teItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
+52
-40
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+131
-320
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.py
...al_components/test.erp5.testSlapOSCloudAllocationAlarm.py
+16
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.xml
...l_components/test.erp5.testSlapOSCloudAllocationAlarm.xml
+3
-24
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow.py
...s/test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow.py
+4
-4
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow.xml
.../test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow.xml
+3
-24
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/ComputeNode_checkState.py
...tal_skins/slapos_crm_monitoring/ComputeNode_checkState.py
+0
-4
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_recheckMonitoring.py
...slapos_crm_monitoring/SupportRequest_recheckMonitoring.py
+0
-13
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
+45
-9
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5Alarm.py
...teItem/portal_components/test.erp5.testSlapOSERP5Alarm.py
+11
-24
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5Alarm.xml
...eItem/portal_components/test.erp5.testSlapOSERP5Alarm.xml
+3
-24
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5InteractionWorkflow.py
...components/test.erp5.testSlapOSERP5InteractionWorkflow.py
+11
-10
master/bt5/slapos_erp5/WorkflowTemplateItem/portal_workflow/slapos_erp5_interaction_workflow/script_ComputeNode_updateAllocation.py
...teraction_workflow/script_ComputeNode_updateAllocation.py
+8
-9
master/bt5/slapos_jio/ActionTemplateItem/portal_types/Compute%20Node/update_allocation_scope.xml
...m/portal_types/Compute%20Node/update_allocation_scope.xml
+0
-85
master/bt5/slapos_jio/ActionTemplateItem/portal_types/Compute%20Node/update_category.xml
...plateItem/portal_types/Compute%20Node/update_category.xml
+0
-85
master/bt5/slapos_jio/bt/template_action_path_list
master/bt5/slapos_jio/bt/template_action_path_list
+0
-2
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/Alarm_ComputeNodeCheckUpgradeSoftwareRelease.py
...lapos_pdm/Alarm_ComputeNodeCheckUpgradeSoftwareRelease.py
+6
-5
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/InstanceTree_createUpgradeDecision.py
...al_skins/slapos_pdm/InstanceTree_createUpgradeDecision.py
+0
-3
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
+84
-114
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.xml
...teItem/portal_components/test.erp5.testSlapOSPDMAlarm.xml
+3
-24
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
...ents/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
+9
-1
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.xml
...nts/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.xml
+3
-24
master/bt5/slapos_pdm/WorkflowTemplateItem/portal_workflow/upgrade_slap_interface_workflow/script_UpgradeDecision_reviewUpgrade.py
...nterface_workflow/script_UpgradeDecision_reviewUpgrade.py
+3
-3
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingAlarm.py
View file @
0f7c72df
...
...
@@ -1276,6 +1276,7 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
open_order
=
self
.
createOpenOrder
()
open_order
.
OpenSaleOrder_updatePeriod
()
@
simulateByEditWorkflowMark
(
'Person_storeOpenSaleOrderJournal'
)
def
test_updatePeriod_validated
(
self
):
open_order
=
self
.
createOpenOrder
()
person
=
self
.
portal
.
person_module
.
template_member
\
...
...
@@ -1284,14 +1285,12 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
destination_decision_value
=
person
,
)
script_name
=
"Person_storeOpenSaleOrderJournal"
self
.
_simulateScript
(
script_name
)
try
:
open_order
.
OpenSaleOrder_updatePeriod
()
finally
:
self
.
_dropScript
(
script_name
)
self
.
assertScriptVisited
(
person
,
script_name
)
self
.
assertEqual
(
'Visited by Person_storeOpenSaleOrderJournal'
,
person
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
]
)
@
simulateByEditWorkflowMark
(
'Person_storeOpenSaleOrderJournal'
)
def
test_updatePeriod_invalidated
(
self
):
open_order
=
self
.
createOpenOrder
()
person
=
self
.
portal
.
person_module
.
template_member
\
...
...
@@ -1300,14 +1299,11 @@ class TestSlapOSUpdateOpenSaleOrderPeriod(SlapOSTestCaseMixin):
destination_decision_value
=
person
,
)
open_order
.
invalidate
()
script_name
=
"Person_storeOpenSaleOrderJournal"
self
.
_simulateScript
(
script_name
)
try
:
open_order
.
OpenSaleOrder_updatePeriod
()
finally
:
self
.
_dropScript
(
script_name
)
self
.
assertScriptNotVisited
(
person
,
script_name
)
self
.
assertNotEqual
(
'Visited by Person_storeOpenSaleOrderJournal'
,
person
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm
(
self
):
open_order
=
self
.
createOpenOrder
()
...
...
@@ -1351,39 +1347,46 @@ class TestSlapOSReindexOpenSaleOrder(SlapOSTestCaseMixin):
)
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
):
open_order
=
self
.
createOpenOrder
()
self
.
tic
()
# Jut wait a bit so the line has a different timestamp > 1 sec.
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
()
script_name
=
"OpenSaleOrder_reindexIfIndexedBeforeLine"
alarm
=
self
.
portal
.
portal_alarms
.
slapos_reindex_open_sale_order
self
.
_test_alarm
(
alarm
,
open_order
,
script_name
)
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
)
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
):
open_order
=
self
.
createOpenOrder
()
self
.
tic
()
script_name
=
"OpenSaleOrder_reindexIfIndexedBeforeLine"
alarm
=
self
.
portal
.
portal_alarms
.
slapos_reindex_open_sale_order
# Rather them test the alarm with fake script, directly
# test the ERP5Site_zGetOpenOrderWithModifiedLineUid code.
open_order_with_modified_line_uid_list
=
[
i
.
uid
for
i
in
\
self
.
portal
.
ERP5Site_zGetOpenOrderWithModifiedLineUid
()]
self
.
assertNotIn
(
open_order
.
getUid
(),
open_order_with_modified_line_uid_list
)
self
.
_test_alarm_not_visited
(
alarm
,
open_order
,
script_name
)
class
TestSlapOSGeneratePackingListFromTioXML
(
SlapOSTestCaseMixin
):
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseDefaultScenarioMixin.py
View file @
0f7c72df
...
...
@@ -147,6 +147,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server
.
edit
(
allocation_scope
=
'open/public'
)
self
.
assertEqual
(
'open/public'
,
server
.
getAllocationScope
())
# Called by alarm
server
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
tic
()
...
...
@@ -155,6 +157,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server
.
edit
(
allocation_scope
=
'open/subscription'
)
self
.
assertEqual
(
'open/subscription'
,
server
.
getAllocationScope
())
# Called by alarm
server
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
tic
()
...
...
@@ -163,6 +167,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server
.
edit
(
allocation_scope
=
'open/personal'
,
subject_list
=
[])
self
.
assertEqual
(
'open/personal'
,
server
.
getAllocationScope
())
# Called by alarm
server
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
tic
()
...
...
@@ -173,6 +179,8 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
server
.
edit
(
allocation_scope
=
'open/friend'
,
subject_list
=
friend_list
)
self
.
assertEqual
(
'open/friend'
,
server
.
getAllocationScope
())
# Called by alarm
server
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
assertSameSet
(
friend_list
,
server
.
getSubjectList
())
self
.
tic
()
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
View file @
0f7c72df
...
...
@@ -78,6 +78,40 @@ def withAbort(func):
self
.
abort
()
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
):
expected_html_payzen_redirect_page
=
None
...
...
@@ -620,53 +654,31 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
resource
=
'foo/bar'
,
)
# Set of methods to help test alarms and to see if the script was called
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
):
def
_test_alarm
(
self
,
alarm
,
document
,
script_name
,
attribute
=
None
):
self
.
tic
()
self
.
_simulateScript
(
script_name
)
try
:
with
TemporaryAlarmScript
(
self
.
portal
,
script_name
,
attribute
=
attribute
):
alarm
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
script_name
)
self
.
assertScriptVisited
(
document
,
script_name
)
if
attribute
is
None
:
content
=
document
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
]
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
.
_simulateScript
(
script_name
)
try
:
with
TemporaryAlarmScript
(
self
.
portal
,
script_name
,
attribute
=
attribute
):
alarm
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
script_name
)
self
.
assertScriptNotVisited
(
document
,
script_name
)
if
attribute
is
None
:
content
=
document
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
]
else
:
content
=
document
.
getProperty
(
attribute
)
self
.
assertNotEqual
(
'Visited by %s'
%
script_name
,
content
)
def
restoreAccountingTemplatesOnPreferences
(
self
):
self
.
login
()
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
0f7c72df
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import
transaction
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
import
time
from
zExceptions
import
Unauthorized
from
DateTime
import
DateTime
...
...
@@ -67,47 +66,21 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self
.
assertFalse
(
self
.
instance_tree
.
getTitle
()
in
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
):
self
.
software_instance
.
edit
(
title
=
self
.
generateNewSoftwareTitle
())
self
.
tic
()
self
.
_simulateInstanceTree_assertSuccessor
()
try
:
self
.
portal
.
portal_alarms
.
slapos_assert_instance_tree_successor
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropInstanceTree_assertSuccessor
()
self
.
assertEqual
(
'Visited by InstanceTree_assertSuccessor'
,
self
.
instance_tree
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_assert_instance_tree_successor
,
self
.
instance_tree
,
'InstanceTree_assertSuccessor'
)
def
test_alarm_not_renamed
(
self
):
self
.
_simulateInstanceTree_assertSuccessor
()
try
:
self
.
portal
.
portal_alarms
.
slapos_assert_instance_tree_successor
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropInstanceTree_assertSuccessor
()
self
.
assertNotEqual
(
'Visited by InstanceTree_assertSuccessor'
,
self
.
instance_tree
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_assert_instance_tree_successor
,
self
.
instance_tree
,
'InstanceTree_assertSuccessor'
)
class
TestSlapOSFreeComputePartitionAlarm
(
SlapOSTestCaseMixin
):
...
...
@@ -170,16 +143,12 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'destroy_requested'
)
self
.
software_instance
.
invalidate
()
self
.
tic
()
self
.
_simulateScript
(
'SoftwareInstance_tryToUnallocatePartition'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToUnallocatePartition'
)
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToUnallocatePartition'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
,
self
.
software_instance
,
'SoftwareInstance_tryToUnallocatePartition'
)
def
test_alarm_unallocated
(
self
):
self
.
_makeComputeNode
()
...
...
@@ -187,16 +156,12 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'destroy_requested'
)
self
.
software_instance
.
invalidate
()
self
.
tic
()
self
.
_simulateScript
(
'SoftwareInstance_tryToUnallocatePartition'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToUnallocatePartition'
)
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToUnallocatePartition'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
,
self
.
software_instance
,
'SoftwareInstance_tryToUnallocatePartition'
)
def
test_alarm_validated
(
self
):
self
.
_makeComputeNode
()
...
...
@@ -204,31 +169,23 @@ class TestSlapOSFreeComputePartitionAlarm(SlapOSTestCaseMixin):
self
.
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'destroy_requested'
)
self
.
tic
()
self
.
_simulateScript
(
'SoftwareInstance_tryToUnallocatePartition'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToUnallocatePartition'
)
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToUnallocatePartition'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
,
self
.
software_instance
,
'SoftwareInstance_tryToUnallocatePartition'
)
def
test_alarm_start_requested
(
self
):
self
.
_makeComputeNode
()
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
partition
.
markBusy
()
self
.
tic
()
self
.
_simulateScript
(
'SoftwareInstance_tryToUnallocatePartition'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToUnallocatePartition'
)
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToUnallocatePartition'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
,
self
.
software_instance
,
'SoftwareInstance_tryToUnallocatePartition'
)
class
TestSlapOSFreeComputePartitionAlarmWithSlave
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
...
...
@@ -372,62 +329,30 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
self
.
assertEqual
(
sub_instance
.
getSlapState
(),
'destroy_requested'
)
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
):
self
.
instance_tree
.
archive
()
self
.
tic
()
self
.
_simulateScript
(
'SoftwareInstance_tryToGarbageCollect'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroyed_root_tree
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToGarbageCollect'
)
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToGarbageCollect'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroyed_root_tree
,
self
.
software_instance
,
'SoftwareInstance_tryToGarbageCollect'
)
def
test_alarm_invalidated
(
self
):
self
.
instance_tree
.
archive
()
self
.
software_instance
.
invalidate
()
self
.
tic
()
self
.
_simulateScript
(
'SoftwareInstance_tryToGarbageCollect'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroyed_root_tree
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToGarbageCollect'
)
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToGarbageCollect'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroyed_root_tree
,
self
.
software_instance
,
'SoftwareInstance_tryToGarbageCollect'
)
def
test_alarm_not_archived
(
self
):
self
.
tic
()
self
.
_simulateScript
(
'SoftwareInstance_tryToGarbageCollect'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroyed_root_tree
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToGarbageCollect'
)
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToGarbageCollect'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroyed_root_tree
,
self
.
software_instance
,
'SoftwareInstance_tryToGarbageCollect'
)
class
TestSlapOSComputeNode_checkAndUpdateCapacityScope
(
SlapOSTestCaseMixin
):
allocation_scope_to_test
=
'open/public'
...
...
@@ -573,35 +498,12 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
self
.
compute_node
.
setAccessStatus
(
"#access ok"
)
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
):
self
.
tic
()
self
.
_simulateComputeNode_checkAndUpdateCapacityScope
()
try
:
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'Visited by ComputeNode_checkAndUpdateCapacityScope'
,
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
,
self
.
compute_node
,
'ComputeNode_checkAndUpdateCapacityScope'
)
def
test_alarm_subscription
(
self
):
self
.
compute_node
.
edit
(
allocation_scope
=
'open/subscription'
)
...
...
@@ -615,31 +517,21 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by C
self
.
compute_node
.
edit
(
allocation_scope
=
'open/friend'
)
self
.
test_alarm
()
def
test_alarm_closed
(
self
):
self
.
compute_node
.
edit
(
allocation_scope
=
'close/outdated'
)
self
.
tic
()
self
.
_simulateComputeNode_checkAndUpdateCapacityScope
()
try
:
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropComputeNode_checkAndUpdateCapacityScope
()
self
.
assertNotEqual
(
'Visited by ComputeNode_checkAndUpdateCapacityScope'
,
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_non_public
(
self
):
self
.
compute_node
.
edit
(
allocation_scope
=
'close'
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
,
self
.
compute_node
,
'ComputeNode_checkAndUpdateCapacityScope'
)
def
test_alarm_invalidated
(
self
):
self
.
compute_node
.
invalidate
()
self
.
tic
()
self
.
_simulateComputeNode_checkAndUpdateCapacityScope
()
try
:
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropComputeNode_checkAndUpdateCapacityScope
()
self
.
assertNotEqual
(
'Visited by ComputeNode_checkAndUpdateCapacityScope'
,
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
,
self
.
compute_node
,
'ComputeNode_checkAndUpdateCapacityScope'
)
class
TestSlapOSGarbageCollectStoppedRootTreeAlarm
(
SlapOSTestCaseMixin
):
...
...
@@ -711,29 +603,20 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
def
test_alarm
(
self
):
instance
=
self
.
createInstance
()
self
.
_simulateScript
(
'SoftwareInstance_tryToStopCollect'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_stop_collect_instance
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToStopCollect'
)
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToStopCollect'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_stop_collect_instance
,
instance
,
'SoftwareInstance_tryToStopCollect'
)
def
test_alarm_invalidated
(
self
):
instance
=
self
.
createInstance
()
instance
.
invalidate
()
self
.
tic
()
self
.
_simulateScript
(
'SoftwareInstance_tryToStopCollect'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_stop_collect_instance
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToStopCollect'
)
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToStopCollect'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_stop_collect_instance
,
instance
,
'SoftwareInstance_tryToStopCollect'
)
class
TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm
(
SlapOSTestCaseMixin
):
...
...
@@ -946,45 +829,31 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
def
test_alarm
(
self
):
instance
=
self
.
createInstance
()
self
.
tic
()
self
.
_simulateScript
(
"SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree"
)
try
:
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
,
instance
,
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
def
test_alarm_invalidated
(
self
):
instance
=
self
.
createInstance
()
instance
.
invalidate
()
self
.
tic
()
self
.
_simulateScript
(
"SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree"
)
try
:
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
,
instance
,
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
def
test_alarm_allocated
(
self
):
instance
=
self
.
createInstance
()
partition
=
self
.
createComputePartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
self
.
_simulateScript
(
"SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree"
)
try
:
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
,
instance
,
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
class
TestSlapOSGarbageCollectUnlinkedInstanceAlarm
(
SlapOSTestCaseMixin
):
...
...
@@ -1043,24 +912,6 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
sub_instance
.
getSpecialise
())
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
):
instance
=
self
.
createInstance
()
partition
=
self
.
createComputePartition
()
...
...
@@ -1190,28 +1041,19 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
instance0
=
self
.
doRequestInstance
(
instance
,
'instance0'
)
self
.
assertEqual
(
instance
.
getSuccessorReference
(),
instance0
.
getReference
())
self
.
_simulateSoftwareInstance_tryToGarbageUnlinkedInstance
()
try
:
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropSoftwareInstance_tryToGarbageUnlinkedInstance
()
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance'
,
instance0
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
# Remove successor link
instance
.
edit
(
successor_list
=
[])
self
.
_simulateSoftwareInstance_tryToGarbageUnlinkedInstance
()
self
.
tic
()
try
:
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropSoftwareInstance_tryToGarbageUnlinkedInstance
()
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance'
,
instance0
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
def
test_alarm_search_inlinked_instance_slave
(
self
):
instance
=
self
.
createInstance
()
...
...
@@ -1220,17 +1062,19 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self
.
tic
()
slave_instance0
=
self
.
doRequestInstance
(
instance
,
'slaveInstance0'
,
True
)
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
=
[])
self
.
tic
()
try
:
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropSoftwareInstance_tryToGarbageUnlinkedInstance
()
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToGarbageUnlinkedInstance'
,
slave_instance0
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
slave_instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
class
TestSlapOSInvalidateDestroyedInstance
(
SlapOSTestCaseMixin
):
...
...
@@ -1301,24 +1145,6 @@ class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
self
.
assertEqual
(
instance
.
getValidationState
(),
"validated"
)
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
):
instance
=
self
.
createSoftwareInstance
()
partition
=
self
.
createComputePartition
()
...
...
@@ -1327,16 +1153,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
self
.
tic
()
self
.
_simulateSoftwareInstance_tryToInvalidateIfDestroyed
()
try
:
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
.
\
activeSense
()
self
.
tic
()
finally
:
self
.
_dropSoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToInvalidateIfDestroyed'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
def
test_alarm_software_instance_invalidated
(
self
):
instance
=
self
.
createSoftwareInstance
()
...
...
@@ -1345,16 +1166,11 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
self
.
tic
()
self
.
_simulateSoftwareInstance_tryToInvalidateIfDestroyed
()
try
:
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
.
\
activeSense
()
self
.
tic
()
finally
:
self
.
_dropSoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToInvalidateIfDestroyed'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
def
test_alarm_software_instance_matching
(
self
):
instance
=
self
.
createSoftwareInstance
()
...
...
@@ -1363,13 +1179,8 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
self
.
tic
()
self
.
_simulateSoftwareInstance_tryToInvalidateIfDestroyed
()
try
:
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
.
\
activeSense
()
self
.
tic
()
finally
:
self
.
_dropSoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToInvalidateIfDestroyed'
,
instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.py
View file @
0f7c72df
...
...
@@ -209,6 +209,10 @@ return True""" )
self
.
software_instance
.
getUrlString
())
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
,
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
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
...
...
@@ -226,6 +230,10 @@ return True""" )
self
.
partition
)
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
,
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
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
...
...
@@ -259,6 +267,10 @@ return True""" )
source_administration
=
person_user
.
getRelativeUrl
(),
destination_section
=
self
.
person_user
.
getRelativeUrl
(),
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
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
...
...
@@ -292,6 +304,10 @@ return True""" )
source_administration
=
person_user
.
getRelativeUrl
(),
destination_section
=
self
.
person_user
.
getRelativeUrl
(),
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
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.xml
View file @
0f7c72df
...
...
@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSCloudAllocationAlarm
</string>
</value>
...
...
@@ -55,28 +49,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -89,7 +68,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow.py
View file @
0f7c72df
...
...
@@ -641,7 +641,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
1
),
compute_node
.
getReference
())
self
.
assertEqual
(
'validated'
,
compute_node
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
compute_node
.
getAllocationScope
())
self
.
assertEqual
(
'
open
'
,
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
'
close
'
,
compute_node
.
getCapacityScope
())
def
test_request_notReindexedCompute
(
self
):
person
=
self
.
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
...
...
@@ -682,7 +682,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
1
),
compute_node
.
getReference
())
self
.
assertEqual
(
'validated'
,
compute_node
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
compute_node
.
getAllocationScope
())
self
.
assertEqual
(
'
open
'
,
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
'
close
'
,
compute_node
.
getCapacityScope
())
self
.
tic
()
...
...
@@ -708,7 +708,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
1
),
compute_node
.
getReference
())
self
.
assertEqual
(
'validated'
,
compute_node
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
compute_node
.
getAllocationScope
())
self
.
assertEqual
(
'
open
'
,
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
'
close
'
,
compute_node
.
getCapacityScope
())
# and now another one
person
.
requestComputeNode
(
compute_node_title
=
compute_node_title2
)
...
...
@@ -735,7 +735,7 @@ class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
2
),
compute_node2
.
getReference
())
self
.
assertEqual
(
'validated'
,
compute_node2
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
compute_node2
.
getAllocationScope
())
self
.
assertEqual
(
'
open
'
,
compute_node2
.
getCapacityScope
())
self
.
assertEqual
(
'
close
'
,
compute_node2
.
getCapacityScope
())
def
test_request_duplicatedComputeNode
(
self
):
person
=
self
.
portal
.
portal_membership
.
getAuthenticatedMember
().
getUserValue
()
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow.xml
View file @
0f7c72df
...
...
@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSCloudPersonSlapInterfaceWorkflow
</string>
</value>
...
...
@@ -61,28 +55,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -95,7 +74,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -104,7 +83,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/ComputeNode_checkState.py
View file @
0f7c72df
...
...
@@ -7,10 +7,6 @@ if not person or \
portal
.
ERP5Site_isSupportRequestCreationClosed
():
return
if
context
.
getAllocationScope
(
"open"
).
startswith
(
"close"
):
context
.
setMonitorScope
(
"disabled"
)
return
reference
=
context
.
getReference
()
compute_node_title
=
context
.
getTitle
()
...
...
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm_monitoring/SupportRequest_recheckMonitoring.py
View file @
0f7c72df
#
# 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
if
context
.
getSimulationState
()
==
"invalidated"
:
...
...
@@ -103,17 +96,11 @@ if aggregate_portal_type == "Instance Tree":
if
instance
.
getAggregate
()
is
not
None
:
compute_node
=
instance
.
getAggregateValue
().
getParentValue
()
if
instance
.
getPortalType
()
==
"Software Instance"
and
\
compute_node
.
getAllocationScope
()
in
[
"open/public"
,
"open/friend"
,
"open/subscription"
]
and
\
instance
.
getSlapState
()
==
"start_requested"
and
\
instance
.
SoftwareInstance_hasReportedError
():
message_list
.
append
(
"%s has error (%s, %s at %s scope %s)"
%
(
instance
.
getReference
(),
instance
.
getTitle
(),
instance
.
getUrlString
(),
compute_node
.
getReference
(),
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
:
message_list
.
append
(
"%s is not allocated"
%
instance
.
getReference
())
return
","
.
join
(
message_list
)
...
...
master/bt5/slapos_crm/TestTemplateItem/portal_components/test.erp5.testSlapOSCRMAlarm.py
View file @
0f7c72df
...
...
@@ -502,6 +502,19 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
slapos_crm_check_compute_node_state
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
,
monitor_scope
=
None
):
self
.
_makeComputeNode
()
...
...
@@ -532,15 +545,15 @@ class TestSlapOSCrmMonitoringCheckComputeNodeState(SlapOSTestCaseMixinWithAbort)
def
test_alarm_check_compute_node_state_closed_forever_compute_node
(
self
):
self
.
_test_alarm_check_compute_node_state_not_selected
(
allocation_scope
=
'close
d
/forever'
)
allocation_scope
=
'close/forever'
)
def
test_alarm_check_compute_node_state_closed_mantainence_compute_node
(
self
):
self
.
_test_alarm_check_compute_node_state_
not_
selected
(
allocation_scope
=
'close
d
/maintenance'
)
self
.
_test_alarm_check_compute_node_state_selected
(
allocation_scope
=
'close/maintenance'
)
def
test_alarm_check_compute_node_state_closed_termination_compute_node
(
self
):
self
.
_test_alarm_check_compute_node_state_
not_
selected
(
allocation_scope
=
'close
d
/termination'
)
self
.
_test_alarm_check_compute_node_state_selected
(
allocation_scope
=
'close/termination'
)
class
TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation
(
SlapOSTestCaseMixinWithAbort
):
...
...
@@ -601,25 +614,48 @@ class TestSlapOSCrmMonitoringCheckComputeNodeSoftwareInstallation(SlapOSTestCase
slapos_crm_check_software_installation_state
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
.
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_software_installation_state
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
):
self
.
_test_alarm_not_run_on_close
(
'close/forever'
)
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
):
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
):
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
):
...
...
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5Alarm.py
View file @
0f7c72df
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import
transaction
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixinWithAbort
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
DateTime
import
DateTime
from
zExceptions
import
Unauthorized
class
TestSlapOSERP5CleanupActiveProcess
(
SlapOSTestCaseMixinWithAbort
):
def
_simulateActiveProcess_deleteSelf
(
self
):
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
check_cleanup_active_process_alarm
(
self
,
date
,
test_method
):
def
verify_getCreationDate_call
(
*
args
,
**
kwargs
):
return
date
ActiveProcessClass
=
self
.
portal
.
portal_types
.
getPortalTypeClass
(
...
...
@@ -44,6 +24,13 @@ context.edit(description=description)""")
)
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._simulateActiveProcess_deleteSelf()
try:
...
...
@@ -56,13 +43,13 @@ context.edit(description=description)""")
assert_method(active_process.getDescription('').
\
endswith("Visited by ActiveProcess_deleteSelf"),
active_process
.
getDescription
(
''
))
active_process.getDescription(''))
"""
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
):
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
):
...
...
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5Alarm.xml
View file @
0f7c72df
...
...
@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSERP5Alarm
</string>
</value>
...
...
@@ -55,28 +49,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -89,7 +68,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
...
...
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5InteractionWorkflow.py
View file @
0f7c72df
...
...
@@ -47,7 +47,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node
.
edit
(
allocation_scope
=
allocation_scope
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'
open
'
)
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'
close
'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'enabled'
)
return
compute_node
...
...
@@ -96,7 +96,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'close'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'
dis
abled'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'
en
abled'
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
None
)
self
.
commit
()
...
...
@@ -107,8 +107,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node
.
edit
(
allocation_scope
=
'open/personal'
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'
open
'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'
dis
abled'
)
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'
close
'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'
en
abled'
)
return
compute_node
def
test_ComputeNode_setAllocationScope_personal
(
self
):
...
...
@@ -169,7 +169,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
compute_node
.
edit
(
allocation_scope
=
'open/friend'
)
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'
open
'
)
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'
close
'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'enabled'
)
return
compute_node
...
...
@@ -205,7 +205,8 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
def
_test_ComputeNode_setAllocationScope_closed
(
self
,
source_administration
=
None
,
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'
,
capacity_scope
=
None
,
monitor_scope
=
None
,
...
...
@@ -217,7 +218,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'close'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'disabled'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
monitor_scope
)
self
.
commit
()
compute_node
.
edit
(
allocation_scope
=
None
)
...
...
@@ -230,12 +231,12 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self
.
commit
()
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
'close'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
'disabled'
)
self
.
assertEqual
(
compute_node
.
getMonitorScope
(),
monitor_scope
)
return
compute_node
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
):
person
=
self
.
makePerson
()
...
...
@@ -243,7 +244,7 @@ class TestSlapOSERP5InteractionWorkflowComputeNodeSetAllocationScope(
self
.
assertNotIn
(
person
.
getDefaultEmailCoordinateText
(),
[
None
,
""
])
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
.
getDestinationSectionList
(),
...
...
master/bt5/slapos_erp5/WorkflowTemplateItem/portal_workflow/slapos_erp5_interaction_workflow/script_ComputeNode_updateAllocation.py
View file @
0f7c72df
...
...
@@ -3,18 +3,17 @@ allocation_scope = compute_node.getAllocationScope()
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'
if
allocation_scope
in
[
'open/public'
,
'open/subscription'
,
'open/friend'
]:
monitor_scope
=
'enabled'
elif
allocation_scope
==
'open/personal'
:
monitor_scope
=
compute_node
.
getMonitorScope
(
"disabled"
)
else
:
monitor_scope
=
'disabled'
edit_kw
[
'capacity_scope'
]
=
'close'
if
compute_node
.
getMonitorScope
()
is
None
:
edit_kw
[
'monitor_scope'
]
=
'enabled'
edit_kw
[
'monitor_scope'
]
=
monitor_scope
if
allocation_scope
==
"close/forever"
:
edit_kw
[
'monitor_scope'
]
=
'disabled'
self_person
=
compute_node
.
getSourceAdministrationValue
(
portal_type
=
"Person"
)
if
self_person
is
None
:
...
...
master/bt5/slapos_jio/ActionTemplateItem/portal_types/Compute%20Node/update_allocation_scope.xml
deleted
100644 → 0
View file @
06a27d31
<?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>
master/bt5/slapos_jio/ActionTemplateItem/portal_types/Compute%20Node/update_category.xml
deleted
100644 → 0
View file @
06a27d31
<?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>
master/bt5/slapos_jio/bt/template_action_path_list
View file @
0f7c72df
...
...
@@ -6,8 +6,6 @@ Compute Node | new_ticket
Compute Node | request_certificate_action
Compute Node | revoke_certificate
Compute Node | slaposjs_view
Compute Node | update_allocation_scope
Compute Node | update_category
Computer Network Module | slaposjs_view
Computer Network | slaposjs_view
ERP5 Login | slaposjs_view
...
...
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/Alarm_ComputeNodeCheckUpgradeSoftwareRelease.py
View file @
0f7c72df
portal
=
context
.
getPortalObject
()
default_allocation_scope_uid
=
[
category
.
getUid
()
\
for
category
in
portal
.
portal_categories
.
allocation_scope
.
open
.
objectValues
()]
default_upgrade_scope_uid
=
[
portal
.
portal_categories
.
upgrade_scope
.
auto
.
getUid
(),
portal
.
portal_categories
.
upgrade_scope
.
confirmation
.
getUid
()
]
if
default_allocation_scope_uid
:
if
default_upgrade_scope_uid
:
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
'Compute Node'
,
validation_state
=
'validated'
,
default_
allocation_scope_uid
=
default_allocation
_scope_uid
,
default_
upgrade_scope_uid
=
default_upgrade
_scope_uid
,
method_id
=
'ComputeNode_checkAndCreateUpgradeDecision'
,
activate_kw
=
{
'tag'
:
tag
}
)
...
...
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/InstanceTree_createUpgradeDecision.py
View file @
0f7c72df
...
...
@@ -40,9 +40,6 @@ if slave_upgrade:
if
url_string
!=
instance_tree
.
getUrlString
():
newer_release
=
context
.
portal_catalog
.
getResultValue
(
portal_type
=
'Software Release'
,
url_string
=
url_string
)
else
:
if
not
partition
.
getParentValue
().
getAllocationScopeUid
()
in
[
category
.
getUid
()
\
for
category
in
portal
.
portal_categories
.
allocation_scope
.
open
.
objectValues
()]:
return
newer_release
=
instance_tree
.
\
InstanceTree_getUpgradableSoftwareRelease
()
if
newer_release
is
None
:
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
View file @
0f7c72df
# 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
class
TestSlapOSUpgradeDecisionProcess
(
SlapOSTestCaseMixin
):
...
...
@@ -32,132 +51,83 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
start
()
self
.
tic
()
self
.
_simulateScript
(
'UpgradeDecision_processUpgrade'
,
'True'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_started
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'UpgradeDecision_processUpgrade'
)
self
.
assertEqual
(
'Visited by UpgradeDecision_processUpgrade'
,
upgrade_decision
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_started
,
upgrade_decision
,
'UpgradeDecision_processUpgrade'
)
def
test_alarm_upgrade_decision_process_planned
(
self
):
upgrade_decision
=
self
.
_makeUpgradeDecision
(
confirm
=
0
)
upgrade_decision
.
plan
()
self
.
tic
()
self
.
_simulateScript
(
'UpgradeDecision_notify'
,
'True'
)
try
:
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'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_planned
,
upgrade_decision
,
'UpgradeDecision_notify'
)
def
test_alarm_upgrade_decision_process_stopped
(
self
):
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
start
()
upgrade_decision
.
stop
()
self
.
tic
()
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'
])
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'
)
def
test_alarm_instance_tree_create_upgrade_decision
(
self
):
instance_tree
=
self
.
_makeInstanceTree
()
instance_tree2
=
self
.
_makeInstanceTree
()
instance_tree3
=
self
.
_makeInstanceTree
()
self
.
tic
()
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'
])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_pdm_instance_tree_create_upgrade_decision
,
instance_tree
,
'InstanceTree_createUpgradeDecision'
)
def
test_alarm_create_upgrade_decision_destroyed_instance_tree
(
self
):
instance_tree
=
self
.
_makeInstanceTree
(
slap_state
=
"destroy_requested"
)
instance_tree2
=
self
.
_makeInstanceTree
(
slap_state
=
"destroy_requested"
)
self
.
tic
()
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
.
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'
])
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_pdm_instance_tree_create_upgrade_decision
,
instance_tree
,
'InstanceTree_createUpgradeDecision'
)
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.xml
View file @
0f7c72df
...
...
@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSPDMAlarm
</string>
</value>
...
...
@@ -55,28 +49,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -89,7 +68,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
View file @
0f7c72df
...
...
@@ -219,7 +219,15 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self
.
tic
()
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
):
person
=
self
.
_makePerson
()
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.xml
View file @
0f7c72df
...
...
@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSPDMCreateUpgradeDecisionSkins
</string>
</value>
...
...
@@ -55,28 +49,13 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -89,7 +68,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
...
...
master/bt5/slapos_pdm/WorkflowTemplateItem/portal_workflow/upgrade_slap_interface_workflow/script_UpgradeDecision_reviewUpgrade.py
View file @
0f7c72df
...
...
@@ -31,11 +31,11 @@ if instance_tree is not None:
compute_node
=
upgrade_decision
.
UpgradeDecision_getAggregateValue
(
"Compute Node"
)
if
compute_node
is
not
None
:
if
compute_node
.
getUpgradeScope
()
in
[
'never'
,
'disabled'
]:
upgrade_decision
.
cancel
(
"Upgrade scope was disabled on the related
Instance Tre
e"
)
upgrade_decision
.
cancel
(
"Upgrade scope was disabled on the related
Compute Nod
e"
)
return
elif
compute_node
.
getAllocationScope
()
in
[
"closed/forever"
,
"closed/termination"
]
:
upgrade_decision
.
cancel
(
comment
=
"Compute Node is close
d
."
)
elif
compute_node
.
getAllocationScope
()
==
"close/forever"
:
upgrade_decision
.
cancel
(
comment
=
"Compute Node is close
forever
."
)
return
already_deployed
=
len
(
portal
.
portal_catalog
(
limit
=
1
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment