Commit 7ca9d25f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Split testSlapOSCloudWorkflow into one test per workflow

  This makes easy write or update tests per workflow-basis
parent 97a2f21c
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from unittest import expectedFailure
from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
# Clone compute_node document
self.compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
new_id = self.generateNewId()
self.compute_node.edit(
title="compute node %s" % (new_id, ),
reference="TESTCOMP-%s" % (new_id, )
)
self.compute_node.validate()
self.tic()
def beforeTearDown(self):
SlapOSTestCaseMixin.beforeTearDown(self)
self.portal.REQUEST['compute_node_key'] = None
self.portal.REQUEST['compute_node_certificate'] = None
def test_generateCertificate(self):
self.login(self.compute_node.getUserId())
self.compute_node.generateCertificate()
compute_node_key = self.portal.REQUEST.get('compute_node_key')
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertNotEqual(None, compute_node_key)
self.assertNotEqual(None, compute_node_certificate)
self.assertNotEqual(None, self.compute_node.getDestinationReference())
serial = '0x%x' % int(self.compute_node.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate)
self.assertTrue(self.compute_node.getReference() in compute_node_certificate.decode('string_escape'))
def test_generateCertificate_twice(self):
self.login(self.compute_node.getUserId())
self.compute_node.generateCertificate()
compute_node_key = self.portal.REQUEST.get('compute_node_key')
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertNotEqual(None, compute_node_key)
self.assertNotEqual(None, compute_node_certificate)
self.assertNotEqual(None, self.compute_node.getDestinationReference())
serial = '0x%x' % int(self.compute_node.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate)
self.assertTrue(self.compute_node.getReference() in compute_node_certificate.decode('string_escape'))
self.assertRaises(ValueError, self.compute_node.generateCertificate)
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
def test_approveComputeNodeRegistration(self):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node',
title="Compute Node %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTCOMP-%s" % self.new_id)
compute_node.requestComputeNodeRegistration()
compute_node.approveComputeNodeRegistration()
self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual(self.person_user.getRelativeUrl(),
compute_node.getSourceAdministration())
self.assertEqual('validated', compute_node.getValidationState())
def _countInstanceBang(self, instance, comment):
return len([q for q in instance.workflow_history[
'instance_slap_interface_workflow'] if q['action'] == 'bang' and \
q['comment'] == comment])
def _countComputeNodeeBang(self, compute_node, comment):
return len([q for q in compute_node.workflow_history[
'compute_node_slap_interface_workflow'] if q['action'] == \
'report_compute_node_bang' and q['comment'] == comment])
def test_reportComputeNodeBang(self):
self._makeComplexComputeNode()
self.login(self.compute_node.getUserId())
comment = 'Bang from compute_node'
started_instance = self.compute_node.partition1.getAggregateRelatedValue(
portal_type='Software Instance')
stopped_instance = self.compute_node.partition2.getAggregateRelatedValue(
portal_type='Software Instance')
destroyed_instance1 = self.compute_node.partition3.getAggregateRelatedValue(
portal_type='Software Instance')
destroyed_instance2 = self.compute_node.partition4.getAggregateRelatedValue(
portal_type='Software Instance')
# test sanity check -- do not trust _makeComplexComputeNode
self.assertEqual('start_requested', started_instance.getSlapState())
self.assertEqual('stop_requested', stopped_instance.getSlapState())
self.assertEqual('destroy_requested', destroyed_instance1.getSlapState())
self.assertEqual('destroy_requested', destroyed_instance2.getSlapState())
# store counts before bang
compute_node_bang_count = self._countComputeNodeeBang(self.compute_node, comment)
started_instance_bang_count = self._countInstanceBang(started_instance,
comment)
stopped_instance_bang_count = self._countInstanceBang(stopped_instance,
comment)
destroyed_instance1_bang_count = self._countInstanceBang(
destroyed_instance1, comment)
destroyed_instance2_bang_count = self._countInstanceBang(
destroyed_instance2, comment)
self.compute_node.reportComputeNodeBang(comment=comment)
self.tic()
self.assertEqual(1+compute_node_bang_count,
self._countComputeNodeeBang(self.compute_node, comment))
self.assertEqual(1+started_instance_bang_count,
self._countInstanceBang(started_instance, comment))
self.assertEqual(1+stopped_instance_bang_count,
self._countInstanceBang(stopped_instance, comment))
self.assertEqual(destroyed_instance1_bang_count,
self._countInstanceBang(destroyed_instance1, comment))
self.assertEqual(destroyed_instance2_bang_count,
self._countInstanceBang(destroyed_instance2, comment))
def test_requestSoftwareRelease_software_release_url_required(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease,
state='available')
transaction.abort()
def test_requestSoftwareRelease_state_required(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease,
software_release_url=url)
transaction.abort()
def test_requestSoftwareRelease_available(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='available')
self.tic()
self.login()
software_installation = self.compute_node.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual(url, software_installation.getUrlString())
self.assertEqual('validated', software_installation.getValidationState())
def test_requestSoftwareRelease_destroyed(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='destroyed')
self.tic()
self.login()
software_installation = self.compute_node.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual(None, software_installation)
def test_requestSoftwareRelease_available_destroyed(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='available')
self.tic()
self.login()
software_installation = self.compute_node.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual(url, software_installation.getUrlString())
self.assertEqual('validated', software_installation.getValidationState())
self.login(self.person_user.getUserId())
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='destroyed')
self.tic()
self.login()
software_installation = self.compute_node.getAggregateRelatedValue(
portal_type='Software Installation')
self.assertEqual('destroy_requested', software_installation.getSlapState())
self.assertEqual(url, software_installation.getUrlString())
self.assertEqual('validated', software_installation.getValidationState())
def test_requestSoftwareRelease_not_indexed(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='available')
transaction.commit()
self.assertRaises(NotImplementedError,
self.compute_node.requestSoftwareRelease, software_release_url=url,
state='available')
transaction.abort()
@expectedFailure
def test_requestSoftwareRelease_same_transaction(self):
self.person_user = self.makePerson()
self.compute_node.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getUserId())
url = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(software_release_url=url,
state='available')
self.assertRaises(NotImplementedError,
self.compute_node.requestSoftwareRelease, software_release_url=url,
state='available')
transaction.abort()
def test_revokeCertificate(self):
self.login(self.compute_node.getUserId())
self.compute_node.generateCertificate()
compute_node_key = self.portal.REQUEST.get('compute_node_key')
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertNotEqual(None, compute_node_key)
self.assertNotEqual(None, compute_node_certificate)
self.assertNotEqual(None, self.compute_node.getDestinationReference())
serial = '0x%x' % int(self.compute_node.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate)
self.assertTrue(self.compute_node.getReference() in compute_node_certificate.decode('string_escape'))
self.compute_node.revokeCertificate()
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
self.assertEqual(None, self.compute_node.getDestinationReference())
def test_revokeCertificateNoCertificate(self):
self.login(self.compute_node.getUserId())
self.assertRaises(ValueError, self.compute_node.revokeCertificate)
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
self.assertEqual(None, self.compute_node.getDestinationReference())
def test_revokeCertificate_twice(self):
self.login(self.compute_node.getUserId())
self.compute_node.generateCertificate()
compute_node_key = self.portal.REQUEST.get('compute_node_key')
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertNotEqual(None, compute_node_key)
self.assertNotEqual(None, compute_node_certificate)
self.assertNotEqual(None, self.compute_node.getDestinationReference())
serial = '0x%x' % int(self.compute_node.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate)
self.assertTrue(self.compute_node.getReference() in compute_node_certificate.decode('string_escape'))
self.compute_node.revokeCertificate()
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
self.assertEqual(None, self.compute_node.getDestinationReference())
self.assertRaises(ValueError, self.compute_node.revokeCertificate)
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
self.assertEqual(None, self.portal.REQUEST.get('compute_node_certificate'))
self.assertEqual(None, self.compute_node.getDestinationReference())
class TestSlapOSCoreComputeNodeSlapInterfaceWorkflowSupply(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
portal = self.getPortalObject()
# Clone compute_node document
compute_node = portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
# Clone person document
person_user = self.makePerson(new_id=self.new_id, index=0)
compute_node.edit(
title="Compute Node %s for %s" % (self.new_id, person_user.getReference()),
reference="TESTCOMP-%s" % self.new_id,
source_administration=person_user.getRelativeUrl()
)
compute_node.validate()
self.compute_node = compute_node
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
if 'software_installation_url' in self.compute_node.REQUEST:
self.compute_node.REQUEST['software_installation_url'] = None
def test_supply_requiredParameter(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease)
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease,
state="available")
self.assertRaises(TypeError, self.compute_node.requestSoftwareRelease,
software_release_url=software_release)
self.assertRaises(ValueError, self.compute_node.requestSoftwareRelease,
state="mana", software_release_url=software_release)
def test_supply_available(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
def test_supply_destroyed(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="destroyed",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(None, software_installation_url)
def test_supply_available_nonIndexed(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
transaction.commit()
self.assertRaises(NotImplementedError,
self.compute_node.requestSoftwareRelease, state="available",
software_release_url=software_release)
def test_supply_available_destroyed_nonIndexed(self):
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
transaction.commit()
self.assertRaises(NotImplementedError,
self.compute_node.requestSoftwareRelease, state="destroyed",
software_release_url=software_release)
def test_supply_available_createdSoftwareInstallation(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
def test_multiple_supply_available_createdSoftwareInstallation(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url2 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(software_installation_url, software_installation_url2)
def test_supply_available_destroyed(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
self.compute_node.requestSoftwareRelease(state="destroyed",
software_release_url=software_release)
software_installation_url2 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(software_installation_url, software_installation_url2)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url2)
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('destroy_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
def test_supply_available_destroyed_available(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
self.compute_node.requestSoftwareRelease(state="destroyed",
software_release_url=software_release)
software_installation_url2 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(software_installation_url, software_installation_url2)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url2)
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('destroy_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
# XXX: This scenario shall be discussed...
self.assertRaises(UnsupportedWorkflowMethod,
self.compute_node.requestSoftwareRelease, state="available",
software_release_url=software_release)
def test_supply_available_destroyed_finalised_available(self):
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference',
id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(None, software_installation_url)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url)
self.assertEqual(software_release, software_installation.getUrlString())
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
self.tic()
self.compute_node.requestSoftwareRelease(state="destroyed",
software_release_url=software_release)
software_installation_url2 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertEqual(software_installation_url, software_installation_url2)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url2)
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('destroy_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+1),
software_installation.getReference())
software_installation.invalidate()
self.tic()
self.compute_node.requestSoftwareRelease(state="available",
software_release_url=software_release)
software_installation_url3 = self.compute_node.REQUEST.get(
'software_installation_url')
self.assertNotEqual(software_installation_url, software_installation_url3)
software_installation = self.compute_node.restrictedTraverse(
software_installation_url3)
self.assertEqual('Software Installation',
software_installation.getPortalType())
self.assertEqual('validated', software_installation.getValidationState())
self.assertEqual('start_requested', software_installation.getSlapState())
self.assertEqual('SOFTINSTALL-%s' % (previous_id+2),
software_installation.getReference())
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudComputeNodeSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSCoreComputePartitionSlapInterfaceWorkflow(SlapOSTestCaseMixin):
def afterSetUp(self):
self.login()
SlapOSTestCaseMixin.afterSetUp(self)
# Clone compute_node document
self.compute_node = self.portal.compute_node_module.template_compute_node\
.Base_createCloneDocument(batch_mode=1)
self.compute_node.edit(
title="compute node %s" % (self.new_id, ),
reference="TESTCOMP-%s" % (self.new_id, ),
allocation_scope='open/personal',
capacity_scope='open',
)
self.compute_node.validate()
login = self.compute_node.newContent(
portal_type="ERP5 Login",
reference=self.compute_node.getReference()
)
login.validate()
# install an software release
self.software_installation = self.portal.software_installation_module\
.newContent(portal_type='Software Installation',
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.compute_node.getRelativeUrl())
self.software_installation.validate()
self.software_installation.requestStart()
self.tic()
self.login(self.compute_node.getUserId())
def test_markFree(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
def test_markFree_markBusy(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
partition.markBusy()
self.tic()
self.assertEqual(0, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
def test_markFree_markBusy_markFree(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
partition.markBusy()
self.tic()
self.assertEqual(0, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
def test_markInactive(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markInactive()
self.tic()
self.assertEqual(0, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
def test_markInactive_markFree(self):
partition = self.compute_node.newContent(portal_type='Compute Partition',
reference='PART-%s' % self.generateNewId())
partition.validate()
partition.markInactive()
self.tic()
self.assertEqual(0, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
partition.markFree()
self.tic()
self.assertEqual(1, self.portal.portal_catalog.countResults(
parent_uid=self.compute_node.getUid(), free_for_request=1)[0][0])
......@@ -14,7 +14,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudWorkflow</string> </value>
<value> <string>testSlapOSCloudComputePartitionSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -24,7 +24,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudWorkflow</string> </value>
<value> <string>test.erp5.testSlapOSCloudComputePartitionSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from unittest import expectedFailure
class TestSlapOSCoreInstanceSlapInterfaceWorkflow(SlapOSTestCaseMixin):
"""Tests instance.requestInstance"""
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
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.generateSafeXml(),
shared=False,
state="started"
)
# prepare part of tree
instance_tree = portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
self.software_instance = portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
instance_tree.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'],
successor=self.software_instance.getRelativeUrl()
)
instance_tree.validate()
self.portal.portal_workflow._jumpToStateFor(instance_tree, '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=instance_tree.getRelativeUrl()
)
self.portal.portal_workflow._jumpToStateFor(self.software_instance, 'start_requested')
self.software_instance.validate()
self.tic()
# Login as new Software Instance
self.login(self.software_instance.getUserId())
def beforeTearDown(self):
transaction.abort()
if 'request_instance' in self.software_instance.REQUEST:
self.software_instance.REQUEST['request_instance'] = None
def test_request_requiredParameter(self):
good_request_kw = self.request_kw.copy()
# in order to have unique requested title
good_request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**good_request_kw)
# substract parameters
request_kw = good_request_kw.copy()
request_kw.pop('software_release')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('software_title')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('software_type')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('instance_xml')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('sla_xml')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('shared')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
request_kw = good_request_kw.copy()
request_kw.pop('state')
self.assertRaises(KeyError, self.software_instance.requestInstance,
**request_kw)
def test_request_createdInstance(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
def test_request_sameTitle(self):
# check that correct request does not raise
self.assertRaises(ValueError, self.software_instance.requestInstance,
**self.request_kw)
def test_request_shared_True(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = True
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Slave Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
def test_request_shared_unsupported(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = 'True'
self.assertRaises(ValueError, self.software_instance.requestInstance,
**request_kw)
def test_request_unindexed(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
transaction.commit()
self.assertRaises(NotImplementedError, self.software_instance.requestInstance,
**request_kw)
def test_request_double(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
self.tic()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance2)
self.assertEqual(requested_instance2.getRelativeUrl(),
requested_instance.getRelativeUrl())
self.assertEqual(request_kw['software_title'],
requested_instance2.getTitle())
self.assertEqual('Software Instance',
requested_instance2.getPortalType())
self.assertEqual('validated',
requested_instance2.getValidationState())
self.assertEqual('start_requested',
requested_instance2.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance2.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance2.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance2.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance2.getSourceReference())
def test_request_duplicated(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
duplicate = self.software_instance.Base_createCloneDocument(batch_mode=1)
duplicate.edit(
reference='TESTSI-%s' % self.generateNewId(),
title=request_kw['software_title'])
duplicate.validate()
self.portal.portal_workflow._jumpToStateFor(duplicate, 'start_requested')
duplicate2 = self.software_instance.Base_createCloneDocument(batch_mode=1)
duplicate2.edit(
reference='TESTSI-%s' % self.generateNewId(),
title=request_kw['software_title'])
duplicate2.validate()
self.portal.portal_workflow._jumpToStateFor(duplicate2, 'start_requested')
self.software_instance.getSpecialiseValue(
portal_type='Instance Tree').edit(
successor_list=[
duplicate.getRelativeUrl(),
duplicate2.getRelativeUrl(),
self.software_instance.getRelativeUrl()
]
)
self.tic()
self.assertRaises(ValueError, self.software_instance.requestInstance,
**request_kw)
def test_request_destroyed_state(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['state'] = 'destroyed'
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
# requesting with destroyed state shall not create new instance
self.assertEqual(None, requested_instance)
def test_request_two_different(self):
request_kw = self.request_kw.copy()
# in order to have unique requested title
request_kw['software_title'] = self.generateNewSoftwareTitle()
# check that correct request does not raise
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertSameSet(
self.software_instance.getSuccessorList(),
[requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl()])
def test_request_tree_change_indexed(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree shall change to:
A
|
A
|
B
|
C"""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.tic() # in order to recalculate tree
B_instance.requestInstance(**request_kw)
C1_instance = self.software_instance.REQUEST.get('request_instance')
self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl())
self.assertSameSet(self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl()])
self.assertSameSet(B_instance.getSuccessorList(),
[C_instance.getRelativeUrl()])
def test_request_tree_change_not_indexed(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree in next transaction, but before indexation,
the system shall disallow the operation."""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
transaction.commit()
self.assertRaises(NotImplementedError, B_instance.requestInstance,
**request_kw)
@expectedFailure
def test_request_tree_change_same_transaction(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree in the same transaction the system shall
disallow the operation."""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.assertRaises(NotImplementedError, B_instance.requestInstance,
**request_kw)
def test_request_started_stopped_destroyed(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance)
self.assertEqual(request_kw['software_title'],
requested_instance.getTitle())
self.assertEqual('Software Instance',
requested_instance.getPortalType())
self.assertEqual('validated',
requested_instance.getValidationState())
self.assertEqual('start_requested',
requested_instance.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance.getSourceReference())
self.tic()
request_kw['state'] = 'stopped'
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
self.assertNotEqual(None, requested_instance2)
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['software_title'],
requested_instance2.getTitle())
self.assertEqual('Software Instance',
requested_instance2.getPortalType())
self.assertEqual('validated',
requested_instance2.getValidationState())
self.assertEqual('stop_requested',
requested_instance2.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance2.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance2.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance2.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance2.getSourceReference())
self.tic()
request_kw['state'] = 'destroyed'
self.software_instance.requestInstance(**request_kw)
requested_instance3 = self.software_instance.REQUEST.get(
'request_instance')
self.assertEqual(None, requested_instance3)
# in case of destruction instance is not returned, so fetch it
# directly form document
requested_instance3 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
self.assertEqual(request_kw['software_title'],
requested_instance3.getTitle())
self.assertEqual('Software Instance',
requested_instance3.getPortalType())
self.assertEqual('validated',
requested_instance3.getValidationState())
self.assertEqual('destroy_requested',
requested_instance3.getSlapState())
self.assertEqual(request_kw['software_release'],
requested_instance3.getUrlString())
self.assertEqual(request_kw['instance_xml'],
requested_instance3.getTextContent())
self.assertEqual(request_kw['sla_xml'],
requested_instance3.getSlaXml())
self.assertEqual(request_kw['software_type'],
requested_instance3.getSourceReference())
def _countBang(self, document):
return len([q for q in document.workflow_history[
'instance_slap_interface_workflow'] if q['action'] == 'bang'])
def test_request_started_no_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(bang_amount, self._countBang(requested_instance))
def test_request_stopped_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['state'] = 'stopped'
self.software_instance.requestInstance(**request_kw)
transaction.commit()
requested_instance2 = self.software_instance.REQUEST.get(
'request_instance')
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_destroyed_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['state'] = 'destroyed'
self.software_instance.requestInstance(**request_kw)
transaction.commit()
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_tree_change_indexed_shared(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree shall change to:
A
|
A
|
B
|
C"""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = True
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.tic() # in order to recalculate tree
B_instance.requestInstance(**request_kw)
C1_instance = self.software_instance.REQUEST.get('request_instance')
self.assertEqual(C_instance.getRelativeUrl(), C1_instance.getRelativeUrl())
self.assertSameSet(self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl()])
self.assertSameSet(B_instance.getSuccessorList(),
[C_instance.getRelativeUrl()])
def test_request_tree_change_not_indexed_shared(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree in next transaction, but before indexation,
the system shall disallow the operation."""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = True
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
transaction.commit()
self.assertRaises(NotImplementedError, B_instance.requestInstance,
**request_kw)
@expectedFailure
def test_request_tree_change_same_transaction_shared(self):
"""Checks tree change forced by request
For a tree like:
A
|
A
|\
B C
When B requests C tree in the same transaction the system shall
disallow the operation."""
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
request_kw['shared'] = True
self.software_instance.requestInstance(**request_kw)
B_instance = self.software_instance.REQUEST.get('request_instance')
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
C_instance = self.software_instance.REQUEST.get('request_instance')
self.assertSameSet(
self.software_instance.getSuccessorList(),
[B_instance.getRelativeUrl(), C_instance.getRelativeUrl()])
self.assertRaises(NotImplementedError, B_instance.requestInstance,
**request_kw)
def test_request_software_release_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['software_release'] = self.generateNewSoftwareReleaseUrl()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['software_release'],
requested_instance2.getUrlString())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_software_type_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['software_type'] = self.generateNewSoftwareReleaseUrl()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['software_type'],
requested_instance2.getSourceReference())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_instance_xml_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['instance_xml'] = self.generateSafeXml()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['instance_xml'],
requested_instance2.getTextContent())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_request_sla_xml_bang(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(requested_instance)
request_kw['sla_xml'] = self.generateSafeXml()
self.software_instance.requestInstance(**request_kw)
requested_instance2 = self.software_instance.getSuccessorValue(
portal_type='Software Instance')
transaction.commit()
self.assertEqual(requested_instance.getRelativeUrl(),
requested_instance2.getRelativeUrl())
self.assertEqual(request_kw['sla_xml'],
requested_instance2.getSlaXml())
self.assertEqual(bang_amount+1, self._countBang(requested_instance))
def test_update_connection_bang_requester(self):
request_kw = self.request_kw.copy()
request_kw['software_title'] = self.generateNewSoftwareTitle()
self.software_instance.requestInstance(**request_kw)
requested_instance = self.software_instance.REQUEST.get(
'request_instance')
self.tic()
bang_amount = self._countBang(self.software_instance)
connection_xml = self.generateSafeXml()
requested_instance.updateConnection(connection_xml=connection_xml)
transaction.commit()
self.assertEqual(bang_amount+1, self._countBang(self.software_instance))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudInstanceSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
class TestSlapOSCoreSlapOSCloudInteractionWorkflow(SlapOSTestCaseMixin):
def test_ComputeNode_setSubjectList(self):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
new_id = self.generateNewId()
compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node',
title="Compute Node %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTCOMP-%s" % new_id)
self.tic()
assert compute_node.getDestinationSectionValue() is None
compute_node.edit(subject_list=[self.person_user.getDefaultEmailText()])
self.tic()
assert compute_node.getDestinationSection() == \
self.person_user.getRelativeUrl()
def check_Instance_validate(self, portal_type):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
# Instance Tree required for security.
hs = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree',
title="HS %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTHS-%s" % self.new_id,
destination_reference="TESTHS-%s" % self.new_id,
destination_section=self.person_user.getRelativeUrl()
)
instance = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTINST-%s" % self.new_id,
specialise_value=hs)
if portal_type == "Software Instance":
self._addERP5Login(instance)
self.tic()
def verify_activeSense_call(self):
if self.getRelativeUrl() == 'portal_alarms/slapos_allocate_instance':
instance.portal_workflow.doActionFor(instance, action='edit_action',
comment='activeSense triggered')
else:
return self.activeSense_call()
from Products.ERP5Type.Document.Alarm import Alarm #pylint: disable=import-error
Alarm.activeSense_call = Alarm.activeSense
Alarm.activeSense = verify_activeSense_call
try:
instance.validate()
self.tic()
finally:
Alarm.activeSense = Alarm.activeSense_call
self.assertEqual(
'activeSense triggered',
instance.workflow_history['edit_workflow'][-1]['comment'])
def test_SoftwareInstance_validate(self):
return self.check_Instance_validate("Software Instance")
def test_SlaveInstance_validate(self):
return self.check_Instance_validate("Slave Instance")
def test_SlaveInstance_requestDestroy(self):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
# Instance Tree required for security.
hs = self.portal.instance_tree_module.newContent(
portal_type='Instance Tree',
title="HS %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTHS-%s" % self.new_id,
destination_reference="TESTHS-%s" % self.new_id,
destination_section=self.person_user.getRelativeUrl()
)
instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance',
title="Instance %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTINST-%s" % self.new_id,
destination_reference="TESTINST-%s" % self.new_id,
destination_section=self.person_user.getRelativeUrl(),
specialise_value=hs
)
request_kw = dict(
software_release='http://example.org',
software_type='http://example.org',
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=True,
)
instance.requestStop(**request_kw)
self.assertEqual(instance.getValidationState(), 'draft')
instance.validate()
self.assertEqual(instance.getValidationState(), 'validated')
instance.requestDestroy(**request_kw)
self.assertEqual(instance.getValidationState(), 'invalidated')
def check_SoftwareInstallation_changeState(self, method_id):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node',
title="Compute Node %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTCOMP-%s" % self.new_id)
self._addERP5Login(compute_node)
installation = self.portal.software_installation_module.newContent(
portal_type='Software Installation',
title="Installation %s for %s" % (self.new_id, self.person_user.getReference()),
aggregate_value=compute_node,
)
self.tic()
def verify_reindexObject_call(self, *args, **kw):
if self.getRelativeUrl() == compute_node.getRelativeUrl():
compute_node.portal_workflow.doActionFor(compute_node, action='edit_action',
comment='reindexObject triggered on %s' % method_id)
else:
return self.reindexObject_call(*args, **kw)
from Products.ERP5Type.Base import Base
Base.reindexObject_call = Base._reindexObject
Base._reindexObject = verify_reindexObject_call
try:
getattr(installation, method_id)()
self.tic()
finally:
Base._reindexObject = Base.reindexObject_call
self.assertEqual(
'reindexObject triggered on %s' % method_id,
compute_node.workflow_history['edit_workflow'][-1]['comment'])
def test_SoftwareInstallation_changeState_onStart(self):
return self.check_SoftwareInstallation_changeState('requestStart')
def test_SoftwareInstallation_changeState_onDestroy(self):
return self.check_SoftwareInstallation_changeState('requestDestroy')
def check_SoftwareInstance_changeState(self, method_id):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
new_id = self.generateNewId()
compute_node = self.portal.compute_node_module.newContent(
portal_type='Compute Node',
title="Compute Node %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTCOMP-%s" % new_id)
self._addERP5Login(compute_node)
partition = compute_node.newContent(
portal_type='Compute Partition',
title="Partition Compute Node %s for %s" % (new_id,
self.person_user.getReference()),
reference="TESTPART-%s" % new_id)
instance = self.portal.software_instance_module.newContent(
portal_type="Software Instance",
title="Instance %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTINST-%s" % new_id,
aggregate_value=partition,
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
)
request_kw = dict(
software_release='http://example.org',
software_type='http://example.org',
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
)
if method_id == 'requestDestroy':
instance.requestStop(**request_kw)
self.tic()
def verify_reindexObject_call(self, *args, **kw):
if self.getRelativeUrl() == partition.getRelativeUrl():
partition.portal_workflow.doActionFor(partition, action='edit_action',
comment='reindexObject triggered on %s' % method_id)
else:
return self.reindexObject_call(*args, **kw)
# Replace activeSense by a dummy method
from Products.ERP5Type.Base import Base
Base.reindexObject_call = Base._reindexObject
Base._reindexObject = verify_reindexObject_call
try:
getattr(instance, method_id)(**request_kw)
self.tic()
finally:
Base._reindexObject = Base.reindexObject_call
self.assertEqual(
'reindexObject triggered on %s' % method_id,
partition.workflow_history['edit_workflow'][-1]['comment'])
def test_SoftwareInstance_changeState_onStart(self):
return self.check_SoftwareInstance_changeState("requestStart")
def test_SoftwareInstance_changeState_onStop(self):
return self.check_SoftwareInstance_changeState("requestStop")
def test_SoftwareInstance_changeState_onDestroy(self):
return self.check_SoftwareInstance_changeState("requestDestroy")
def check_change_instance_parameter(self, portal_type, method_id):
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
instance = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (self.new_id, self.person_user.getReference()),
reference="TESTINST-%s" % self.new_id,
destination_reference="TESTINST-%s" % self.new_id,
ssl_certificate="foo",
ssl_key="bar",
)
self.tic()
self.assertEqual(None,
instance.workflow_history['instance_slap_interface_workflow'][-1]['action'])
instance.edit(**{method_id: self.generateSafeXml()})
self.tic()
self.assertEqual('bang',
instance.workflow_history['instance_slap_interface_workflow'][-1]['action'])
def test_change_instance_parameter_onInstanceUrlString(self):
return self.check_change_instance_parameter("Software Instance",
'url_string')
def test_change_instance_parameter_onInstanceTextContent(self):
return self.check_change_instance_parameter("Software Instance",
'text_content')
def test_change_instance_parameter_onInstanceSourceReference(self):
return self.check_change_instance_parameter("Software Instance",
'source_reference')
def test_change_instance_parameter_onInstanceSlaXML(self):
return self.check_change_instance_parameter("Software Instance",
'sla_xml')
def test_change_instance_parameter_onSlaveUrlString(self):
return self.check_change_instance_parameter("Slave Instance",
'url_string')
def test_change_instance_parameter_onSlaveTextContent(self):
return self.check_change_instance_parameter("Slave Instance",
'text_content')
def test_change_instance_parameter_onSlaveSourceReference(self):
return self.check_change_instance_parameter("Slave Instance",
'source_reference')
def test_change_instance_parameter_onSlaveSlaXML(self):
return self.check_change_instance_parameter("Slave Instance",
'sla_xml')
def test_SoftwareInstance_setSuccessorList(self):
portal_type = "Software Instance"
self.person_user = self.makePerson()
self.login(self.person_user.getUserId())
new_id = self.generateNewId()
instance3 = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTINST-%s" % new_id,
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
)
new_id = self.generateNewId()
instance2 = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTINST-%s" % new_id,
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
successor_value=instance3,
)
new_id = self.generateNewId()
instance1 = self.portal.software_instance_module.newContent(
portal_type=portal_type,
title="Instance %s for %s" % (new_id, self.person_user.getReference()),
reference="TESTINST-%s" % new_id,
destination_reference="TESTINST-%s" % new_id,
ssl_certificate="foo",
ssl_key="bar",
successor_value=instance2,
)
self.tic()
def verify_reindexObject_call(self, *args, **kw):
if self.getRelativeUrl() in (instance2.getRelativeUrl(),
instance3.getRelativeUrl()):
self.portal_workflow.doActionFor(instance1, action='edit_action',
comment='reindexObject triggered')
else:
return self.reindexObject_call(*args, **kw)
# Replace activeSense by a dummy method
from Products.ERP5Type.Base import Base
Base.reindexObject_call = Base._reindexObject
Base._reindexObject = verify_reindexObject_call
try:
instance1.edit(successor_value=instance3)
self.tic()
finally:
Base._reindexObject = Base.reindexObject_call
self.assertEqual(
'reindexObject triggered',
instance1.workflow_history['edit_workflow'][-1]['comment'])
self.assertEqual(
'reindexObject triggered',
instance1.workflow_history['edit_workflow'][-2]['comment'])
self.assertEqual(
None,
instance1.workflow_history['edit_workflow'][-3]['comment'])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudInteractionWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudInteractionWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
import transaction
from unittest import expectedFailure
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager
class TestSlapOSCorePersonRequest(SlapOSTestCaseMixin):
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
pass
def test_Person_requestSoftwareInstance_requiredParameter(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
self.assertRaises(TypeError, person.requestSoftwareInstance)
# software_release is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# software_title is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# software_type is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# instance_xml is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# instance_xml is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
sla_xml=sla_xml,
shared=shared,
state=state,
)
# sla_xml is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state=state,
)
# shared is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
state=state,
)
# state is mandatory
self.assertRaises(TypeError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
)
def test_Person_requestSoftwareInstance_acceptedState(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
# Only started, stopped, destroyed
self.assertRaises(ValueError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="foo",
)
person.requestSoftwareInstance(
software_release=software_release,
software_title="started",
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="started",
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual("start_requested", instance_tree.getSlapState())
person.requestSoftwareInstance(
software_release=software_release,
software_title="stopped",
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="stopped",
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual("stop_requested", instance_tree.getSlapState())
person.requestSoftwareInstance(
software_release=software_release,
software_title="destroyed",
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="destroyed",
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual(None, instance_tree)
def test_Person_requestSoftwareInstance_returnInstanceTreeUrl(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual("Instance Tree",
instance_tree.getPortalType())
def test_Person_requestSoftwareInstance_createInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_hosting_subscription_reference',
id_generator='uid')
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
self.assertEqual(software_release,
instance_tree.getUrlString())
self.assertEqual(software_title, instance_tree.getTitle())
self.assertEqual(software_type, instance_tree.getSourceReference())
self.assertEqual(instance_xml, instance_tree.getTextContent())
self.assertEqual(sla_xml, instance_tree.getSlaXml())
self.assertEqual(shared, instance_tree.getRootSlave())
self.assertEqual("start_requested", instance_tree.getSlapState())
self.assertEqual("HOSTSUBS-%s" % (previous_id+1),
instance_tree.getReference())
self.assertEqual("validated", instance_tree.getValidationState())
def test_Person_requestSoftwareInstance_InstanceTreeNotReindexed(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
transaction.commit()
self.assertRaises(NotImplementedError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
@expectedFailure
def test_Person_requestSoftwareInstance_updateInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
instance_tree_reference = instance_tree.getReference()
transaction.commit()
self.tic()
software_release2 = self.generateNewSoftwareReleaseUrl()
software_type2 = "test2"
instance_xml2 = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
sla_xml2 = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
shared2 = False
state2 = "stopped"
person.requestSoftwareInstance(
software_release=software_release2,
software_title=software_title,
software_type=software_type2,
instance_xml=instance_xml2,
sla_xml=sla_xml2,
shared=shared2,
state=state2,
)
instance_tree2 = person.REQUEST.get('request_instance_tree')
self.assertEqual(instance_tree.getRelativeUrl(),
instance_tree2.getRelativeUrl())
self.assertEqual(instance_tree_reference,
instance_tree2.getReference())
self.assertEqual(software_release2,
instance_tree.getUrlString())
self.assertEqual(software_title, instance_tree.getTitle())
self.assertEqual(software_type2, instance_tree.getSourceReference())
self.assertEqual(instance_xml2, instance_tree.getTextContent())
self.assertEqual(sla_xml2, instance_tree.getSlaXml())
self.assertEqual(shared2, instance_tree.getRootSlave())
self.assertEqual("stop_requested", instance_tree.getSlapState())
self.assertEqual("validated", instance_tree.getValidationState())
def test_Person_requestSoftwareInstance_duplicatedInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
transaction.commit()
instance_tree2 = instance_tree.Base_createCloneDocument(
batch_mode=1)
instance_tree2.validate()
transaction.commit()
self.tic()
self.assertRaises(NotImplementedError, person.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
def test_Person_requestSoftwareInstance_InstanceTreeNewTitle(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
sla_xml = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
shared = True
state = "started"
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state=state,
)
instance_tree = person.REQUEST.get('request_instance_tree')
transaction.commit()
software_release2 = self.generateNewSoftwareReleaseUrl()
software_title2 = "test2"
software_type2 = "test2"
instance_xml2 = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
sla_xml2 = """<?xml version='1.0' encoding='utf-8'?>
<instance>
</instance>"""
shared2 = False
state2 = "stopped"
person.requestSoftwareInstance(
software_release=software_release2,
software_title=software_title2,
software_type=software_type2,
instance_xml=instance_xml2,
sla_xml=sla_xml2,
shared=shared2,
state=state2,
)
instance_tree2 = person.REQUEST.get('request_instance_tree')
self.assertNotEqual(instance_tree.getRelativeUrl(),
instance_tree2.getRelativeUrl())
self.assertNotEqual(instance_tree.getReference(),
instance_tree2.getReference())
self.assertEqual(software_release2,
instance_tree2.getUrlString())
self.assertEqual(software_title2, instance_tree2.getTitle())
self.assertEqual(software_type2, instance_tree2.getSourceReference())
self.assertEqual(instance_xml2, instance_tree2.getTextContent())
self.assertEqual(sla_xml2, instance_tree2.getSlaXml())
self.assertEqual(shared2, instance_tree2.getRootSlave())
self.assertEqual("stop_requested", instance_tree2.getSlapState())
self.assertEqual("validated", instance_tree2.getValidationState())
def test_Person_requestSoftwareInstance_deletedInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="stopped",
)
instance_tree = person.REQUEST.get('request_instance_tree')
transaction.commit()
self.tic()
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="destroyed",
)
instance_tree2 = person.REQUEST.get('request_instance_tree')
self.assertEqual(None, instance_tree2)
self.assertEqual("destroy_requested", instance_tree.getSlapState())
def test_Person_requestSoftwareInstance_noConflictWithDeletedInstanceTree(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "test"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
sla_xml = "test"
shared = True
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="stopped",
)
instance_tree = person.REQUEST.get('request_instance_tree')
transaction.commit()
self.tic()
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="destroyed",
)
self.assertEqual("destroy_requested", instance_tree.getSlapState())
transaction.commit()
self.tic()
person.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
sla_xml=sla_xml,
shared=shared,
state="started",
)
instance_tree2 = person.REQUEST.get('request_instance_tree')
self.assertEqual("start_requested", instance_tree2.getSlapState())
self.assertNotEqual(instance_tree.getRelativeUrl(),
instance_tree2.getRelativeUrl())
class TestSlapOSCorePersonRequestComputeNode(SlapOSTestCaseMixin):
def generateNewComputeNodeTitle(self):
return 'My Comp %s' % self.generateNewId()
def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self)
person_user = self.makePerson()
self.tic()
# Login as new user
self.login(person_user.getUserId())
new_person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
self.assertEqual(person_user.getRelativeUrl(), new_person.getRelativeUrl())
def beforeTearDown(self):
pass
def test_request_requiredParameter(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
# compute_node_title is mandatory
self.assertRaises(TypeError, person.requestComputeNode)
# if provided does not raise
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
def test_request(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
def test_request_createdComputeNode(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_computer_reference',
id_generator='uid')
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
# check that title is ok
compute_node = person.restrictedTraverse(compute_node_url)
self.assertEqual(compute_node_title, compute_node.getTitle())
# check that data are sane
self.assertEqual(compute_node_absolute_url, compute_node.absolute_url())
self.assertEqual(compute_node_reference, compute_node.getReference())
self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference())
self.assertEqual('validated', compute_node.getValidationState())
self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual('open', compute_node.getCapacityScope())
def test_request_notReindexedCompute(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
transaction.commit()
self.assertRaises(NotImplementedError, person.requestComputeNode,
compute_node_title=compute_node_title)
def test_multiple_request_createdComputeNode(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_computer_reference',
id_generator='uid')
compute_node_title = self.generateNewComputeNodeTitle()
compute_node_title2 = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
# check that title is ok
compute_node = person.restrictedTraverse(compute_node_url)
self.assertEqual(compute_node_title, compute_node.getTitle())
# check that data are sane
self.assertEqual(compute_node_absolute_url, compute_node.absolute_url())
self.assertEqual(compute_node_reference, compute_node.getReference())
self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference())
self.assertEqual('validated', compute_node.getValidationState())
self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual('open', compute_node.getCapacityScope())
self.tic()
# request again the same compute_node
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
# check that title is ok
compute_node = person.restrictedTraverse(compute_node_url)
self.assertEqual(compute_node_title, compute_node.getTitle())
# check that data are sane
self.assertEqual(compute_node_absolute_url, compute_node.absolute_url())
self.assertEqual(compute_node_reference, compute_node.getReference())
self.assertEqual('COMP-%s' % (previous_id + 1), compute_node.getReference())
self.assertEqual('validated', compute_node.getValidationState())
self.assertEqual('open/personal', compute_node.getAllocationScope())
self.assertEqual('open', compute_node.getCapacityScope())
# and now another one
person.requestComputeNode(compute_node_title=compute_node_title2)
# check what is returned via request
compute_node_url2 = person.REQUEST.get('compute_node')
compute_node_absolute_url2 = person.REQUEST.get('compute_node_url')
compute_node_reference2 = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url2)
self.assertNotEqual(None, compute_node_absolute_url2)
self.assertNotEqual(None, compute_node_reference2)
# check that compute_nodes are really different objects
self.assertNotEqual(compute_node_url2, compute_node_url)
# check that title is ok
compute_node2 = person.restrictedTraverse(compute_node_url2)
self.assertEqual(compute_node_title2, compute_node2.getTitle())
# check that data are sane
self.assertEqual(compute_node_absolute_url2, compute_node2.absolute_url())
self.assertEqual(compute_node_reference2, compute_node2.getReference())
self.assertEqual('COMP-%s' % (previous_id + 2), compute_node2.getReference())
self.assertEqual('validated', compute_node2.getValidationState())
self.assertEqual('open/personal', compute_node2.getAllocationScope())
self.assertEqual('open', compute_node2.getCapacityScope())
def test_request_duplicatedComputeNode(self):
person = self.portal.portal_membership.getAuthenticatedMember().getUserValue()
compute_node_title = self.generateNewComputeNodeTitle()
person.requestComputeNode(compute_node_title=compute_node_title)
# check what is returned via request
compute_node_url = person.REQUEST.get('compute_node')
compute_node_absolute_url = person.REQUEST.get('compute_node_url')
compute_node_reference = person.REQUEST.get('compute_node_reference')
self.assertNotEqual(None, compute_node_url)
self.assertNotEqual(None, compute_node_absolute_url)
self.assertNotEqual(None, compute_node_reference)
# check that title is ok
compute_node = person.restrictedTraverse(compute_node_url)
sm = getSecurityManager()
try:
self.login()
compute_node2 = compute_node.Base_createCloneDocument(batch_mode=1)
compute_node2.validate()
finally:
setSecurityManager(sm)
self.tic()
self.assertRaises(NotImplementedError, person.requestComputeNode,
compute_node_title=compute_node_title)
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCloudPersonSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
This source diff could not be displayed because it is too large. You can view the blob instead.
test.erp5.testSlapOSCloudAlarm
test.erp5.testSlapOSCloudAllocationAlarm
test.erp5.testSlapOSCloudWorkflow
test.erp5.testSlapOSCloudComputePartitionSlapInterfaceWorkflow
test.erp5.testSlapOSCloudInteractionWorkflow
test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow
test.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow
test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow
test.erp5.testSlapOSCloudSecurityGroup
test.erp5.testSlapOSCloudConstraint
test.erp5.testSlapOSCloudUpgrader
......
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