Commit 393cd249 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5:

* WIP move test for scenario without accounting
* show latest consistency error
* ensure that no unexpected document has been created
* required setting a project on a Credential Request
* set default project on test web site
parent 245ee369
......@@ -10,6 +10,9 @@
<item>SlapOSCloudContractAccounting</item>
<item>Url</item>
</portal_type>
<portal_type id="Credential Request">
<item>SlapOSVirtualMasterSourceProjectConstraint</item>
</portal_type>
<portal_type id="Id Tool">
<item>SlapOSModuleIdGeneratorConstraint</item>
</portal_type>
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2022 Nexedi SA and Contributors. All Rights Reserved.
#
##############################################################################
from erp5.component.test.SlapOSTestCaseDefaultScenarioMixin import DefaultScenarioMixin
# from DateTime import DateTime
class TestSlapOSVirtualMasterScenario(DefaultScenarioMixin):
"""
def addSlapOSAdministratorAssignment(self, person):
person.newContent(
portal_type='Assignment',
# XXX should be project/function instead
group='company'
).open()
"""
def addProjectProductionManagerAssignment(self, person, project):
person.newContent(
portal_type='Assignment',
destination_project_value=project,
function='production/manager'
).open()
def addProjectCustomerAssignment(self, person, project):
person.newContent(
portal_type='Assignment',
destination_project_value=project,
function='customer'
).open()
def addProject(self):
project = self.portal.project_module.newContent(
portal_type='Project',
title='project-%s' % self.generateNewId()
)
project.validate()
return project
def stepcheckERP5Consistency(self):
not_consistent_document = self.portal.portal_catalog.getResultValue(
consistency_error=1,
sort_on=[('modification_date', 'DESC')]
)
if not_consistent_document is not None:
assert not_consistent_document.checkConsistency() == [], not_consistent_document.checkConsistency()[0]
def test_virtual_master_without_accounting_scenario(self):
# create a default project
project = self.addProject()
self.web_site = self.portal.web_site_module.slapos_master_panel
self.web_site.edit(
configuration_default_project_relative_url=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)
# 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()
self.addProjectCustomerAssignment(public_person, project)
public_instance_title = 'Public title %s' % self.generateNewId()
public_instance_type = 'public type'
self.checkInstanceAllocation(public_person.getUserId(),
public_reference, public_instance_title,
public_server_software, public_instance_type,
public_server, project.getReference())
self.login()
public_person = self.portal.portal_catalog.getResultValue(
portal_type='ERP5 Login', reference=public_reference).getParentValue()
self.login(owner_person.getUserId())
# and the instances
self.checkInstanceUnallocation(public_person.getUserId(),
public_reference, public_instance_title,
public_server_software, public_instance_type, public_server,
project.getReference())
# and uninstall some software on them
self.logout()
self.login(owner_person.getUserId())
self.supplySoftware(public_server, public_server_software,
state='destroyed')
self.logout()
# Uninstall from compute_node
self.login()
self.simulateSlapgridSR(public_server)
self.tic()
# XXX Do this for every scenario tests
self.logout()
self.stepCallAlarmList()
self.tic()
self.login()
# Ensure no unexpected object has been created
# 2 assignment, 1 instance tree, 1 compute node, 1 software installation
# 1 software instance
# 2 credential request
related_object_list = project.Base_getRelatedObjectList()
assert len(related_object_list) == 8, [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
\ 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>default_reference</string> </key>
<value> <string>testSlapOSERP5VirtualMasterScenario</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.testSlapOSERP5VirtualMasterScenario</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">AAAAAAAAAAI=</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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<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>
......@@ -3,6 +3,7 @@ Certificate Authority Tool | CertificateAuthorityToolConsistencyConstraint
Contract Invitation Token | Reference
Contract Invitation Token | SlapOSCloudContractAccounting
Contract Invitation Token | Url
Credential Request | SlapOSVirtualMasterSourceProjectConstraint
Id Tool | SlapOSModuleIdGeneratorConstraint
Invitation Token | Reference
Invitation Token | Url
......
......@@ -10,4 +10,6 @@ test.erp5.testSlapOSERP5SiteDump
test.erp5.testSlapOSERP5SkinSelection
test.erp5.testSlapOSPrecacheManifest
test.erp5.testSlapOSWendelinCoreTwo
test.erp5.testSlapOSXHTML
\ No newline at end of file
test.erp5.testSlapOSXHTML
test.erp5.testSlapOSPrecacheManifest
test.erp5.testSlapOSERP5VirtualMasterScenario
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