Commit 0991dfca authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: preallocate test data

this will break many tests...
parent 64f62351
...@@ -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.generateSafeXml(), sla_xml=self.generateEmptyXml(),
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,
......
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