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
Thomas Gambier
slapos.core
Commits
4bc490ad
Commit
4bc490ad
authored
Nov 27, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_pdm: Fix up cancellation of Upgrade Decision when monitor is disabled
parent
2b3288f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
2 deletions
+65
-2
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/UpgradeDecisionLine_cancel.py
...tem/portal_skins/slapos_pdm/UpgradeDecisionLine_cancel.py
+6
-2
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
...ateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
+59
-0
No files found.
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/UpgradeDecisionLine_cancel.py
View file @
4bc490ad
...
@@ -4,6 +4,9 @@ software_release = context.getAggregateValue(portal_type="Software Release")
...
@@ -4,6 +4,9 @@ software_release = context.getAggregateValue(portal_type="Software Release")
upgrade_decision
=
context
.
getParentValue
()
upgrade_decision
=
context
.
getParentValue
()
if
upgrade_decision
.
getSimulationState
()
==
"cancelled"
:
return
if
software_release
.
getValidationState
()
==
"archived"
:
if
software_release
.
getValidationState
()
==
"archived"
:
upgrade_decision
.
cancel
(
comment
=
"Software Release is archived."
)
upgrade_decision
.
cancel
(
comment
=
"Software Release is archived."
)
return
return
...
@@ -12,7 +15,7 @@ if hosting_subscription is not None:
...
@@ -12,7 +15,7 @@ if hosting_subscription is not None:
if
hosting_subscription
.
getUpgradeScope
()
in
[
'never'
,
'disabled'
]:
if
hosting_subscription
.
getUpgradeScope
()
in
[
'never'
,
'disabled'
]:
upgrade_decision
.
cancel
(
"Upgrade scope was disabled on the related Hosting Subscription"
)
upgrade_decision
.
cancel
(
"Upgrade scope was disabled on the related Hosting Subscription"
)
if
hosting_subscription
.
getSlapState
()
==
"destroy_requested"
:
el
if
hosting_subscription
.
getSlapState
()
==
"destroy_requested"
:
upgrade_decision
.
cancel
(
comment
=
"Hosting Subscription is destroyed."
)
upgrade_decision
.
cancel
(
comment
=
"Hosting Subscription is destroyed."
)
elif
hosting_subscription
.
getUrlString
()
==
software_release
.
getUrlString
():
elif
hosting_subscription
.
getUrlString
()
==
software_release
.
getUrlString
():
...
@@ -24,8 +27,9 @@ computer = context.getAggregateValue(portal_type="Computer")
...
@@ -24,8 +27,9 @@ computer = context.getAggregateValue(portal_type="Computer")
if
computer
is
not
None
:
if
computer
is
not
None
:
if
computer
.
getUpgradeScope
()
in
[
'never'
,
'disabled'
]:
if
computer
.
getUpgradeScope
()
in
[
'never'
,
'disabled'
]:
upgrade_decision
.
cancel
(
"Upgrade scope was disabled on the related Hosting Subscription"
)
upgrade_decision
.
cancel
(
"Upgrade scope was disabled on the related Hosting Subscription"
)
return
if
computer
.
getAllocationScope
()
in
[
"closed/forever"
,
"closed/termination"
]:
el
if
computer
.
getAllocationScope
()
in
[
"closed/forever"
,
"closed/termination"
]:
upgrade_decision
.
cancel
(
comment
=
"Computer is closed."
)
upgrade_decision
.
cancel
(
comment
=
"Computer is closed."
)
return
return
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMSkins.py
View file @
4bc490ad
...
@@ -1559,6 +1559,19 @@ ${new_software_release_url}""",
...
@@ -1559,6 +1559,19 @@ ${new_software_release_url}""",
self
.
assertEqual
(
event
.
getSimulationState
(),
"delivered"
)
self
.
assertEqual
(
event
.
getSimulationState
(),
"delivered"
)
def
testUpgradeDecisionLine_cancel_already_cancelled
(
self
):
software_release
=
self
.
_makeSoftwareRelease
()
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
cancel
(
comment
=
"Cancelled by the test"
)
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
])
self
.
tic
()
upgrade_decision_line
.
UpgradeDecisionLine_cancel
()
self
.
assertEqual
(
'cancelled'
,
upgrade_decision
.
getSimulationState
())
workflow_history_list
=
upgrade_decision
.
Base_getWorkflowHistoryItemList
(
'upgrade_decision_workflow'
,
display
=
0
)
self
.
assertEqual
(
"Cancelled by the test"
,
workflow_history_list
[
-
1
].
comment
)
def
testUpgradeDecisionLine_cancel_archived_software_release
(
self
):
def
testUpgradeDecisionLine_cancel_archived_software_release
(
self
):
software_release
=
self
.
_makeSoftwareRelease
()
software_release
=
self
.
_makeSoftwareRelease
()
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
=
self
.
_makeUpgradeDecision
()
...
@@ -1617,6 +1630,52 @@ ${new_software_release_url}""",
...
@@ -1617,6 +1630,52 @@ ${new_software_release_url}""",
workflow_history_list
=
upgrade_decision
.
Base_getWorkflowHistoryItemList
(
'upgrade_decision_workflow'
,
display
=
0
)
workflow_history_list
=
upgrade_decision
.
Base_getWorkflowHistoryItemList
(
'upgrade_decision_workflow'
,
display
=
0
)
self
.
assertEqual
(
"Hosting Subscription is destroyed."
,
workflow_history_list
[
-
1
].
comment
)
self
.
assertEqual
(
"Hosting Subscription is destroyed."
,
workflow_history_list
[
-
1
].
comment
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'assert reference == "slapos-upgrade-delivered-computer.notification"
\
n
'
\
'return context.restrictedTraverse('
\
'context.REQUEST["testUpgradeDecisionLine_cancel_destroyed_hosting_subscription"])'
)
def
testUpgradeDecisionLine_cancel_destroyed_hosting_subscription_and_disabled_monitor
(
self
):
software_release
=
self
.
_makeSoftwareRelease
()
hosting_subscription
=
self
.
_makeFullHostingSubscription
(
software_release
.
getUrlString
())
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision_line
=
self
.
_makeUpgradeDecisionLine
(
upgrade_decision
)
upgrade_decision_line
.
setAggregateValueList
([
software_release
,
hosting_subscription
])
notification_message
=
self
.
portal
.
notification_message_module
.
newContent
(
portal_type
=
"Notification Message"
,
title
=
'Test NM title %s'
%
self
.
new_id
,
text_content_substitution_mapping_method_id
=
"NotificationMessage_getSubstitutionMappingDictFromArgument"
,
text_content
=
"""${software_product_title}
${computer_title}
${computer_reference}
${software_release_name}
${software_release_reference}
${new_software_release_url}"""
,
content_type
=
'text/html'
,
)
self
.
portal
.
REQUEST
\
[
'testUpgradeDecisionLine_cancel_destroyed_hosting_subscription'
]
=
\
notification_message
.
getRelativeUrl
()
self
.
tic
()
kw
=
dict
(
software_release
=
hosting_subscription
.
getUrlString
(),
software_type
=
hosting_subscription
.
getSourceReference
(),
instance_xml
=
hosting_subscription
.
getTextContent
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
)
hosting_subscription
.
requestDestroy
(
**
kw
)
hosting_subscription
.
setMonitorScope
(
"disabled"
)
self
.
tic
()
upgrade_decision_line
.
UpgradeDecisionLine_cancel
()
self
.
assertEqual
(
'cancelled'
,
upgrade_decision
.
getSimulationState
())
workflow_history_list
=
upgrade_decision
.
Base_getWorkflowHistoryItemList
(
'upgrade_decision_workflow'
,
display
=
0
)
self
.
assertEqual
(
"Hosting Subscription is destroyed."
,
workflow_history_list
[
-
1
].
comment
)
@
simulate
(
'NotificationTool_getDocumentValue'
,
@
simulate
(
'NotificationTool_getDocumentValue'
,
'reference=None'
,
'reference=None'
,
'assert reference == "slapos-upgrade-delivered-computer.notification"
\
n
'
\
'assert reference == "slapos-upgrade-delivered-computer.notification"
\
n
'
\
...
...
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