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
4daf4d85
Commit
4daf4d85
authored
Nov 07, 2012
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test slave instance allocation.
parent
8eb6e1d3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
331 additions
and
10 deletions
+331
-10
master/bt5/slapos_cloud/PathTemplateItem/software_instance_module/template_slave_instance.xml
...Item/software_instance_module/template_slave_instance.xml
+141
-0
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCoreSlapOSAllocateInstanceAlarm.py
...TemplateItem/testSlapOSCoreSlapOSAllocateInstanceAlarm.py
+186
-7
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
master/bt5/slapos_cloud/bt/template_path_list
master/bt5/slapos_cloud/bt/template_path_list
+1
-0
master/product/SlapOS/tests/testSlapOSMixin.py
master/product/SlapOS/tests/testSlapOSMixin.py
+2
-2
No files found.
master/bt5/slapos_cloud/PathTemplateItem/software_instance_module/template_slave_instance.xml
0 → 100644
View file @
4daf4d85
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Slave Instance"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_Access_contents_information_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Add_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Delete_objects_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Modify_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_View_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
connection_xml
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
<?xml version=\'1.0\' encoding=\'utf-8\'?>
\n
<instance>
\n
<parameter
id=
"parameter1"
>
valueof1
</parameter>
\n
<parameter
id=
"parameter2"
>
https://niut:pass@example.com:4567/arfarf/oink?m=1#4.5
</parameter>
\n
</instance>
\n
]]>
</string>
</value>
</item>
<item>
<key>
<string>
default_destination_reference
</string>
</key>
<value>
<string>
02
</string>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
SItestVifibSlaposRestAPIV1.TestVifibSlaposRestAPIV1.test_instance_destruction_started0.325656030454
</string>
</value>
</item>
<item>
<key>
<string>
default_source_reference
</string>
</key>
<value>
<string>
RootSoftwareInstance
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
template_slave_instance
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Slave Instance
</string>
</value>
</item>
<item>
<key>
<string>
sla_xml
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
<?xml version=\'1.0\' encoding=\'utf-8\'?>
\n
<instance>
\n
<parameter
id=
"computer_guid"
>
SOMECOMP
</parameter>
\n
</instance>
\n
]]>
</string>
</value>
</item>
<item>
<key>
<string>
text_content
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
<?xml version="1.0" encoding="utf-8"?>
\n
<instance>
\n
<parameter
id=
"parameter1"
>
valueof1
</parameter>
\n
<parameter
id=
"parameter2"
>
valueof2
</parameter>
\n
</instance>
]]>
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Template Slave Instance
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCoreSlapOSAllocateInstanceAlarm.py
View file @
4daf4d85
...
...
@@ -6,15 +6,24 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript
class
TestSlapOSAllocation
(
testSlapOSMixin
):
def
afterSetUp
(
self
):
super
(
TestSlapOSAllocation
,
self
).
afterSetUp
()
def
_makeSlaveTree
(
self
,
requested_template_id
=
'template_slave_instance'
):
super
(
TestSlapOSAllocation
,
self
).
\
_makeTree
(
requested_template_id
=
requested_template_id
)
def
test_allocation_no_free_partition
(
self
):
self
.
_makeTree
()
self
.
login
()
def
beforeTearDown
(
self
):
pass
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
def
test_allocation_no_host_instance
(
self
):
self
.
_makeSlaveTree
()
self
.
login
()
def
test_allocation_no_free_partition
(
self
):
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
...
...
@@ -32,6 +41,9 @@ class TestSlapOSAllocation(testSlapOSMixin):
self
.
tic
()
def
test_allocation_free_partition
(
self
):
self
.
_makeTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_installSoftware
(
self
.
computer
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -42,7 +54,31 @@ class TestSlapOSAllocation(testSlapOSMixin):
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
_allocateHost
(
self
,
software_instance
,
computer_partition
):
software_instance
.
edit
(
aggregate_value
=
computer_partition
)
computer_partition
.
markBusy
()
self
.
tic
()
def
test_allocation_host_instance
(
self
):
self
.
_makeSlaveTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
test_allocation_capacity_scope_close
(
self
):
self
.
_makeTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_installSoftware
(
self
.
computer
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -55,7 +91,26 @@ class TestSlapOSAllocation(testSlapOSMixin):
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
test_allocation_host_capacity_scope_close
(
self
):
self
.
_makeSlaveTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
computer
.
edit
(
capacity_scope
=
'close'
)
self
.
tic
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
test_allocation_allocation_scope_close
(
self
):
self
.
_makeTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_installSoftware
(
self
.
computer
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -68,7 +123,26 @@ class TestSlapOSAllocation(testSlapOSMixin):
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
test_allocation_host_allocation_scope_close
(
self
):
self
.
_makeSlaveTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
computer
.
edit
(
allocation_scope
=
'close'
)
self
.
tic
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
test_allocation_allocation_scope_open_personal
(
self
):
self
.
_makeTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_installSoftware
(
self
.
computer
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -82,7 +156,27 @@ class TestSlapOSAllocation(testSlapOSMixin):
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
test_allocation_host_allocation_scope_open_personal
(
self
):
self
.
_makeSlaveTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
computer
.
edit
(
allocation_scope
=
'open/personal'
,
source_administration
=
self
.
person_user
.
getRelativeUrl
())
self
.
tic
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
test_allocation_allocation_scope_open_friend
(
self
):
self
.
_makeTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_installSoftware
(
self
.
computer
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -112,7 +206,55 @@ class TestSlapOSAllocation(testSlapOSMixin):
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
test_allocation_host_allocation_scope_open_friend
(
self
):
self
.
_makeSlaveTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
# change computer owner
new_id
=
self
.
generateNewId
()
person_user
=
self
.
portal
.
person_module
.
template_member
.
\
Base_createCloneDocument
(
batch_mode
=
1
)
person_user
.
edit
(
title
=
"live_test_%s"
%
new_id
,
reference
=
"live_test_%s"
%
new_id
,
default_email_text
=
"live_test_%s@example.org"
%
new_id
,
)
person_user
.
validate
()
for
assignment
in
person_user
.
contentValues
(
portal_type
=
"Assignment"
):
assignment
.
open
()
self
.
computer
.
edit
(
source_administration
=
person_user
.
getRelativeUrl
(),
destination_section
=
self
.
person_user
.
getRelativeUrl
(),
allocation_scope
=
'open/friend'
)
self
.
tic
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
software_instance
.
getAggregate
(
portal_type
=
'Computer Partition'
))
def
test_allocation_does_not_fail_on_instance_with_damaged_sla_xml
(
self
):
self
.
_makeTree
()
self
.
login
()
self
.
software_instance
.
setSlaXml
(
'this is not xml'
)
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
transaction
.
abort
()
def
test_allocation_does_not_fail_on_slave_with_damaged_sla_xml
(
self
):
self
.
_makeSlaveTree
()
self
.
login
()
self
.
software_instance
.
setSlaXml
(
'this is not xml'
)
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
...
...
@@ -139,7 +281,24 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_alarm_unallocated
(
self
):
def
test_alarm_software_instance_unallocated
(
self
):
self
.
_makeTree
()
self
.
login
()
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_slave_instance_unallocated
(
self
):
self
.
_makeSlaveTree
()
self
.
login
()
self
.
_simulateSoftwareInstance_tryToAllocatePartition
()
try
:
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
...
...
@@ -150,7 +309,27 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
'Visited by SoftwareInstance_tryToAllocatePartition'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_allocated
(
self
):
def
test_alarm_software_instance_allocated
(
self
):
self
.
_makeTree
()
self
.
login
()
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'
])
def
test_alarm_slave_instance_allocated
(
self
):
self
.
_makeSlaveTree
()
self
.
login
()
self
.
_makeComputer
()
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
tic
()
...
...
master/bt5/slapos_cloud/bt/revision
View file @
4daf4d85
224
\ No newline at end of file
225
\ No newline at end of file
master/bt5/slapos_cloud/bt/template_path_list
View file @
4daf4d85
...
...
@@ -13,4 +13,5 @@ portal_alarms/slapos_free_computer_partition
portal_alarms/slapos_garbage_collect_destroyed_root_tree
portal_alarms/slapos_update_computer_capacity_scope
software_installation_module/template_software_installation
software_instance_module/template_slave_instance
software_instance_module/template_software_instance
\ No newline at end of file
master/product/SlapOS/tests/testSlapOSMixin.py
View file @
4daf4d85
...
...
@@ -122,7 +122,7 @@ class testSlapOSMixin(Products.Vifib.tests.VifibMixin.testVifibMixin):
]
return
result
def
_makeTree
(
self
):
def
_makeTree
(
self
,
requested_template_id
=
'template_software_instance'
):
new_id
=
self
.
generateNewId
()
self
.
request_kw
=
dict
(
...
...
@@ -152,7 +152,7 @@ class testSlapOSMixin(Products.Vifib.tests.VifibMixin.testVifibMixin):
self
.
hosting_subscription
=
self
.
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
self
.
software_instance
=
self
.
portal
.
software_instance_module
\
.
template_software_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
[
requested_template_id
]
.
Base_createCloneDocument
(
batch_mode
=
1
)
self
.
hosting_subscription
.
edit
(
title
=
self
.
request_kw
[
'software_title'
],
...
...
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