Commit 806d0d57 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud:

* preallocate test data
  this will break many tests...
* one day, I'll stop using boolean as argument...
parent e6d9f4fa
......@@ -611,7 +611,9 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
url_string='type%s' % self.generateNewId(),
)
def bootstrapAllocableInstanceTree(self, is_allocated=False, shared=False, node="compute"):
def bootstrapAllocableInstanceTree(self, allocation_state='possible', shared=False, node="compute"):
if allocation_state not in ('impossible', 'possible', 'allocated'):
raise ValueError('Not supported allocation_state: %s' % allocation_state)
project = self.addProject()
person = self.makePerson(project)
software_product = self._makeSoftwareProduct(project)
......@@ -649,7 +651,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
software_release=release_variation.getUrlString(),
software_type=type_variation.getTitle(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
sla_xml=self.generateEmptyXml(),
shared=shared,
software_title='test tree',
state='started',
......@@ -658,11 +660,14 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
person.requestSoftwareInstance(**request_kw)
instance_tree = self.portal.REQUEST.get('request_instance_tree')
if is_allocated:
if allocation_state in ('possible', 'allocated'):
if (node == "instance") and (shared):
real_compute_node = self.portal.compute_node_module.newContent(
portal_type="Compute Node",
follow_up_value=project
follow_up_value=project,
reference='TEST-%s' % self.generateNewId(),
allocation_scope="open",
capacity_scope='open'
)
# The edit above will update capacity scope due the interaction workflow
# The line above force capacity scope to be open, keeping the previous
......@@ -673,12 +678,29 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
portal_type='Compute Partition',
reference='reference%s' % self.generateNewId()
)
node_instance_tree = self.portal.instance_tree_module.newContent(
title='TEST-%s' % self.generateNewId(),
)
software_instance = self.portal.software_instance_module.newContent(
portal_type="Software Instance",
follow_up_value=project,
aggregate_value=partition
specialise_value=node_instance_tree,
url_string=release_variation.getUrlString(),
title='TEST-%s' % self.generateNewId(),
reference='TEST-%s' % self.generateNewId(),
source_reference='TEST-%s' % self.generateNewId(),
destination_reference='TEST-%s' % self.generateNewId(),
ssl_certificate='TEST-%s' % self.generateNewId(),
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.markFree()
partition.markBusy()
elif (node == "instance") and (not shared):
raise NotImplementedError('can not allocate on instance node')
else:
......@@ -687,14 +709,20 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
reference='reference%s' % self.generateNewId()
)
partition.validate()
partition.markFree()
#compute_node.validate()
if allocation_state == 'allocated':
instance = instance_tree.getSuccessorValue()
instance.edit(aggregate_value=partition)
partition.validate()
partition.markFree()
partition.markBusy()
if not ((node == "instance") and (shared)):
partition.markBusy()
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,
software_release, software_type,
......
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