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
Paul Graydon
slapos.core
Commits
1d5cf8e8
Commit
1d5cf8e8
authored
Oct 26, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test allocation alarm.
parent
9f176de1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCoreAllocation.py
...slapos_cloud/TestTemplateItem/testSlapOSCoreAllocation.py
+43
-0
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCoreAllocation.py
View file @
1d5cf8e8
...
...
@@ -2,6 +2,7 @@
from
Products.SlapOS.tests.testSlapOSMixin
import
\
testSlapOSMixin
import
transaction
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
class
TestSlapOSAllocation
(
testSlapOSMixin
):
...
...
@@ -142,3 +143,45 @@ class TestSlapOSAllocation(testSlapOSMixin):
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
_simulateSoftwareInstance_tryToAllocatePartition
(
self
):
script_name
=
'SoftwareInstance_tryToAllocatePartition'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'*args, **kwargs'
,
'# Script body
\
n
'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by SoftwareInstance_tryToAllocatePartition') """
)
transaction
.
commit
()
def
_dropSoftwareInstance_tryToAllocatePartition
(
self
):
script_name
=
'SoftwareInstance_tryToAllocatePartition'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_alarm_unallocated
(
self
):
self
.
_simulateSoftwareInstance_tryToAllocatePartition
()
try
:
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropSoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToAllocatePartition'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_allocated
(
self
):
self
.
_makeComputer
()
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
tic
()
self
.
_simulateSoftwareInstance_tryToAllocatePartition
()
try
:
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
self
.
tic
()
finally
:
self
.
_dropSoftwareInstance_tryToAllocatePartition
()
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToAllocatePartition'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
master/bt5/slapos_cloud/bt/revision
View file @
1d5cf8e8
111
\ No newline at end of file
112
\ No newline at end of file
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