Commit cc979e5e authored by Ivan Tyagov's avatar Ivan Tyagov

Add specific wendelin scripts fot the tests.

Add minimal security.
parent 98d77b78
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_group</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Scalability company</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -4,16 +4,4 @@
<property id='description'>Configured by ERP5 Configurator</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
<role id='Auditor; Author'>
<property id='title'>admin</property>
<multi_property id='category'>function/admin</multi_property>
</role>
<role id='Auditor; Author'>
<property id='title'>contributor</property>
<multi_property id='category'>function/contributor</multi_property>
</role>
<role id='Auditor'>
<property id='title'>downloader</property>
<multi_property id='category'>function/downloader</multi_property>
</role>
</type_roles>
\ No newline at end of file
......@@ -4,20 +4,4 @@
<property id='description'>Configured by ERP5 Configurator</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
<role id='Auditor; Author; Manager'>
<property id='title'>admin</property>
<multi_property id='category'>function/admin</multi_property>
</role>
<role id='Auditor; Author; Manager'>
<property id='title'>contributor</property>
<multi_property id='category'>function/contributor</multi_property>
</role>
<role id='Auditor'>
<property id='title'>downloader</property>
<multi_property id='category'>function/downloader</multi_property>
</role>
<role id='Auditor'>
<property id='title'>visitor</property>
<multi_property id='category'>function/visitor</multi_property>
</role>
</type_roles>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_wendelin_scalability_tests</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# Script that installs the configurator for scalabiility tests
import random
import string
import json
request = context.REQUEST
portal = context.getPortalObject()
portal_catalog = portal.portal_catalog
status_code = 0
error_message = "No error."
context.ERP5Site_setUpActivityTool()
if user_quantity is None:
return json.dumps({"status_code" : 1,
"error_message": "Parameter 'user_quantity' is required.",
"password" : None })
password = ''.join(random.choice(string.digits + string.letters) for i in xrange(10))
# check erp5_scalability_test business template is present
configurator = portal.business_configuration_module.default_standard_configuration
if configurator == None or not configurator.contentValues(portal_type='Configuration Save'):
error_message = "Could not find the scalability business configuration object. Be sure to have erp5_scalability_test business template installed."
return json.dumps({"status_code" : 1,
"error_message": error_message })
# install configurator if not intalled
if configurator.getSimulationState() == "draft":
person = portal_catalog.getResultValue(portal_type="Person", title = 'Scalability company')
organisation = portal_catalog.getResultValue(portal_type="Organisation", title = 'Scalability company')
if person is None or organisation is None:
try:
configurator.buildConfiguration()
except Exception as e:
status_code = 1
error_message = "Error during installation: " + str(e)
return json.dumps({"status_code" : 1,
"error_message": error_message })
# create users if installation is done
try:
context.portal_categories.activate(after_method_id = ('ERP5Site_afterConfigurationSetup',
'immediateReindexObject')
).ERP5Site_createTestData(user_quantity, password)
context.portal_categories.activate(after_method_id = ('ERP5Site_afterConfigurationSetup',
'immediateReindexObject')
).ERP5Site_setIdGenerator()
except Exception as e:
status_code = 1
error_message = "Error calling ERP5Site_createTestData script: " + str(e)
return json.dumps({"status_code" : 1,
"error_message": error_message })
return json.dumps({"status_code" : status_code,
"error_message": error_message,
"password" : password,
"quantity" : user_quantity })
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>user_quantity=None</string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_bootstrapScalabilityTest</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import json
from DateTime import DateTime
portal = context.getPortalObject()
portal_catalog = portal.portal_catalog
now = DateTime()
now_minus_6 = now - 1.0/24/60*6
now_minus_1 = now - 1.0/24/60*1
catalog_kw = {'creation_date': {'query': (now_minus_6, now_minus_1), 'range': 'minmax'},
#'validation_state': 'validated'
}
data_stream_count = len(portal_catalog(portal_type="Data Stream", **catalog_kw))
data_stream_per_hour = 60 * data_stream_count / 5
return json.dumps({"data_stream_per_hour" : data_stream_per_hour})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_getScalabilityTestMetric</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal_categories/group/my_group
portal_categories/group/my_group/**
\ No newline at end of file
erp5_wendelin_scalability_tests
\ 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