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
748aa612
Commit
748aa612
authored
Jul 05, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: fix InstanceTree_assertSuccessor tests
parent
d3d3971d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
64 deletions
+122
-64
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
...teItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
+30
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+92
-64
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
View file @
748aa612
...
...
@@ -248,6 +248,36 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
return
person_user
def
addInstanceTree
(
self
,
project
=
None
,
person
=
None
,
shared
=
False
):
# XXX supposed to replace _makeTree
if
project
is
None
:
project
=
self
.
addProject
()
self
.
tic
()
new_id
=
self
.
generateNewId
()
if
person
is
None
:
person
=
self
.
makePerson
(
project
,
new_id
=
new_id
,
index
=
False
)
person_user
=
person
request_kw
=
dict
(
software_release
=
self
.
generateNewSoftwareReleaseUrl
(),
software_title
=
self
.
generateNewSoftwareTitle
(),
software_type
=
self
.
generateNewSoftwareType
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateEmptyXml
(),
shared
=
shared
,
state
=
"started"
,
project_reference
=
project
.
getReference
()
)
# As the software url does not match any service, and any trade condition
# no instance is automatically created.
# except if we fake Item_getSubscriptionStatus
with
TemporaryAlarmScript
(
self
.
portal
,
'Item_getSubscriptionStatus'
,
"'subscribed'"
):
person_user
.
requestSoftwareInstance
(
**
request_kw
)
return
person_user
.
REQUEST
.
get
(
'request_instance_tree'
)
def
_makeTree
(
self
,
project
,
requested_template_id
=
'template_software_instance'
):
new_id
=
self
.
generateNewId
()
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
748aa612
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
import
transaction
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
,
TemporaryAlarmScript
import
time
from
zExceptions
import
Unauthorized
from
DateTime
import
DateTime
from
erp5.component.module.DateUtils
import
addToDate
class
TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
self
.
project
=
self
.
addProject
()
self
.
_makeTree
(
self
.
project
)
def
test_InstanceTree_assertSuccessor
(
self
):
self
.
software_instance
.
rename
(
new_name
=
self
.
generateNewSoftwareTitle
())
self
.
tic
()
# check that no interaction has recreated the instance
self
.
assertFalse
(
self
.
instance_tree
.
getTitle
()
in
self
.
instance_tree
.
getSuccessorTitleList
())
self
.
instance_tree
.
InstanceTree_assertSuccessor
()
self
.
assertTrue
(
self
.
instance_tree
.
getTitle
()
in
self
.
instance_tree
.
getSuccessorTitleList
())
def
test_InstanceTree_assertSuccessor_stop_requested
(
self
):
self
.
software_instance
.
rename
(
new_name
=
self
.
generateNewSoftwareTitle
())
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
instance_tree
,
'stop_requested'
)
self
.
tic
()
# check that no interaction has recreated the instance
self
.
assertFalse
(
self
.
instance_tree
.
getTitle
()
in
self
.
instance_tree
.
getSuccessorTitleList
())
self
.
instance_tree
.
InstanceTree_assertSuccessor
()
self
.
assertTrue
(
self
.
instance_tree
.
getTitle
()
in
self
.
instance_tree
.
getSuccessorTitleList
())
def
test_InstanceTree_assertSuccessor_destroy_requested
(
self
):
self
.
software_instance
.
rename
(
new_name
=
self
.
generateNewSoftwareTitle
())
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
instance_tree
,
'destroy_requested'
)
self
.
tic
()
# check that no interaction has recreated the instance
self
.
assertFalse
(
self
.
instance_tree
.
getTitle
()
in
self
.
instance_tree
.
getSuccessorTitleList
())
self
.
instance_tree
.
InstanceTree_assertSuccessor
()
self
.
assertFalse
(
self
.
instance_tree
.
getTitle
()
in
self
.
instance_tree
.
getSuccessorTitleList
())
def
test_InstanceTree_assertSuccessor_archived
(
self
):
self
.
software_instance
.
rename
(
new_name
=
self
.
generateNewSoftwareTitle
())
self
.
instance_tree
.
archive
()
self
.
tic
()
# check that no interaction has recreated the instance
self
.
assertFalse
(
self
.
instance_tree
.
getTitle
()
in
self
.
instance_tree
.
getSuccessorTitleList
())
self
.
instance_tree
.
InstanceTree_assertSuccessor
()
self
.
assertFalse
(
self
.
instance_tree
.
getTitle
()
in
self
.
instance_tree
.
getSuccessorTitleList
())
class
TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm
(
SlapOSTestCaseMixin
):
#################################################################
# InstanceTree_assertSuccessor
#################################################################
def
test_InstanceTree_assertSuccessor_alarm_orphaned
(
self
):
instance_tree
=
self
.
portal
.
instance_tree_module
.
newContent
(
portal_type
=
'Instance Tree'
...
...
@@ -80,21 +24,105 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
)
def
test_InstanceTree_assertSuccessor_alarm_renamed
(
self
):
self
.
software_instance
.
edit
(
title
=
self
.
generateNewSoftwareTitle
())
instance_tree
=
self
.
addInstanceTree
()
instance_tree
.
getSuccessorValue
().
edit
(
title
=
self
.
generateNewSoftwareTitle
())
self
.
_test_alarm
(
self
.
portal
.
portal_alarms
.
slapos_assert_instance_tree_successor
,
self
.
instance_tree
,
instance_tree
,
'InstanceTree_assertSuccessor'
)
def
test_InstanceTree_assertSuccessor_alarm_not_renamed
(
self
):
self
.
_test_alarm_not_visited
(
self
.
portal
.
portal_alarms
.
slapos_assert_instance_tree_successor
,
self
.
instance_tree
,
self
.
addInstanceTree
()
,
'InstanceTree_assertSuccessor'
)
#################################################################
# InstanceTree_assertSuccessor
#################################################################
def
test_InstanceTree_assertSuccessor_script_renamed
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
edit
(
title
=
self
.
generateNewSoftwareTitle
())
self
.
tic
()
# check that no interaction has recreated the instance
self
.
assertNotEqual
(
instance_tree
.
getTitle
(),
software_instance
.
getTitle
())
self
.
assertFalse
(
instance_tree
.
getTitle
()
in
instance_tree
.
getSuccessorTitleList
())
with
TemporaryAlarmScript
(
self
.
portal
,
'Item_getSubscriptionStatus'
,
"'subscribed'"
):
instance_tree
.
InstanceTree_assertSuccessor
()
self
.
assertNotEqual
(
instance_tree
.
getTitle
(),
software_instance
.
getTitle
())
self
.
assertTrue
(
instance_tree
.
getTitle
()
in
instance_tree
.
getSuccessorTitleList
())
def
test_InstanceTree_assertSuccessor_script_renamedAndStopped
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
edit
(
title
=
self
.
generateNewSoftwareTitle
())
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance_tree
,
'stop_requested'
)
self
.
tic
()
# check that no interaction has recreated the instance
self
.
assertNotEqual
(
instance_tree
.
getTitle
(),
software_instance
.
getTitle
())
self
.
assertFalse
(
instance_tree
.
getTitle
()
in
instance_tree
.
getSuccessorTitleList
())
with
TemporaryAlarmScript
(
self
.
portal
,
'Item_getSubscriptionStatus'
,
"'subscribed'"
):
instance_tree
.
InstanceTree_assertSuccessor
()
self
.
assertNotEqual
(
instance_tree
.
getTitle
(),
software_instance
.
getTitle
())
self
.
assertTrue
(
instance_tree
.
getTitle
()
in
instance_tree
.
getSuccessorTitleList
())
def
test_InstanceTree_assertSuccessor_script_renamedAndDestroyed
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
edit
(
title
=
self
.
generateNewSoftwareTitle
())
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
instance_tree
,
'destroy_requested'
)
self
.
tic
()
# check that no interaction has recreated the instance
self
.
assertNotEqual
(
instance_tree
.
getTitle
(),
software_instance
.
getTitle
())
self
.
assertFalse
(
instance_tree
.
getTitle
()
in
instance_tree
.
getSuccessorTitleList
())
with
TemporaryAlarmScript
(
self
.
portal
,
'Item_getSubscriptionStatus'
,
"'subscribed'"
):
instance_tree
.
InstanceTree_assertSuccessor
()
self
.
assertNotEqual
(
instance_tree
.
getTitle
(),
software_instance
.
getTitle
())
self
.
assertFalse
(
instance_tree
.
getTitle
()
in
instance_tree
.
getSuccessorTitleList
())
def
test_InstanceTree_assertSuccessor_script_archived
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
software_instance
.
edit
(
title
=
self
.
generateNewSoftwareTitle
())
instance_tree
.
archive
()
self
.
tic
()
# check that no interaction has recreated the instance
self
.
assertNotEqual
(
instance_tree
.
getTitle
(),
software_instance
.
getTitle
())
self
.
assertFalse
(
instance_tree
.
getTitle
()
in
instance_tree
.
getSuccessorTitleList
())
with
TemporaryAlarmScript
(
self
.
portal
,
'Item_getSubscriptionStatus'
,
"'subscribed'"
):
instance_tree
.
InstanceTree_assertSuccessor
()
self
.
assertNotEqual
(
instance_tree
.
getTitle
(),
software_instance
.
getTitle
())
self
.
assertFalse
(
instance_tree
.
getTitle
()
in
instance_tree
.
getSuccessorTitleList
())
#################################################################
# slapos_free_compute_partition
#################################################################
class
TestSlapOSFreeComputePartitionAlarm
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
...
...
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