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
48856b4e
Commit
48856b4e
authored
Jan 09, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: project needed in test
Allocation Supply is now needed...
parent
338d5585
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
56 deletions
+61
-56
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.py
...al_components/test.erp5.testSlapOSCloudAllocationAlarm.py
+61
-56
No files found.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAllocationAlarm.py
View file @
48856b4e
...
...
@@ -7,8 +7,13 @@ from unittest import skip
class
TestSlapOSAllocation
(
SlapOSTestCaseMixin
):
def
_makeSlaveTree
(
self
,
requested_template_id
=
'template_slave_instance'
):
SlapOSTestCaseMixin
.
_makeTree
(
self
,
requested_template_id
=
requested_template_id
)
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
self
.
project
=
self
.
addProject
()
def
_makeSlaveTree
(
self
,
project
,
requested_template_id
=
'template_slave_instance'
):
SlapOSTestCaseMixin
.
_makeTree
(
self
,
project
,
requested_template_id
=
requested_template_id
)
def
_simulatePerson_isAllowedToAllocate
(
self
):
script_name
=
'Person_isAllowedToAllocate'
...
...
@@ -41,7 +46,7 @@ return True""" )
transaction
.
commit
()
def
test_person_allocation_checked
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_simulatePerson_isAllowedToAllocate
()
try
:
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
...
...
@@ -52,9 +57,9 @@ return True""" )
self
.
person_user
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_no_allocation_if_person_is_not_allowed
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -73,7 +78,7 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_no_free_partition
(
self
):
self
.
_makeTree
()
self
.
_makeTree
self
.
project
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
...
...
@@ -83,7 +88,7 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_no_host_instance
(
self
):
self
.
_makeSlaveTree
()
self
.
_makeSlaveTree
(
self
.
project
)
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
))
...
...
@@ -103,9 +108,9 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_free_partition
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -124,9 +129,9 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_host_instance
(
self
):
self
.
_makeSlaveTree
()
self
.
_makeSlaveTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
...
...
@@ -138,9 +143,9 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_capacity_scope_close
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
self
.
compute_node
.
edit
(
capacity_scope
=
'close'
)
...
...
@@ -154,9 +159,9 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_host_capacity_scope_close
(
self
):
self
.
_makeSlaveTree
()
self
.
_makeSlaveTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
compute_node
.
edit
(
capacity_scope
=
'close'
)
...
...
@@ -170,9 +175,9 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_allocation_scope_close
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
self
.
compute_node
.
edit
(
allocation_scope
=
'close'
)
...
...
@@ -186,9 +191,9 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_host_allocation_scope_close
(
self
):
self
.
_makeSlaveTree
()
self
.
_makeSlaveTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
compute_node
.
edit
(
allocation_scope
=
'close'
)
...
...
@@ -202,9 +207,9 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_allocation_scope_open_personal
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
,
...
...
@@ -223,9 +228,9 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_host_allocation_scope_open_personal
(
self
):
self
.
_makeSlaveTree
()
self
.
_makeSlaveTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
self
.
compute_node
.
edit
(
allocation_scope
=
'open/personal'
,
...
...
@@ -244,7 +249,7 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_does_not_fail_on_instance_with_damaged_sla_xml
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
software_instance
.
setSlaXml
(
'this is not xml'
)
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
...
...
@@ -256,7 +261,7 @@ return True""" )
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_does_not_fail_on_slave_with_damaged_sla_xml
(
self
):
self
.
_makeSlaveTree
()
self
.
_makeSlaveTree
(
self
.
project
)
self
.
software_instance
.
setSlaXml
(
'this is not xml'
)
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
...
...
@@ -286,7 +291,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_alarm_software_instance_unallocated
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_simulateSoftwareInstance_tryToAllocatePartition
()
try
:
...
...
@@ -300,7 +305,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_alarm_slave_instance_unallocated
(
self
):
self
.
_makeSlaveTree
()
self
.
_makeSlaveTree
(
self
.
project
)
self
.
_simulateSoftwareInstance_tryToAllocatePartition
()
try
:
...
...
@@ -314,9 +319,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_alarm_software_instance_allocated
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
tic
()
self
.
_simulateSoftwareInstance_tryToAllocatePartition
()
...
...
@@ -331,9 +336,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_alarm_slave_instance_allocated
(
self
):
self
.
_makeSlaveTree
()
self
.
_makeSlaveTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
software_instance
.
setAggregate
(
self
.
partition
.
getRelativeUrl
())
self
.
tic
()
self
.
_simulateSoftwareInstance_tryToAllocatePartition
()
...
...
@@ -348,9 +353,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_computer_guid
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
assertEqual
(
self
.
compute_node
.
getAllocationScope
(),
"open/public"
)
self
.
assertEqual
(
self
.
compute_node
.
getCapacityScope
(),
"open"
)
...
...
@@ -378,9 +383,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_instance_guid
(
self
):
self
.
_makeSlaveTree
()
self
.
_makeSlaveTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_allocateHost
(
self
.
requested_software_instance
,
self
.
partition
)
...
...
@@ -407,9 +412,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_network_guid
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
new_id
=
self
.
generateNewId
()
computer_network
=
self
.
portal
.
computer_network_module
.
newContent
(
portal_type
=
'Computer Network'
,
...
...
@@ -456,9 +461,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
<instance>
<parameter id='mode'>unique_by_network</parameter>
</instance>"""
self
.
_makeTree
()
compute_node1
=
self
.
_makeComputeNode
()[
0
]
compute_node2
=
self
.
_makeComputeNode
()[
0
]
self
.
_makeTree
(
self
.
project
)
compute_node1
=
self
.
_makeComputeNode
(
self
.
project
)[
0
]
compute_node2
=
self
.
_makeComputeNode
(
self
.
project
)[
0
]
self
.
_installSoftware
(
compute_node1
,
self
.
software_instance
.
getUrlString
())
self
.
_installSoftware
(
compute_node2
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -535,10 +540,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
<instance>
<parameter id='mode'>unique_by_network</parameter>
</instance>"""
self
.
_makeTree
()
compute_node1
,
partition1
=
self
.
_makeComputeNode
()
compute_node2
=
self
.
_makeComputeNode
()[
0
]
compute_node3
,
partition3
=
self
.
_makeComputeNode
()
self
.
_makeTree
(
self
.
project
)
compute_node1
,
partition1
=
self
.
_makeComputeNode
(
self
.
project
)
compute_node2
=
self
.
_makeComputeNode
(
self
.
project
)[
0
]
compute_node3
,
partition3
=
self
.
_makeComputeNode
(
self
.
project
)
computer_network1
=
self
.
_makeComputerNetwork
()
computer_network2
=
self
.
_makeComputerNetwork
()
...
...
@@ -615,8 +620,8 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
Test that when we request instance with mode as 'unique_by_network',
instance is not deployed on compute_node with no network.
"""
self
.
_makeTree
()
self
.
_makeComputeNode
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -650,7 +655,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
else
:
return
self
.
serialize_call
()
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
software_instance
.
setSlaXml
(
"""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id='mode'>unique_by_network</parameter>
...
...
@@ -678,9 +683,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
<instance>
<parameter id='mode'>unique_by_network</parameter>
</instance>"""
self
.
_makeTree
()
compute_node1
=
self
.
_makeComputeNode
()[
0
]
compute_node2
=
self
.
_makeComputeNode
()[
0
]
self
.
_makeTree
(
self
.
project
)
compute_node1
=
self
.
_makeComputeNode
(
self
.
project
)[
0
]
compute_node2
=
self
.
_makeComputeNode
(
self
.
project
)[
0
]
self
.
_installSoftware
(
compute_node1
,
self
.
software_instance
.
getUrlString
())
self
.
_installSoftware
(
compute_node2
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -743,9 +748,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@
simulate
(
'Person_isAllowedToAllocate'
,
'*args, **kwargs'
,
'return True'
)
def
test_allocation_unexpected_sla_parameter
(
self
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
_makeComputeNode
(
self
.
project
)
self
.
_installSoftware
(
self
.
compute_node
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -762,13 +767,13 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
def
check_allocation_category_sla
(
self
,
base_category
,
compute_node_category
,
other_category
):
self
.
_makeTree
()
self
.
_makeTree
(
self
.
project
)
self
.
_makeComputeNode
()
self
.
assertEqual
(
self
.
compute_node
.
getAllocationScope
(),
"open
/public
"
)
self
.
_makeComputeNode
(
self
.
project
)
self
.
assertEqual
(
self
.
compute_node
.
getAllocationScope
(),
"open"
)
self
.
assertEqual
(
self
.
compute_node
.
getCapacityScope
(),
"open"
)
self
.
compute_node
.
edit
(
**
{
base_category
:
compute_node_category
})
self
.
assertEqual
(
self
.
compute_node
.
getAllocationScope
(),
"open
/public
"
)
self
.
assertEqual
(
self
.
compute_node
.
getAllocationScope
(),
"open"
)
self
.
assertEqual
(
self
.
compute_node
.
getCapacityScope
(),
"open"
)
self
.
_installSoftware
(
self
.
compute_node
,
...
...
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