diff --git a/erp5/util/benchmark/examples/createPerson.py b/erp5/util/benchmark/examples/createPerson.py index 4c137e11900eafd52aed9db383a2cfb8d34ae4d8..ba33e79a4342cadb2808c9f577f9598d1bcc44d6 100644 --- a/erp5/util/benchmark/examples/createPerson.py +++ b/erp5/util/benchmark/examples/createPerson.py @@ -1,4 +1,12 @@ # -*- coding: utf-8 -*- + +TMIN_SLEEP_SHORT = 0 # 2 +TMAX_SLEEP_SHORT = 0 # 6 +TMIN_SLEEP = 0 # 5 +TMAX_SLEEP = 0 # 15 +TMIN_SLEEP_LONG = 0 # 10 +TMAX_SLEEP_LONG = 0 # 30 + def createPerson(result, browser): """ Create a Person and add a telephone number. It can be ran infinitely (e.g. @@ -21,15 +29,15 @@ def createPerson(result, browser): instance). """ # Open ERP5 homepage - browser.open(sleep=(0, 0)) + browser.open(sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT)) # Log in unless already logged in by a previous test suite - browser.mainForm.submitLogin(sleep=(0, 0)) + browser.mainForm.submitLogin(sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT)) # Go to Persons module (person_module) result('Go to person module', browser.mainForm.submitSelectModule(value='/person_module', - sleep=(0, 0))) + sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT))) # Create a new person and record the time elapsed in seconds result('Add Person', browser.mainForm.submitNew()) @@ -40,11 +48,12 @@ def createPerson(result, browser): # Fill the first and last name of the newly created person browser.mainForm.getControl(name='field_my_first_name').value = 'Create' browser.mainForm.getControl(name='field_my_last_name').value = 'Person' + # Link to organisation, this will add subobjects - browser.mainForm.getControl(name='field_my_career_subordination_title').value = 'Supplier' +# browser.mainForm.getControl(name='field_my_career_subordination_title').value = 'Supplier' # Submit the changes, record the time elapsed in seconds - result('Save', browser.mainForm.submitSave(sleep=(0, 0))) + result('Save', browser.mainForm.submitSave(sleep=(TMIN_SLEEP, TMAX_SLEEP))) # Check whether the changes have been successfully updated assert browser.getTransitionMessage() == 'Data updated.' @@ -53,14 +62,14 @@ def createPerson(result, browser): # Add phone number result('Add telephone', browser.mainForm.submitSelectAction(value='add Telephone', - sleep=(0, 0))) + sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT))) # Fill telephone title and number browser.mainForm.getControl(name='field_my_title').value = 'Personal' browser.mainForm.getControl(name='field_my_telephone_number').value = '0123456789' # Submit the changes, record the time elapsed in seconds - result('Save', browser.mainForm.submitSave(sleep=(0, 0))) + result('Save', browser.mainForm.submitSave(sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT))) # Check whether the changes have been successfully updated assert browser.getTransitionMessage() == 'Data updated.' @@ -74,9 +83,11 @@ def createPerson(result, browser): browser.mainForm.submitSelectWorkflow(value='validate_action', maximum_attempt_number=5, sleep_between_attempt=5, - sleep=(0, 0)) + sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT)) result('Waiting for validate_action', waiting_for_validate_action) result('Show validate', show_validate_time) result('Validated', browser.mainForm.submitDialogConfirm()) assert browser.getTransitionMessage() == 'Status changed.' + + print "OK" diff --git a/erp5/util/benchmark/examples/createWebPage.py b/erp5/util/benchmark/examples/createWebPage.py index 8e3bf9e1ac166deecbca6d381b4762e750997b4c..1285760b43c32e308d79c0728cbec716c966f147 100644 --- a/erp5/util/benchmark/examples/createWebPage.py +++ b/erp5/util/benchmark/examples/createWebPage.py @@ -1,20 +1,52 @@ # -*- coding: utf-8 -*- + +import datetime +import random +import time +import string +import genericToolToFillForm +from genericToolToFillForm import * + +PREFIX_TITLE = "" + +if False : + TMIN_SLEEP_SHORT = 0 # 2 + TMAX_SLEEP_SHORT = 0 # 6 + TMIN_SLEEP = 0 # 5 + TMAX_SLEEP = 0 # 15 + TMIN_SLEEP_LONG = 0 # 10 + TMAX_SLEEP_LONG = 0 # 30 + NUMMAX_FOLLOW_UP = 0 + NUMMAX_CONTRIBUTORS = 0 +else : + TMIN_SLEEP_SHORT = 2 + TMAX_SLEEP_SHORT = 6 + TMIN_SLEEP = 5 + TMAX_SLEEP = 15 + TMIN_SLEEP_LONG = 10 + TMAX_SLEEP_LONG = 30 + NUMMAX_FOLLOW_UP = 1 + NUMMAX_CONTRIBUTORS = 2 + + + def createWebPage(result, browser): """ Create a minimal web page with some content & submit it Note : you need your user to have Assignor role to do workflow transition + you must select the source code editor (plain text) on the preference """ # Open ERP5 homepage - browser.open(sleep=(2, 6)) - + browser.open(sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT)) + # Log in unless already logged in by a previous test suite - browser.mainForm.submitLogin(sleep=(2, 6)) + browser.mainForm.submitLogin(sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT)) # Go to WebPage module (person_module) result('Go to Web Page module', browser.mainForm.submitSelectModule(value='/web_page_module', - sleep=(2, 6))) + sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT))) # Create a new person and record the time elapsed in seconds result('Add Web Page', browser.mainForm.submitNew()) @@ -23,42 +55,81 @@ def createWebPage(result, browser): assert browser.getTransitionMessage() == 'Object created.' # Fill the form - browser.mainForm.getControl(name='field_my_title').value = 'Web Page Bench' + browser.mainForm.getControl(name='field_my_title').value = PREFIX_TITLE+'Web Page Bench' browser.mainForm.getControl(name='field_my_short_title').value = 'test' browser.mainForm.getControl(name='field_my_reference').value = '001' browser.mainForm.getControl(name='field_my_version').value = "001" browser.mainForm.getControl(name='field_my_language').value = 'en' browser.mainForm.getControl(name='field_my_int_index').value = '10' - browser.mainForm.getControl(name='field_my_description').value= 'Benchmark test' + date = datetime.datetime.now() + browser.mainForm.getControl(name='subfield_field_my_effective_date_day').value = str(date.day) + browser.mainForm.getControl(name='subfield_field_my_effective_date_month').value = str(date.month) + browser.mainForm.getControl(name='subfield_field_my_effective_date_year').value = str(date.year) + select_random_option(browser, "subfield_field_my_publication_section_list_default:list") + browser.mainForm.getControl(name='field_my_description').value = 'Benchmark test' + select_random_option(browser, "field_my_classification") + select_random_option(browser, "subfield_field_my_group_list_default:list") + select_random_option(browser, "subfield_field_my_site_list_default:list") + select_random_option(browser, "subfield_field_my_function_list_default:list") + browser.mainForm.getControl(name='field_my_subject_list').value = gen_string(30) + + + ## Fill the Follow-up input + fill_related_objects(browser, result, + "portal_selections/viewSearchRelatedDocumentDialog0:method", NUMMAX_FOLLOW_UP, + "FollowUp", TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT) + ## Fill the Contributors input + fill_related_objects(browser, result, + "portal_selections/viewSearchRelatedDocumentDialog1:method", NUMMAX_CONTRIBUTORS, + "Contributors", TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT) + # Submit the changes, record the time elapsed in seconds - result('Save', browser.mainForm.submitSave(sleep=(5, 15))) + result('Save', browser.mainForm.submitSave(sleep=(TMIN_SLEEP, TMAX_SLEEP))) # Check whether the changes have been successfully updated assert browser.getTransitionMessage() == 'Data updated.' WebPage_url = browser.url + + + ## Edit the relations with other existing documents + # Go to the Related Documents view + browser.open(WebPage_url+"/Document_viewRelated") + + # Fill the Referenced Documents input + fill_related_objects(browser, result, + "portal_selections/viewSearchRelatedDocumentDialog0:method", 3, + "ReferencedDocument", TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT) + # Fill the Similar Documents input + fill_related_objects(browser, result, + "portal_selections/viewSearchRelatedDocumentDialog1:method", 3, + " SimilarDocuments", TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT) + # Fill the Related Documents input + #fill_related_objects(browser, result, + # "portal_selections/viewSearchRelatedDocumentDialog2:method", 3, + # "RelatedDocuments", TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT) + - # Edit content + ## Edit content WebPage_url = '/'.join(WebPage_url.split('/')[:-1]) browser.open(WebPage_url+"/WebPage_viewEditor") - browser.mainForm.getControl(name='field_my_text_content').value = '<html><body><h1>Test</h1><p>Content if test</p></body></html>' + browser.mainForm.getControl(name='field_my_text_content').value = '<html><body><h1>Test</h1><p>Content of test</p></body></html>' # Submit the changes, record the time elapsed in seconds - result('Save', browser.mainForm.submitSave(sleep=(10, 30))) - + result('Save', browser.mainForm.submitSave(sleep=(TMIN_SLEEP_LONG, TMAX_SLEEP_LONG))) # Check whether the changes have been successfully updated assert browser.getTransitionMessage() == 'Data updated.' + # Publish it show_publish_time, waiting_for_publish_action = \ - browser.mainForm.submitSelectWorkflow(value='publish_action', + browser.mainForm.submitSelectWorkflow(value='submit_action', maximum_attempt_number=5, sleep_between_attempt=5, - sleep=(2, 6)) + sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT)) result('Waiting for publish_action', waiting_for_publish_action) result('Show publish', show_publish_time) result('Published', browser.mainForm.submitDialogConfirm()) - + + # Check whether the changes have been successfully updated assert browser.getTransitionMessage() == 'Status changed.' - -