Confluence Jmeter performance script

Recently for a project we needed to measure the performance of an instance of Confluence for a certain number of concurrent users.

Fortunately Atlassian releases a procedure to measure the performance using  Jmeter here. The latest script version we used is 4.2.2 which has been released on 27th of August with Confluence 4.3.1

The script needs some fixes:

  • it doesn’t save the session on the Remote API and then operations like Create Personal Space and Grant View on Personal Space fail to connect because of the rpc token
  • the labels used as tags in Confluence are not the same (we used demonstration and sales)
  • the Browsse User Status operation has an incomplete Response Assertion
  • When deleting  the space, operation that can take some time,  the script doesn’t wait in a loop so it can’t remove some users and also when deleting a space Confluence doesn’t go back to the Dashboard but instead stays on the page

Further I improved the script giving the possibility:

  • to create users from Crowd, using a new command line parameter -Jenable.sso=true, which is false by default
  • to use https in case Confluence is setup with https instead of http, using a new command like parameter -Jconfluence.protocol=https, which is http by default

Therefore, after you download the script (with the resources) , just remember to adapt the Crowd configuration (parameter -Jcrowd.host) and that the operation Create User from Crowd expect to have Crowd under the same ip address of Confluence (you can of course change it).

Create, release and find your own font

Recently I had a look to the fonts, yes those that you use in your office suite or web browser, so moved by curiosity I checked out utilities and other things related to fonts.

First of all for the creation of the font you can use Fontstruct.com, this website uses a Flash application (I know some purist wouldn’t like) to create your font through predefined bricks and it allows you to share it with others. The application is quite user friendly and it allows to share your font in one of these licenses:

  • Creative Common Attribution Share Alike (CC-BY-SA)
  • Creative Common Attribution Non-commercial Share Alike
  • Creative Common Attribution (CC-BY)
  • Creative Common Attribution Non-commercial
  • Creative Common Attribution No Derivatives
  • Creative Common Attribution Non-commercial No Derivatives

The font is then saved in TTF format.

Among those above the CC-BY license is the only one considered in the list of good licenses for font in Fedora list, although the preferred one is the SIL Open Font License.

For Debian they accept CC-BY-SA and the Sil licences.

An application that you could use is FontForge (I didn’t personally try) but it seems well advanced. FontForge is released with BSD License and you can find also the binaries for Windows. Although the interface looks not the best one, it allows to manage different font formats.

If you are searching for inspiration you can also go on other websites like:

Sometimes you really want to know which font is used inside an image, there are 2 websites which can help you:

  • WhatTheFont, where you can upload an image directly and by matching the characters you can be lucky to find the right font. They also release mobile applications (so maybe you just found  a shop with a nice sign and you can take a photo and upload it directly on WhatTheFont) which you can download for free. I tried the Android version on a DVD title and it worked very well
  • Identifont, a web site where you can search fonts by Appearance, using a wizard that helps you to identify the font (it really helped me to find out a font used in a jpg), by Name, by Similarity, by Picture and by Author. They also have a section of free fonts

As Firefox extension I found Font Finder, which I still have to try but looks useful for font designers; for what I can see you can also use Firebug and look at the font rendered with the help of FireFontFamily extension.

Concerning the format you have to know that one of the recommendation (just recent – 11 October 2012) of the W3C is to use the WOFF format , which is a wrapper for TTF font (and other types). Since the SIL license allows to compress the font you could use some tool like sntf2woof that can help you in doing that (the author of the tool is one of the author of the WOFF specifications)

Concerning performance there some of considerations you can take in account:

  • you can reduce the size of the font by selecting the subset language alphabet you need only (latin instead of cyrillic if the font contains it) or even simply selecting only those characters that you really need (in a logo you already know), this is possible through the Google Web Font API and through the font squirrel service in expert mode with custom subsetting. If you don’t want use a service you can have  a look to the font-optimizer released by Philip Taylor under MIT license or having your own loader from Artz Studio.
  • Another consideration is the caching with Google Font Loader that apparently can change depending on the version.
  • The other consideration is about IE browser that you have to put the @font-face declaration before the script tag accordingly to Steve Souders blog post.

Enjoy you new font !

JAXB and the root element

Recently I helped a friend to implement the client of a web service using Axis2 and Tomcat, developing the client first and the jsp after. After testing the web service with SoapUI we started to develop the client with Eclipse.

The problem with this web service is that the body of the method is an entire xml string contained in a CDATA element, not only for for the request but also for the answer, of course this creates problem to generate the java objects from the wsdl file since the element is not defined as XML.

Luckily we received the xsd files so we generated the java classes with JAXB data binding which is implemented, and it can be executed, through the application xjc that you can find inside the bin folder of the Java Virtual Machine. Note that JAXB is the default databinding of Apache Cxf.

JAXB worked nicely but we had the problem to extract from the xml string the node container which needed to be declared as root element, in other words you need to use the @XMLRootElement annotation otherwise you can have the exception:

unexpected element (…) , Expected elements are (none).

when you unmarshal (from string to java object) the element.

 

PHP Code metrics statistics

I believe doing statistics about the quality of the code it can be a good incentive for developers to improve their application and for new coming developers in the project to see a well structured program and put easily their hands on.

Sometime ago I started to verify the quality of the code of Drupal using PHPdepend in Jenkins a bit for fun, so every time there was a new commit pdepend was launched to analyze the code.

I noticed in the code that the threshold to identify max and min limits were based on Java threshold (these threshold have been published in the book “Object Oriented Metrics in Practice” which you can find also in slideshare (slide 12)) which of course cannot be a good comparison since PHP and Java are 2 different programming languages, so I started to analyze other software in order to calculate an average and defining new thresholds.

The comparison was done with pdepend 0.10.7 (I am aware of the version 1.0.0) on 60 php projects which I selected in different environments.

You can find the file at the link Comparison of php application to determine thresholds in pdepend.

Even though you can find a degree among all the applications, it could be more interesting doing  it between similar application (CMS, etc.) .

The summary is:
MIN – AVG – MAX
cyclo-loc:    0.16 – 0.20 – 0.24 (not changed)
loc-nom:        13 -    20 -    27 (doubled)
nom-noc:         5 -   12 -    18
noc-nop:          1 -   14 –    27
calls-nom:   2.66 – 3.68 – 4.69
fanout-calls: 0.01 – 0.06 – 0.11 (much lower)
andc:          0.27 – 0.52 – 0.76
ahh:            0.17 – 0.37 – 0.58

What it is interesting to see is that the line of code for each method is doubled and the fanout-calls is much lower (then the next question would be: why ?), it would be even more interesting to see how the new versions of each application change or with the new version of pdepend, If I had more time I would like to work on it but at least I shared this thought with you :-)

I hope this result can be of inspiration somebody else :-)

JSLint4java, Jenkins and Violation plugin

In a previous article I told you about the existence of the violation plugin for Jenkins which can take in consideration the output generated by jslint4java.

jslint4java has an ant plugin which can be easily integrated in your environment and you need just to configure it for your javascript.

Let’s suppose you have a javascript file, in my case user-extensions.js coming from Selenium, in your repository.

At the same level create a folder named “jslint”. Under this folder place the jslint4java-2.0.1.jar file that you can find inside the zip file of jslint4java and create a build.xml file with the following content:

<project name="proj" default="main" basedir=".">
<target name="main" depends="jslint"/>

<taskdef name="jslint"
classname="com.googlecode.jslint4java.ant.JSLintTask"
classpath="jslint4java-2.0.1.jar" />

<target name="jslint">
<jslint haltOnFailure="false" options="sloppy">
<predef>selenium,Selenium,storedVars,LOG,Assert</predef>
<formatter type="xml" destfile="jslint.xml"/>
<fileset dir="../" includes="user-extensions.js"/>
</jslint>
</target>

</project>

In practice in the taskdef tag we say where the jar file is located (same folder), in the jslint tag I specified:

  1. haltOnFailure=”false”, to not  make stop and fail the plugin if a violation is found (in this way the entire job in Jenkins will not fail)
  2. options=”sloppy”, to disable the strict control in the file (used for ECMAScript 5)
  3. using predefined variables like “selenium” with the predef tag
  4. specifying the output file (in the same folder) in xml format (useful for the violation plugin)
  5. specifying just the input file that I have (which is in the top folder)

Once the folder is created with the 2 files (build.xml and jslint4java jar file) in the repository let’s go to the Jenkins job to install the violation plugin and configure the job.

First let’s configure the ant task in the Job (my directory is under trunk/test):

Ant configuration

Then we configure the Violation plugin in the Job:

Violation plugin configuration

Let’s save and run the build and we should see a graph the following in the Job page:

Violation graph in job page

If you click on the left menu on Violations (or in the graph) you will see the same graph with the number of violations per file:

Number of violations per file

If you click on the filename you will see all the violations with the respective row numbers:

Violations in a file

If you click on the row number you can see the line of the code (just below):

Photobucket

Enjoy fixing your javascript file :-)

Selenium, JSLint and editors

Testing with Selenium can require adding a user-extensions.js to your Selenium IDE and Server.

While modifying the user-extensions.js you could need a javascript editor with a JSLint plugin suggesting how to make your code better.

Among open source solutions with JSLint plugin I found: Notepad++, jEdit, Netbeans, Eclipse and Aptana (please suggest others if you know).

Notepad++ (5.9.6.2) has a good plugin updated to 2011 (I can see the Node.js option) and you can put the variable Selenium in the options (Predefined field) of the plugin. The errors are displayed in the JSLint panel which is good but you cannot order them by error description. The only problem is that Notepad++ is for Windows (I have seen people using it with wine for Linux).

Notepad++ doesn’t provide a function navigator but it is possible to setup a Function List plugin manually (put the dll in the program files directory and the rest in the %appdata%/Notepad++/plugins/config with the xml in readonly) and add a rule as explained in this blog.

jEdit (4.5.1 pre1) is a good multiplatform editor. It has a function navigator (you have to install Sidekick plugin with the XML plugin) and it has a JSLint plugin (0.8)

The JSLint plugin is old (in the page you see that the latest release is in 2009) and indeed you don’t see the Node.js option, further you need to add /*global Selenium */ inside your script to make disappear the undefined variable Selenium message. The errors are displayed in the Error List panel and underlined in the file andyou cannot order them by error description

Netbeans (7.0.1) has his own JSLint plugin, with a configuration under Tools->Options->Miscellaneous->JSLint but the Predefined field doesn’t seem to work so you need to add /*global Selenium */ in your script. The error are displayed next to the file and under the Task list (see the instructions) and you can order them by error description.

With Netbeans you can see the function navigator in the Navigator panel. Compared with others IDE (Eclipse/Aptana) you can do the check on a file or in a project while the others can work only in the project.

For Eclipse (Indigo) I setup the JSLint plugin using the update site:

http://update.rockstarapps.com/site.xml

When you have setup the plugin, you see a RockStarApps menu and, as you can notice, the plugin is not updated to the last version of JSLint (Node.js is not there) but the Predefined field works.

The errors are displayed next to the file and under the Problems panel and you can group them by error description.

For the function navigator Eclipse has a JavaScript Development Tools plugin that you can setup using the following site under WTP 3.3.1:

http://download.eclipse.org/webtools/repository/indigo

Then open the perspective Javascript and you find the function navigator in the Script Explorer panel.

Concerning Aptana Studio 3, there is a native JSLint plugin to be enabled under Window->Preferences->Aptana Studio->Validation->Javascript. I don’t see the configuration panel like in the other plugins so you need to add all the options in your javascript file but you can fiter some warnings.

The errors are displayed next to the file and under the Problems panel and you can group them by error description. It doesn’t look to me stable for the moment (it seems not all the warnings I get with the others plugin are there).

Aptana has a function navigator in the Outline panel.

At Continuous Integration level I found a Jenkins Violation Plugin or just using jslint4java which has an ant plugin on which is based the Sonar plugin.