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
0991dfca
Commit
0991dfca
authored
Jan 26, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: preallocate test data
this will break many tests...
parent
64f62351
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
198 additions
and
209 deletions
+198
-209
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
...teItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
+59
-33
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.py
...al_components/test.erp5.testSlapOSCloudAllocationAlarm.py
+139
-176
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.SlapOSTestCaseMixin.py
View file @
0991dfca
...
@@ -611,6 +611,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
...
@@ -611,6 +611,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
url_string
=
'type%s'
%
self
.
generateNewId
(),
url_string
=
'type%s'
%
self
.
generateNewId
(),
)
)
# XXX XXX XXX XXX replqce is_allocated by allocation="prepare" "allocate" None
def
bootstrapAllocableInstanceTree
(
self
,
is_allocated
=
False
,
shared
=
False
,
node
=
"compute"
):
def
bootstrapAllocableInstanceTree
(
self
,
is_allocated
=
False
,
shared
=
False
,
node
=
"compute"
):
project
=
self
.
addProject
()
project
=
self
.
addProject
()
person
=
self
.
makePerson
(
project
)
person
=
self
.
makePerson
(
project
)
...
@@ -649,7 +650,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
...
@@ -649,7 +650,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
software_release
=
release_variation
.
getUrlString
(),
software_release
=
release_variation
.
getUrlString
(),
software_type
=
type_variation
.
getTitle
(),
software_type
=
type_variation
.
getTitle
(),
instance_xml
=
self
.
generateSafeXml
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generate
Safe
Xml
(),
sla_xml
=
self
.
generate
Empty
Xml
(),
shared
=
shared
,
shared
=
shared
,
software_title
=
'test tree'
,
software_title
=
'test tree'
,
state
=
'started'
,
state
=
'started'
,
...
@@ -658,43 +659,68 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
...
@@ -658,43 +659,68 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
person
.
requestSoftwareInstance
(
**
request_kw
)
person
.
requestSoftwareInstance
(
**
request_kw
)
instance_tree
=
self
.
portal
.
REQUEST
.
get
(
'request_instance_tree'
)
instance_tree
=
self
.
portal
.
REQUEST
.
get
(
'request_instance_tree'
)
if
is_allocated
:
if
(
node
==
"instance"
)
and
(
shared
):
if
(
node
==
"instance"
)
and
(
shared
):
real_compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
real_compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Compute Node"
,
portal_type
=
"Compute Node"
,
follow_up_value
=
project
,
follow_up_value
=
project
reference
=
'TEST-%s'
%
self
.
generateNewId
(),
)
allocation_scope
=
"open"
,
# The edit above will update capacity scope due the interaction workflow
capacity_scope
=
'open'
# The line above force capacity scope to be open, keeping the previous
)
# behaviour.
# The edit above will update capacity scope due the interaction workflow
real_compute_node
.
edit
(
capacity_scope
=
'open'
)
# The line above force capacity scope to be open, keeping the previous
real_compute_node
.
validate
()
# behaviour.
partition
=
real_compute_node
.
newContent
(
real_compute_node
.
edit
(
capacity_scope
=
'open'
)
portal_type
=
'Compute Partition'
,
real_compute_node
.
validate
()
reference
=
'reference%s'
%
self
.
generateNewId
()
partition
=
real_compute_node
.
newContent
(
)
portal_type
=
'Compute Partition'
,
software_instance
=
self
.
portal
.
software_instance_module
.
newContent
(
reference
=
'reference%s'
%
self
.
generateNewId
()
portal_type
=
"Software Instance"
,
)
follow_up_value
=
project
,
node_instance_tree
=
self
.
portal
.
instance_tree_module
.
newContent
(
aggregate_value
=
partition
title
=
'TEST-%s'
%
self
.
generateNewId
(),
)
)
compute_node
.
edit
(
specialise_value
=
software_instance
)
software_instance
=
self
.
portal
.
software_instance_module
.
newContent
(
elif
(
node
==
"instance"
)
and
(
not
shared
):
portal_type
=
"Software Instance"
,
raise
NotImplementedError
(
'can not allocate on instance node'
)
follow_up_value
=
project
,
else
:
specialise_value
=
node_instance_tree
,
partition
=
compute_node
.
newContent
(
url_string
=
release_variation
.
getUrlString
(),
portal_type
=
'Compute Partition'
,
title
=
'TEST-%s'
%
self
.
generateNewId
(),
reference
=
'reference%s'
%
self
.
generateNewId
()
reference
=
'TEST-%s'
%
self
.
generateNewId
(),
)
source_reference
=
'TEST-%s'
%
self
.
generateNewId
(),
destination_reference
=
'TEST-%s'
%
self
.
generateNewId
(),
instance
=
instance_tree
.
getSuccessorValue
()
ssl_certificate
=
'TEST-%s'
%
self
.
generateNewId
(),
instance
.
edit
(
aggregate_value
=
partition
)
ssl_key
=
'TEST-%s'
%
self
.
generateNewId
(),
)
self
.
tic
()
compute_node
.
edit
(
specialise_value
=
software_instance
)
software_instance
.
edit
(
aggregate_value
=
partition
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'start_requested'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'validated'
)
partition
.
validate
()
partition
.
validate
()
partition
.
markFree
()
partition
.
markFree
()
partition
.
markBusy
()
partition
.
markBusy
()
elif
(
node
==
"instance"
)
and
(
not
shared
):
raise
NotImplementedError
(
'can not allocate on instance node'
)
else
:
partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
,
reference
=
'reference%s'
%
self
.
generateNewId
()
)
partition
.
validate
()
partition
.
markFree
()
#compute_node.validate()
if
is_allocated
:
instance
=
instance_tree
.
getSuccessorValue
()
instance
.
edit
(
aggregate_value
=
partition
)
if
not
((
node
==
"instance"
)
and
(
shared
)):
partition
.
markBusy
()
self
.
tic
()
self
.
tic
()
return
software_product
,
release_variation
,
type_variation
,
compute_node
,
instance_tree
return
software_product
,
release_variation
,
type_variation
,
compute_node
,
partition
,
instance_tree
def
addAllocationSupply
(
self
,
title
,
node
,
software_product
,
def
addAllocationSupply
(
self
,
title
,
node
,
software_product
,
software_release
,
software_type
,
software_release
,
software_type
,
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.py
View file @
0991dfca
...
@@ -6,84 +6,107 @@ from unittest import skip
...
@@ -6,84 +6,107 @@ from unittest import skip
class
TestSlapOSAllocation
(
SlapOSTestCaseMixin
):
class
TestSlapOSAllocation
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
def
makeAllocableSoftwareInstance
(
self
,
is_allocated
=
False
,
shared
=
False
,
node
=
"compute"
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
software_product
,
release_variation
,
type_variation
,
compute_node
,
partition
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_allocated
=
is_allocated
,
shared
=
shared
,
node
=
node
)
self
.
project
=
self
.
addProject
()
self
.
addAllocationSupply
(
"for compute node"
,
compute_node
,
software_product
,
release_variation
,
type_variation
)
real_compute_node
=
partition
.
getParentValue
()
self
.
_installSoftware
(
real_compute_node
,
release_variation
.
getUrlString
()
)
self
.
tic
()
"""
if not shared:
partition = compute_node.newContent(
portal_type='Compute Partition',
reference='reference%s' % self.generateNewId()
)
partition.validate()
partition.markFree()
self.tic()"""
self
.
assertEqual
(
real_compute_node
.
getAllocationScope
(),
"open"
)
self
.
assertEqual
(
real_compute_node
.
getCapacityScope
(),
"open"
)
software_instance
=
instance_tree
.
getSuccessorValue
()
return
software_instance
,
compute_node
,
partition
def
_makeSlaveTree
(
self
,
project
,
requested_template_id
=
'template_slave_instance'
):
def
_installSoftware
(
self
,
compute_node
,
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
=
compute_node
.
getRelativeUrl
())
software_installation
.
validate
()
software_installation
.
requestStart
()
self
.
tic
()
compute_node
.
reindexObject
()
self
.
tic
()
def
_makeSlaveTreeXXX
(
self
,
project
,
requested_template_id
=
'template_slave_instance'
):
SlapOSTestCaseMixin
.
_makeTree
(
self
,
project
,
SlapOSTestCaseMixin
.
_makeTree
(
self
,
project
,
requested_template_id
=
requested_template_id
)
requested_template_id
=
requested_template_id
)
def
test_person_allocation_checked
(
self
):
def
test_person_allocation_checked
(
self
):
s
elf
.
_makeTree
(
self
.
project
)
s
oftware_instance
,
_
,
_
=
self
.
makeAllocableSoftwareInstance
(
)
with
TemporaryAlarmScript
(
self
.
portal
,
'Person_isAllowedToAllocate'
,
with
TemporaryAlarmScript
(
self
.
portal
,
'Person_isAllowedToAllocate'
,
fake_return
=
"True"
):
fake_return
=
"True"
):
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
self
.
assertEqual
(
'Visited by Person_isAllowedToAllocate'
,
'Visited by Person_isAllowedToAllocate'
,
s
elf
.
person_user
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
s
oftware_instance
.
getSpecialiseValue
().
getDestinationSectionValue
()
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_no_allocation_if_person_is_not_allowed
(
self
):
def
test_no_allocation_if_person_is_not_allowed
(
self
):
s
elf
.
_makeTree
(
self
.
project
)
s
oftware_instance
,
_
,
_
=
self
.
makeAllocableSoftwareInstance
(
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
with
TemporaryAlarmScript
(
self
.
portal
,
'Person_isAllowedToAllocate'
,
with
TemporaryAlarmScript
(
self
.
portal
,
'Person_isAllowedToAllocate'
,
fake_return
=
"False"
):
fake_return
=
"False"
):
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
self
.
assertEqual
(
self
.
assertEqual
(
'Allocation failed: Allocation disallowed'
,
'Allocation failed: Allocation disallowed'
,
s
elf
.
s
oftware_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_no_free_partition
(
self
):
def
test_allocation_no_free_partition
(
self
):
self
.
_makeTree
(
self
.
project
)
software_instance
,
_
,
partition
=
self
.
makeAllocableSoftwareInstance
()
partition
.
markBusy
()
self
.
tic
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_no_host_instance
(
self
):
def
test_allocation_no_host_instance
(
self
):
self
.
_makeSlaveTree
(
self
.
project
)
software_instance
,
_
,
partition
=
self
.
makeAllocableSoftwareInstance
(
shared
=
True
,
node
=
"instance"
)
partition
.
markFree
()
self
.
tic
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
def
_installSoftware
(
self
,
compute_node
,
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
=
compute_node
.
getRelativeUrl
())
software_installation
.
validate
()
software_installation
.
requestStart
()
self
.
tic
()
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_free_partition
(
self
):
def
test_allocation_free_partition
(
self
):
self
.
_makeTree
(
self
.
project
)
software_instance
,
_
,
partition
=
self
.
makeAllocableSoftwareInstance
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
assertEqual
(
partition
.
getRelativeUrl
(),
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
def
_allocateHost
(
self
,
software_instance
,
compute_partition
):
def
_allocateHost
(
self
,
software_instance
,
compute_partition
):
software_instance
.
edit
(
software_instance
.
edit
(
...
@@ -94,103 +117,83 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
...
@@ -94,103 +117,83 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_host_instance
(
self
):
def
test_allocation_host_instance
(
self
):
self
.
_makeSlaveTree
(
self
.
project
)
software_instance
,
_
,
partition
=
self
.
makeAllocableSoftwareInstance
(
shared
=
True
,
node
=
"instance"
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
assertEqual
(
partition
.
getRelativeUrl
(),
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_capacity_scope_close
(
self
):
def
test_allocation_capacity_scope_close
(
self
):
self
.
_makeTree
(
self
.
project
)
software_instance
,
_
,
partition
=
self
.
makeAllocableSoftwareInstance
()
partition
.
getParentValue
().
edit
(
capacity_scope
=
'close'
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
self
.
compute_node
.
edit
(
capacity_scope
=
'close'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_host_capacity_scope_close
(
self
):
def
test_allocation_host_capacity_scope_close
(
self
):
self
.
_makeSlaveTree
(
self
.
project
)
software_instance
,
_
,
partition
=
self
.
makeAllocableSoftwareInstance
(
shared
=
True
,
node
=
"instance"
)
partition
.
getParentValue
().
edit
(
capacity_scope
=
'close'
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
compute_node
.
edit
(
capacity_scope
=
'close'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_allocation_scope_close
(
self
):
def
test_allocation_allocation_scope_close
(
self
):
self
.
_makeTree
(
self
.
project
)
software_instance
,
_
,
partition
=
self
.
makeAllocableSoftwareInstance
()
partition
.
getParentValue
().
edit
(
allocation_scope
=
'close'
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
self
.
compute_node
.
edit
(
allocation_scope
=
'close'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_host_allocation_scope_close
(
self
):
def
test_allocation_host_allocation_scope_close
(
self
):
self
.
_makeSlaveTree
(
self
.
project
)
software_instance
,
_
,
partition
=
self
.
makeAllocableSoftwareInstance
(
shared
=
True
,
node
=
"instance"
)
partition
.
getParentValue
().
edit
(
allocation_scope
=
'close'
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
compute_node
.
edit
(
allocation_scope
=
'close'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_does_not_fail_on_instance_with_damaged_sla_xml
(
self
):
def
test_allocation_does_not_fail_on_instance_with_damaged_sla_xml
(
self
):
s
elf
.
_makeTree
(
self
.
project
)
s
oftware_instance
,
_
,
_
=
self
.
makeAllocableSoftwareInstance
(
)
s
elf
.
s
oftware_instance
.
setSlaXml
(
'this is not xml'
)
software_instance
.
setSlaXml
(
'this is not xml'
)
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
transaction
.
abort
()
transaction
.
abort
()
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_does_not_fail_on_slave_with_damaged_sla_xml
(
self
):
def
test_allocation_does_not_fail_on_slave_with_damaged_sla_xml
(
self
):
s
elf
.
_makeSlaveTree
(
self
.
project
)
s
oftware_instance
,
_
,
_
=
self
.
makeAllocableSoftwareInstance
(
shared
=
True
,
node
=
"instance"
)
s
elf
.
s
oftware_instance
.
setSlaXml
(
'this is not xml'
)
software_instance
.
setSlaXml
(
'this is not xml'
)
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
transaction
.
abort
()
transaction
.
abort
()
...
@@ -199,7 +202,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
...
@@ -199,7 +202,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
##################################################
##################################################
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_alarm_software_instance_unallocated
(
self
):
def
test_alarm_software_instance_unallocated
(
self
):
s
elf
.
_makeTree
(
self
.
project
)
s
oftware_instance
,
_
,
_
=
self
.
makeAllocableSoftwareInstance
(
)
with
TemporaryAlarmScript
(
self
.
portal
,
'SoftwareInstance_tryToAllocatePartition'
):
with
TemporaryAlarmScript
(
self
.
portal
,
'SoftwareInstance_tryToAllocatePartition'
):
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
...
@@ -207,11 +210,11 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
...
@@ -207,11 +210,11 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
self
.
assertEqual
(
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToAllocatePartition'
,
'Visited by SoftwareInstance_tryToAllocatePartition'
,
s
elf
.
s
oftware_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_alarm_slave_instance_unallocated
(
self
):
def
test_alarm_slave_instance_unallocated
(
self
):
s
elf
.
_makeSlaveTree
(
self
.
project
)
s
oftware_instance
,
_
,
_
=
self
.
makeAllocableSoftwareInstance
(
shared
=
True
,
node
=
"instance"
)
with
TemporaryAlarmScript
(
self
.
portal
,
'SoftwareInstance_tryToAllocatePartition'
):
with
TemporaryAlarmScript
(
self
.
portal
,
'SoftwareInstance_tryToAllocatePartition'
):
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
...
@@ -219,15 +222,11 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
...
@@ -219,15 +222,11 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
self
.
assertEqual
(
self
.
assertEqual
(
'Visited by SoftwareInstance_tryToAllocatePartition'
,
'Visited by SoftwareInstance_tryToAllocatePartition'
,
s
elf
.
s
oftware_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_alarm_software_instance_allocated
(
self
):
def
test_alarm_software_instance_allocated
(
self
):
self
.
_makeTree
(
self
.
project
)
software_instance
,
_
,
_
=
self
.
makeAllocableSoftwareInstance
(
is_allocated
=
True
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
tic
()
with
TemporaryAlarmScript
(
self
.
portal
,
'SoftwareInstance_tryToAllocatePartition'
):
with
TemporaryAlarmScript
(
self
.
portal
,
'SoftwareInstance_tryToAllocatePartition'
):
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
...
@@ -235,15 +234,11 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
...
@@ -235,15 +234,11 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
self
.
assertNotEqual
(
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToAllocatePartition'
,
'Visited by SoftwareInstance_tryToAllocatePartition'
,
s
elf
.
s
oftware_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_alarm_slave_instance_allocated
(
self
):
def
test_alarm_slave_instance_allocated
(
self
):
self
.
_makeSlaveTree
(
self
.
project
)
software_instance
,
_
,
_
=
self
.
makeAllocableSoftwareInstance
(
is_allocated
=
True
,
shared
=
True
,
node
=
"instance"
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
tic
()
with
TemporaryAlarmScript
(
self
.
portal
,
'SoftwareInstance_tryToAllocatePartition'
):
with
TemporaryAlarmScript
(
self
.
portal
,
'SoftwareInstance_tryToAllocatePartition'
):
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
self
.
portal
.
portal_alarms
.
slapos_allocate_instance
.
activeSense
()
...
@@ -251,69 +246,59 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
...
@@ -251,69 +246,59 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
self
.
assertNotEqual
(
self
.
assertNotEqual
(
'Visited by SoftwareInstance_tryToAllocatePartition'
,
'Visited by SoftwareInstance_tryToAllocatePartition'
,
s
elf
.
s
oftware_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
##################################################
##################################################
# SoftwareInstance_tryToAllocatePartition
# SoftwareInstance_tryToAllocatePartition
##################################################
##################################################
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_computer_guid
(
self
):
def
test_allocation_computer_guid
(
self
):
s
elf
.
_makeTree
(
self
.
project
)
s
oftware_instance
,
compute_node
,
partition
=
self
.
makeAllocableSoftwareInstance
(
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
self
.
assertEqual
(
self
.
compute_node
.
getAllocationScope
(),
"open"
)
self
.
assertEqual
(
self
.
compute_node
.
getCapacityScope
(),
"open"
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
software_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
<instance>
<instance>
<parameter id='computer_guid'>%s</parameter>
<parameter id='computer_guid'>%s</parameter>
</instance>"""
%
'%s_foo'
%
self
.
partition
.
getParentValue
()
.
getReference
())
</instance>"""
%
'%s_foo'
%
compute_node
.
getReference
())
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
software_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
<instance>
<instance>
<parameter id='computer_guid'>%s</parameter>
<parameter id='computer_guid'>%s</parameter>
</instance>"""
%
'%s'
%
self
.
partition
.
getParentValue
()
.
getReference
())
</instance>"""
%
'%s'
%
compute_node
.
getReference
())
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
assertEqual
(
partition
.
getRelativeUrl
(),
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_instance_guid
(
self
):
def
test_allocation_instance_guid
(
self
):
self
.
_makeSlaveTree
(
self
.
project
)
software_instance
,
_
,
partition
=
self
.
makeAllocableSoftwareInstance
(
shared
=
True
,
node
=
"instance"
)
requested_software_instance
=
partition
.
getAggregateRelatedValue
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
software_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
<instance>
<instance>
<parameter id='instance_guid'>%s</parameter>
<parameter id='instance_guid'>%s</parameter>
</instance>"""
%
'%s_foo'
%
\
</instance>"""
%
'%s_foo'
%
\
self
.
requested_software_instance
.
getReference
())
requested_software_instance
.
getReference
())
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
software_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
<instance>
<instance>
<parameter id='instance_guid'>%s</parameter>
<parameter id='instance_guid'>%s</parameter>
</instance>"""
%
'%s'
%
\
</instance>"""
%
'%s'
%
\
self
.
requested_software_instance
.
getReference
())
requested_software_instance
.
getReference
())
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
self
.
partition
.
getRelativeUrl
(),
self
.
assertEqual
(
partition
.
getRelativeUrl
(),
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_network_guid
(
self
):
def
test_allocation_network_guid
(
self
):
...
@@ -657,51 +642,29 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
...
@@ -657,51 +642,29 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_unexpected_sla_parameter
(
self
):
def
test_allocation_unexpected_sla_parameter
(
self
):
s
elf
.
_makeTree
(
self
.
project
)
s
oftware_instance
,
_
,
_
=
self
.
makeAllocableSoftwareInstance
(
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
s
elf
.
s
oftware_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
software_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
<instance>
<instance>
<parameter id='foo'>bar</parameter>
<parameter id='foo'>bar</parameter>
</instance>"""
)
</instance>"""
)
s
elf
.
s
oftware_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
None
,
self
.
assertEqual
(
None
,
s
elf
.
s
oftware_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
))
def
check_allocation_category_sla
(
self
,
base_category
,
compute_node_category
,
def
check_allocation_category_sla
(
self
,
base_category
,
compute_node_category
,
other_category
):
other_category
):
software_product
,
release_variation
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
()
software_instance
,
compute_node
,
partition
=
self
.
makeAllocableSoftwareInstance
()
self
.
addAllocationSupply
(
"for compute node"
,
compute_node
,
software_product
,
release_variation
,
type_variation
)
self
.
_installSoftware
(
compute_node
,
release_variation
.
getUrlString
()
)
self
.
tic
()
partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
,
reference
=
'reference%s'
%
self
.
generateNewId
()
)
partition
.
validate
()
partition
.
markFree
()
self
.
assertEqual
(
compute_node
.
getAllocationScope
(),
"open"
)
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
"open"
)
compute_node
.
edit
(
**
{
base_category
:
compute_node_category
})
compute_node
.
edit
(
**
{
base_category
:
compute_node_category
})
self
.
assertEqual
(
compute_node
.
getAllocationScope
(),
"open"
)
self
.
assertEqual
(
compute_node
.
getAllocationScope
(),
"open"
)
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
"open"
)
self
.
assertEqual
(
compute_node
.
getCapacityScope
(),
"open"
)
self
.
tic
()
self
.
tic
()
software_instance
=
instance_tree
.
getSuccessorValue
()
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
self
.
assertEqual
(
None
,
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
portal_type
=
'Compute Partition'
))
...
@@ -731,7 +694,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
...
@@ -731,7 +694,7 @@ class TestSlapOSAllocation(SlapOSTestCaseMixin):
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
self
.
assertEqual
(
self
.
assertEqual
(
compute_node
.
contentValues
(
portal_type
=
'Compute Partition'
)[
0
]
.
getRelativeUrl
(),
partition
.
getRelativeUrl
(),
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
),
software_instance
.
getAggregate
(
portal_type
=
'Compute Partition'
),
software_instance
.
getRelativeUrl
()
software_instance
.
getRelativeUrl
()
)
)
...
...
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