Commit 2573a41a authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: create 2 projects to simulate remote allocation

parent b34ed47d
......@@ -748,16 +748,18 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin):
def test_virtual_master_on_remote_tree_without_accounting_scenario(self):
# 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
####################################
# Create a remote project
####################################
remote_project = self.addProject()
preference.edit(
preferred_subscription_assignment_category_list=[
'function/customer',
'role/client',
'destination_project/%s' % project.getRelativeUrl()
'destination_project/%s' % remote_project.getRelativeUrl()
]
)
......@@ -765,13 +767,70 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin):
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)
remote_owner_reference = 'remote-owner-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, remote_owner_reference)
self.login()
owner_person = self.portal.portal_catalog.getResultValue(
remote_owner_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=owner_reference).getParentValue()
reference=remote_owner_reference).getParentValue()
# first slapos administrator assignment can only be created by
# the erp5 manager
self.addProjectProductionManagerAssignment(remote_owner_person, remote_project)
self.tic()
# hooray, now it is time to create compute_nodes
self.login(remote_owner_person.getUserId())
remote_server_title = 'Remote Server for %s' % remote_owner_person
remote_server_id = self.requestComputeNode(remote_server_title, remote_project.getReference())
remote_server = self.portal.portal_catalog.getResultValue(
portal_type='Compute Node', reference=remote_server_id)
self.setAccessToMemcached(remote_server)
self.assertNotEqual(None, remote_server)
self.setServerOpenPublic(remote_server)
# and install some software on them
remote_server_software = self.generateNewSoftwareReleaseUrl()
remote_instance_type = 'public type'
self.supplySoftware(remote_server, remote_server_software)
# format the compute_nodes
self.formatComputeNode(remote_server)
remote_software_product, remote_release_variation, remote_type_variation = self.addSoftwareProduct(
"remote product", remote_project, remote_server_software, remote_instance_type
)
self.addAllocationSupply("for compute node", remote_server, remote_software_product,
remote_release_variation, remote_type_variation)
# join as the another visitor and request software instance on public
# compute_node
self.logout()
remote_public_reference = 'remote-public-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, remote_public_reference)
self.login()
remote_public_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=remote_public_reference).getParentValue()
####################################
# Create a local project
####################################
project = self.addProject()
preference.edit(
preferred_subscription_assignment_category_list=[
'function/customer',
'role/client',
'destination_project/%s' % project.getRelativeUrl()
]
)
owner_person = remote_public_person
# first slapos administrator assignment can only be created by
# the erp5 manager
......@@ -819,14 +878,23 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin):
self.tic()
self.login()
# Ensure no unexpected object has been created
# 3 (can reduce to 2) assignment, 1 instance tree, 1 remote node, 1 software installation
# 1 software instance
# 3 (can reduce to 2) assignment, 1 remote node, 1 software installation
# 2 credential request
# 1 software product
# 3 allocation supply/line/cell
related_object_list = remote_project.Base_getRelatedObjectList(**{'category.category_strict_membership': 1})
assert len(related_object_list) == 11, [x.getRelativeUrl() for x in related_object_list]
# Ensure no unexpected object has been created
# 2 (can reduce to 2) assignment, 1 instance tree, 1 remote node, 1 software installation
# 1 software instance
# 1 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) == 13, [x.getRelativeUrl() for x in related_object_list]
assert len(related_object_list) == 11, [x.getRelativeUrl() for x in related_object_list]
self.stepcheckERP5Consistency()
......
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