Commit f6448a21 authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: drop deprecated tests

parent a9020c91
......@@ -20,99 +20,9 @@
##############################################################################
from erp5.component.test.testSlapOSPDMSkins import TestSlapOSPDMMixinSkins
import transaction
class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
def _makeTreeForTestSlapOSPDMCreateUpgradeDecisionSkins(self, software_release_url, software_type, project):
self.instance_tree, self.instance = self._createInstance(software_release_url, software_type, project)
self.shared_instance_tree, self.shared_instance = self._createInstance(software_release_url, software_type, project, True)
self.instance.setAggregate(self.partition.getRelativeUrl())
self.shared_instance.setAggregate(self.partition.getRelativeUrl())
self.partition.markBusy()
self.tic()
def afterSetUpXXX(self):
TestSlapOSPDMMixinSkins.afterSetUp(self)
# XXX Stop modifying system preferences
# as it prevents using test on live system
preference = self.portal.portal_preferences.getActiveSystemPreference()
preference.setPreferredCloudContractEnabled(True)
self.tic()
self.project = self.addProject()
self._makeComputeNode(self.project)
self._makeSoftwareProductCatalog(self.project)
self._installSoftwareOnTheComputeNode([
self.previous_software_release.getUrlString(),
self.new_software_release.getUrlString()
])
self.person = self.makePerson(self.project)
self.tic()
self._makeTreeForTestSlapOSPDMCreateUpgradeDecisionSkins(
self.previous_software_release.getUrlString(),
self.software_product.contentValues(portal_type='Software Product Type Variation')[0].getTitle(),
self.project
)
def _makeSoftwareProductCatalog(self, project):
self.software_product = self._makeSoftwareProduct(
project,
new_id=self.generateNewId(),
url=self.generateNewSoftwareReleaseUrl(),
software_type='foobartype'
)
self.previous_software_release = self._makeSoftwareRelease(self.software_product)
self.new_software_release = self._makeSoftwareRelease(self.software_product)
self.addAllocationSupply(
"for compute node",
self.compute_node,
self.software_product,
self.new_software_release,
self.software_product.contentValues(portal_type='Software Product Type Variation')[0],
)
self.tic()
def _installSoftwareOnTheComputeNode(self, software_release_url_list):
for software_release in software_release_url_list:
software_installation = self.portal.software_installation_module\
.newContent(portal_type='Software Installation',
url_string=software_release,
aggregate=self.compute_node.getRelativeUrl())
software_installation.validate()
software_installation.requestStart()
self.tic()
def _createInstance(self, url_string, software_type, project, shared=False):
instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
instance_tree.edit(
)
instance_tree.validate()
instance_tree.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTHS-%s" % self.generateNewId(),
destination_section_value=self.person,
follow_up_value=project
)
request_kw = dict(
software_release=url_string,
software_type=software_type,
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=shared,
software_title=instance_tree.getTitle(),
state='started',
project_reference=project.getReference()
)
instance_tree.requestStart(**request_kw)
instance_tree.requestInstance(**request_kw)
instance = instance_tree.getSuccessorValue()
self.tic()
return instance_tree, instance
def test_createUpgradeDecision_destroyed_instance(self):
instance_tree = self.portal.instance_tree_module.newContent(
portal_type="Instance Tree"
......@@ -293,296 +203,3 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self.tic()
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
##########################################################################
# tocheck
##########################################################################
def test_tocheck_InstanceTree_createUpgradeDecision(self):
upgrade_decision = self.instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual('started', upgrade_decision.getSimulationState())
shared_upgrade_decision = self.shared_instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(None, shared_upgrade_decision)
# simulate upgrade of the instance tree
upgrade_decision.stop()
upgrade_decision.deliver()
self.instance_tree.edit(url_string=self.new_software_release.getUrlString())
self.instance.edit(url_string=self.new_software_release.getUrlString())
self.tic()
shared_upgrade_decision = self.shared_instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual('started', shared_upgrade_decision.getSimulationState())
def test_tocheck_InstanceTree_createUpgradeDecision_upgradeScopeDisabled(self):
# check upgrade decision on HS
self.instance_tree.setUpgradeScope('disabled')
self.tic()
upgrade_decision = self.instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(None, upgrade_decision)
shared_upgrade_decision = self.shared_instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(None, shared_upgrade_decision)
def test_tocheckInstanceTree_createUpgradeDecision_no_newer(self):
person = self._makePerson(self.project)
compute_node, _ = self._makeComputeNode(self.project)#, owner=person)
self._makeComputePartitions(compute_node)
software_product = self._makeSoftwareProduct(self.project)
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
url_string = software_release.getUrlString()
self._makeSoftwareInstallation(compute_node, url_string)
self.tic()
# Create Instance Tree
instance_tree = self._makeFullInstanceTree(
url_string, person)
self.tic()
upgrade_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(upgrade_decision, None)
self._makeFullSoftwareInstance(instance_tree, url_string)
self._markComputePartitionBusy(compute_node,
instance_tree.getSuccessorValue())
self._requestSoftwareRelease(software_product.getRelativeUrl())
self.tic()
upgrade_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(upgrade_decision, None)
def test_tocheckInstanceTree_createUpgradeDecision_closed_compute_node(self):
person = self._makePerson(self.project)
compute_node, _ = self._makeComputeNode(self.project, allocation_scope="close/outdated")
self._makeComputePartitions(compute_node)
software_product = self._makeSoftwareProduct(self.project)
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
url_string = software_release.getUrlString()
self._makeSoftwareInstallation( compute_node, url_string)
# Create Instance Tree and Software Instance
instance_tree = self._makeFullInstanceTree(
url_string, person)
self._makeFullSoftwareInstance(instance_tree, url_string)
self._markComputePartitionBusy(compute_node,
instance_tree.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
software_product.getRelativeUrl())
self._makeSoftwareInstallation(compute_node,
software_release2.getUrlString())
self.tic()
up_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertNotEqual(up_decision, None)
self.assertEqual(up_decision.getSimulationState(), 'planned')
self.assertEqual(up_decision.UpgradeDecision_getAggregateValue("Instance Tree").\
getReference(), instance_tree.getReference())
self.assertEqual(software_release2.getUrlString(),
up_decision.UpgradeDecision_getAggregateValue("Software Release").\
getUrlString())
def test_tocheckInstanceTree_createUpgradeDecision_create_once_transaction(self):
person = self._makePerson(self.project)
compute_node, _ = self._makeComputeNode(self.project, allocation_scope="open/personal")
self._makeComputePartitions(compute_node)
software_product = self._makeSoftwareProduct(self.project)
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
url_string = software_release.getUrlString()
self._makeSoftwareInstallation( compute_node, url_string)
# Create Instance Tree and Software Instance
instance_tree = self._makeFullInstanceTree(
url_string, person)
self._makeFullSoftwareInstance(instance_tree, url_string)
self._markComputePartitionBusy(compute_node,
instance_tree.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
software_product.getRelativeUrl())
self._makeSoftwareInstallation(compute_node,
software_release2.getUrlString())
self.tic()
up_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertNotEqual(up_decision, None)
self.assertEqual(up_decision.getSimulationState(), 'planned')
transaction.commit()
# call a second time without tic
up_decision = instance_tree.InstanceTree_createUpgradeDecision()
# no new Upgrade decision created
self.assertEqual(up_decision, None)
def test_tocheckInstanceTree_createUpgradeDecision(self):
person = self._makePerson(self.project)
compute_node, _ = self._makeComputeNode(self.project)
self._makeComputePartitions(compute_node)
software_product = self._makeSoftwareProduct(self.project)
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
url_string = software_release.getUrlString()
self._makeSoftwareInstallation( compute_node, url_string)
# Create Instance Tree and Software Instance
instance_tree = self._makeFullInstanceTree(
url_string, person)
self._makeFullSoftwareInstance(instance_tree, url_string)
self._markComputePartitionBusy(compute_node,
instance_tree.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
software_product.getRelativeUrl())
self._makeSoftwareInstallation(compute_node,
software_release2.getUrlString())
self.tic()
up_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertNotEqual(up_decision, None)
self.assertEqual(up_decision.getSimulationState(), 'planned')
self.assertEqual(up_decision.UpgradeDecision_getAggregateValue("Instance Tree").\
getReference(), instance_tree.getReference())
self.assertEqual(software_release2.getUrlString(),
up_decision.UpgradeDecision_getAggregateValue("Software Release").\
getUrlString())
self.tic()
up_decision2 = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(up_decision2, None)
def test_tocheckInstanceTree_createUpgradeDecision_with_exist(self):
person = self._makePerson(self.project)
compute_node, _ = self._makeComputeNode(self.project)
self._makeComputePartitions(compute_node)
software_product = self._makeSoftwareProduct(self.project)
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
url_string = software_release.getUrlString()
self._makeSoftwareInstallation( compute_node, url_string)
# Create Instance Tree and Software Instance
instance_tree = self._makeFullInstanceTree(
url_string, person)
self._makeFullSoftwareInstance(instance_tree, url_string)
self._markComputePartitionBusy(compute_node,
instance_tree.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
software_product.getRelativeUrl())
self._makeSoftwareInstallation(compute_node, software_release2.getUrlString())
self.tic()
up_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(up_decision.getSimulationState(), 'planned')
# Install the another software release
software_release3 = self._requestSoftwareRelease(
software_product.getRelativeUrl())
self._makeSoftwareInstallation(compute_node, software_release3.getUrlString())
self.tic()
up_decision2 = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(up_decision2.getSimulationState(), 'planned')
self.assertEqual(up_decision.getSimulationState(), 'cancelled')
release = up_decision2.UpgradeDecision_getAggregateValue("Software Release")
self.assertEqual(release.getUrlString(),
software_release3.getUrlString())
def test_tocheckInstanceTree_createUpgradeDecision_rejected(self):
person = self._makePerson(self.project)
compute_node, _ = self._makeComputeNode(self.project)
self._makeComputePartitions(compute_node)
software_product = self._makeSoftwareProduct(self.project)
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
url_string = software_release.getUrlString()
self._makeSoftwareInstallation(compute_node, url_string)
# Create Instance Tree and Software Instance
instance_tree = self._makeFullInstanceTree(
url_string, person)
self._makeFullSoftwareInstance(instance_tree, url_string)
self._markComputePartitionBusy(compute_node,
instance_tree.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
software_product.getRelativeUrl())
self._makeSoftwareInstallation(compute_node, software_release2.getUrlString())
self.tic()
up_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(up_decision.getSimulationState(), 'planned')
# Reject upgrade decision
up_decision.reject()
self.tic()
in_progress = software_release2.SoftwareRelease_getUpgradeDecisionInProgress(
instance_tree.getUid())
up_decision = instance_tree.InstanceTree_createUpgradeDecision()
# There is an upgrade decision in progress
self.assertNotEqual(in_progress, None)
# No new upgrade decision created with software_release2
self.assertEqual(up_decision, None)
def test_tocheckInstanceTree_createUpgradeDecision_rejected_2(self):
person = self._makePerson(self.project)
compute_node, _ = self._makeComputeNode(self.project)#, owner=person)
self._makeComputePartitions(compute_node)
software_product = self._makeSoftwareProduct(self.project)
software_release = self._requestSoftwareRelease(
software_product.getRelativeUrl())
url_string = software_release.getUrlString()
self._makeSoftwareInstallation(compute_node, url_string)
# Create Instance Tree and Software Instance
instance_tree = self._makeFullInstanceTree(
url_string, person)
self._makeFullSoftwareInstance(instance_tree, url_string)
self._markComputePartitionBusy(compute_node,
instance_tree.getSuccessorValue())
# Install the Newest software release
software_release2 = self._requestSoftwareRelease(
software_product.getRelativeUrl())
self._makeSoftwareInstallation(compute_node, software_release2.getUrlString())
self.tic()
up_decision = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(up_decision.getSimulationState(), 'planned')
# Reject upgrade decision
up_decision.reject()
self.tic()
# Install the another software release
software_release3 = self._requestSoftwareRelease(
software_product.getRelativeUrl())
self._makeSoftwareInstallation(compute_node, software_release3.getUrlString())
self.tic()
decision2 = instance_tree.InstanceTree_createUpgradeDecision()
self.assertEqual(decision2.getSimulationState(), 'planned')
self.assertEqual(up_decision.getSimulationState(), 'rejected')
release = decision2.UpgradeDecision_getAggregateValue("Software Release")
self.assertEqual(release.getUrlString(),
software_release3.getUrlString())
\ No newline at end of file
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