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
fcb26053
Commit
fcb26053
authored
Jul 07, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: fixup slapos_cloud_invalidate_destroyed_instance tests
parent
e2903c82
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
92 deletions
+88
-92
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+88
-92
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
fcb26053
...
...
@@ -1063,114 +1063,110 @@ class TestSlapOSGarbageCollectUnlinkedInstanceAlarm(SlapOSTestCaseMixin):
class
TestSlapOSInvalidateDestroyedInstance
(
SlapOSTestCaseMixin
):
#################################################################
# slapos_cloud_invalidate_destroyed_instance
#################################################################
def
test_tryToInvalidateIfDestroyed_alarm_softwareInstanceInvalidated
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
self
.
project
=
self
.
addProject
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'invalidated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
tic
()
def
createSoftwareInstance
(
self
):
new_id
=
self
.
generateNewId
()
return
self
.
portal
.
software_instance_module
.
newContent
(
portal_type
=
'Software Instance'
,
title
=
"Test instance %s"
%
new_id
,
reference
=
"TESTINST-%s"
%
new_id
,
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
software_instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
def
createComputePartition
(
self
):
new_id
=
self
.
generateNewId
()
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
'Compute Node'
,
title
=
"Test compute_node %s"
%
new_id
,
reference
=
"TESTCOMP-%s"
%
new_id
,
def
test_tryToInvalidateIfDestroyed_alarm_softwareInstanceMatching
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
tic
()
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
software_instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
compute_partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
,
def
test_tryToInvalidateIfDestroyed_alarm_softwareInstanceAllocated
(
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
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
self
.
tic
()
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
software_instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
return
compute_partition
#################################################################
# SoftwareInstance_tryToInvalidateIfDestroyed
#################################################################
def
test_tryToInvalidateIfDestroyed_REQUEST_disallowed
(
self
):
instance
=
self
.
createSoftwareInstance
()
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
assertRaises
(
Unauthorized
,
instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
,
software_
instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
,
REQUEST
=
{})
def
test_tryToInvalidateIfDestroyed_
unexpected_c
ontext
(
self
):
def
test_tryToInvalidateIfDestroyed_
script_unexpectedC
ontext
(
self
):
self
.
assertRaises
(
TypeError
,
self
.
portal
.
SoftwareInstance_tryToInvalidateIfDestroyed
,
)
def
test_tryToInvalidateIfDestroyed_expected_instance
(
self
):
instance
=
self
.
createSoftwareInstance
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
instance
.
getValidationState
(),
"invalidated"
)
self
.
assertEqual
(
instance
.
getSlapState
(),
"destroy_requested"
)
def
test_tryToInvalidateIfDestroyed_invalidated_instance
(
self
):
instance
=
self
.
createSoftwareInstance
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'invalidated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
instance
.
getValidationState
(),
"invalidated"
)
self
.
assertEqual
(
instance
.
getSlapState
(),
"destroy_requested"
)
def
test_tryToInvalidateIfDestroyed_not_destroyed_instance
(
self
):
instance
=
self
.
createSoftwareInstance
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'stop_requested'
)
instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
instance
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
instance
.
getSlapState
(),
"stop_requested"
)
def
test_tryToInvalidateIfDestroyed_allocated_instance
(
self
):
instance
=
self
.
createSoftwareInstance
()
partition
=
self
.
createComputePartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
instance
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
instance
.
getSlapState
(),
"destroy_requested"
)
def
test_alarm_software_instance_allocated
(
self
):
instance
=
self
.
createSoftwareInstance
()
partition
=
self
.
createComputePartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
self
.
tic
()
def
test_tryToInvalidateIfDestroyed_script_expectedInstance
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
software_instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
software_instance
.
getValidationState
(),
"invalidated"
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
"destroy_requested"
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
def
test_tryToInvalidateIfDestroyed_script_invalidatedInstance
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'invalidated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
software_instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
software_instance
.
getValidationState
(),
"invalidated"
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
"destroy_requested"
)
def
test_alarm_software_instance_invalidated
(
self
):
instance
=
self
.
createSoftwareInstance
()
self
.
createComputePartition
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'invalidated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
self
.
tic
()
def
test_tryToInvalidateIfDestroyed_script_notDestroyedInstance
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'stop_requested'
)
software_instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
software_instance
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
"stop_requested"
)
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
def
test_tryToInvalidateIfDestroyed_script_allocatedInstance
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
def
test_alarm_software_instance_matching
(
self
):
instance
=
self
.
createSoftwareInstance
()
self
.
createComputePartition
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance
,
'destroy_requested'
)
self
.
tic
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
())
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
software_instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
software_instance
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
"destroy_requested"
)
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
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