Commit 35c854b3 authored by Benjamin Blanc's avatar Benjamin Blanc Committed by Sebastien Robin

benchmark: modify and add new benchmark

These benchmarks are used during scalability tests.
A file which contains list of scalability users is also added.
parent 17504301
# -*- coding: utf-8 -*-
TMIN_SLEEP_SHORT = 2
TMAX_SLEEP_SHORT = 6
TMIN_SLEEP = 5
TMAX_SLEEP = 15
TMIN_SLEEP_LONG = 10
TMAX_SLEEP_LONG = 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=(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 Persons module (person_module)
result('Go to person module',
browser.mainForm.submitSelectModule(value='/person_module',
sleep=(2, 6)))
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=(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.'
......@@ -53,14 +62,14 @@ def createPerson(result, browser):
# Add phone number
result('Add telephone',
browser.mainForm.submitSelectAction(value='add Telephone',
sleep=(2, 6)))
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=(3, 9)))
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,7 +83,7 @@ def createPerson(result, browser):
browser.mainForm.submitSelectWorkflow(value='validate_action',
maximum_attempt_number=5,
sleep_between_attempt=5,
sleep=(2, 6))
sleep=(TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT))
result('Waiting for validate_action', waiting_for_validate_action)
result('Show validate', show_validate_time)
......
# -*- coding: utf-8 -*-
import datetime
import random
import time
import string
from utils import *
TMIN_SLEEP = 2
TMAX_SLEEP = 6
SALE_TRADE_CONDITION_NAME = "Scalability Sale Trade Condition"
PREFIX_TITLE = ""
MAX_PRODUCT = 5
def addOrderLine(browser, my_title, result) :
"""
Add an order line to the sale order
@param browser: Browser
@type browser: Browser
@param my_title: The sale order title
@type my_title: string
"""
# Create a new Sale Order Line
browser.mainForm.submitSelectAction(label="Add Sale Order Line")
assert browser.getTransitionMessage() == 'Object created.'
# Fill the quantity randomly
browser.mainForm.getControl(name='field_my_quantity').value = str(random.randint(1, 20))
result('SetRelationProduct', browser.mainForm.submitSave(
sleep=(TMIN_SLEEP, TMAX_SLEEP)))
## Choose the product randomly
fillRelatedObjects(browser, result,
"portal_selections/viewSearchRelatedDocumentDialog0:method", 1,
"AddOrderLine", TMIN_SLEEP, TMAX_SLEEP)
def createSaleOrder(result, browser):
"""
Create a Sale Order with details using Sale Trade Condition to fill,
and add some random sale order lines.
Use the following command:
performance_tester_erp5 http://foo.bar:4242/erp5/ 1 createSaleOrder
Please note that you must run this command from the same directory of this
script and userInfo.py. Further information about performance_tester_erp5
options and arguments are available by specifying ``--help''.
This test requires the bt5 erp5_simulation_performance_test to be installed
for relation with organisation, also it requires a configured Sale Trade Condition.
"""
# Open ERP5 homepage and log in
result('Open', browser.open())
# Log in unless already logged in by a previous test suite
result('Login', browser.mainForm.submitLogin(
sleep=(TMIN_SLEEP, TMAX_SLEEP)))
# Go to sale Order module
result('GotoModule',
browser.mainForm.submitSelectModule(value='/sale_order_module',
sleep=(TMIN_SLEEP, TMAX_SLEEP)))
# Create a new sale order and record the time elapsed in seconds
result('Create',
browser.mainForm.submitNew(sleep=(TMIN_SLEEP, TMAX_SLEEP)))
# Check whether it has been successfully created
assert browser.getTransitionMessage() == 'Object created.'
my_order_sale_url = browser.url.split("?")[0]
# Fill the title
my_title = PREFIX_TITLE + generateString(6)
browser.mainForm.getControl(name='field_my_title').value = my_title
# Set some random informations
my_str = generateString(random.randint(1,100))
browser.mainForm.getControl(name='field_my_comment').value = my_str
browser.mainForm.getControl(name='field_my_description').value = my_str
# Select some options randomly
selectRandomOption(browser, "field_my_order")
# Set dates
date = datetime.datetime.now()
browser.mainForm.getControl(name='subfield_field_my_start_date_day').value = str(date.day)
browser.mainForm.getControl(name='subfield_field_my_start_date_month').value = str(date.month)
browser.mainForm.getControl(name='subfield_field_my_start_date_year').value = str(date.year)
# Submit the changes, record the time elapsed in seconds
result('Save',
browser.mainForm.submitSave(sleep=(TMIN_SLEEP, TMAX_SLEEP)))
# Check whether the changes have been successfully updated
assert browser.getTransitionMessage() == 'Data updated.'
sale_order_url = browser.url
## Set Sale Trade conditions
# Click on the specified menu
result('GoToSaleTradeConditionRelations', browser.mainForm.getControl(
name="portal_selections/viewSearchRelatedDocumentDialog2:method").click())
assert browser.getTransitionMessage() == 'Please select one object.'
line_number = browser.getListboxPosition(SALE_TRADE_CONDITION_NAME, column_number=2)
# Check the box corresponding to line_number
browser.mainForm.getListboxControl(line_number=line_number, column_number=1).click()
result('SubmitSaleTradeConditionRelation',
browser.mainForm.submit(name='Base_callDialogMethod:method',
sleep=(TMIN_SLEEP, TMAX_SLEEP)))
# Add Sale order lines
max_ite = random.randint(1,MAX_PRODUCT)
for i in range (0, max_ite):
browser.open(sale_order_url+"/view")
addOrderLine(browser, my_title, result)
browser.open(my_order_sale_url)
# Validate the Sale Order
browser.mainForm.submitSelectWorkflow(value='plan_action')
result('Validate',
browser.mainForm.submitDialogConfirm(sleep=(TMIN_SLEEP, TMAX_SLEEP)))
assert browser.getTransitionMessage() == 'Status changed.'
# -*- coding: utf-8 -*-
import datetime
import random
import time
import string
from utils import *
PREFIX_TITLE = ""
TMIN_SLEEP_SHORT = 1
TMAX_SLEEP_SHORT = 3
TMIN_SLEEP = 2
TMAX_SLEEP = 6
TMIN_SLEEP_LONG = 4
TMAX_SLEEP_LONG = 8
NUMMAX_FOLLOW_UP = 1
NUMMAX_CONTRIBUTORS = 1
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 +42,66 @@ 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)
selectRandomOption(browser, "subfield_field_my_publication_section_list_default:list")
browser.mainForm.getControl(name='field_my_description').value = 'Benchmark test'
selectRandomOption(browser, "subfield_field_my_group_list_default:list")
selectRandomOption(browser, "subfield_field_my_site_list_default:list")
selectRandomOption(browser, "subfield_field_my_function_list_default:list")
browser.mainForm.getControl(name='field_my_subject_list').value = generateString(30)
## Fill the Follow-up input
fillRelatedObjects(browser, result,
"portal_selections/viewSearchRelatedDocumentDialog0:method", NUMMAX_FOLLOW_UP,
"FollowUp", 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
web_page_url = browser.url
# 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>'
# Submit the changes, record the time elapsed in seconds
result('Save', browser.mainForm.submitSave(sleep=(10, 30)))
## Edit the relations with other existing documents
# Go to the Related Documents view
browser.open(web_page_url+"/Document_viewRelated")
# Fill the Referenced Documents input
fillRelatedObjects(browser, result,
"portal_selections/viewSearchRelatedDocumentDialog0:method", 3,
"ReferencedDocument", TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT)
## Edit content
web_page_url = '/'.join(web_page_url.split('/')[:-1])
browser.open(web_page_url+"/WebPage_viewEditor")
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=(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.'
This diff is collapsed.
import random
import string
def selectRandomOption(browser, select_name):
"""
Function to select randomly an option
@param browser: Browser
@type browser: Browser
@param select_name: Name of the input
@type select_name: string
"""
# Get the option values
options = browser.mainForm.getControl(name=select_name).options[1:]
if len(options) > 0:
# Select randomly one value
browser.mainForm.getControl(name=select_name).value = [random.choice(options)]
def generateString(size) :
"""
Function to generate a string randomly (a-z)
@param size: Size of the string
@type size: int
"""
new_string = random.choice(string.ascii_uppercase)
new_string = new_string + ''.join(random.choice(string.ascii_lowercase) for x in range(size))
return new_string
def fillRelatedObjects(browser, result, name, maximum=1, actionName="", TMIN_SLEEP=0, TMAX_SLEEP=0, col_num=0, text="") :
"""
Function to fill randomly related objetcs
@param browser: browser
@type browser: Browser
@param result: result
@type result:
@param name: Name of the input name attribute
@type name: string
@param maximum: Max number of related objects
@type maximum: int
@param actionName: Name of the action (used for backtrace and statistic ?)
@type actionName: string
@param TMIN_SLEEP: Min time to sleep (in second)
@type TMIN_SLEEP: int
@param TMAX_SLEEP: Max time to sleep (in second)
@type TMAX_SLEEP: int
@param col_num: The numero of the column to filter
@type col_num: int
@param text: Text used to filter
@type text: string
"""
# Go to the section linked by the input
result('GoTo '+actionName+' Relations', browser.mainForm.getControl(
name=name).click())
# Check the status
assert (( browser.getTransitionMessage() == 'Please select one (or more) object.' )
or ( browser.getTransitionMessage() == 'Please select one object.' ))
# Check if it is possible to choose many objects
if (browser.getTransitionMessage() == 'Please select one object.'):
assert ( maximum <= 1 )
# Filter applied the 'col_num' column with text 'text'
if col_num != 0 :
browser.mainForm.getListboxControl(line_number=2, column_number=col_num).value = text
browser.mainForm.submitDialogUpdate()
# Get the number of lines
page_stop_number = browser.etree.xpath('//span[@class="listbox-current-page-stop-number"]')
if len(page_stop_number) > 0:
num_line = int(page_stop_number[0].text)
else:
num_line = 0
# Choose randomly one or more objects
if ( num_line > 0 ) and ( maximum > 0 ):
iteration = random.randint(1, maximum)
for i in range(0, iteration):
line_number = random.randint(1,num_line) + 2
# Check the box corresponding to line_number if not already checked
if browser.mainForm.getListboxControl(line_number=line_number, column_number=1).selected == False:
browser.mainForm.getListboxControl(line_number=line_number, column_number=1).click()
result('Submit '+actionName+' Relations',
browser.mainForm.submit(name='Base_callDialogMethod:method',
sleep=(TMIN_SLEEP, TMAX_SLEEP)))
# Check whether the changes have been successfully updated
assert browser.getTransitionMessage() == 'Data updated.'
def fillOneRelatedObjectSimplified(browser, name):
"""
Function to fill randomly related objetcs
@param browser: browser
@type browser: Browser
@param name: Name of the input name attribute
@type name: string
"""
# Go to the section linked by the input
browser.mainForm.getControl(name=name).click()
# Check the status
assert ( browser.getTransitionMessage() == 'Please select one object.' )
# Get the number of line
page_stop_number = browser.etree.xpath('//span[@class="listbox-current-page-stop-number"]')
if len(page_stop_number) > 0 :
num_line = int(page_stop_number[0].text)
else :
num_line = 0
# Choose randomly one or more objects
if num_line > 0 :
line_number = random.randint(1,num_line) + 2
# Check the box corresponding to line_number if not already checked
browser.mainForm.getListboxControl(line_number=line_number, column_number=1).click()
browser.mainForm.submit(name='Base_callDialogMethod:method')
# Check whether the changes have been successfully updated
assert browser.getTransitionMessage() == 'Data updated.'
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