Commit 9f463efd authored by Xavier Thompson's avatar Xavier Thompson

slapos_cloud: Add allocation tests for capabilities

parent 8195653b
...@@ -853,3 +853,66 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S ...@@ -853,3 +853,66 @@ 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_storage_redundancy_sla(self): def test_allocation_storage_redundancy_sla(self):
return self.check_allocation_category_sla('storage_redundancy', 'dht', 'raid') return self.check_allocation_category_sla('storage_redundancy', 'dht', 'raid')
def check_allocation_capability(self, capability, *bad_capability_list):
self._makeTree()
self._makeComputeNode()
self.partition.edit(subject=capability)
self._installSoftware(self.compute_node,
self.software_instance.getUrlString())
self.assertEqual(None,
self.software_instance.getAggregate(portal_type='Compute Partition'))
for bad_capability in bad_capability_list:
self.software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id='capability'>%s</parameter>
</instance>""" % bad_capability)
self.software_instance.SoftwareInstance_tryToAllocatePartition()
try:
partition = self.software_instance.getAggregate(
portal_type='Compute Partition')
self.assertEqual(None, partition)
except AssertionError:
raise AssertionError("Allocated %s on %s with capability %s" % (
bad_capability, partition, capability))
self.software_instance.setSlaXml("""<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id='capability'>%s</parameter>
</instance>""" % capability)
self.software_instance.SoftwareInstance_tryToAllocatePartition()
self.assertEqual(self.partition.getRelativeUrl(),
self.software_instance.getAggregate(portal_type='Compute Partition'))
@simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True')
def test_allocation_capability(self):
valid_id = self.generateNewId()
capability = 'toto_' + valid_id
self.check_allocation_capability(
capability,
'tutu_' + self.generateNewId(),
't%to_' + valid_id,
'%_' + valid_id,
'%',
't_to_' + valid_id,
'__' + valid_id,
'_',
'.*_' + valid_id,
'.*',
)
@simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True')
def test_allocation_capability_percent(self):
self.check_allocation_capability('%', '_')
@simulate('Person_isAllowedToAllocate', '*args, **kwargs', 'return True')
def test_allocation_capability_ipv6(self):
self.check_allocation_capability('fe80::1ff:fe23:4567:890a', 'fe80::1')
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