Commit f6aa6c03 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test slave allocation on the same instance tree

parent 22545fe1
......@@ -78,12 +78,14 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin):
return software_product, release_variation, type_variation
def addAllocationSupply(self, title, node, software_product,
software_release, software_type):
software_release, software_type,
is_slave_on_same_instance_tree_allocable=False):
allocation_supply = self.portal.allocation_supply_module.newContent(
portal_type="Allocation Supply",
title=title,
aggregate_value=node,
destination_project_value=node.getFollowUpValue(),
destination_project_value=software_product.getFollowUpValue(),
slave_on_same_instance_tree_allocable=is_slave_on_same_instance_tree_allocable
)
resource_vcl = [
'software_release/%s' % software_release.getRelativeUrl(),
......@@ -618,6 +620,113 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin):
assert last_message is None, last_message
def test_virtual_master_slave_on_same_tree_without_accounting_scenario(self):
self.portal.testromain()
# create a default project
project = self.addProject()
self.web_site = self.portal.web_site_module.slapos_master_panel
preference = self.portal.portal_preferences.slapos_default_system_preference
preference.edit(
preferred_subscription_assignment_category_list=[
'function/customer',
'role/client',
'destination_project/%s' % project.getRelativeUrl()
]
)
# some preparation
self.logout()
# lets join as slapos administrator, which will own few compute_nodes
owner_reference = 'owner-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, owner_reference)
self.login()
owner_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=owner_reference).getParentValue()
# first slapos administrator assignment can only be created by
# the erp5 manager
self.addProjectProductionManagerAssignment(owner_person, project)
self.tic()
# hooray, now it is time to create compute_nodes
self.login(owner_person.getUserId())
public_server_title = 'Public Server for %s' % owner_reference
public_server_id = self.requestComputeNode(public_server_title, project.getReference())
public_server = self.portal.portal_catalog.getResultValue(
portal_type='Compute Node', reference=public_server_id)
self.setAccessToMemcached(public_server)
self.assertNotEqual(None, public_server)
self.setServerOpenPublic(public_server)
# and install some software on them
public_server_software = self.generateNewSoftwareReleaseUrl()
self.supplySoftware(public_server, public_server_software)
#software_product, release_variation, type_variation = self.addSoftwareProduct(
public_instance_type = 'public type'
software_product, software_release, software_type = self.addSoftwareProduct(
"instance product", project, public_server_software, public_instance_type
)
self.addAllocationSupply("for compute node", public_server, software_product,
software_release, software_type,
is_slave_on_same_instance_tree_allocable=True)
# format the compute_nodes
self.formatComputeNode(public_server)
# join as the another visitor and request software instance on public
# compute_node
self.logout()
public_reference = 'public-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, public_reference)
self.login()
public_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=public_reference).getParentValue()
public_instance_title = 'Public title %s' % self.generateNewId()
self.checkInstanceAllocation(public_person.getUserId(),
public_reference, public_instance_title,
public_server_software, public_instance_type,
public_server, project.getReference())
self.tic()
# request slave instance on the same instance tree
self.login(public_person.getUserId())
slave_instance_title = 'Slave title %s' % self.generateNewId()
self.checkInstanceTreeSlaveInstanceAllocation(
public_person.getUserId(),
public_reference, public_instance_title,
slave_instance_title,
public_server_software, public_instance_type,
public_server, project.getReference()
)
self.login()
# Ensure no unexpected object has been created
# 3 (can reduce to 2) assignment, 1 instance tree, 1 compute node, 1 software installation
# 2 software instance
# 2 credential request
# 1 software product
# 3 allocation supply/line/cell
related_object_list = project.Base_getRelatedObjectList(**{'category.category_strict_membership': 1})
assert len(related_object_list) == 14, [x.getRelativeUrl() for x in related_object_list]
self.stepcheckERP5Consistency()
# after accept, an email is send containing the reset link
last_message = self.portal.MailHost._last_message
assert last_message is None, last_message
def test_open_order_with_service_scenario(self):
# create a default project
......
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