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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
f6448a21
Commit
f6448a21
authored
Jan 19, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_pdm: drop deprecated tests
parent
a9020c91
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
383 deletions
+0
-383
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
...ents/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
+0
-383
No files found.
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
View file @
f6448a21
...
@@ -20,99 +20,9 @@
...
@@ -20,99 +20,9 @@
##############################################################################
##############################################################################
from
erp5.component.test.testSlapOSPDMSkins
import
TestSlapOSPDMMixinSkins
from
erp5.component.test.testSlapOSPDMSkins
import
TestSlapOSPDMMixinSkins
import
transaction
class
TestSlapOSPDMCreateUpgradeDecisionSkins
(
TestSlapOSPDMMixinSkins
):
class
TestSlapOSPDMCreateUpgradeDecisionSkins
(
TestSlapOSPDMMixinSkins
):
def
_makeTreeForTestSlapOSPDMCreateUpgradeDecisionSkins
(
self
,
software_release_url
,
software_type
,
project
):
self
.
instance_tree
,
self
.
instance
=
self
.
_createInstance
(
software_release_url
,
software_type
,
project
)
self
.
shared_instance_tree
,
self
.
shared_instance
=
self
.
_createInstance
(
software_release_url
,
software_type
,
project
,
True
)
self
.
instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
shared_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
partition
.
markBusy
()
self
.
tic
()
def
afterSetUpXXX
(
self
):
TestSlapOSPDMMixinSkins
.
afterSetUp
(
self
)
# XXX Stop modifying system preferences
# as it prevents using test on live system
preference
=
self
.
portal
.
portal_preferences
.
getActiveSystemPreference
()
preference
.
setPreferredCloudContractEnabled
(
True
)
self
.
tic
()
self
.
project
=
self
.
addProject
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_makeSoftwareProductCatalog
(
self
.
project
)
self
.
_installSoftwareOnTheComputeNode
([
self
.
previous_software_release
.
getUrlString
(),
self
.
new_software_release
.
getUrlString
()
])
self
.
person
=
self
.
makePerson
(
self
.
project
)
self
.
tic
()
self
.
_makeTreeForTestSlapOSPDMCreateUpgradeDecisionSkins
(
self
.
previous_software_release
.
getUrlString
(),
self
.
software_product
.
contentValues
(
portal_type
=
'Software Product Type Variation'
)[
0
].
getTitle
(),
self
.
project
)
def
_makeSoftwareProductCatalog
(
self
,
project
):
self
.
software_product
=
self
.
_makeSoftwareProduct
(
project
,
new_id
=
self
.
generateNewId
(),
url
=
self
.
generateNewSoftwareReleaseUrl
(),
software_type
=
'foobartype'
)
self
.
previous_software_release
=
self
.
_makeSoftwareRelease
(
self
.
software_product
)
self
.
new_software_release
=
self
.
_makeSoftwareRelease
(
self
.
software_product
)
self
.
addAllocationSupply
(
"for compute node"
,
self
.
compute_node
,
self
.
software_product
,
self
.
new_software_release
,
self
.
software_product
.
contentValues
(
portal_type
=
'Software Product Type Variation'
)[
0
],
)
self
.
tic
()
def
_installSoftwareOnTheComputeNode
(
self
,
software_release_url_list
):
for
software_release
in
software_release_url_list
:
software_installation
=
self
.
portal
.
software_installation_module
\
.
newContent
(
portal_type
=
'Software Installation'
,
url_string
=
software_release
,
aggregate
=
self
.
compute_node
.
getRelativeUrl
())
software_installation
.
validate
()
software_installation
.
requestStart
()
self
.
tic
()
def
_createInstance
(
self
,
url_string
,
software_type
,
project
,
shared
=
False
):
instance_tree
=
self
.
portal
.
instance_tree_module
\
.
template_instance_tree
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance_tree
.
edit
(
)
instance_tree
.
validate
()
instance_tree
.
edit
(
title
=
self
.
generateNewSoftwareTitle
(),
reference
=
"TESTHS-%s"
%
self
.
generateNewId
(),
destination_section_value
=
self
.
person
,
follow_up_value
=
project
)
request_kw
=
dict
(
software_release
=
url_string
,
software_type
=
software_type
,
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
shared
,
software_title
=
instance_tree
.
getTitle
(),
state
=
'started'
,
project_reference
=
project
.
getReference
()
)
instance_tree
.
requestStart
(
**
request_kw
)
instance_tree
.
requestInstance
(
**
request_kw
)
instance
=
instance_tree
.
getSuccessorValue
()
self
.
tic
()
return
instance_tree
,
instance
def
test_createUpgradeDecision_destroyed_instance
(
self
):
def
test_createUpgradeDecision_destroyed_instance
(
self
):
instance_tree
=
self
.
portal
.
instance_tree_module
.
newContent
(
instance_tree
=
self
.
portal
.
instance_tree_module
.
newContent
(
portal_type
=
"Instance Tree"
portal_type
=
"Instance Tree"
...
@@ -293,296 +203,3 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
...
@@ -293,296 +203,3 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
##########################################################################
# tocheck
##########################################################################
def
test_tocheck_InstanceTree_createUpgradeDecision
(
self
):
upgrade_decision
=
self
.
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
'started'
,
upgrade_decision
.
getSimulationState
())
shared_upgrade_decision
=
self
.
shared_instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
None
,
shared_upgrade_decision
)
# simulate upgrade of the instance tree
upgrade_decision
.
stop
()
upgrade_decision
.
deliver
()
self
.
instance_tree
.
edit
(
url_string
=
self
.
new_software_release
.
getUrlString
())
self
.
instance
.
edit
(
url_string
=
self
.
new_software_release
.
getUrlString
())
self
.
tic
()
shared_upgrade_decision
=
self
.
shared_instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
'started'
,
shared_upgrade_decision
.
getSimulationState
())
def
test_tocheck_InstanceTree_createUpgradeDecision_upgradeScopeDisabled
(
self
):
# check upgrade decision on HS
self
.
instance_tree
.
setUpgradeScope
(
'disabled'
)
self
.
tic
()
upgrade_decision
=
self
.
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
None
,
upgrade_decision
)
shared_upgrade_decision
=
self
.
shared_instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
None
,
shared_upgrade_decision
)
def
test_tocheckInstanceTree_createUpgradeDecision_no_newer
(
self
):
person
=
self
.
_makePerson
(
self
.
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
project
)
#, owner=person)
self
.
_makeComputePartitions
(
compute_node
)
software_product
=
self
.
_makeSoftwareProduct
(
self
.
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
url_string
=
software_release
.
getUrlString
()
self
.
_makeSoftwareInstallation
(
compute_node
,
url_string
)
self
.
tic
()
# Create Instance Tree
instance_tree
=
self
.
_makeFullInstanceTree
(
url_string
,
person
)
self
.
tic
()
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
upgrade_decision
,
None
)
self
.
_makeFullSoftwareInstance
(
instance_tree
,
url_string
)
self
.
_markComputePartitionBusy
(
compute_node
,
instance_tree
.
getSuccessorValue
())
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
tic
()
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
upgrade_decision
,
None
)
def
test_tocheckInstanceTree_createUpgradeDecision_closed_compute_node
(
self
):
person
=
self
.
_makePerson
(
self
.
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
project
,
allocation_scope
=
"close/outdated"
)
self
.
_makeComputePartitions
(
compute_node
)
software_product
=
self
.
_makeSoftwareProduct
(
self
.
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
url_string
=
software_release
.
getUrlString
()
self
.
_makeSoftwareInstallation
(
compute_node
,
url_string
)
# Create Instance Tree and Software Instance
instance_tree
=
self
.
_makeFullInstanceTree
(
url_string
,
person
)
self
.
_makeFullSoftwareInstance
(
instance_tree
,
url_string
)
self
.
_markComputePartitionBusy
(
compute_node
,
instance_tree
.
getSuccessorValue
())
# Install the Newest software release
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release2
.
getUrlString
())
self
.
tic
()
up_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
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
test_tocheckInstanceTree_createUpgradeDecision_create_once_transaction
(
self
):
person
=
self
.
_makePerson
(
self
.
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
project
,
allocation_scope
=
"open/personal"
)
self
.
_makeComputePartitions
(
compute_node
)
software_product
=
self
.
_makeSoftwareProduct
(
self
.
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
url_string
=
software_release
.
getUrlString
()
self
.
_makeSoftwareInstallation
(
compute_node
,
url_string
)
# Create Instance Tree and Software Instance
instance_tree
=
self
.
_makeFullInstanceTree
(
url_string
,
person
)
self
.
_makeFullSoftwareInstance
(
instance_tree
,
url_string
)
self
.
_markComputePartitionBusy
(
compute_node
,
instance_tree
.
getSuccessorValue
())
# Install the Newest software release
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release2
.
getUrlString
())
self
.
tic
()
up_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertNotEqual
(
up_decision
,
None
)
self
.
assertEqual
(
up_decision
.
getSimulationState
(),
'planned'
)
transaction
.
commit
()
# call a second time without tic
up_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
# no new Upgrade decision created
self
.
assertEqual
(
up_decision
,
None
)
def
test_tocheckInstanceTree_createUpgradeDecision
(
self
):
person
=
self
.
_makePerson
(
self
.
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
project
)
self
.
_makeComputePartitions
(
compute_node
)
software_product
=
self
.
_makeSoftwareProduct
(
self
.
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
url_string
=
software_release
.
getUrlString
()
self
.
_makeSoftwareInstallation
(
compute_node
,
url_string
)
# Create Instance Tree and Software Instance
instance_tree
=
self
.
_makeFullInstanceTree
(
url_string
,
person
)
self
.
_makeFullSoftwareInstance
(
instance_tree
,
url_string
)
self
.
_markComputePartitionBusy
(
compute_node
,
instance_tree
.
getSuccessorValue
())
# Install the Newest software release
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release2
.
getUrlString
())
self
.
tic
()
up_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
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
())
self
.
tic
()
up_decision2
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
up_decision2
,
None
)
def
test_tocheckInstanceTree_createUpgradeDecision_with_exist
(
self
):
person
=
self
.
_makePerson
(
self
.
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
project
)
self
.
_makeComputePartitions
(
compute_node
)
software_product
=
self
.
_makeSoftwareProduct
(
self
.
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
url_string
=
software_release
.
getUrlString
()
self
.
_makeSoftwareInstallation
(
compute_node
,
url_string
)
# Create Instance Tree and Software Instance
instance_tree
=
self
.
_makeFullInstanceTree
(
url_string
,
person
)
self
.
_makeFullSoftwareInstance
(
instance_tree
,
url_string
)
self
.
_markComputePartitionBusy
(
compute_node
,
instance_tree
.
getSuccessorValue
())
# Install the Newest software release
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release2
.
getUrlString
())
self
.
tic
()
up_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
up_decision
.
getSimulationState
(),
'planned'
)
# Install the another software release
software_release3
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release3
.
getUrlString
())
self
.
tic
()
up_decision2
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
up_decision2
.
getSimulationState
(),
'planned'
)
self
.
assertEqual
(
up_decision
.
getSimulationState
(),
'cancelled'
)
release
=
up_decision2
.
UpgradeDecision_getAggregateValue
(
"Software Release"
)
self
.
assertEqual
(
release
.
getUrlString
(),
software_release3
.
getUrlString
())
def
test_tocheckInstanceTree_createUpgradeDecision_rejected
(
self
):
person
=
self
.
_makePerson
(
self
.
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
project
)
self
.
_makeComputePartitions
(
compute_node
)
software_product
=
self
.
_makeSoftwareProduct
(
self
.
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
url_string
=
software_release
.
getUrlString
()
self
.
_makeSoftwareInstallation
(
compute_node
,
url_string
)
# Create Instance Tree and Software Instance
instance_tree
=
self
.
_makeFullInstanceTree
(
url_string
,
person
)
self
.
_makeFullSoftwareInstance
(
instance_tree
,
url_string
)
self
.
_markComputePartitionBusy
(
compute_node
,
instance_tree
.
getSuccessorValue
())
# Install the Newest software release
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release2
.
getUrlString
())
self
.
tic
()
up_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
up_decision
.
getSimulationState
(),
'planned'
)
# Reject upgrade decision
up_decision
.
reject
()
self
.
tic
()
in_progress
=
software_release2
.
SoftwareRelease_getUpgradeDecisionInProgress
(
instance_tree
.
getUid
())
up_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
# There is an upgrade decision in progress
self
.
assertNotEqual
(
in_progress
,
None
)
# No new upgrade decision created with software_release2
self
.
assertEqual
(
up_decision
,
None
)
def
test_tocheckInstanceTree_createUpgradeDecision_rejected_2
(
self
):
person
=
self
.
_makePerson
(
self
.
project
)
compute_node
,
_
=
self
.
_makeComputeNode
(
self
.
project
)
#, owner=person)
self
.
_makeComputePartitions
(
compute_node
)
software_product
=
self
.
_makeSoftwareProduct
(
self
.
project
)
software_release
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
url_string
=
software_release
.
getUrlString
()
self
.
_makeSoftwareInstallation
(
compute_node
,
url_string
)
# Create Instance Tree and Software Instance
instance_tree
=
self
.
_makeFullInstanceTree
(
url_string
,
person
)
self
.
_makeFullSoftwareInstance
(
instance_tree
,
url_string
)
self
.
_markComputePartitionBusy
(
compute_node
,
instance_tree
.
getSuccessorValue
())
# Install the Newest software release
software_release2
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release2
.
getUrlString
())
self
.
tic
()
up_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
up_decision
.
getSimulationState
(),
'planned'
)
# Reject upgrade decision
up_decision
.
reject
()
self
.
tic
()
# Install the another software release
software_release3
=
self
.
_requestSoftwareRelease
(
software_product
.
getRelativeUrl
())
self
.
_makeSoftwareInstallation
(
compute_node
,
software_release3
.
getUrlString
())
self
.
tic
()
decision2
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
decision2
.
getSimulationState
(),
'planned'
)
self
.
assertEqual
(
up_decision
.
getSimulationState
(),
'rejected'
)
release
=
decision2
.
UpgradeDecision_getAggregateValue
(
"Software Release"
)
self
.
assertEqual
(
release
.
getUrlString
(),
software_release3
.
getUrlString
())
\ No newline at end of file
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