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
Xavier Thompson
slapos.core
Commits
c602883e
Commit
c602883e
authored
Feb 03, 2023
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_pdm: drop _simulateScript and add more tests
parent
d4216bd4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
138 deletions
+87
-138
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
No files found.
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
View file @
c602883e
# 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
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_stopped
,
upgrade_decision
,
'UpgradeDecision_notifyDelivered'
)
def
_test_alarm_compute_node_create_upgrade_decision
(
self
,
allocation_scope
,
upgrade_scope
):
compute_node
=
self
.
_makeComputeNode
(
allocation_scope
=
allocation_scope
)[
0
]
compute_node
.
setUpgradeScope
(
upgrade_scope
)
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_pdm_compute_node_create_upgrade_decision
,
compute_node
,
'ComputeNode_checkAndCreateUpgradeDecision'
)
def
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
self
,
allocation_scope
,
upgrade_scope
):
compute_node
=
self
.
_makeComputeNode
(
allocation_scope
=
allocation_scope
)[
0
]
compute_node
.
setUpgradeScope
(
upgrade_scope
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_pdm_compute_node_create_upgrade_decision
,
compute_node
,
'ComputeNode_checkAndCreateUpgradeDecision'
)
def
test_alarm_compute_node_create_upgrade_decision_auto
(
self
):
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/public'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/personal'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/friend'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/subscription'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/outdated'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/maintanance'
,
'auto'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/termination'
,
'auto'
)
def
test_alarm_compute_node_create_upgrade_decision_ask_confirmation
(
self
):
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/public'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/personal'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/friend'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'open/subscription'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/outdated'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/maintanance'
,
'confirmation'
)
self
.
_test_alarm_compute_node_create_upgrade_decision
(
'close/termination'
,
'confirmation'
)
def
test_alarm_compute_node_create_upgrade_decision_never
(
self
):
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'open/public'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'open/personal'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'open/friend'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'open/subscription'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'close/outdated'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'close/maintanance'
,
'never'
)
self
.
_test_alarm_compute_node_create_upgrade_decision_not_visited
(
'close/termination'
,
'never'
)
self
.
_simulateScript
(
'UpgradeDecision_notifyDelivered'
,
'True'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_stopped
.
\
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'UpgradeDecision_notifyDelivered'
)
self
.
assertEqual
(
'Visited by UpgradeDecision_notifyDelivered'
,
upgrade_decision
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_compute_node_create_upgrade_decision
(
self
):
compute_node
=
self
.
_makeComputeNode
(
allocation_scope
=
'open/public'
)[
0
]
compute_node2
=
self
.
_makeComputeNode
(
allocation_scope
=
'open/personal'
)[
0
]
compute_node3
=
self
.
_makeComputeNode
(
allocation_scope
=
'open/friend'
)[
0
]
self
.
tic
()
self
.
_simulateScript
(
'ComputeNode_checkAndCreateUpgradeDecision'
,
'True'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_pdm_compute_node_create_upgrade_decision
.
\
activeSense
()
self
.
tic
()
finally
:
self
.
_dropScript
(
'ComputeNode_checkAndCreateUpgradeDecision'
)
self
.
assertEqual
(
'Visited by ComputeNode_checkAndCreateUpgradeDecision'
,
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
assertEqual
(
'Visited by ComputeNode_checkAndCreateUpgradeDecision'
,
compute_node2
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
assertEqual
(
'Visited by ComputeNode_checkAndCreateUpgradeDecision'
,
compute_node3
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_instance_tree_create_upgrade_decision
(
self
):
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 @
c602883e
...
...
@@ -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>
...
...
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