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 @@ ...@@ -70,12 +70,6 @@
<tuple/> <tuple/>
</value> </value>
</item> </item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
...@@ -76,12 +76,6 @@ ...@@ -76,12 +76,6 @@
<tuple/> <tuple/>
</value> </value>
</item> </item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
...@@ -12,10 +12,20 @@ ...@@ -12,10 +12,20 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>acquire_local_roles</string> </key>
<value> <int>0</int> </value>
</item>
<item> <item>
<key> <string>content_icon</string> </key> <key> <string>content_icon</string> </key>
<value> <string>folder_icon.gif</string> </value> <value> <string>folder_icon.gif</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>factory</string> </key> <key> <string>factory</string> </key>
<value> <string>addFolder</string> </value> <value> <string>addFolder</string> </value>
...@@ -32,6 +42,18 @@ ...@@ -32,6 +42,18 @@
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Allocation Supply Module</string> </value> <value> <string>Allocation Supply Module</string> </value>
</item> </item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value> <value> <string>Base Type</string> </value>
...@@ -40,6 +62,12 @@ ...@@ -40,6 +62,12 @@
<key> <string>type_class</string> </key> <key> <string>type_class</string> </key>
<value> <string>Folder</string> </value> <value> <string>Folder</string> </value>
</item> </item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
...@@ -60,12 +60,6 @@ ...@@ -60,12 +60,6 @@
<tuple/> <tuple/>
</value> </value>
</item> </item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
...@@ -58,12 +58,6 @@ ...@@ -58,12 +58,6 @@
<tuple/> <tuple/>
</value> </value>
</item> </item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
...@@ -58,12 +58,6 @@ ...@@ -58,12 +58,6 @@
<tuple/> <tuple/>
</value> </value>
</item> </item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -11,9 +11,13 @@ ...@@ -11,9 +11,13 @@
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -11,9 +11,13 @@ ...@@ -11,9 +11,13 @@
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
service = context item = context
portal = context.getPortalObject() portal = context.getPortalObject()
if (item.getPortalType() == 'Instance Tree') and (item.getSlapState() == "destroy_requested"):
return 'todestroy'
# If no open order, subscription must be approved # If no open order, subscription must be approved
open_sale_order_movement_list = portal.portal_catalog( open_sale_order_movement_list = portal.portal_catalog(
portal_type=['Open Sale Order Line', 'Open Sale Order Cell'], portal_type=['Open Sale Order Line', 'Open Sale Order Cell'],
aggregate__uid=service.getUid(), aggregate__uid=item.getUid(),
validation_state='validated', validation_state='validated',
limit=1 limit=1
) )
context.log("%s %s" % (service.getRelativeUrl(), len(open_sale_order_movement_list)))
if len(open_sale_order_movement_list) == 0: if len(open_sale_order_movement_list) == 0:
return "not_subscribed" return "not_subscribed"
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -6,18 +6,18 @@ ...@@ -6,18 +6,18 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item> <item>
<key> <string>_bind_names</string> </key> <key> <string>_bind_names</string> </key>
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -11,9 +11,13 @@ ...@@ -11,9 +11,13 @@
<value> <value>
<object> <object>
<klass> <klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple/> <tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
......
...@@ -248,6 +248,36 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -248,6 +248,36 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
return person_user 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'): def _makeTree(self, project, requested_template_id='template_software_instance'):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -322,6 +352,37 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -322,6 +352,37 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
def _makeSlaveTree(self, project, requested_template_id='template_slave_instance'): def _makeSlaveTree(self, project, requested_template_id='template_slave_instance'):
return self._makeTree(project, requested_template_id=requested_template_id) 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'): def _makeComputeNode(self, project, allocation_scope='open'):
self.compute_node = self.portal.compute_node_module.template_compute_node\ self.compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1) .Base_createCloneDocument(batch_mode=1)
...@@ -436,7 +497,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -436,7 +497,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference() project_reference=project.getReference()
) )
instance_tree.requestStart(**kw) instance_tree.requestStart(**kw)
instance_tree.requestInstance(**kw) with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**kw)
self.start_requested_software_instance = instance_tree.getSuccessorValue() self.start_requested_software_instance = instance_tree.getSuccessorValue()
self.start_requested_software_instance.edit(aggregate=self.compute_node.partition1.getRelativeUrl()) self.start_requested_software_instance.edit(aggregate=self.compute_node.partition1.getRelativeUrl())
...@@ -462,7 +524,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -462,7 +524,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference() project_reference=project.getReference()
) )
instance_tree.requestStart(**slave_kw) instance_tree.requestStart(**slave_kw)
instance_tree.requestInstance(**slave_kw) with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**slave_kw)
self.start_requested_slave_instance = instance_tree.getSuccessorValue() self.start_requested_slave_instance = instance_tree.getSuccessorValue()
self.start_requested_slave_instance.edit(aggregate=self.compute_node.partition1.getRelativeUrl()) self.start_requested_slave_instance.edit(aggregate=self.compute_node.partition1.getRelativeUrl())
...@@ -488,7 +551,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -488,7 +551,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference() project_reference=project.getReference()
) )
instance_tree.requestStop(**kw) instance_tree.requestStop(**kw)
instance_tree.requestInstance(**kw) with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**kw)
self.stop_requested_software_instance = instance_tree.getSuccessorValue() self.stop_requested_software_instance = instance_tree.getSuccessorValue()
self.stop_requested_software_instance.edit( self.stop_requested_software_instance.edit(
...@@ -515,7 +579,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -515,7 +579,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference() project_reference=project.getReference()
) )
instance_tree.requestStop(**kw) instance_tree.requestStop(**kw)
instance_tree.requestInstance(**kw) with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**kw)
kw['state'] = 'destroyed' kw['state'] = 'destroyed'
instance_tree.requestDestroy(**kw) instance_tree.requestDestroy(**kw)
...@@ -546,7 +611,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -546,7 +611,8 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project_reference=project.getReference() project_reference=project.getReference()
) )
instance_tree.requestStop(**kw) instance_tree.requestStop(**kw)
instance_tree.requestInstance(**kw) with TemporaryAlarmScript(self.portal, 'Item_getSubscriptionStatus', "'subscribed'"):
instance_tree.requestInstance(**kw)
kw['state'] = 'destroyed' kw['state'] = 'destroyed'
instance_tree.requestDestroy(**kw) instance_tree.requestDestroy(**kw)
...@@ -647,9 +713,12 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -647,9 +713,12 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
# behaviour. # behaviour.
compute_node.edit(capacity_scope='open') compute_node.edit(capacity_scope='open')
elif node == "remote": elif node == "remote":
remote_project = self.addProject(is_accountable=False)
compute_node = self.portal.compute_node_module.newContent( compute_node = self.portal.compute_node_module.newContent(
portal_type="Remote Node", portal_type="Remote Node",
follow_up_value=project follow_up_value=project,
destination_project_value=remote_project,
destination_section_value=person
) )
elif node == "instance": elif node == "instance":
compute_node = self.portal.compute_node_module.newContent( compute_node = self.portal.compute_node_module.newContent(
...@@ -733,7 +802,10 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -733,7 +802,10 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
partition.markBusy() partition.markBusy()
# create fake open order, to bypass Service_getSubscriptionStatus # 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( open_order = self.portal.open_sale_order_module.newContent(
portal_type="Open Sale Order", portal_type="Open Sale Order",
ledger="automated", 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