Commit 48856b4e authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: project needed in test

Allocation Supply is now needed...
parent 338d5585
...@@ -7,8 +7,13 @@ from unittest import skip ...@@ -7,8 +7,13 @@ from unittest import skip
class TestSlapOSAllocation(SlapOSTestCaseMixin): class TestSlapOSAllocation(SlapOSTestCaseMixin):
def _makeSlaveTree(self, requested_template_id='template_slave_instance'): def afterSetUp(self):
SlapOSTestCaseMixin._makeTree(self, requested_template_id=requested_template_id) 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): def _simulatePerson_isAllowedToAllocate(self):
script_name = 'Person_isAllowedToAllocate' script_name = 'Person_isAllowedToAllocate'
...@@ -41,7 +46,7 @@ return True""" ) ...@@ -41,7 +46,7 @@ return True""" )
transaction.commit() transaction.commit()
def test_person_allocation_checked(self): def test_person_allocation_checked(self):
self._makeTree() self._makeTree(self.project)
self._simulatePerson_isAllowedToAllocate() self._simulatePerson_isAllowedToAllocate()
try: try:
self.software_instance.SoftwareInstance_tryToAllocatePartition() self.software_instance.SoftwareInstance_tryToAllocatePartition()
...@@ -52,9 +57,9 @@ return True""" ) ...@@ -52,9 +57,9 @@ return True""" )
self.person_user.workflow_history['edit_workflow'][-1]['comment']) self.person_user.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):
self._makeTree() self._makeTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._installSoftware(self.compute_node, self._installSoftware(self.compute_node,
self.software_instance.getUrlString()) self.software_instance.getUrlString())
...@@ -73,7 +78,7 @@ return True""" ) ...@@ -73,7 +78,7 @@ return True""" )
@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._makeTreeself.project()
self.assertEqual(None, self.software_instance.getAggregateValue( self.assertEqual(None, self.software_instance.getAggregateValue(
portal_type='Compute Partition')) portal_type='Compute Partition'))
...@@ -83,7 +88,7 @@ return True""" ) ...@@ -83,7 +88,7 @@ return True""" )
@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._makeSlaveTree(self.project)
self.assertEqual(None, self.software_instance.getAggregateValue( self.assertEqual(None, self.software_instance.getAggregateValue(
portal_type='Compute Partition')) portal_type='Compute Partition'))
...@@ -103,9 +108,9 @@ return True""" ) ...@@ -103,9 +108,9 @@ return True""" )
@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._makeTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._installSoftware(self.compute_node, self._installSoftware(self.compute_node,
self.software_instance.getUrlString()) self.software_instance.getUrlString())
...@@ -124,9 +129,9 @@ return True""" ) ...@@ -124,9 +129,9 @@ return True""" )
@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._makeSlaveTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._allocateHost(self.requested_software_instance, self._allocateHost(self.requested_software_instance,
self.partition) self.partition)
...@@ -138,9 +143,9 @@ return True""" ) ...@@ -138,9 +143,9 @@ return True""" )
@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._makeTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._installSoftware(self.compute_node, self._installSoftware(self.compute_node,
self.software_instance.getUrlString()) self.software_instance.getUrlString())
self.compute_node.edit(capacity_scope='close') self.compute_node.edit(capacity_scope='close')
...@@ -154,9 +159,9 @@ return True""" ) ...@@ -154,9 +159,9 @@ return True""" )
@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._makeSlaveTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._allocateHost(self.requested_software_instance, self._allocateHost(self.requested_software_instance,
self.partition) self.partition)
self.compute_node.edit(capacity_scope='close') self.compute_node.edit(capacity_scope='close')
...@@ -170,9 +175,9 @@ return True""" ) ...@@ -170,9 +175,9 @@ return True""" )
@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._makeTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._installSoftware(self.compute_node, self._installSoftware(self.compute_node,
self.software_instance.getUrlString()) self.software_instance.getUrlString())
self.compute_node.edit(allocation_scope='close') self.compute_node.edit(allocation_scope='close')
...@@ -186,9 +191,9 @@ return True""" ) ...@@ -186,9 +191,9 @@ return True""" )
@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._makeSlaveTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._allocateHost(self.requested_software_instance, self._allocateHost(self.requested_software_instance,
self.partition) self.partition)
self.compute_node.edit(allocation_scope='close') self.compute_node.edit(allocation_scope='close')
...@@ -202,9 +207,9 @@ return True""" ) ...@@ -202,9 +207,9 @@ return True""" )
@simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True') @simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True')
def test_allocation_allocation_scope_open_personal(self): 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._installSoftware(self.compute_node,
self.software_instance.getUrlString()) self.software_instance.getUrlString())
self.compute_node.edit(allocation_scope='open/personal', self.compute_node.edit(allocation_scope='open/personal',
...@@ -223,9 +228,9 @@ return True""" ) ...@@ -223,9 +228,9 @@ return True""" )
@simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True') @simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True')
def test_allocation_host_allocation_scope_open_personal(self): 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._allocateHost(self.requested_software_instance,
self.partition) self.partition)
self.compute_node.edit(allocation_scope='open/personal', self.compute_node.edit(allocation_scope='open/personal',
...@@ -244,7 +249,7 @@ return True""" ) ...@@ -244,7 +249,7 @@ return True""" )
@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):
self._makeTree() self._makeTree(self.project)
self.software_instance.setSlaXml('this is not xml') self.software_instance.setSlaXml('this is not xml')
self.assertEqual(None, self.software_instance.getAggregateValue( self.assertEqual(None, self.software_instance.getAggregateValue(
...@@ -256,7 +261,7 @@ return True""" ) ...@@ -256,7 +261,7 @@ return True""" )
@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):
self._makeSlaveTree() self._makeSlaveTree(self.project)
self.software_instance.setSlaXml('this is not xml') self.software_instance.setSlaXml('this is not xml')
self.assertEqual(None, self.software_instance.getAggregateValue( self.assertEqual(None, self.software_instance.getAggregateValue(
...@@ -286,7 +291,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -286,7 +291,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@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):
self._makeTree() self._makeTree(self.project)
self._simulateSoftwareInstance_tryToAllocatePartition() self._simulateSoftwareInstance_tryToAllocatePartition()
try: try:
...@@ -300,7 +305,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -300,7 +305,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@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):
self._makeSlaveTree() self._makeSlaveTree(self.project)
self._simulateSoftwareInstance_tryToAllocatePartition() self._simulateSoftwareInstance_tryToAllocatePartition()
try: try:
...@@ -314,9 +319,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -314,9 +319,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@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._makeTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.tic() self.tic()
self._simulateSoftwareInstance_tryToAllocatePartition() self._simulateSoftwareInstance_tryToAllocatePartition()
...@@ -331,9 +336,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -331,9 +336,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@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._makeSlaveTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self.software_instance.setAggregate(self.partition.getRelativeUrl()) self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.tic() self.tic()
self._simulateSoftwareInstance_tryToAllocatePartition() self._simulateSoftwareInstance_tryToAllocatePartition()
...@@ -348,9 +353,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -348,9 +353,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@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):
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.getAllocationScope(), "open/public")
self.assertEqual(self.compute_node.getCapacityScope(), "open") self.assertEqual(self.compute_node.getCapacityScope(), "open")
...@@ -378,9 +383,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -378,9 +383,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@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._makeSlaveTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._allocateHost(self.requested_software_instance, self._allocateHost(self.requested_software_instance,
self.partition) self.partition)
...@@ -407,9 +412,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -407,9 +412,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@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):
self._makeTree() self._makeTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
new_id = self.generateNewId() new_id = self.generateNewId()
computer_network = self.portal.computer_network_module.newContent( computer_network = self.portal.computer_network_module.newContent(
portal_type='Computer Network', portal_type='Computer Network',
...@@ -456,9 +461,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -456,9 +461,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
<instance> <instance>
<parameter id='mode'>unique_by_network</parameter> <parameter id='mode'>unique_by_network</parameter>
</instance>""" </instance>"""
self._makeTree() self._makeTree(self.project)
compute_node1 = self._makeComputeNode()[0] compute_node1 = self._makeComputeNode(self.project)[0]
compute_node2 = self._makeComputeNode()[0] compute_node2 = self._makeComputeNode(self.project)[0]
self._installSoftware(compute_node1, self.software_instance.getUrlString()) self._installSoftware(compute_node1, self.software_instance.getUrlString())
self._installSoftware(compute_node2, 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 ...@@ -535,10 +540,10 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
<instance> <instance>
<parameter id='mode'>unique_by_network</parameter> <parameter id='mode'>unique_by_network</parameter>
</instance>""" </instance>"""
self._makeTree() self._makeTree(self.project)
compute_node1, partition1 = self._makeComputeNode() compute_node1, partition1 = self._makeComputeNode(self.project)
compute_node2 = self._makeComputeNode()[0] compute_node2 = self._makeComputeNode(self.project)[0]
compute_node3, partition3 = self._makeComputeNode() compute_node3, partition3 = self._makeComputeNode(self.project)
computer_network1 = self._makeComputerNetwork() computer_network1 = self._makeComputerNetwork()
computer_network2 = self._makeComputerNetwork() computer_network2 = self._makeComputerNetwork()
...@@ -615,8 +620,8 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -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', Test that when we request instance with mode as 'unique_by_network',
instance is not deployed on compute_node with no network. instance is not deployed on compute_node with no network.
""" """
self._makeTree() self._makeTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._installSoftware(self.compute_node, self._installSoftware(self.compute_node,
self.software_instance.getUrlString()) self.software_instance.getUrlString())
...@@ -650,7 +655,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -650,7 +655,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
else: else:
return self.serialize_call() return self.serialize_call()
self._makeTree() self._makeTree(self.project)
self.software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?> self.software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?>
<instance> <instance>
<parameter id='mode'>unique_by_network</parameter> <parameter id='mode'>unique_by_network</parameter>
...@@ -678,9 +683,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -678,9 +683,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
<instance> <instance>
<parameter id='mode'>unique_by_network</parameter> <parameter id='mode'>unique_by_network</parameter>
</instance>""" </instance>"""
self._makeTree() self._makeTree(self.project)
compute_node1 = self._makeComputeNode()[0] compute_node1 = self._makeComputeNode(self.project)[0]
compute_node2 = self._makeComputeNode()[0] compute_node2 = self._makeComputeNode(self.project)[0]
self._installSoftware(compute_node1, self.software_instance.getUrlString()) self._installSoftware(compute_node1, self.software_instance.getUrlString())
self._installSoftware(compute_node2, 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 ...@@ -743,9 +748,9 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
@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):
self._makeTree() self._makeTree(self.project)
self._makeComputeNode() self._makeComputeNode(self.project)
self._installSoftware(self.compute_node, self._installSoftware(self.compute_node,
self.software_instance.getUrlString()) self.software_instance.getUrlString())
...@@ -762,13 +767,13 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -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, def check_allocation_category_sla(self, base_category, compute_node_category,
other_category): other_category):
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.getAllocationScope(), "open")
self.assertEqual(self.compute_node.getCapacityScope(), "open") self.assertEqual(self.compute_node.getCapacityScope(), "open")
self.compute_node.edit(**{base_category: compute_node_category}) 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.assertEqual(self.compute_node.getCapacityScope(), "open")
self._installSoftware(self.compute_node, self._installSoftware(self.compute_node,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment