Load testing OpenERP with JMeter

Introduction:

Apache JMeter is open source software, a 100% pure Java desktop application designed to load test functional behavior and measure performance.I am going to explain on load testing OpenERP with Jmeter.

Installation:

Download Apache Jmeter from,
http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi
Extract it
Go to jakarta-jmeter-2.4/bin
Run ./jmeter.sh(linux) or jmeter.bat (windows)

Procedure:

1) Right click on Test plan -> Add -> Threads -> Thread group

2) In the thread group, enter

Number of users:Number of users for which you are going to simulate the test.
Ramp-Up period: Number of seconds delay between user call.
Loop count: Number of times to repeat the test

3) Right click the new thread group -> Add -> Sampler -> SOAP/XML-RPC request. Rename it to XML-RPC Login.

Fill the fields,

URL: http://IP_ADDRESS:8069/xmlrpc/common
XML-RPC Data:

    <?xml version="1.0"?>
            <methodCall>
          <methodName>login</methodName>
          <params>
            <param>
                <value>DB_NAME</value>
            </param>
            <param>
                <value>USERNAME</value>
            </param>
            <param>
                <value>PASSWORD</value>
            </param>
          </params>
        </methodCall>

Note: Change IP_ADDRESS,DB_NAME, USERNAME and PASSWORD according to your real values.I assume XML-RPC of openerp listens at 8069, which is default.

4) Add another SOAP/XML-RPC request and name it as XML-RPC partners.

URL:http://IP_ADDRESS:8069/xmlrpc/object

<?xml version="1.0"?>
<methodCall>
  <methodName>execute</methodName>
  <params>
    <param>
        <value><string>DB_NAME</string></value>
    </param>
    <param>
<value>         <int>UID</int></value>
    </param>
    <param>
        <value><string>PASSWORD</string></value>
    </param>

    <param>
        <value><string>res.partner</string></value>
    </param>
    <param>
        <value><string>read</string></value>
    </param>

    <param>
      <array>
     <data>   <int>1</int>
  </data>
     <data>   <int>2</int>

</array>
    </param>

    <param>
      <array>
     <data>   <string>name</string>
  </data>
<data>   <string>title</string>
  </data>
</array>
 </param>
  </params>
</methodCall>

We are trying to read ‘name’ and ‘title’ from partners table, where id is in [1,2]. You can change/add according to your need.

5) Now time to put monitoring tools,

Right click on Thread group -> Add -> Listeners -> View Results Tree or Aggregate Graph or Aggregate report or Monitor Results or Graph results and so on.

6) Time to run the test now, Click Run -> Start from menu.
Click on each listeners and see the responses.

a)

b)

c)

Notes:

You can disable the login XML-RPC after the first time.

OpenERP and TDS support

As promised, here I am with the basic TDS functionality for OpenERP, Indian standards.

Please refer Income_tax_in_India for details related to Indian tax structure.

Features:

  • TDS linked with Invoice Line
  • Accounting TDS and Deduction
  • TDS with Lower and Zero Rate
  • Accounting TDS and Deducting it Later
  • TDS Helper for paying TDS to Govt
  • Viewing TDS Pending, payable, zero/reduced rate

Legal Reports:

  • Form 16A
  • Form 26Q
  • Form 26Q Annexure
  • Form 27Q
  • Form 27Q Annexure
  • Form 26A
  • Form 26A Annexure
  • Form 27A
  • Form 27A Annexure

Download Link:

To provide core functionality,

https://code.launchpad.net/~e-ndicusteam/openerpgit/account_india_tds

To provide legal reports,

https://code.launchpad.net/~e-ndicusteam/openerpgit/account_tds_report

Configuration Steps:
Once installed the two modules,

Go to Accounting ->Coniguration ->Financial Accounting -> TDS

You will see three sub-menus,

  • Nature of Payment
  • Deductee Types,
  • Deductors,

Nature Of Payment:
Enter the details like code,name. From this window, create a section and link it here.
Choose a Duties&taxes account, where all the TDS amount related with this Nature of payment will be encoded.

Deductee Type:
This is the important part,
Enter a name,choose residential status.

In deductee line tree, add a new line.

Choose a nature of payment and enter respective Tax rates.
Date from is the start date, For eg April 1,2011.

Feed the exemption limit for respective taxes.

Deductors:
Enter name,designation and choose a address.This is only useful for TDS reports which are to be filed.

The next step is to configure the respective accounts,

There are three types of account,
1) Patner account
2) Expense account
3) TDS account (Chosen in the nature of payment)

Partner Account:
Go to the partner account, for eg,Creditors.
Enable TDS applicable check box and choose a deductee type created before.

Advanced TDS entries for Lower/Zero tds deductions, where you can overwrite the default tax rates.

Expense Account:
Go to the expense account, For eg, Expense.

Enable TDS applicable and choose a Nature of payment and leave deductee type empty.
Raising Invoice with TDS:

Navigate to Supplier Invoice, create a new invoice as usual.

In invoice line, enable Is TDS applicable and deduct now options.

Now in invoice main window, press ‘Gen TDS’ button before approving invoice.Then click compute taxes button, which will populate tds amount field.

You can now approve the invoice and check the Residual amount.

TDS Payment to Government:

TDS helper aids for TDS payment.
Navigate to Accounting -> Suppliers -> TDS helper.

Fill the fields,

This will create a payment voucher against a partner named, GOVT (yes it is hardcoded as of now ).

To validate the payment, you need to re-visit supplier payment and validate the TDS voucher, just created.

TDS Payables/Pending:

To see pending and paid TDS amount,go to TDS Main menu item.
TDS Main -> TDS entries and filter the needed reports.

Note: There is a known bug which affects TDS searching TDS paid entries; they are not being properly updated.

Reporting:
Visit, Accouting -> Legal reports -> TDS reports.

You will find quartler and annual reports for 26 and 27 with annexure for both report along with Form !6A.

Demo Video:

Notes:

1) The current module may not fulfill all TDS related stuffs, still we believe, is a good start. We request you people to consider this version as alpha release and report bugs/blueprints in the lauchpad pages. We are open to get feedbacks and improve things.

2) https://code.launchpad.net/~e-ndicusteam/openerpgit/account_voucher_cheque is a dependent module for reporting module.

Who we are:

We, E-ndicus, is an Opensource technologies based organization, an official OpenERP partner, from Chennai.

Reportlab Tamil characters OpenERP

Introduction:

I have finished hacking Reportlab, Python for Tamil character support.

Now reportlab can cleanly render Tamil characters which means OpenERP with nice Tamil PDF reports.

Tamil Characters:

Some of character sets like Tamil or Hindhi can fall in two scenarios,

1) Substitution of original character with two or more glyphs.(க +ி = கி)

2) Re-adjustment of character glyphs. ( க ெ =கெ )

Note: Characters are mapped to respective glyphs (image representation of character ) for PDF rendering.

Reportlab:

I tried to analyse reportlab for the mentioned two scenario and found nothing useful.

Hence I hacked the reportlab/pdfbase/ttfonts.py which is reponsible for mapping characters to glyphs.

I have added code which looks and perform,

1) Substitution

2) Re-adjustment

before rendering PDF.

Here is a sample PDF report from OpenERP,

Code:

I will soon share the changes as patch.


OpenERP with Subdomain

OpenERP in Subdomain Mode

To acess your OpenERP database with subdomain binding, can be easily done with the following steps in Ubuntu ( or similar Linux distros )

1)  Edit your /etc/hosts and add new lines like,

IP   HOSTNAME

For eg:

127.0.0.1    selvam.locahost

2) Then add a new file,assuming endicus is the site name,

$ sudo gedit /etc/apache2/sites-available/endicus

<VirtualHost *>

DocumentRoot /usr/local/lib/python2.6/dist-packages/openerp_web-6.0.1-py2.6.egg

ServerName db1.localhost

ServerAlias *.localhost

<Directory /usr/local/lib/python2.6/dist-packages/openerp_web-6.0.1-py2.6.egg>

Options Indexes FollowSymLinks MultiViews +Includes

AllowOverride All

Order allow,deny

allow from all

</Directory>

</VirtualHost>

I believe DocumentRoot does not have any impact here.

3) $sudo a2ensite endicus

4) In openerp-web.cfg (/usr/local/lib/python2.6/dist-packages/openerp_web-6.0.1-py2.6.egg/doc or in /etc/ ),

modify

dblist.filter=’BOTH’  (To filter Databases based on domain )

dbbutton.visible = False  ( To disable Databases button in login page )

Thats it, Restart apache and openerp-web.

When you access http://selvam.IP:8080 should list only the database,selvam.

XLS Reporting in OpenERP

Update:

I have added my code which you can find here,

http://www.4shared.com/archive/XbokLlzO/reporting_latesttar.html

Extract it and read the help.txt file for further info. Good Luck !

What is it ?
I was looking for a native XLS report from OpenERP, which I could not find out. Instead of writing a new extension,

I thought of extending the existing Report engine. I completed the basic version of it.

How to get XLS report ?
You can go to Administration -> Low Level Objects -> Actions -> Report XML and choose a report, then change its type to XLS.

Now try accessing the report as you would do normally. It will through you XLS report.

This extension may not be stable yet, but can be used in development version.

Features:

  • No need to write new reports, It will just work with existing RML reports.
  • It can handle maximum of two levels of nested table in RML.
  • No external dependency except python-xlwt module.

How it Works ?

The new modified code adds a new type called xls and additional functions. When a report is invoked and the type is XLS, it will invoke rml2xls module, which will take care of converting the rml to xls and emit it. The rml2xls, depends on rml2html. The output html generated by rml2html is passed to a custom HTML parser. The HTML parser parses the necessary tags and writes into XLS file.

Where to Download ?

Once testing from our side gets over, I will share it with you.

OpenERP XML-RPC Java

Introduction

OpenERP’s communication normally happens in two modes

  • Net-RPC
  • XML-RPC

where, net-rpc is considered to be fast for python based applications.
I will discuss here about the xml-rpc calls from Java.
If you want to see all the xml-rpc calls made from GTK client,
start the client with,

./openerp-client.py -l debug_rpc

Java and XML-RPC:

I chose to use Java examples here with apache-xmlrpc-3.1.3 package.

The actual xml-rpc call made for reading Purchase Order is,

1) Setting up things:


XmlRpcClient xmlrpcLogin = new XmlRpcClient();
XmlRpcClientConfigImpl xmlrpcConfigLogin = new XmlRpcClientConfigImpl();
xmlrpcConfigLogin.setEnabledForExtensions(true);
xmlrpcConfigLogin.setEnabledForExceptions(true);
xmlrpcConfigLogin.setServerURL(new URL(“http”,host,port,”/xmlrpc/common”));
xmlrpcLogin.setConfig(xmlrpcConfigLogin);



host and port are self explanatory. Normally, XML-RPC port is 8069.

2) Login to the system:


Vector params = new Vector();

params.addElement(tinydb);//database
params.addElement(login);//user id
params.addElement(password);//pwd
Object id = xmlrpcLogin.execute(“login”, params);


3) Find all the Purchase Order which are in ‘draft’ state:

The actual call made from GTK client looks like this,

rpc.request:(‘execute’, ‘v14’, 1, ‘admin’, (‘purchase.order’, ‘search’, [(‘state’, ‘=’, ‘draft’)], 0.0, 80.0, 0)),

In java, i could write it as,


XmlRpcClientConfigImpl rpc = new XmlRpcClientConfigImpl();
rpc.setEnabledForExtensions(true);
rpc.setEnabledForExceptions(true);
rpc.setServerURL(new URL(“http”,host,port,”/xmlrpc/object”));
xmlrpcLogin.setConfig(rpc);

Object r[]=new Object[6];
r[0]=tinydb;
r[1]=(Integer)id;
r[2]=password;
r[3]=”purchase.order”;
r[4]=”search”;

Object names[]=new Object[3];


Get the PO in state draft,


names[0]=”state”;
names[1]=”=”;
names[2] = “draft”;

Vector param2 = new Vector();
param2.addElement(names);
r[5]=param2;
Object po_ids;
po_ids=xmlrpcLogin.execute(“execute”, r);
Object[] d = (Object[]) po_ids;

Integer i=0;

for(i=0; i<d.length; i++)
System.out.println((Integer)d[i]);


The last loop will print the purchase order ids.

4) Confirm the Purchase Order:

Now, let me just confirm the first purchase order,

The actual python call made would be,
rpc.request:('exec_workflow', 'energy', 1, 'admin', (u'purchase.order', 'purchase_confirm', 4))

and we could write in Java as,


Object r2[]=new Object[7];
r2[0]=tinydb;
r2[1]=(Integer)id;
r2[2]=password;
r2[3]="purchase.order";
r2[4] = "purchase_confirm";
r2[5] = d[0];
Object po_data;
po_data=xmlrpcLogin.execute("exec_workflow", r2);


The exec_workflow, as the name implies, triggers workflow.

Some better java programmer can write simple code for the same purpose 🙂

This post is made from Gedit Editor

OpenERP-Apache-SSL

OpenERP-Apache with SSL:


I am writing here, how I configured openerp-apache for SSL support in Ubuntu 10.04

LTS.I believe, this could hold good for most debian based systems.

Installing openerp server and client:

You can read the official document in,

http://doc.openerp.com/install/linux/index.html

Installing apache and enabling supporting modules:

$ sudo apt-get install apache2

$ sudo a2enmod ssl

$ sudo a2ensite default-ssl

$ sudo /etc/init.d/apache2 restart

$ sudo a2enmod proxy

$ sudo a2enmod proxy_http

$ sudo a2enmod proxy_connect

$ sudo a2enmod proxy_ftp

$ sudo a2enmod headers

$ sudo /etc/init.d/apache2 restart

Generating keys and certificates:

Now you should see the default certificate and key files,
/etc/ssl/certs/ssl-cert-snakeoil.pem

/etc/ssl/private/ssl-cert-snakeoil.key
You may use openssl to generate your own certificates.

You can read more in,

https://help.ubuntu.com/8.04/serverguide/C/certificates-and-security.html

Web server configurations:

Edit /etc/apache2/ports.conf and add a new line,
Listen 443
Make sure you don’t have two entries for same port.
If you have static IP and domain name, edit the file /etc/hosts and add a new line,
127.0.0.1       localhost

127.0.1.1       selvam-laptop

MY_STATIC_IP    MY_DOMAIN

Proxy setting:

We will use reverse proxy here.

You can read more about reverse proxy in,

http://en.wikipedia.org/wiki/Reverse_proxy

To setup Reverse proxy,
Edit /etc/apache2/sites-available/default-ssl and add these lines in the last part.
<VirtualHost 127.0.0.1:443>

<Proxy *>

AddDefaultCharset off

Order deny,allow

Allow from all

</Proxy>

ProxyRequests Off
ProxyPass   /   http://127.0.0.1:8080/

ProxyPassReverse /   http://127.0.0.1:8080/

RequestHeader set “X-Forwarded-Proto” “https”
# Fix IE problem (http error 408/409)

SetEnv proxy-nokeepalive 1

</VirtualHost>

The same file should already contain the lines,

SSLEngine on

SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem

SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

Postgres permissions:

Add postgres user to the ssl-cert group by,

usermod -aG ssl-cert postgres

Change the permission of key file like below,

chmod -R 650 /etc/ssl/private/

It should look like,
drw-r-x— 2 root ssl-cert  4096 2010-10-26 00:14 private

Otherwise you may face error “Can not read server.key file, permission denied”

on postgres start.

To make sure the key file is accessible, login as postgres user and use,

$cat /etc/ssl/private/ssl-cert-snakeoil.key

The symbolic links from postgres will look like,

$  ls -l /var/lib/postgresql/8.4/main/s*

lrwxrwxrwx  1 postgres ssl-cert   36 2010-10-25 19:55 server.crt -> /etc/ssl/certs/ssl-cert-snakeoil.pem
lrwxrwxrwx  1 postgres ssl-cert   38 2010-10-25 19:55 server.key -> /etc/ssl/private/ssl-cert-snakeoil.key

Openerp-Web Configuration:

update the openerp-web.cfg with,

server.socket_host = “127.0.0.1”

tools.proxy.on = True

base_url_filter.on=True

base_url_filter.use_x_forwarded_host = False

base_url_filter.base_url = “https://127.0.0.1&#8221;

tools.csrf.on = False

Starting Server:

$ sudo /etc/init.d/apache2 restart

$ sudo /etc/init.d/postgresql-8.4 force-reload

Restart the openerp-web.

Restart the openerp-server as,

openerp-server –secure –cert-file=/etc/ssl/certs/ssl-cert-snakeoil.pem –pkey-file=/etc/ssl/private/ssl-cert-snakeoil.key

You can use -s to save configuration to ~/.openerp_serverrc

Now, you should be able to access,

https://127.0.0.1/ as well as http://127.0.0.1:8080.

Troubleshooting:

If you face any errors in accessing the final https://127.0.0.1/ site,

You could see the output of error log to figure out the issue,

$tail -f /var/log/apache2/error.log

References:
http://tipstricks.itmatrix.eu/?p=497
http://doc.openerp.com/install/linux/web/index.html
http://www.openerp.com/forum/topic20712.html

%d bloggers like this: