Commit 8d7f3879 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test allocation on Remote Node

parent 1cc7639a
...@@ -40,11 +40,13 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin): ...@@ -40,11 +40,13 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin):
project.validate() project.validate()
return project return project
def requestRemoteNode(self, project): def requestRemoteNode(self, project, remote_project, remote_person):
remote_node = self.portal.compute_node_module.newContent( remote_node = self.portal.compute_node_module.newContent(
portal_type='Remote Node', portal_type='Remote Node',
title='remote-%s' % self.generateNewId(), title='remote-%s' % self.generateNewId(),
follow_up_value=project, follow_up_value=project,
destination_project_value=remote_project.getRelativeUrl(),
destination_section_value=remote_person.getRelativeUrl(),
# XXX # XXX
capacity_scope='close' capacity_scope='close'
) )
...@@ -840,23 +842,24 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin): ...@@ -840,23 +842,24 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin):
# hooray, now it is time to create compute_nodes # hooray, now it is time to create compute_nodes
self.login(owner_person.getUserId()) self.login(owner_person.getUserId())
remote_server = self.requestRemoteNode(project) remote_compute_node = self.requestRemoteNode(project, remote_project,
remote_public_person)
# and install some software on them # and install some software on them
public_server_software = self.generateNewSoftwareReleaseUrl() public_server_software = remote_server_software
remote_server.requestSoftwareRelease(software_release_url=public_server_software, remote_compute_node.requestSoftwareRelease(software_release_url=public_server_software,
state='available') state='available')
#software_product, release_variation, type_variation = self.addSoftwareProduct( #software_product, release_variation, type_variation = self.addSoftwareProduct(
public_instance_type = 'public type' public_instance_type = remote_instance_type
software_product, software_release, software_type = self.addSoftwareProduct( software_product, software_release, software_type = self.addSoftwareProduct(
"instance product", project, public_server_software, public_instance_type "instance product", project, public_server_software, public_instance_type
) )
self.addAllocationSupply("for compute node", remote_server, software_product, self.addAllocationSupply("for remote node", remote_compute_node, software_product,
software_release, software_type, software_release, software_type)
is_slave_on_same_instance_tree_allocable=True) self.tic()
# join as the another visitor and request software instance on public # join as the another visitor and request software instance on public
# compute_node # compute_node
...@@ -873,23 +876,71 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin): ...@@ -873,23 +876,71 @@ class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin):
self.checkRemoteInstanceAllocation(public_person.getUserId(), self.checkRemoteInstanceAllocation(public_person.getUserId(),
public_reference, public_instance_title, public_reference, public_instance_title,
public_server_software, public_instance_type, public_server_software, public_instance_type,
remote_server, project.getReference()) remote_compute_node, project.getReference())
# XXX Do this for every scenario tests
self.logout()
for _ in range(3):
self.stepCallAlarmList()
self.tic()
# now instantiate it on compute_node and set some nice connection dict
self.simulateSlapgridCP(remote_server)
self.tic() self.tic()
self.login()
# owner_person should have one Instance Tree created by alarm
owner_instance_tree_list = self.portal.portal_catalog(
portal_type='Instance Tree',
destination_section__uid=owner_person.getUid()
)
self.assertEqual(1, len(owner_instance_tree_list))
owner_software_instance = owner_instance_tree_list[0].getSuccessorValue()
self.assertEqual('Software Instance', owner_software_instance.getPortalType())
self.assertEqual(
remote_server.getRelativeUrl(),
owner_software_instance.getAggregateValue().getParentValue().getRelativeUrl()
)
# public_person should have one Instance Tree
public_instance_tree_list = self.portal.portal_catalog(
portal_type='Instance Tree',
destination_section__uid=public_person.getUid()
)
self.assertEqual(1, len(public_instance_tree_list))
self.assertEqual(
'_remote_%s_%s' % (project.getReference(),
public_instance_tree_list[0].getSuccessorReference()),
owner_software_instance.getTitle()
)
connection_dict = owner_software_instance.getConnectionXmlAsDict()
self.assertSameSet(('url_1', 'url_2'), connection_dict.keys())
self.assertSameSet(
['http://%s/' % q.getIpAddress() for q in
owner_software_instance.getAggregateValue().contentValues(portal_type='Internet Protocol Address')],
connection_dict.values())
self.checkRemoteInstanceAllocation(public_person.getUserId(),
public_reference, public_instance_title,
public_server_software, public_instance_type,
remote_compute_node, project.getReference(),
connection_dict_to_check=owner_software_instance.getConnectionXmlAsDict())
self.login() self.login()
# Ensure no unexpected object has been created # Ensure no unexpected object has been created
# 3 (can reduce to 2) assignment, 1 remote node, 1 software installation # 3 (can reduce to 2) assignment, 1 remote node, 1 software installation
# 1 compute node
# 1 instance tree, 1 software instance
# 2 credential request # 2 credential request
# 1 software product # 1 software product
# 3 allocation supply/line/cell # 3 allocation supply/line/cell
related_object_list = remote_project.Base_getRelatedObjectList(**{'category.category_strict_membership': 1}) 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] assert len(related_object_list) == 14, [x.getRelativeUrl() for x in related_object_list]
# Ensure no unexpected object has been created # Ensure no unexpected object has been created
# 2 (can reduce to 2) assignment, 1 instance tree, 1 remote node, 1 software installation # 2 (can reduce to 2) assignment, 1 remote node, 1 software installation
# 1 software instance # 1 instance tree, 1 software instance
# 1 credential request # 1 credential request
# 1 software product # 1 software product
# 3 allocation supply/line/cell # 3 allocation supply/line/cell
......
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