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
27566ac4
Commit
27566ac4
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
0efe6b2f
Changes
1
Hide 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 @
27566ac4
...
...
@@ -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
()
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
,
)
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
,
)
compute_partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
,
)
return
compute_partition
def
test_tryToInvalidateIfDestroyed_REQUEST_disallowed
(
self
):
instance
=
self
.
createSoftwareInstance
()
self
.
assertRaises
(
Unauthorized
,
instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
,
REQUEST
=
{})
def
test_tryToInvalidateIfDestroyed_unexpected_context
(
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
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'invalidated'
)
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
,
instance
,
software_
instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
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'
)
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
_not_visited
(
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
instance
,
software_
instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
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'
)
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
(
self
.
_test_alarm
_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_cloud_invalidate_destroyed_instance
,
instance
,
software_
instance
,
'SoftwareInstance_tryToInvalidateIfDestroyed'
)
#################################################################
# SoftwareInstance_tryToInvalidateIfDestroyed
#################################################################
def
test_tryToInvalidateIfDestroyed_REQUEST_disallowed
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
assertRaises
(
Unauthorized
,
software_instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
,
REQUEST
=
{})
def
test_tryToInvalidateIfDestroyed_script_unexpectedContext
(
self
):
self
.
assertRaises
(
TypeError
,
self
.
portal
.
SoftwareInstance_tryToInvalidateIfDestroyed
,
)
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"
)
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_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"
)
def
test_tryToInvalidateIfDestroyed_script_allocatedInstance
(
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'
)
software_instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
software_instance
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
"destroy_requested"
)
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