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
08824550
Commit
08824550
authored
Jul 07, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: fixup slapos_update_compute_node_capacity_scope tests
parent
51e8990f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
110 deletions
+146
-110
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
...teItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
+5
-1
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+141
-109
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
View file @
08824550
...
@@ -352,8 +352,12 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
...
@@ -352,8 +352,12 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
def
_makeSlaveTree
(
self
,
project
,
requested_template_id
=
'template_slave_instance'
):
def
_makeSlaveTree
(
self
,
project
,
requested_template_id
=
'template_slave_instance'
):
return
self
.
_makeTree
(
project
,
requested_template_id
=
requested_template_id
)
return
self
.
_makeTree
(
project
,
requested_template_id
=
requested_template_id
)
def
addComputeNodeAndPartition
(
self
,
project
):
def
addComputeNodeAndPartition
(
self
,
project
=
None
):
# XXX replace _makeComputeNode
# XXX replace _makeComputeNode
if
project
is
None
:
project
=
self
.
addProject
()
self
.
tic
()
reference
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
reference
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Compute Node"
,
portal_type
=
"Compute Node"
,
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
08824550
...
@@ -423,148 +423,180 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
...
@@ -423,148 +423,180 @@ class TestSlapOSGarbageCollectDestroyedRootTreeAlarm(SlapOSTestCaseMixin):
class
TestSlapOSUpdateComputeNodeCapacityScopeAlarm
(
SlapOSTestCaseMixin
):
class
TestSlapOSUpdateComputeNodeCapacityScopeAlarm
(
SlapOSTestCaseMixin
):
#################################################################
def
afterSetUp
(
self
):
# slapos_update_compute_node_capacity_scope
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
#################################################################
self
.
project
=
self
.
addProject
()
def
test_ComputeNode_checkAndUpdateCapacityScope_alarm_open
(
self
):
self
.
compute_node
=
self
.
portal
.
compute_node_module
.
template_compute_node
\
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
.
Base_createCloneDocument
(
batch_mode
=
1
)
compute_node
.
edit
(
self
.
compute_node
.
edit
(
allocation_scope
=
'open'
,
allocation_scope
=
'open'
,
)
reference
=
'TESTC-%s'
%
self
.
generateNewId
(),
self
.
_test_alarm
(
follow_up_value
=
self
.
project
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
,
compute_node
,
'ComputeNode_checkAndUpdateCapacityScope'
)
)
self
.
compute_node
.
edit
(
capacity_scope
=
'open'
)
self
.
compute_node
.
validate
()
self
.
compute_node
.
setAccessStatus
(
"#access ok"
)
transaction
.
commit
()
def
test_ComputeNode_checkAndUpdateCapacityScope
(
self
):
def
test_ComputeNode_checkAndUpdateCapacityScope_alarm_close
(
self
):
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
self
.
assertEqual
(
'open'
,
self
.
compute_node
.
getCapacityScope
())
compute_node
.
edit
(
allocation_scope
=
'close'
,
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
,
compute_node
,
'ComputeNode_checkAndUpdateCapacityScope'
)
def
_newComputerModel
(
self
,
quantity
=
None
):
def
test_ComputeNode_checkAndUpdateCapacityScope_alarm_invalidated
(
self
):
computer_model
=
self
.
portal
.
computer_model_module
.
\
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
template_computer_model
.
Base_createCloneDocument
(
batch_mode
=
1
)
compute_node
.
invalidate
()
computer_model
.
edit
(
capacity_quantity
=
quantity
,
compute_node
.
edit
(
reference
=
'TESTCM-%s'
%
self
.
generateNewId
(),
allocation_scope
=
'open'
,
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
,
compute_node
,
'ComputeNode_checkAndUpdateCapacityScope'
)
)
return
computer_model
def
_addPartitionToComputeNode
(
self
):
#################################################################
partition
=
self
.
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
,
# ComputeNode_checkAndUpdateCapacityScope
reference
=
'part1'
)
#################################################################
partition
.
markFree
()
def
test_ComputeNode_checkAndUpdateCapacityScope_script_open
(
self
):
partition
.
markBusy
()
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
partition
.
validate
()
compute_node
.
edit
(
allocation_scope
=
'open'
)
self
.
software_instance
.
setAggregate
(
partition
.
getRelativeUrl
())
compute_node
.
edit
(
capacity_scope
=
'open'
)
self
.
tic
()
compute_node
.
setAccessStatus
(
"#access ok"
)
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'open'
,
compute_node
.
getCapacityScope
())
def
addComputerModel
(
self
,
capacity_quantity
=
None
):
return
self
.
portal
.
computer_model_module
.
newContent
(
portal_type
=
"Computer Model"
,
reference
=
'TESTCM-%s'
%
self
.
generateNewId
(),
capacity_quantity
=
capacity_quantity
)
def
test_ComputeNode_checkAndUpdateCapacityScope_model
(
self
):
def
test_ComputeNode_checkAndUpdateCapacityScope_script_model
(
self
):
computer_model
=
self
.
_newComputerModel
(
9999
)
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
compute_node
.
edit
(
allocation_scope
=
'open'
)
compute_node
.
edit
(
capacity_scope
=
'open'
)
compute_node
.
setAccessStatus
(
"#access ok"
)
self
.
compute_node
.
edit
(
specialise_value
=
computer_model
,
computer_model
=
self
.
addComputerModel
(
9999
)
capacity_quantity
=
None
)
compute_node
.
edit
(
specialise_value
=
computer_model
,
capacity_quantity
=
None
)
transaction
.
commit
()
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'open'
,
self
.
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
'open'
,
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
computer_model
.
getCapacityQuantity
(),
self
.
assertEqual
(
computer_model
.
getCapacityQuantity
(),
self
.
compute_node
.
getCapacityQuantity
())
compute_node
.
getCapacityQuantity
())
def
test_ComputeNode_checkAndUpdateCapacityScope_model_no_capacity
(
self
):
def
test_ComputeNode_checkAndUpdateCapacityScope_script_modelNoCapacity
(
self
):
self
.
_makeTree
(
self
.
project
)
compute_node
,
partition
=
self
.
addComputeNodeAndPartition
()
compute_node
.
edit
(
allocation_scope
=
'open'
)
compute_node
.
edit
(
capacity_scope
=
'open'
)
compute_node
.
setAccessStatus
(
"#access ok"
)
computer_model
=
self
.
_newComputerModel
(
1
)
computer_model
=
self
.
addComputerModel
(
1
)
self
.
compute_node
.
edit
(
specialise_value
=
computer_model
,
compute_node
.
edit
(
specialise_value
=
computer_model
,
capacity_quantity
=
None
)
capacity_quantity
=
None
)
self
.
_addPartitionToComputeNode
()
instance_tree
=
self
.
addInstanceTree
()
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
assertEqual
(
'close'
,
self
.
compute_node
.
getCapacityScope
())
software_instance
.
setAggregateValue
(
partition
)
self
.
assertEqual
(
'Compute Node capacity limit exceeded'
,
partition
.
markBusy
()
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
tic
()
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'close'
,
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
'Compute Node capacity limit exceeded'
,
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
assertEqual
(
computer_model
.
getCapacityQuantity
(),
self
.
assertEqual
(
computer_model
.
getCapacityQuantity
(),
self
.
compute_node
.
getCapacityQuantity
())
compute_node
.
getCapacityQuantity
())
def
test_ComputeNode_checkAndUpdateCapacityScope_
model_has_c
apacity
(
self
):
def
test_ComputeNode_checkAndUpdateCapacityScope_
script_modelHasC
apacity
(
self
):
# If capacity is set on compute_node, model value is ignored.
# If capacity is set on compute_node, model value is ignored.
self
.
_makeTree
(
self
.
project
)
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
compute_node
.
edit
(
allocation_scope
=
'open'
)
compute_node
.
edit
(
capacity_scope
=
'open'
)
compute_node
.
setAccessStatus
(
"#access ok"
)
computer_model
=
self
.
_newComputerModel
(
1
)
computer_model
=
self
.
addComputerModel
(
1
)
self
.
compute_node
.
edit
(
specialise_value
=
computer_model
,
compute_node
.
edit
(
specialise_value
=
computer_model
,
capacity_quantity
=
2
)
capacity_quantity
=
2
)
self
.
_addPartitionToComputeNode
()
self
.
tic
()
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'open'
,
self
.
compute_node
.
getCapacityScope
())
self
.
assertNotEqual
(
computer_model
.
getCapacityQuantity
(),
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
compute_node
.
getCapacityQuantity
())
self
.
assertEqual
(
'open'
,
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
2
,
compute_node
.
getCapacityQuantity
())
def
test_ComputeNode_checkAndUpdateCapacityScope_with_old_access
(
self
):
def
test_ComputeNode_checkAndUpdateCapacityScope_script_withOldAccess
(
self
):
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
compute_node
.
edit
(
allocation_scope
=
'open'
)
compute_node
.
edit
(
capacity_scope
=
'open'
)
try
:
try
:
self
.
pinDateTime
(
addToDate
(
DateTime
(),
to_add
=
{
'minute'
:
-
11
}))
self
.
pinDateTime
(
addToDate
(
DateTime
(),
to_add
=
{
'minute'
:
-
11
}))
self
.
compute_node
.
setAccessStatus
(
"#access ok"
)
compute_node
.
setAccessStatus
(
"#access ok"
)
finally
:
finally
:
self
.
unpinDateTime
()
self
.
unpinDateTime
()
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'close'
,
self
.
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
'close'
,
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
"Compute Node didn't contact for more than 10 minutes"
,
self
.
assertEqual
(
"Compute Node didn't contact for more than 10 minutes"
,
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_ComputeNode_checkAndUpdateCapacityScope_no_capacity_quantity
(
self
):
def
test_ComputeNode_checkAndUpdateCapacityScope_script_noCapacityQuantity
(
self
):
self
.
_makeTree
(
self
.
project
)
compute_node
,
partition
=
self
.
addComputeNodeAndPartition
()
self
.
compute_node
.
edit
(
capacity_quantity
=
1
)
compute_node
.
edit
(
allocation_scope
=
'open'
)
self
.
_addPartitionToComputeNode
()
compute_node
.
edit
(
capacity_scope
=
'open'
)
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
compute_node
.
setAccessStatus
(
"#access ok"
)
self
.
assertEqual
(
'close'
,
self
.
compute_node
.
getCapacityScope
())
compute_node
.
edit
(
capacity_quantity
=
1
)
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
tic
()
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'close'
,
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
'Compute Node capacity limit exceeded'
,
self
.
assertEqual
(
'Compute Node capacity limit exceeded'
,
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_ComputeNode_checkAndUpdateCapacityScope_script_noAccess
(
self
):
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
compute_node
.
edit
(
allocation_scope
=
'open'
)
compute_node
.
edit
(
capacity_scope
=
'open'
)
def
test_ComputeNode_checkAndUpdateCapacityScope_no_access
(
self
):
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
compute_node
.
edit
(
reference
=
'TESTC-%s'
%
self
.
generateNewId
())
self
.
assertEqual
(
'close'
,
compute_node
.
getCapacityScope
())
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'close'
,
self
.
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
"Compute Node didn't contact the server"
,
self
.
assertEqual
(
"Compute Node didn't contact the server"
,
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_ComputeNode_checkAndUpdateCapacityScope_close
(
self
):
def
test_ComputeNode_checkAndUpdateCapacityScope_script_capacityClose
(
self
):
self
.
compute_node
.
edit
(
capacity_scope
=
'close'
)
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
compute_node
.
edit
(
allocation_scope
=
'open'
)
self
.
assertEqual
(
'open'
,
self
.
compute_node
.
getCapacityScope
())
compute_node
.
setAccessStatus
(
"#access ok"
)
compute_node
.
edit
(
capacity_scope
=
'close'
)
def
test_ComputeNode_checkAndUpdateCapacityScope_with_error
(
self
):
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
compute_node
.
setAccessStatus
(
'#error not ok'
)
self
.
assertEqual
(
'open'
,
compute_node
.
getCapacityScope
())
self
.
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'close'
,
self
.
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
"Compute Node reported an error"
,
self
.
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm
(
self
):
def
test_ComputeNode_checkAndUpdateCapacityScope_script_withError
(
self
):
self
.
_test_alarm
(
compute_node
,
_
=
self
.
addComputeNodeAndPartition
()
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
,
compute_node
.
edit
(
allocation_scope
=
'open'
)
self
.
compute_node
,
compute_node
.
edit
(
capacity_scope
=
'open'
)
'ComputeNode_checkAndUpdateCapacityScope'
compute_node
.
setAccessStatus
(
'#error not ok'
)
)
def
test_alarm_non_public
(
self
):
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
compute_node
.
edit
(
allocation_scope
=
'close'
)
self
.
assertEqual
(
'close'
,
compute_node
.
getCapacityScope
())
self
.
_test_alarm_not_visited
(
self
.
assertEqual
(
"Compute Node reported an error"
,
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
,
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
self
.
compute_node
,
'ComputeNode_checkAndUpdateCapacityScope'
)
def
test_alarm_invalidated
(
self
):
self
.
compute_node
.
invalidate
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_update_compute_node_capacity_scope
,
self
.
compute_node
,
'ComputeNode_checkAndUpdateCapacityScope'
)
class
TestSlapOSGarbageCollectStoppedRootTreeAlarm
(
SlapOSTestCaseMixin
):
class
TestSlapOSGarbageCollectStoppedRootTreeAlarm
(
SlapOSTestCaseMixin
):
...
...
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