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
b495b8e7
Commit
b495b8e7
authored
Jul 07, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: fixup slapos_garbage_collect_non_allocated_root_tree tests
parent
38e9d877
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
133 additions
and
164 deletions
+133
-164
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+133
-164
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
b495b8e7
...
...
@@ -665,134 +665,165 @@ class TestSlapOSGarbageCollectStoppedRootTreeAlarm(SlapOSTestCaseMixin):
class
TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
self
.
project
=
self
.
addProject
()
def
createInstance
(
self
,
project
):
instance_tree
=
self
.
portal
.
instance_tree_module
\
.
template_instance_tree
.
Base_createCloneDocument
(
batch_mode
=
1
)
instance_tree
.
edit
(
follow_up_value
=
project
)
instance_tree
.
validate
()
instance_tree
.
edit
(
title
=
self
.
generateNewSoftwareTitle
(),
reference
=
"TESTHS-%s"
%
self
.
generateNewId
(),
#################################################################
# slapos_garbage_collect_non_allocated_root_tree
#################################################################
def
test_tryToGarbageCollectNonAllocatedRootTree_alarm
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
,
software_instance
,
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
request_kw
=
dict
(
software_release
=
\
self
.
generateNewSoftwareReleaseUrl
(),
software_type
=
self
.
generateNewSoftwareType
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
,
software_title
=
instance_tree
.
getTitle
(),
state
=
'started'
,
project_reference
=
project
def
test_tryToGarbageCollectNonAllocatedRootTree_alarm_invalidated
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
invalidate
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
,
software_instance
,
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
instance_tree
.
requestStart
(
**
request_kw
)
instance_tree
.
requestInstance
(
**
request_kw
)
instance
=
instance_tree
.
getSuccessorValue
()
return
instance
def
test_tryToGarbageCollectNonAllocatedRootTree_alarm_allocated
(
self
):
_
,
partition
=
self
.
addComputeNodeAndPartition
()
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
def
createComputePartition
(
self
):
compute_node
=
self
.
portal
.
compute_node_module
\
.
template_compute_node
.
Base_createCloneDocument
(
batch_mode
=
1
)
compute_node
.
validate
()
compute_node
.
edit
(
title
=
self
.
generateNewSoftwareTitle
(),
reference
=
"TESTCOMP-%s"
%
self
.
generateNewId
(),
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
,
software_instance
,
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
partition
=
compute_node
.
newContent
(
portal_type
=
"Compute Partition"
)
return
partition
def
test_tryToGarbageCollect_REQUEST_disallowed
(
self
):
#################################################################
# SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
#################################################################
def
test_tryToGarbageCollectNonAllocatedRootTree_REQUEST_disallowed
(
self
):
self
.
assertRaises
(
Unauthorized
,
self
.
portal
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
,
REQUEST
=
{})
def
test_tryToGarbageCollect
_invalidated_i
nstance
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance
.
invalidat
e
()
s
elf
.
tic
()
def
test_tryToGarbageCollect
NonAllocatedRootTree_script_invalidatedI
nstance
(
self
):
instance
_tree
=
self
.
addInstanceTree
(
)
software_instance
=
instance_tree
.
getSuccessorValu
e
()
s
oftware_instance
.
invalidate
()
instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
s
elf
.
assertEqual
(
'start_requested'
,
instance
.
getSlapState
()
)
instance_tree
=
instance
.
getSpecialiseValue
(
)
self
.
tic
()
s
oftware_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
(
)
self
.
assertEqual
(
'start_requested'
,
software_instance
.
getSlapState
()
)
self
.
assertEqual
(
'start_requested'
,
instance_tree
.
getSlapState
())
def
test_tryToGarbageCollect
_destroyed_i
nstance
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
s
elf
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
self
.
tic
(
)
def
test_tryToGarbageCollect
NonAllocatedRootTree_script_destroyedI
nstance
(
self
):
instance
_tree
=
self
.
addInstanceTree
(
)
s
oftware_instance
=
instance_tree
.
getSuccessorValue
(
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
s
elf
.
assertEqual
(
'destroy_requested'
,
instance
.
getSlapState
()
)
instance_tree
=
instance
.
getSpecialiseValue
(
)
self
.
tic
()
s
oftware_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
(
)
self
.
assertEqual
(
'destroy_requested'
,
software_instance
.
getSlapState
()
)
self
.
assertEqual
(
'start_requested'
,
instance_tree
.
getSlapState
())
def
test_tryToGarbageCollect_allocated_instance
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
partition
=
self
.
createComputePartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
def
test_tryToGarbageCollectNonAllocatedRootTree_script_allocatedInstance
(
self
):
_
,
partition
=
self
.
addComputeNodeAndPartition
()
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
s
elf
.
assertEqual
(
'start_requested'
,
instance
.
getSlapState
()
)
instance_tree
=
instance
.
getSpecialiseValue
(
)
self
.
tic
()
s
oftware_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
(
)
self
.
assertEqual
(
'start_requested'
,
software_instance
.
getSlapState
()
)
self
.
assertEqual
(
'start_requested'
,
instance_tree
.
getSlapState
())
def
test_tryToGarbageCollect
_no_allocation_try_f
ound
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
s
elf
.
tic
()
def
test_tryToGarbageCollect
NonAllocatedRootTree_script_noAllocationTryF
ound
(
self
):
instance
_tree
=
self
.
addInstanceTree
(
)
s
oftware_instance
=
instance_tree
.
getSuccessorValue
()
instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
s
elf
.
assertEqual
(
'start_requested'
,
instance
.
getSlapState
()
)
instance_tree
=
instance
.
getSpecialiseValue
(
)
self
.
tic
()
s
oftware_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
(
)
self
.
assertEqual
(
'start_requested'
,
software_instance
.
getSlapState
()
)
self
.
assertEqual
(
'start_requested'
,
instance_tree
.
getSlapState
())
def
test_tryToGarbageCollect
_recent_allocation_try_f
ound
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
s
elf
.
tic
()
instance
.
workflow_history
[
'edit_workflow'
].
append
(
{
def
test_tryToGarbageCollect
NonAllocatedRootTree_script_recentAllocationTryF
ound
(
self
):
instance
_tree
=
self
.
addInstanceTree
(
)
s
oftware_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
workflow_history
[
'edit_workflow'
]
=
[
{
'comment'
:
'Allocation failed: no free Compute Partition'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
's
lap_state'
:
'
'
,
's
tate'
:
'current
'
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
2
}),
'action'
:
'edit'
}
)
}
]
instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
s
elf
.
assertEqual
(
'start_requested'
,
instance
.
getSlapState
()
)
instance_tree
=
instance
.
getSpecialiseValue
(
)
self
.
tic
()
s
oftware_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
(
)
self
.
assertEqual
(
'start_requested'
,
software_instance
.
getSlapState
()
)
self
.
assertEqual
(
'start_requested'
,
instance_tree
.
getSlapState
())
def
test_tryToGarbageCollect_recent_allocation_try_found_allocation_disallowed
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
def
test_tryToGarbageCollectNonAllocatedRootTree_script_oldAllocationTryFound
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
(
)
self
.
tic
()
instance
.
workflow_history
[
'edit_workflow'
].
append
({
software_instance
.
workflow_history
[
'edit_workflow'
]
=
[{
'comment'
:
'Allocation failed: no free Compute Partition'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'state'
:
'current'
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
4
}),
'action'
:
'edit'
}]
software_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'destroy_requested'
,
instance_tree
.
getSlapState
())
self
.
assertEqual
(
'archived'
,
instance_tree
.
getValidationState
())
self
.
assertEqual
(
'start_requested'
,
software_instance
.
getSlapState
())
def
test_tryToGarbageCollectNonAllocatedRootTree_script_recentAllocationTryFoundAllocationDisallowed
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
workflow_history
[
'edit_workflow'
]
=
[{
'comment'
:
'Allocation failed: Allocation disallowed'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
's
lap_state'
:
'
'
,
's
tate'
:
'current
'
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
2
}),
'action'
:
'edit'
}
)
}
]
instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
s
elf
.
assertEqual
(
'start_requested'
,
instance
.
getSlapState
()
)
instance_tree
=
instance
.
getSpecialiseValue
(
)
self
.
tic
()
s
oftware_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
(
)
self
.
assertEqual
(
'start_requested'
,
software_instance
.
getSlapState
()
)
self
.
assertEqual
(
'start_requested'
,
instance_tree
.
getSlapState
())
def
test_tryToGarbageCollect_complex_tree
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance_tree
=
instance
.
getSpecialiseValue
()
def
test_tryToGarbageCollectNonAllocatedRootTree_script_oldAllocationTryFoundAllocationDisallowed
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
tic
()
software_instance
.
workflow_history
[
'edit_workflow'
]
=
[{
'comment'
:
'Allocation failed: Allocation disallowed'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'state'
:
'current'
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
4
}),
'action'
:
'edit'
}]
software_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'destroy_requested'
,
instance_tree
.
getSlapState
())
self
.
assertEqual
(
'archived'
,
instance_tree
.
getValidationState
())
self
.
assertEqual
(
'start_requested'
,
software_instance
.
getSlapState
())
def
test_tryToGarbageCollectNonAllocatedRootTree_script_complexTree
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
request_kw
=
dict
(
software_release
=
\
self
.
generateNewSoftwareReleaseUrl
(),
...
...
@@ -803,24 +834,24 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
software_title
=
"another %s"
%
instance_tree
.
getTitle
(),
state
=
'started'
)
instance
.
requestInstance
(
**
request_kw
)
sub_instance
=
instance
.
getSuccessorValue
()
software_
instance
.
requestInstance
(
**
request_kw
)
sub_instance
=
software_
instance
.
getSuccessorValue
()
self
.
tic
()
sub_instance
.
workflow_history
[
'edit_workflow'
]
.
append
(
{
sub_instance
.
workflow_history
[
'edit_workflow'
]
=
[
{
'comment'
:
'Allocation failed: no free Compute Partition'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
's
lap_state'
:
'
'
,
's
tate'
:
'current
'
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
4
}),
'action'
:
'edit'
}
)
}
]
sub_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'start_requested'
,
instance_tree
.
getSlapState
())
def
test_tryToGarbageCollect
_complex_tree_allocation_d
isallowed
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance_tree
=
instance
.
getSpecialise
Value
()
def
test_tryToGarbageCollect
NonAllocatedRootTree_script_complexTreeAllocationD
isallowed
(
self
):
instance
_tree
=
self
.
addInstanceTree
(
)
software_instance
=
instance_tree
.
getSuccessor
Value
()
request_kw
=
dict
(
software_release
=
\
self
.
generateNewSoftwareReleaseUrl
(),
...
...
@@ -831,83 +862,21 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
software_title
=
"another %s"
%
instance_tree
.
getTitle
(),
state
=
'started'
)
instance
.
requestInstance
(
**
request_kw
)
sub_instance
=
instance
.
getSuccessorValue
()
software_
instance
.
requestInstance
(
**
request_kw
)
sub_instance
=
software_
instance
.
getSuccessorValue
()
self
.
tic
()
sub_instance
.
workflow_history
[
'edit_workflow'
]
.
append
(
{
sub_instance
.
workflow_history
[
'edit_workflow'
]
=
[
{
'comment'
:
'Allocation failed: Allocation disallowed'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
's
lap_state'
:
'
'
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
4
}),
's
tate'
:
'current
'
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
2
}),
'action'
:
'edit'
}
)
}
]
sub_instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'start_requested'
,
instance_tree
.
getSlapState
())
def
test_tryToGarbageCollect_old_allocation_try_found
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance_tree
=
instance
.
getSpecialiseValue
()
self
.
tic
()
instance
.
workflow_history
[
'edit_workflow'
].
append
({
'comment'
:
'Allocation failed: no free Compute Partition'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
''
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
8
}),
'action'
:
'edit'
})
instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'destroy_requested'
,
instance_tree
.
getSlapState
())
self
.
assertEqual
(
'archived'
,
instance_tree
.
getValidationState
())
def
test_tryToGarbageCollect_old_allocation_try_found_allocation_disallowed
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance_tree
=
instance
.
getSpecialiseValue
()
self
.
tic
()
instance
.
workflow_history
[
'edit_workflow'
].
append
({
'comment'
:
'Allocation failed: Allocation disallowed'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
''
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
8
}),
'action'
:
'edit'
})
instance
.
SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'destroy_requested'
,
instance_tree
.
getSlapState
())
self
.
assertEqual
(
'archived'
,
instance_tree
.
getValidationState
())
def
test_alarm
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
,
instance
,
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
def
test_alarm_invalidated
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance
.
invalidate
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
,
instance
,
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
def
test_alarm_allocated
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
partition
=
self
.
createComputePartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_non_allocated_root_tree
,
instance
,
'SoftwareInstance_tryToGarbageCollectNonAllocatedRootTree'
)
class
TestSlapOSGarbageCollectUnlinkedInstanceAlarm
(
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