Commit dd185796 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud:

* update xml
* fix InstanceTree_assertSuccessor tests
* fixup slapos_free_compute_partition tests
* more slapos_free_compute_partition tests
* return todestroy status when instance tree is destroyed
* fixup tests for slapos_garbage_collect_destroyed_root_tree
* fixup slapos_update_compute_node_capacity_scope tests
* fixup slapos_stop_collect_instance tests
* fixup slapos_garbage_collect_non_allocated_root_tree tests
* fixup slapos_cloud_invalidate_destroyed_instance tests
* tests: prevent test to impact other tests
* test: commit transaction before end of test
* test: compatibility with _makeComplexComputeNode
* test: fixup remote node creation
parent 6ec414fc
......@@ -70,12 +70,6 @@
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -76,12 +76,6 @@
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -12,10 +12,20 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>acquire_local_roles</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>content_icon</string> </key>
<value> <string>folder_icon.gif</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>factory</string> </key>
<value> <string>addFolder</string> </value>
......@@ -32,6 +42,18 @@
<key> <string>id</string> </key>
<value> <string>Allocation Supply Module</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value>
......@@ -40,6 +62,12 @@
<key> <string>type_class</string> </key>
<value> <string>Folder</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -60,12 +60,6 @@
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -58,12 +58,6 @@
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -58,12 +58,6 @@
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -6,18 +6,18 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -6,18 +6,18 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -6,18 +6,18 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -11,9 +11,13 @@
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -6,18 +6,18 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -6,18 +6,18 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -11,9 +11,13 @@
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -6,18 +6,18 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
service = context
item = context
portal = context.getPortalObject()
if (item.getPortalType() == 'Instance Tree') and (item.getSlapState() == "destroy_requested"):
return 'todestroy'
# If no open order, subscription must be approved
open_sale_order_movement_list = portal.portal_catalog(
portal_type=['Open Sale Order Line', 'Open Sale Order Cell'],
aggregate__uid=service.getUid(),
aggregate__uid=item.getUid(),
validation_state='validated',
limit=1
)
context.log("%s %s" % (service.getRelativeUrl(), len(open_sale_order_movement_list)))
if len(open_sale_order_movement_list) == 0:
return "not_subscribed"
......
......@@ -6,18 +6,18 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -6,18 +6,18 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -11,9 +11,13 @@
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple/>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
......
......@@ -248,6 +248,36 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
return person_user
def addInstanceTree(self, project=None, person=None, shared=False):
# XXX supposed to replace _makeTree
if project is None:
project = self.addProject()
self.tic()
new_id = self.generateNewId()
if person is None:
person = self.makePerson(project, new_id=new_id, index=False)
person_user = person
request_kw = dict(
software_release=self.generateNewSoftwareReleaseUrl(),
software_title=self.generateNewSoftwareTitle(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateEmptyXml(),
shared=shared,
state="started",
project_reference=project.getReference()
)
# As the software url does not match any service, and any trade condition
# no instance is automatically created.
# except if we fake Item_getSubscriptionStatus
with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
person_user.requestSoftwareInstance(**request_kw)
return person_user.REQUEST.get('request_instance_tree')
def _makeTree(self, project, requested_template_id='template_software_instance'):
new_id = self.generateNewId()
......@@ -322,6 +352,37 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
def _makeSlaveTree(self, project, requested_template_id='template_slave_instance'):
return self._makeTree(project, requested_template_id=requested_template_id)
def addComputeNodeAndPartition(self, project=None):
# XXX replace _makeComputeNode
if project is None:
project = self.addProject()
self.tic()
reference = 'TESTCOMP-%s' % self.generateNewId()
compute_node = self.portal.compute_node_module.newContent(
portal_type="Compute Node",
#allocation_scope=allocation_scope,
reference=reference,
title=reference,
follow_up_value=project
)
# The edit above will update capacity scope due the interaction workflow
# The line above force capacity scope to be open, keeping the previous
# behaviour.
compute_node.edit(capacity_scope='open')
compute_node.validate()
reference = 'TESTPART-%s' % self.generateNewId()
partition = compute_node.newContent(
portal_type='Compute Partition',
reference=reference,
title=reference
)
partition.markFree()
partition.validate()
return compute_node, partition
def _makeComputeNode(self, project, allocation_scope='open'):
self.compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
......@@ -436,6 +497,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference()
)
instance_tree.requestStart(**kw)
with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**kw)
self.start_requested_software_instance = instance_tree.getSuccessorValue()
......@@ -462,6 +524,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference()
)
instance_tree.requestStart(**slave_kw)
with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**slave_kw)
self.start_requested_slave_instance = instance_tree.getSuccessorValue()
......@@ -488,6 +551,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference()
)
instance_tree.requestStop(**kw)
with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**kw)
self.stop_requested_software_instance = instance_tree.getSuccessorValue()
......@@ -515,6 +579,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference()
)
instance_tree.requestStop(**kw)
with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**kw)
kw['state'] = 'destroyed'
......@@ -546,6 +611,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference()
)
instance_tree.requestStop(**kw)
with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**kw)
kw['state'] = 'destroyed'
......@@ -647,9 +713,12 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
# behaviour.
compute_node.edit(capacity_scope='open')
elif node == "remote":
remote_project = self.addProject(is_accountable=False)
compute_node = self.portal.compute_node_module.newContent(
portal_type="Remote Node",
follow_up_value=project
follow_up_value=project,
destination_project_value=remote_project,
destination_section_value=person
)
elif node == "instance":
compute_node = self.portal.compute_node_module.newContent(
......@@ -733,7 +802,10 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
partition.markBusy()
# create fake open order, to bypass Service_getSubscriptionStatus
for item in [instance_tree.getSuccessorValue(), partition.getParentValue()]:
subscrible_item_list = [instance_tree]
if partition is not None:
subscrible_item_list.append(partition.getParentValue())
for item in subscrible_item_list:
open_order = self.portal.open_sale_order_module.newContent(
portal_type="Open Sale Order",
ledger="automated",
......
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