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
Łukasz Nowak
slapos.core
Commits
89ed29c3
Commit
89ed29c3
authored
Sep 29, 2016
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: test destroy unlinked instances with delay and root instance case
parent
71801958
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
3 deletions
+56
-3
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareInstance_tryToGarbageUnlinkedInstance.py
...os_cloud/SoftwareInstance_tryToGarbageUnlinkedInstance.py
+7
-1
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareInstance_tryToGarbageUnlinkedInstance.xml
...s_cloud/SoftwareInstance_tryToGarbageUnlinkedInstance.xml
+1
-1
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+48
-1
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareInstance_tryToGarbageUnlinkedInstance.py
View file @
89ed29c3
...
@@ -16,7 +16,13 @@ if hosting_subscription is None or \
...
@@ -16,7 +16,13 @@ if hosting_subscription is None or \
# If instance modificationDate is too recent, skip
# If instance modificationDate is too recent, skip
# Delay destroy of unlinked instances
# Delay destroy of unlinked instances
if
instance
.
getModificationDate
()
-
addToDate
(
DateTime
(),
{
'minute'
:
-
50
})
>
0
:
if
not
delay_time
:
delay_time
=
50
if
instance
.
getModificationDate
()
-
addToDate
(
DateTime
(),
{
'minute'
:
-
1
*
delay_time
})
>
0
:
return
if
hosting_subscription
.
getTitle
()
==
instance
.
getTitle
():
# Refuse to destroy root instance
return
return
if
instance
.
getPredecessorRelatedValue
()
is
None
:
if
instance
.
getPredecessorRelatedValue
()
is
None
:
...
...
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareInstance_tryToGarbageUnlinkedInstance.xml
View file @
89ed29c3
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None
</string>
</value>
<value>
<string>
REQUEST=None
, delay_time=50
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
89ed29c3
...
@@ -5,6 +5,7 @@ from Products.SlapOS.tests.testSlapOSMixin import \
...
@@ -5,6 +5,7 @@ from Products.SlapOS.tests.testSlapOSMixin import \
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
unittest
import
skip
from
unittest
import
skip
import
json
import
json
import
time
from
zExceptions
import
Unauthorized
from
zExceptions
import
Unauthorized
from
DateTime
import
DateTime
from
DateTime
import
DateTime
from
Products.ERP5Type.DateUtils
import
addToDate
from
Products.ERP5Type.DateUtils
import
addToDate
...
@@ -2104,7 +2105,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
...
@@ -2104,7 +2105,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
instance
.
edit
(
predecessor_list
=
[])
instance
.
edit
(
predecessor_list
=
[])
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getPredecessorRelatedTitle
(),
None
)
self
.
assertEqual
(
instance0
.
getPredecessorRelatedTitle
(),
None
)
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
()
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
(
delay_time
=-
1
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSlapState
(),
'destroy_requested'
)
self
.
assertEqual
(
instance0
.
getSlapState
(),
'destroy_requested'
)
...
@@ -2141,13 +2142,59 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
...
@@ -2141,13 +2142,59 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getPredecessorRelatedTitle
(),
None
)
self
.
assertEqual
(
instance0
.
getPredecessorRelatedTitle
(),
None
)
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
(
delay_time
=-
1
)
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSlapState
(),
'destroy_requested'
)
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
# Link of child removed
self
.
assertEqual
(
instance_instance0
.
getPredecessorRelatedTitle
(),
None
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_will_delay
(
self
):
instance
=
self
.
createInstance
()
partition
=
self
.
createComputerPartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
instance0
=
self
.
doRequestInstance
(
instance
,
'instance0'
)
instance_instance0
=
self
.
doRequestInstance
(
instance0
,
'Subinstance0'
)
self
.
assertEqual
(
instance_instance0
.
getPredecessorRelatedTitle
(),
'instance0'
)
instance
.
edit
(
predecessor_list
=
[])
self
.
tic
()
self
.
assertEqual
(
instance0
.
getPredecessorRelatedTitle
(),
None
)
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
()
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
()
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSlapState
(),
'start_requested'
)
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
# delay a bit
time
.
sleep
(
2
)
# run with delay of 3 seconds
instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
(
delay_time
=
3
/
60.0
)
self
.
tic
()
self
.
assertEqual
(
instance0
.
getSlapState
(),
'destroy_requested'
)
self
.
assertEqual
(
instance0
.
getSlapState
(),
'destroy_requested'
)
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
# Link of child removed
# Link of child removed
self
.
assertEqual
(
instance_instance0
.
getPredecessorRelatedTitle
(),
None
)
self
.
assertEqual
(
instance_instance0
.
getPredecessorRelatedTitle
(),
None
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_unlinked_root
(
self
):
instance
=
self
.
createInstance
()
partition
=
self
.
createComputerPartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
self
.
assertEqual
(
self
.
hosting_subscription
.
getTitle
(),
instance
.
getTitle
())
# Remove predecessor link
self
.
hosting_subscription
.
edit
(
predecessor_list
=
[])
self
.
tic
()
self
.
assertEqual
(
instance
.
getPredecessorRelatedTitle
(),
None
)
# will not destroy
instance
.
SoftwareInstance_tryToGarbageUnlinkedInstance
(
delay_time
=-
10
)
self
.
tic
()
self
.
assertEqual
(
instance
.
getSlapState
(),
'start_requested'
)
def
test_alarm_search_inlinked_instance
(
self
):
def
test_alarm_search_inlinked_instance
(
self
):
instance
=
self
.
createInstance
()
instance
=
self
.
createInstance
()
partition
=
self
.
createComputerPartition
()
partition
=
self
.
createComputerPartition
()
...
...
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