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
e2903c82
Commit
e2903c82
authored
Jul 07, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: fixup slapos_garbage_collect_destroy_unlinked_instance tests
parent
b5a8c15c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
139 deletions
+94
-139
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+94
-139
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
e2903c82
...
@@ -880,50 +880,6 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
...
@@ -880,50 +880,6 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
class
TestSlapOSGarbageCollectUnlinkedInstanceAlarm
(
SlapOSTestCaseMixin
):
class
TestSlapOSGarbageCollectUnlinkedInstanceAlarm
(
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
(),
)
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
.
getReference
()
)
instance_tree
.
requestStart
(
**
request_kw
)
instance_tree
.
requestInstance
(
**
request_kw
)
self
.
instance_tree
=
instance_tree
instance
=
instance_tree
.
getSuccessorValue
()
return
instance
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
(),
)
partition
=
compute_node
.
newContent
(
portal_type
=
"Compute Partition"
)
return
partition
def
doRequestInstance
(
self
,
instance
,
title
,
slave
=
False
):
def
doRequestInstance
(
self
,
instance
,
title
,
slave
=
False
):
instance_kw
=
dict
(
software_release
=
self
.
generateNewSoftwareReleaseUrl
(),
instance_kw
=
dict
(
software_release
=
self
.
generateNewSoftwareReleaseUrl
(),
software_type
=
self
.
generateNewSoftwareType
(),
software_type
=
self
.
generateNewSoftwareType
(),
...
@@ -936,42 +892,86 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
...
@@ -936,42 +892,86 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
instance
.
requestInstance
(
**
instance_kw
)
instance
.
requestInstance
(
**
instance_kw
)
self
.
tic
()
self
.
tic
()
sub_instance
=
instance
.
getSuccessorValue
()
sub_instance
=
instance
.
getSuccessorValue
()
partition
=
self
.
createComputePartition
()
self
.
assertEqual
(
instance
.
getSpecialiseValue
().
getRelativeUrl
(),
sub_instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
self
.
assertEqual
(
self
.
instance_tree
.
getRelativeUrl
(),
sub_instance
.
getSpecialise
())
sub_instance
.
getSpecialise
())
return
sub_instance
return
sub_instance
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance
(
self
):
#################################################################
instance
=
self
.
createInstance
(
self
.
project
)
# slapos_garbage_collect_destroy_unlinked_instance
partition
=
self
.
createComputePartition
()
#################################################################
instance
.
edit
(
aggregate_value
=
partition
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_alarm_inlinkedInstance
(
self
):
self
.
tic
()
instance_tree
=
self
.
addInstanceTree
()
instance0
=
self
.
doRequestInstance
(
instance
,
'instance0'
)
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
instance
.
getTitle
())
instance0
=
self
.
doRequestInstance
(
software_instance
,
'instance0'
)
self
.
assertEqual
(
software_instance
.
getSuccessorReference
(),
instance0
.
getReference
())
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
# Remove successor link
# Remove successor link
instance
.
edit
(
successor_list
=
[])
software_instance
.
edit
(
successor_list
=
[])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_alarm_inlinkedInstanceSlave
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
instance0
=
self
.
doRequestInstance
(
software_instance
,
'instance0'
,
True
)
self
.
assertEqual
(
software_instance
.
getSuccessorReference
(),
instance0
.
getReference
())
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
# Remove successor link
software_instance
.
edit
(
successor_list
=
[])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
#################################################################
# SoftwareInstance_tryToGarbageUnlinkedInstance
#################################################################
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_script
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
instance0
=
self
.
doRequestInstance
(
software_instance
,
'instance0'
)
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
software_instance
.
getTitle
())
# Remove successor link
software_instance
.
edit
(
successor_list
=
[])
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
None
)
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
None
)
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
(
delay_time
=-
1
)
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
(
delay_time
=-
1
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSlapState
(),
'destroy_requested'
)
self
.
assertEqual
(
instance0
.
getSlapState
(),
'destroy_requested'
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_
hosting_d
estroyed
(
self
):
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_
script_hostingD
estroyed
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance
_tree
=
self
.
addInstanceTree
(
)
partition
=
self
.
createComputePartition
()
software_instance
=
instance_tree
.
getSuccessorValue
()
instance
.
edit
(
aggregate_value
=
partition
)
instance
0
=
self
.
doRequestInstance
(
software_instance
,
'instance0'
)
self
.
tic
(
)
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
software_instance
.
getTitle
()
)
instance0
=
self
.
doRequestInstance
(
instance
,
'instance0'
)
# Remove successor link
instance
.
edit
(
successor_list
=
[])
software_
instance
.
edit
(
successor_list
=
[])
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
None
)
self
.
instance_tree
.
archive
()
instance_tree
.
archive
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
instance_tree
,
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance_tree
,
'destroy_requested'
)
'destroy_requested'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_
instance
,
'destroy_requested'
)
self
.
tic
()
self
.
tic
()
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
()
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
()
...
@@ -979,16 +979,16 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
...
@@ -979,16 +979,16 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
# Will not be destroyed by this script
# Will not be destroyed by this script
self
.
assertEqual
(
instance0
.
getSlapState
(),
'start_requested'
)
self
.
assertEqual
(
instance0
.
getSlapState
(),
'start_requested'
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_will_unlink_children
(
self
):
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_script_willUnlinkChildren
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance_tree
=
self
.
addInstanceTree
()
partition
=
self
.
createComputePartition
()
software_instance
=
instance_tree
.
getSuccessorValue
()
instance
.
edit
(
aggregate_value
=
partition
)
instance0
=
self
.
doRequestInstance
(
software_instance
,
'instance0'
)
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
software_instance
.
getTitle
())
instance0
=
self
.
doRequestInstance
(
instance
,
'instance0'
)
instance_instance0
=
self
.
doRequestInstance
(
instance0
,
'Subinstance0'
)
instance_instance0
=
self
.
doRequestInstance
(
instance0
,
'Subinstance0'
)
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
'instance0'
)
'instance0'
)
instance
.
edit
(
successor_list
=
[])
# Remove successor link
software_instance
.
edit
(
successor_list
=
[])
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
None
)
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
None
)
...
@@ -999,21 +999,22 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
...
@@ -999,21 +999,22 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
# Link of child removed
# Link of child removed
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
None
)
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
None
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_will_delay
(
self
):
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_script_willDelay
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance_tree
=
self
.
addInstanceTree
()
partition
=
self
.
createComputePartition
()
software_instance
=
instance_tree
.
getSuccessorValue
()
instance
.
edit
(
aggregate_value
=
partition
)
instance0
=
self
.
doRequestInstance
(
software_instance
,
'instance0'
)
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
software_instance
.
getTitle
())
instance0
=
self
.
doRequestInstance
(
instance
,
'instance0'
)
instance_instance0
=
self
.
doRequestInstance
(
instance0
,
'Subinstance0'
)
instance_instance0
=
self
.
doRequestInstance
(
instance0
,
'Subinstance0'
)
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
'instance0'
)
'instance0'
)
instance
.
edit
(
successor_list
=
[])
# Remove successor link
software_instance
.
edit
(
successor_list
=
[])
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
None
)
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
None
)
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
()
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
()
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSlapState
(),
'start_requested'
)
self
.
assertEqual
(
instance0
.
getSlapState
(),
'start_requested'
)
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
...
@@ -1028,32 +1029,27 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
...
@@ -1028,32 +1029,27 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
# Link of child removed
# Link of child removed
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
None
)
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
None
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_unlinked_root
(
self
):
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_script_unlinkedRoot
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
instance_tree
=
self
.
addInstanceTree
()
partition
=
self
.
createComputePartition
()
software_instance
=
instance_tree
.
getSuccessorValue
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
self
.
assertEqual
(
self
.
instance_tree
.
getTitle
(),
instance
.
getTitle
())
# Remove successor link
# Remove successor link
self
.
instance_tree
.
edit
(
successor_list
=
[])
instance_tree
.
edit
(
successor_list
=
[])
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance
.
getSuccessorRelatedTitle
(),
None
)
self
.
assertEqual
(
software_
instance
.
getSuccessorRelatedTitle
(),
None
)
# will not destroy
# will not destroy
self
.
assertRaises
(
self
.
assertRaises
(
ValueError
,
ValueError
,
instance
.
SoftwareInstance_tryToGarbageUnlinkedInstance
,
software_
instance
.
SoftwareInstance_tryToGarbageUnlinkedInstance
,
delay_time
=-
10
)
delay_time
=-
10
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance
.
getSlapState
(),
'start_requested'
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
'start_requested'
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_script_notUnlinked
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
instance0
=
self
.
doRequestInstance
(
software_instance
,
'instance0'
)
self
.
assertEqual
(
instance0
.
getSuccessorRelatedTitle
(),
software_instance
.
getTitle
())
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_not_unlinked
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
partition
=
self
.
createComputePartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
instance0
=
self
.
doRequestInstance
(
instance
,
'instance0'
)
instance_instance0
=
self
.
doRequestInstance
(
instance0
,
'Subinstance0'
)
instance_instance0
=
self
.
doRequestInstance
(
instance0
,
'Subinstance0'
)
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
self
.
assertEqual
(
instance_instance0
.
getSuccessorRelatedTitle
(),
'instance0'
)
'instance0'
)
...
@@ -1064,47 +1060,6 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
...
@@ -1064,47 +1060,6 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
def
test_alarm_search_inlinked_instance
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
partition
=
self
.
createComputePartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
instance0
=
self
.
doRequestInstance
(
instance
,
'instance0'
)
self
.
assertEqual
(
instance
.
getSuccessorReference
(),
instance0
.
getReference
())
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
# Remove successor link
instance
.
edit
(
successor_list
=
[])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
def
test_alarm_search_inlinked_instance_slave
(
self
):
instance
=
self
.
createInstance
(
self
.
project
)
partition
=
self
.
createComputePartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
slave_instance0
=
self
.
doRequestInstance
(
instance
,
'slaveInstance0'
,
True
)
self
.
assertEqual
(
instance
.
getSuccessorTitle
(),
'slaveInstance0'
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
slave_instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
instance
.
edit
(
successor_list
=
[])
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_garbage_collect_destroy_unlinked_instance
,
slave_instance0
,
'SoftwareInstance_tryToGarbageUnlinkedInstance'
)
class
TestSlapOSInvalidateDestroyedInstance
(
SlapOSTestCaseMixin
):
class
TestSlapOSInvalidateDestroyedInstance
(
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