MeterMaid

bsoremsugar —  August 4, 2010 — 1 Comment

MeterMaid is an XML-based language that can simplify the task of writing test plans for Adobe JMeter.  It was born from a desire to simplify and clean up our internal JMeter tests.  Using MeterMaid, you can write JMeter tests directly in a text editor without learning the arcane details of JMeter’s XML format.

Below you’ll find a MeterMaid script – it’s an example of the type of script you can generate using Sugar MMM (another testing tool that I’ll discuss in a later post).  It adds a relationship from a record in the Contacts module, to a record in another random module:

<speed>
<controller>
<name>10percent</name>
<precent>100</precent>
<http>
<name>Request module popup form</name>
<domain>localhost</domain>
<path>/SugarCE-Full-6.1.0beta/</path>
<method>GET</method>
<data>
<var name=”module”>${SUBPANEL_RELATE_MODULE_g1}</var>
<var name=”action”>Popup</var>
<var name=”hide_clear_button”>true</var>
<var name=”mode”>MultiSelect</var>
<var name=”create”>true</var>
<var name=”metadata”>undefined</var>
</data>
<regex>
<name>Search field name extractor</name>
<refname>SEARCH_FIELD</refname>
<type>body</type>
<matchnum>1</matchnum>
<defaultvalue>SEARCH_FIELD_ERROR</defaultvalue>
<expression>(input type=’text’ name=’)([a-zA-Z0-9-_]+)</expression>
<template>$2$</template>
</regex>
</http>
<http>
<name>Search</name>
<domain>localhost</domain>
<path>/SugarCE-Full-6.1.0beta/</path>
<method>POST</method>
<data>
<var name=”${SEARCH_FIELD_g2}”>${RANDOM_CHAR_g1}</var>
<var name=”module”>${SUBPANEL_RELATE_MODULE_g1}</var>
<var name=”action”>Popup</var>
<var name=”query”>true</var>
<var name=”populate_parent”>false</var>
<var name=”hide_clear_button”>true</var>
<var name=”button”>Search</var>
</data>
<regex>
<name>Found ID regex</name>
<refname>FOUND_ID</refname>
<type>body</type>
<matchnum>1</matchnum>
<defaultvalue>1</defaultvalue>
<expression>(onclick=”send_back(‘[a-zA-Z]+’,’)([a-zA-Z0-9-]+)(‘);”&gt;)([a-zA-Z ]+)</expression>
<template>$2$</template>
</regex>
</http>
<http>
<name>Perform save request</name>
<domain>localhost</domain>
<path>/SugarCE-Full-6.1.0beta/</path>
<method>POST</method>
<data>
<var name=”subpanel_id”>${FOUND_ID_g2}</var>
<var name=”value”>DetailView</var>
<var name=”http_method”>get</var>
<var name=”return_id”>${RECORD_NUMBER_g2}</var>
<var name=”record”>${RECORD_NUMBER_g2}</var>
<var name=”isDuplicate”>false</var>
<var name=”action”>Save2</var>
<var name=”inline”>1</var>
<var name=”select_entire_list”>0</var>
<var name=”child_field”>${SUBPANEL_RELATE_MODULE_g2}</var>
<var name=”subpanel_module_name”>${SUBPANEL_RELATE_MODULE_g4}</var>
<var name=”subpanel_field_name”>${SUBPANEL_RELATE_MODULE_g3}</var>
<var name=”refresh_page”>0</var>
<var name=”module”>Contacts</var><var name=”return_module”>Contacts</var></data>
</http>
</controller>
</speed>

The first element you’ll notice is <speed>.  This is just the standard root element of all MeterMaid documents.  Next, you’ll see that all nodes in the document are children of a <controller> node.  This translates to a JMeter throughput controller.  The effect is that  anything inside the <controller> element will only be executed on a specified percent of total run-throughs of the test plan (here, 10%).

The remainder of the document is a series of <http> nodes, corresponding to JMeter HTTP elements.  Some of the children are self-explanatory such as path, domain, method, and data.  There are examples of a strange syntax:

${SUBPANEL_RELATE_MODULE_g1}

This is a reference to a variable created by a JMeter regular expression extractor.  The regex extractor to create this particular variable isn’t present in the script; this is because this example is a sub-script designed to be included as part of a larger script using the <script> tag.  It won’t do anything interesting when run in isolation, but it’s still useful to illustrate MeterMaid syntax.

There are several <regex> nodes present in the example, and you can read the specific purpose of all the child nodes in MeterMaid’s README.  They correspond to the fields you would fill out in the JMeter GUI.  For example, the FOUND_ID regex extractor finds the record id of a related record from the response to performing a search in the module popup form.

I hope this example, being slightly more involved than the ones from the README or github wiki, is helpful in demonstrating some of the capabilities of MeterMaid.

Head over to the Developer Tools Forum to share your questions or comments.

MeterMaid is available here.

Trackbacks and Pingbacks:

  1. load test for Sugarcrm using ApacheBench - February 21, 2013

    […] […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s