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
Klaus Wölfel
slapos.core
Commits
200a1570
Commit
200a1570
authored
Oct 26, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cover the basic cases of allocation.
parent
453dc863
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
2 deletions
+149
-2
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCoreAllocation.py
...slapos_cloud/TestTemplateItem/testSlapOSCoreAllocation.py
+146
-0
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
master/bt5/slapos_cloud/bt/template_test_id_list
master/bt5/slapos_cloud/bt/template_test_id_list
+2
-1
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCoreAllocation.py
0 → 100644
View file @
200a1570
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from
Products.SlapOS.tests.testSlapOSMixin
import
\
testSlapOSMixin
import
transaction
class
TestSlapOSAllocation
(
testSlapOSMixin
):
def
generateNewId
(
self
):
return
self
.
getPortalObject
().
portal_ids
.
generateNewId
(
id_group
=
(
'slapos_core_test'
))
def
generateNewSoftwareReleaseUrl
(
self
):
return
'http://example.org/test%s.cfg'
%
self
.
generateNewId
()
def
generateNewSoftwareType
(
self
):
return
'Type%s'
%
self
.
generateNewId
()
def
generateNewSoftwareTitle
(
self
):
return
'Title%s'
%
self
.
generateNewId
()
def
generateSafeXml
(
self
):
return
'<?xml version="1.0" encoding="utf-8"?><instance><parameter '
\
'id="param">%s</parameter></instance>'
%
self
.
generateNewId
()
def
generateEmptyXml
(
self
):
return
'<?xml version="1.0" encoding="utf-8"?><instance></instance>'
def
afterSetUp
(
self
):
super
(
TestSlapOSAllocation
,
self
).
afterSetUp
()
portal
=
self
.
getPortalObject
()
new_id
=
self
.
generateNewId
()
self
.
request_kw
=
dict
(
software_release
=
self
.
generateNewSoftwareReleaseUrl
(),
software_title
=
self
.
generateNewSoftwareTitle
(),
software_type
=
self
.
generateNewSoftwareType
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateEmptyXml
(),
shared
=
False
,
state
=
"started"
)
# Clone person document
person_user
=
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
.
updateLocalRolesOnSecurityGroups
()
person_user
.
validate
()
for
assignment
in
person_user
.
contentValues
(
portal_type
=
"Assignment"
):
assignment
.
open
()
transaction
.
commit
()
# prepare part of tree
hosting_subscription
=
portal
.
hosting_subscription_module
\
.
template_hosting_subscription
.
Base_createCloneDocument
(
batch_mode
=
1
)
self
.
software_instance
=
portal
.
software_instance_module
\
.
template_software_instance
.
Base_createCloneDocument
(
batch_mode
=
1
)
hosting_subscription
.
edit
(
title
=
self
.
request_kw
[
'software_title'
],
reference
=
"TESTHS-%s"
%
new_id
,
url_string
=
self
.
request_kw
[
'software_release'
],
source_reference
=
self
.
request_kw
[
'software_type'
],
text_content
=
self
.
request_kw
[
'instance_xml'
],
sla_xml
=
self
.
request_kw
[
'sla_xml'
],
root_slave
=
self
.
request_kw
[
'shared'
],
predecessor
=
self
.
software_instance
.
getRelativeUrl
(),
destination_section
=
person_user
.
getRelativeUrl
()
)
hosting_subscription
.
updateLocalRolesOnSecurityGroups
()
hosting_subscription
.
validate
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
hosting_subscription
,
'start_requested'
)
self
.
software_instance
.
edit
(
title
=
self
.
request_kw
[
'software_title'
],
reference
=
"TESTSI-%s"
%
new_id
,
url_string
=
self
.
request_kw
[
'software_release'
],
source_reference
=
self
.
request_kw
[
'software_type'
],
text_content
=
self
.
request_kw
[
'instance_xml'
],
sla_xml
=
self
.
request_kw
[
'sla_xml'
],
specialise
=
hosting_subscription
.
getRelativeUrl
(),
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
software_instance
,
'start_requested'
)
self
.
software_instance
.
validate
()
self
.
software_instance
.
updateLocalRolesOnSecurityGroups
()
self
.
tic
()
# Login as new Software Instance
self
.
login
(
self
.
software_instance
.
getReference
())
def
beforeTearDown
(
self
):
pass
def
test_allocation_no_free_partition
(
self
):
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
_makeComputer
(
self
):
self
.
computer
=
self
.
portal
.
computer_module
.
template_computer
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
reference
=
'TESTCOMP-%s'
%
self
.
generateNewId
()
self
.
computer
.
edit
(
allocation_scope
=
'open/public'
,
capacity_scope
=
'open'
,
reference
=
reference
,
title
=
reference
)
self
.
computer
.
validate
()
reference
=
'TESTPART-%s'
%
self
.
generateNewId
()
self
.
partition
=
self
.
computer
.
newContent
(
portal_type
=
'Computer Partition'
,
reference
=
reference
,
title
=
reference
)
self
.
partition
.
markFree
()
self
.
partition
.
validate
()
self
.
tic
()
def
_installSoftware
(
self
,
computer
,
url
):
software_installation
=
self
.
portal
.
software_installation_module
\
.
template_software_installation
.
Base_createCloneDocument
(
batch_mode
=
1
)
software_installation
.
edit
(
url_string
=
url
,
reference
=
'TESTSOFTINST-%s'
%
self
.
generateNewId
(),
aggregate
=
computer
.
getRelativeUrl
())
software_installation
.
validate
()
software_installation
.
requestStart
()
self
.
tic
()
def
test_allocation_free_partition
(
self
):
self
.
login
()
self
.
_makeComputer
()
self
.
_installSoftware
(
self
.
computer
,
self
.
software_instance
.
getUrlString
())
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'
))
master/bt5/slapos_cloud/bt/revision
View file @
200a1570
107
108
\ No newline at end of file
\ No newline at end of file
master/bt5/slapos_cloud/bt/template_test_id_list
View file @
200a1570
...
@@ -4,3 +4,4 @@ testSlapOSCorePersonRequestComputer
...
@@ -4,3 +4,4 @@ testSlapOSCorePersonRequestComputer
testSlapOSCoreSoftwareInstanceRequest
testSlapOSCoreSoftwareInstanceRequest
testSlapOSShadow
testSlapOSShadow
testSlapOSSlapTool
testSlapOSSlapTool
testSlapOSCoreAllocation
\ 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