https://www.zkoss.org/_w/index.php?title=Small_Talks/2012/May/Perform_stress_test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example&feed=atom&action=historySmall Talks/2012/May/Perform stress test on ZK using JMeter-take Shopping Cart as an example - Revision history2024-03-29T07:04:35ZRevision history for this page on the wikiMediaWiki 1.35.1https://www.zkoss.org/_w/index.php?title=Small_Talks/2012/May/Perform_stress_test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example&diff=55649&oldid=prevHawk: /* Configuring ZK */2023-04-26T09:32:43Z<p><span dir="auto"><span class="autocomment">Configuring ZK</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 09:32, 26 April 2023</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l60" >Line 60:</td>
<td colspan="2" class="diff-lineno">Line 60:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>*Set [http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/sys/IdGenerator.html IdGenerator] for your ZK app</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>*Set [http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/sys/IdGenerator.html IdGenerator] for your ZK app</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>As illustrated in [<del class="diffchange diffchange-inline">http://books.zkoss.org/index.php?title=</del>Small_Talks/2012/January/Execute_a_Loading_or_Performance_Test_on_ZK_using_JMeter Dennis’ small talk], you need to define IdGenerator to fix the desktop IDs and component IDs so that we can record and play the testing script. The IdGenerator is implemented as follows:</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>As illustrated in [<ins class="diffchange diffchange-inline">[</ins>Small_Talks/2012/January/Execute_a_Loading_or_Performance_Test_on_ZK_using_JMeter<ins class="diffchange diffchange-inline">| </ins>Dennis’ small talk<ins class="diffchange diffchange-inline">]</ins>], you need to define IdGenerator to fix the desktop IDs and component IDs so that we can record and play the testing script. The IdGenerator is implemented as follows:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><source lang="java"></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><source lang="java"></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>public class MyIdgenerator implements IdGenerator {</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>public class MyIdgenerator implements IdGenerator {</div></td></tr>
</table>Hawkhttps://www.zkoss.org/_w/index.php?title=Small_Talks/2012/May/Perform_stress_test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example&diff=55648&oldid=prevHawk: /* Preface */2023-04-26T09:32:14Z<p><span dir="auto"><span class="autocomment">Preface</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 09:32, 26 April 2023</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l6" >Line 6:</td>
<td colspan="2" class="diff-lineno">Line 6:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Preface=</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Preface=</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Dennis Chen has shared a small talk illustrating how you can [<del class="diffchange diffchange-inline">http://books.zkoss.org/index.php?title=</del>Small_Talks/2012/January/Execute_a_Loading_or_Performance_Test_on_ZK_using_JMeter execute a loading test with ZK applications using JMeter]. Now, in this small talk we will take a real application as an example to demonstrate in detail how you can actually apply the ideas illustrated in Dennis’ article to perform a stress test.</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Dennis Chen has shared a small talk illustrating how you can [<ins class="diffchange diffchange-inline">[</ins>Small_Talks/2012/January/Execute_a_Loading_or_Performance_Test_on_ZK_using_JMeter<ins class="diffchange diffchange-inline">| </ins>execute a loading test with ZK applications using JMeter<ins class="diffchange diffchange-inline">]</ins>]. Now, in this small talk we will take a real application as an example to demonstrate in detail how you can actually apply the ideas illustrated in Dennis’ article to perform a stress test.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Test plan=</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Test plan=</div></td></tr>
</table>Hawkhttps://www.zkoss.org/_w/index.php?title=Small_Talks/2012/May/Perform_stress_test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example&diff=36304&oldid=prevSamchuang: /* Configuring ZK */2013-03-19T01:50:33Z<p><span dir="auto"><span class="autocomment">Configuring ZK</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 01:50, 19 March 2013</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l99" >Line 99:</td>
<td colspan="2" class="diff-lineno">Line 99:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></source></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></source></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>*[http://books.zkoss.org/wiki/User:Jimmyshiau/Etc_Id_Generator Id Generator]</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>*[http://books.zkoss.org/wiki/User:Jimmyshiau/Etc_Id_Generator <ins class="diffchange diffchange-inline">More about </ins>Id Generator]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Preparing Testing Scripts=</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Preparing Testing Scripts=</div></td></tr>
</table>Samchuanghttps://www.zkoss.org/_w/index.php?title=Small_Talks/2012/May/Perform_stress_test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example&diff=36303&oldid=prevSamchuang: /* Configuring ZK */2013-03-19T01:49:44Z<p><span dir="auto"><span class="autocomment">Configuring ZK</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 01:49, 19 March 2013</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l98" >Line 98:</td>
<td colspan="2" class="diff-lineno">Line 98:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></system-config></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></system-config></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></source></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></source></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">*[http://books.zkoss.org/wiki/User:Jimmyshiau/Etc_Id_Generator Id Generator]</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Preparing Testing Scripts=</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=Preparing Testing Scripts=</div></td></tr>
</table>Samchuanghttps://www.zkoss.org/_w/index.php?title=Small_Talks/2012/May/Perform_stress_test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example&diff=27049&oldid=prevSoutherncrossie at 07:37, 8 May 20122012-05-08T07:37:23Z<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 07:37, 8 May 2012</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Template:Smalltalk_Author|</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{{Template:Smalltalk_Author|</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|author=Matthew Cheng, Engineer, Potix Corporation</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|author=Matthew Cheng, Engineer, Potix Corporation</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>|date=<del class="diffchange diffchange-inline">January 27</del>, 2012</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>|date=<ins class="diffchange diffchange-inline">May 08</ins>, 2012</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|version=ZK 5/6</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>|version=ZK 5/6</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}}</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}}</div></td></tr>
</table>Southerncrossiehttps://www.zkoss.org/_w/index.php?title=Small_Talks/2012/May/Perform_stress_test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example&diff=27048&oldid=prevSoutherncrossie: Created page with "{{Template:Smalltalk_Author| |author=Matthew Cheng, Engineer, Potix Corporation |date=January 27, 2012 |version=ZK 5/6 }} =Preface= Dennis Chen has shared a small talk illustrat..."2012-05-08T07:36:42Z<p>Created page with "{{Template:Smalltalk_Author| |author=Matthew Cheng, Engineer, Potix Corporation |date=January 27, 2012 |version=ZK 5/6 }} =Preface= Dennis Chen has shared a small talk illustrat..."</p>
<p><b>New page</b></p><div>{{Template:Smalltalk_Author|<br />
|author=Matthew Cheng, Engineer, Potix Corporation<br />
|date=January 27, 2012<br />
|version=ZK 5/6<br />
}}<br />
<br />
=Preface=<br />
Dennis Chen has shared a small talk illustrating how you can [http://books.zkoss.org/index.php?title=Small_Talks/2012/January/Execute_a_Loading_or_Performance_Test_on_ZK_using_JMeter execute a loading test with ZK applications using JMeter]. Now, in this small talk we will take a real application as an example to demonstrate in detail how you can actually apply the ideas illustrated in Dennis’ article to perform a stress test.<br />
<br />
=Test plan=<br />
We will be using the "shopping cart" example from [http://books.zkoss.org/wiki/ZK_Essentials ZK Essentials] as the template application to perform the stress test.<br />
====Setup====<br />
*ZK 5.0.11<br />
*zk testing demo ( a demo based on the shopping cart sample)<br />
*Jmeter 2.5.1<br />
<br />
====Test Scenario====<br />
<br />
#User enters his user name and password for authentication<br />
#Login successfully to the shopping site, redirect to index.zul<br />
#User selects an item and drag to the shopping cart<br />
#User checks out <br />
Since this is a stress test, we can apply 50, 100, 150,... concurrent users to perform the test scenario simultaneously. In our example we have created a max of 300 accounts, which allows you to perform the test with as many as 300 concurrent users.<br />
<br />
=Before we start=<br />
As mentioned above we will be using the "shopping cart" example from ZK Essentials as the template application. However there is only one set of login/password in the current shopping cart implementation which is not sufficient for multiple users. To support multiple users, we have modified the shopping cart example to generate multiple accounts, so that each user will be logged in using a different account. This is done as follows, and it will be triggered as you click "createUserBtn" in login.zul:<br />
<br />
'''1. prepare a CSV file that includes a list of user names and passwords:'''<br />
<br />
[[Image:Csv.png|300px]]<br />
<br />
'''2. Add the following code to LoginViewCtrl.java'''<br />
<source lang=java><br />
public void onClick$createUserBtn() {<br />
Map map = userinfo();<br />
Session session = StoreHibernateUtil.openSession();<br />
Transaction t = session.beginTransaction();<br />
<br />
Iterator entries = map.entrySet().iterator();<br />
int i = 0;<br />
while (entries.hasNext()) {<br />
i ++;<br />
Map.Entry entry = (Map.Entry) entries.next();<br />
String name = (String)entry.getKey();<br />
String pwd = (String)entry.getValue();<br />
User user = new User(i, name, pwd, "user");<br />
session.save(user);<br />
if (i % 20 == 0) { <br />
session.flush();<br />
session.clear();<br />
}<br />
}<br />
t.commit();<br />
session.close();<br />
}<br />
<br />
</source><br />
<br />
=Configuring ZK=<br />
<br />
*Set [http://www.zkoss.org/javadoc/latest/zk/org/zkoss/zk/ui/sys/IdGenerator.html IdGenerator] for your ZK app<br />
As illustrated in [http://books.zkoss.org/index.php?title=Small_Talks/2012/January/Execute_a_Loading_or_Performance_Test_on_ZK_using_JMeter Dennis’ small talk], you need to define IdGenerator to fix the desktop IDs and component IDs so that we can record and play the testing script. The IdGenerator is implemented as follows:<br />
<source lang="java"><br />
public class MyIdgenerator implements IdGenerator {<br />
private static ThreadLocal<HttpServletResponse> response = new ThreadLocal<HttpServletResponse>();<br />
private static AtomicInteger ai = new AtomicInteger();<br />
<br />
public String nextComponentUuid(Desktop desktop, Component comp) {<br />
String number;<br />
if ((number = (String) desktop.getAttribute("Id_Num")) == null) {<br />
number = "0";<br />
desktop.setAttribute("Id_Num", number);<br />
}<br />
int i = Integer.parseInt(number);<br />
i++;// Start from 1<br />
desktop.setAttribute("Id_Num", String.valueOf(i));<br />
return "t_" + i;<br />
}<br />
<br />
public String nextDesktopId(Desktop desktop) {<br />
HttpServletRequest req = (HttpServletRequest)Executions.getCurrent().getNativeRequest();<br />
String dtid = req.getParameter("tdtid");<br />
if(dtid!=null){<br />
}<br />
return dtid==null?null:dtid;<br />
}<br />
<br />
public String nextPageUuid(Page page) {<br />
return null;<br />
}<br />
}<br />
</source><br />
*Define your IdGenerator in zk.xml<br />
Then, define your IdGenerator in zk.xml, for example,<br />
<source lang="xml"><br />
<system-config><br />
<id-generator-class>foo.MyIdgenerator</id-generator-class><br />
</system-config><br />
</source><br />
<br />
=Preparing Testing Scripts=<br />
<br />
Now we are ready to record the scripts. We will be recording 6 HTTP requests as illustrated in the image below. What we need to do is to configure the parameters of these 6 requests based on the application that we wish to test.<br />
<br />
[[Image:All.png|300px]]<br />
<br />
===Load CSV file as the variable of the user name and password===<br />
<br />
*'''Add a CSV Data Set Config'''<br />
<br />
First we need to add a CSV Data Set Config here. The element will iterate the csv data set to simulate muti-users login into the application. Please specify a fully qualified name to the Filename field (ex: C:\mycsv\users.csv ), and specify the variable name to the Variable Names field for later use.<br />
<br />
[[Image:Csv data set.png|700px]]<br />
<br />
*'''Add BSF PostProcessor'''<br />
<br />
Then we need to ask jmeter to generate the accounts and passwords automatically based on our CSV file. What we need to do is to add a BSF PostProcessor element, set the language to beanshell, and define:<br />
<br />
<br />
var username = vars.get("username");<br />
<br />
var password = vars.get("password");<br />
<br />
vars.put("user","{\"value\":\""+username+"\",\"start\":2}");<br />
<br />
vars.put("pwd","{\"value\":\""+password+"\",\"start\":2}");<br />
<br />
<br />
This script will get the username and password variables generated by CSV Data Set Config element, and combine the result and some text as a parameter which will be used as user names and passwords later.<br />
<br />
[[Image:BSF PostProcessor.png|700px]]<br />
<br />
===Set account & password as variables===<br />
With these settings ready, we can now set the parameter dtid as ${dtid} and use EL to replace a fixed account and password in the first ajax request (i.e. the login request).<br />
For example if we send zk/zk as user name and password, then we will be seeing <br />
<br />
''data_3: {"value":"zk","start":2}'' //for username<br />
<br />
''data_4: {"value":"zk","start":2}'' //for password<br />
<br />
in the recorded jmeter’s request. Then, we use ${user} and ${pwd} to replace {"value":"zk","start":2} for handling the accounts and passwords dynamically.<br />
<br />
[[Image:Submit.png|400px]]<br />
<br />
===Generate new desktop ID for redirecting to a new page===<br />
After an user logged into the system, he will be redirected to index.zul. Since the URL is changed, the desktop and it’s id will also be changed, we need to retrieve the desktop id again using ${__intSum(${dtid},1,dtid)}.<br />
<br />
===Specify parameter===<br />
The last 3 http requests are for adding products to the shopping cart, check out, and close the browser tab. What we need to do is just to modify their tdtid to ${__intSum(${dtid},1,dtid).<br />
<br />
[[Image:DTID.png|900px]]<br />
<br />
===Add the listeners for creating reports===<br />
There are many different elements that allows you to generate different kinds of reports, such as Aggregate Report and Graph Results. You can add these listeners to Thread Group or HTTP request depending on the report you wish to generate.<br />
<br />
[[Image:Listener1.png|400px]]<br />
<br />
Now we have completed all the settings and have saved these configurations as test.jmx.<br />
<br />
=Running the test=<br />
Now we are ready to start the application and to run the test.<br />
<ol><br />
<br />
<li><b>Generate accounts</b></li><br />
Start your web server, and access login.zul. Click <b>createUserBtn</b> for creating multiple accounts.<br />
<br />
[[Image:CreateAccounts.png|400px]]<br />
<br />
<li><b>Run the testing script</b></li><br />
<ol type="a"><br />
<li>Open jmeter’s menu, File > Open , and load test.jmx.</li><br />
<li>Specify your IP and port, for example we use localhost/8080 as ip and port number</li><br />
<br />
[[Image:Http request default.png|800px]]<br />
<br />
<li>In Thread Group ( the root element), set the number of concurrent users to test.</li><br />
<br />
[[Image:Set_number_of_Users_.png|400px]]<br />
<br />
<li>Perform Run > Start to run the test.</li><br />
<br />
You can then observe the average response time, 90% line response time, median response time and other results by accessing the Aggregate Report .<br />
<br />
[[Image:Aggregate_report.png|700px]]<br />
</ol><br />
</ol><br />
<br />
=Trouble-shooting & Tips=<br />
<ol><br />
<br />
<li><b>Tips: Performing repeating tests</b></li><br />
If you have finished a round of test (for example 0~50) you should restart your server before performing another round of test. This is because after you finish a round of test, there will be an extra item listed in each user’s page because they all ordered an item. This extra item is displayed at the bottom of the page (see the image on the right). As there is a DOM change due to this extra item, components’ IDs and orders are also changed thus different from the script you recorded earlier. To solve this problem, just restart your server before performing another round of test.<br />
<br />
[[Image:Without_order.png|400px]]<br />
[[Image:One_order.png|400px]]<br />
<br />
<li><b>Trouble-shooting: Erred response</b></li><br />
<br />
[[Image:Nothing_response.png|700px]]<br />
<br />
If you encounter the Response data error shown as the image above, it is most likely that you did not implement <b>IdGenerator</b> correctly. Please refer to [http://books.zkoss.org/wiki/Small_Talks/2011/December/Execute_a_Loading_or_Performance_Test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example#Configuring_ZK Configuring ZK section] to implement UUID.<br />
<br />
<li><b>Trouble-shooting: Timeout error</b></li><br />
<br />
[[Image:Timeout.png|700px]]<br />
<br />
Timeout errors occur when the desktop id in the Ajax request is no longer available at the server side. This normally happens when the URL is changed. If this happens, you need to retrieve desktop ID again. Please refer to [http://books.zkoss.org/wiki/Small_Talks/2011/December/Execute_a_Loading_or_Performance_Test_on_ZK_using_JMeter-take_Shopping_Cart_as_an_example#Generate_new_desktop_ID_for_redirect_to_a_new_page Testing Scripts section] to implement Desktop ID.<br />
<br />
Timeout may also relate to the max allowed desktops. In ZK there is a setting called “max-desktops-per-session” which defines the max concurrent desktops for each session. The more browser tabs an user opens the more desktops will be saved on the session. If the number exceeds the max allowed desktops then some desktops will be dropped with the timeout error.<br />
<br />
By default the number is 15 which means an user can open as many as 15 tabs in a same browser at the same time. If you have configured it to a smaller number for saving the memory, and in your use case the users will be opening up multiple tabs then you should double check whether this is the reason causing the timeout error. To change this setting, use:<br />
<br />
<source lang="xml"><br />
<session-config><br />
<max-desktops-per-session>1</max-desktops-per-session><br />
</session-config><br />
</source><br />
<br />
<li><b>Tips: close browser tab for saving memory</b></li><br />
<br />
ZK stores desktops in sessions, when user closes the browser tab ZK will send the rmDesktop command to remove the desktop.<br />
We can simulate this behavior to save memory when performing a stress test. This is done in the last http request defined in <b>test.jmx</b>. You can refer to the image below:<br />
<br />
[[Image:RmDesktop.png|850px]]<br />
</ol><br />
<br />
=Downloads=<br />
<br />
users.csv - [http://sourceforge.net/projects/zkforge/files/Small%20Talks/Performance%20Test%20on%20ZK/users.csv/download users.csv]<br />
(Please place the csv file under C:/mycsv/)<br />
<br />
zk testing demo – [http://sourceforge.net/projects/zkforge/files/Small%20Talks/Performance%20Test%20on%20ZK/shoppingcart_jmtest.war/download the modified shopping cart application used in this small talk]<br />
<br />
jmeter 2.5.1 – [http://jmeter.apache.org/download_jmeter.cgi http://jmeter.apache.org/download_jmeter.cgi]<br />
<br />
test.jmx – [http://sourceforge.net/projects/zkforge/files/Small%20Talks/Performance%20Test%20on%20ZK/test.jmx/download test.jmx]<br />
<br />
{{Template:CommentedSmalltalk_Footer_new|<br />
|name=Potix Corporation<br />
}}</div>Southerncrossie