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
Titouan Soulard
slapos.core
Commits
3d185d29
Commit
3d185d29
authored
Jul 06, 2023
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: fixup slapos_free_compute_partition tests
parent
ef804145
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
138 additions
and
79 deletions
+138
-79
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
...teItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
+27
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+111
-79
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
View file @
3d185d29
...
...
@@ -344,6 +344,33 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
def
_makeSlaveTree
(
self
,
project
,
requested_template_id
=
'template_slave_instance'
):
return
self
.
_makeTree
(
project
,
requested_template_id
=
requested_template_id
)
def
addComputeNodeAndPartition
(
self
,
project
):
# XXX replace _makeComputeNode
reference
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Compute Node"
,
#allocation_scope=allocation_scope,
reference
=
reference
,
title
=
reference
,
follow_up_value
=
project
)
# The edit above will update capacity scope due the interaction workflow
# The line above force capacity scope to be open, keeping the previous
# behaviour.
compute_node
.
edit
(
capacity_scope
=
'open'
)
compute_node
.
validate
()
reference
=
'TESTPART-%s'
%
self
.
generateNewId
()
partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
,
reference
=
reference
,
title
=
reference
)
partition
.
markFree
()
partition
.
validate
()
return
compute_node
,
partition
def
_makeComputeNode
(
self
,
project
,
allocation_scope
=
'open'
):
self
.
compute_node
=
self
.
portal
.
compute_node_module
.
template_compute_node
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
3d185d29
...
...
@@ -9,7 +9,7 @@ from erp5.component.module.DateUtils import addToDate
class
TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm
(
SlapOSTestCaseMixin
):
#################################################################
#
InstanceTree_assertS
uccessor
#
slapos_assert_instance_tree_s
uccessor
#################################################################
def
test_InstanceTree_assertSuccessor_alarm_orphaned
(
self
):
instance_tree
=
self
.
portal
.
instance_tree_module
.
newContent
(
...
...
@@ -120,115 +120,147 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(SlapOSTestCaseMixin):
instance_tree
.
getSuccessorTitleList
())
#################################################################
# slapos_free_compute_partition
#################################################################
class
TestSlapOSFreeComputePartitionAlarm
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
self
.
project
=
self
.
addProject
()
self
.
_makeTree
(
self
.
project
)
def
test_SoftwareInstance_tryToUnallocatePartition
(
self
):
self
.
_makeComputeNode
(
self
.
project
)
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'destroy_requested'
)
self
.
tic
()
self
.
software_instance
.
SoftwareInstance_tryToUnallocatePartition
()
self
.
tic
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregate
())
self
.
assertEqual
(
'free'
,
self
.
partition
.
getSlapState
())
def
test_SoftwareInstance_tryToUnallocatePartition_concurrency
(
self
):
self
.
_makeComputeNode
(
self
.
project
)
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'destroy_requested'
)
self
.
tic
()
self
.
partition
.
activate
(
tag
=
"allocate_%s"
%
self
.
partition
.
getRelativeUrl
()
\
).
getId
()
transaction
.
commit
()
self
.
software_instance
.
SoftwareInstance_tryToUnallocatePartition
()
self
.
tic
()
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
software_instance
.
getAggregate
())
self
.
assertEqual
(
'busy'
,
self
.
partition
.
getSlapState
())
def
test_SoftwareInstance_tryToUnallocatePartition_twoInstances
(
self
):
software_instance
=
self
.
portal
.
software_instance_module
\
.
template_software_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
#################################################################
# slapos_free_compute_partition
#################################################################
def
test_SoftwareInstance_tryToUnallocatePartition_alarm_allocated
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
())
self
.
_makeComputeNode
(
self
.
project
)
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
tic
()
# invalidate transition triggers the alarm
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'invalidated'
)
self
.
software_instance
.
SoftwareInstance_tryToUnallocatePartition
()
self
.
tic
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregate
())
self
.
assertEqual
(
'busy'
,
self
.
partition
.
getSlapState
())
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
software_instance
.
getAggregate
())
def
test_alarm_allocated
(
self
):
self
.
_makeComputeNode
(
self
.
project
)
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'destroy_requested'
)
self
.
software_instance
.
invalidate
()
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
,
s
elf
.
s
oftware_instance
,
software_instance
,
'SoftwareInstance_tryToUnallocatePartition'
)
def
test_alarm_unallocated
(
self
):
self
.
_makeComputeNode
(
self
.
project
)
self
.
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
def
test_SoftwareInstance_tryToUnallocatePartition_alarm_unallocated
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
())
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
software_instance
.
invalidate
()
# invalidate transition triggers the alarm
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'invalidated'
)
self
.
tic
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
,
s
elf
.
s
oftware_instance
,
software_instance
,
'SoftwareInstance_tryToUnallocatePartition'
)
def
test_alarm_validated
(
self
):
self
.
_makeComputeNode
(
self
.
project
)
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
def
test_SoftwareInstance_tryToUnallocatePartition_alarm_allocatedAndValidated
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
())
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
tic
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
,
s
elf
.
s
oftware_instance
,
software_instance
,
'SoftwareInstance_tryToUnallocatePartition'
)
def
test_
alarm_start_reques
ted
(
self
):
self
.
_makeComputeNode
(
self
.
project
)
s
elf
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
()
)
self
.
partition
.
markBusy
(
)
def
test_
SoftwareInstance_tryToUnallocatePartition_alarm_allocatedAndStar
ted
(
self
):
instance_tree
=
self
.
addInstanceTree
(
)
s
oftware_instance
=
instance_tree
.
getSuccessorValue
(
)
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
()
)
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
tic
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_free_compute_partition
,
s
elf
.
s
oftware_instance
,
software_instance
,
'SoftwareInstance_tryToUnallocatePartition'
)
#################################################################
# SoftwareInstance_tryToUnallocatePartition
#################################################################
def
test_SoftwareInstance_tryToUnallocatePartition_script_allocated
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
())
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
tic
()
software_instance
.
SoftwareInstance_tryToUnallocatePartition
()
self
.
assertEqual
(
None
,
software_instance
.
getAggregate
())
self
.
assertEqual
(
'free'
,
partition
.
getSlapState
())
def
test_SoftwareInstance_tryToUnallocatePartition_script_concurrency
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
())
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
tic
()
partition
.
activate
(
tag
=
"allocate_%s"
%
partition
.
getRelativeUrl
()
\
).
getId
()
transaction
.
commit
()
software_instance
.
SoftwareInstance_tryToUnallocatePartition
()
self
.
assertEqual
(
partition
.
getRelativeUrl
(),
software_instance
.
getAggregate
())
self
.
assertEqual
(
'busy'
,
partition
.
getSlapState
())
def
test_SoftwareInstance_tryToUnallocatePartition_script_twoInstances
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
())
instance_tree2
=
self
.
addInstanceTree
(
project
=
instance_tree
.
getFollowUpValue
())
software_instance2
=
instance_tree2
.
getSuccessorValue
()
self
.
tic
()
# Prevent calling interaction workflows
software_instance
.
setCategoryList
(
software_instance
.
getCategoryList
()
+
[
'aggregate/%s'
%
partition
.
getRelativeUrl
()]
)
software_instance2
.
setCategoryList
(
software_instance2
.
getCategoryList
()
+
[
'aggregate/%s'
%
partition
.
getRelativeUrl
()]
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
partition
,
'busy'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
tic
()
software_instance
.
SoftwareInstance_tryToUnallocatePartition
()
self
.
assertEqual
(
None
,
software_instance
.
getAggregate
())
self
.
assertEqual
(
'busy'
,
partition
.
getSlapState
())
self
.
assertEqual
(
partition
.
getRelativeUrl
(),
software_instance2
.
getAggregate
())
class
TestSlapOSFreeComputePartitionAlarmWithSlave
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
...
...
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