Commit 72e909c8 authored by Łukasz Nowak's avatar Łukasz Nowak

Start testing slapos_free_computer_partition alarm.

parent aca27fb0
......@@ -79,26 +79,6 @@ class TestSlapOSAllocation(testSlapOSMixin):
self.assertEqual(None, self.software_instance.getAggregateValue(
portal_type='Computer Partition'))
def _makeComputer(self):
self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
reference = 'TESTCOMP-%s' % self.generateNewId()
self.computer.edit(
allocation_scope='open/public',
capacity_scope='open',
reference=reference,
title=reference
)
self.computer.validate()
reference = 'TESTPART-%s' % self.generateNewId()
self.partition = self.computer.newContent(portal_type='Computer Partition',
reference=reference,
title=reference
)
self.partition.markFree()
self.partition.validate()
self.tic()
def _installSoftware(self, computer, url):
software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
......
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
import transaction
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestSlapOSFreeComputerPartitionAlarm(testSlapOSMixin):
def afterSetUp(self):
super(TestSlapOSFreeComputerPartitionAlarm, self).afterSetUp()
portal = self.getPortalObject()
new_id = self.generateNewId()
self.request_kw = dict(
software_release=self.generateNewSoftwareReleaseUrl(),
software_title=self.generateNewSoftwareTitle(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateEmptyXml(),
shared=False,
state="started"
)
# Clone person document
self.person_user = portal.person_module.template_member.\
Base_createCloneDocument(batch_mode=1)
self.person_user.edit(
title="live_test_%s" % new_id,
reference="live_test_%s" % new_id,
default_email_text="live_test_%s@example.org" % new_id,
)
self.person_user.validate()
for assignment in self.person_user.contentValues(portal_type="Assignment"):
assignment.open()
transaction.commit()
# prepare part of tree
hosting_subscription = portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
self.software_instance = portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
hosting_subscription.edit(
title=self.request_kw['software_title'],
reference="TESTHS-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
root_slave=self.request_kw['shared'],
predecessor=self.software_instance.getRelativeUrl(),
destination_section=self.person_user.getRelativeUrl()
)
hosting_subscription.validate()
self.portal.portal_workflow._jumpToStateFor(hosting_subscription, 'start_requested')
self.software_instance.edit(
title=self.request_kw['software_title'],
reference="TESTSI-%s" % new_id,
url_string=self.request_kw['software_release'],
source_reference=self.request_kw['software_type'],
text_content=self.request_kw['instance_xml'],
sla_xml=self.request_kw['sla_xml'],
specialise=hosting_subscription.getRelativeUrl(),
)
self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested')
self.software_instance.validate()
self.tic()
self.login()
def test_Instance_tryToUnallocatePartition(self):
self._makeComputer()
self.software_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy()
self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested')
self.tic()
self.software_instance.Instance_tryToUnallocatePartition()
self.tic()
self.assertEqual(None, self.software_instance.getAggregate())
self.assertEqual('free', self.partition.getSlapState())
202
\ No newline at end of file
203
\ No newline at end of file
......@@ -7,4 +7,5 @@ testSlapOSCorePromiseSlapOSModuleIdGeneratorAlarm
testSlapOSCoreSlapOSAllocateInstanceAlarm
testSlapOSCoreSlapOSAssertHostingSubscriptionPredecessorAlarm
testSlapOSCoreSlapOSCloudInteractionWorkflow
testSlapOSCoreSlapOSFreeComputerPartition
testSlapOSShadow
\ No newline at end of file
......@@ -122,6 +122,26 @@ class testSlapOSMixin(Products.Vifib.tests.VifibMixin.testVifibMixin):
]
return result
def _makeComputer(self):
self.computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
reference = 'TESTCOMP-%s' % self.generateNewId()
self.computer.edit(
allocation_scope='open/public',
capacity_scope='open',
reference=reference,
title=reference
)
self.computer.validate()
reference = 'TESTPART-%s' % self.generateNewId()
self.partition = self.computer.newContent(portal_type='Computer Partition',
reference=reference,
title=reference
)
self.partition.markFree()
self.partition.validate()
self.tic()
def _makeComplexComputer(self):
for i in range(1, 5):
id_ = 'partition%s' % i
......
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