Advertisement
Guest User

xsl ant jmeter

a guest
Apr 30th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 12.78 KB | None | 0 0
  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  2. <xsl:output method="html" indent="yes" encoding="US-ASCII" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
  3.  
  4. <!-- Defined parameters (overrideable) -->
  5. <xsl:param    name="showData" select="'N'"/>
  6.  
  7. <xsl:template match="testResults">
  8.     <html>
  9.         <head>
  10.             <title>Load Test Results</title>
  11.             <style type="text/css">
  12.                 body {
  13.                     font:normal 68% verdana,arial,helvetica;
  14.                     color:#000000;
  15.                 }
  16.                 table tr td, table tr th {
  17.                     font-size: 68%;
  18.                 }
  19.                 table.details tr th{
  20.                     font-weight: bold;
  21.                     text-align:left;
  22.                     background:#a6caf0;
  23.                     white-space: nowrap;
  24.                 }
  25.                 table.details tr td{
  26.                     background:#eeeee0;
  27.                     white-space: nowrap;
  28.                 }
  29.                 h1 {
  30.                     margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
  31.                 }
  32.                 h2 {
  33.                     margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
  34.                 }
  35.                 h3 {
  36.                     margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
  37.                 }
  38.                 .Failure {
  39.                     font-weight:bold; color:red;
  40.                 }
  41.                
  42.    
  43.                 img
  44.                 {
  45.                   border-width: 0px;
  46.                 }
  47.                
  48.                 .expand_link
  49.                 {
  50.                    position=absolute;
  51.                    right: 0px;
  52.                    width: 27px;
  53.                    top: 1px;
  54.                    height: 27px;
  55.                 }
  56.                
  57.                 .page_details
  58.                 {
  59.                    display: none;
  60.                 }
  61.                                
  62.                                 .page_details_expanded
  63.                                 {
  64.                                     display: block;
  65.                                     display/* hide this definition from  IE5/6 */: table-row;
  66.                                 }
  67.  
  68.  
  69.             </style>
  70.             <script language="JavaScript"><![CDATA[
  71.                           function expand(details_id)
  72.                {
  73.                  
  74.                   document.getElementById(details_id).className = "page_details_expanded";
  75.                }
  76.                
  77.                function collapse(details_id)
  78.                {
  79.                  
  80.                   document.getElementById(details_id).className = "page_details";
  81.                }
  82.                
  83.                function change(details_id)
  84.                {
  85.                   if(document.getElementById(details_id+"_image").src.match("expand"))
  86.                   {
  87.                      document.getElementById(details_id+"_image").src = "collapse.jpg";
  88.                      expand(details_id);
  89.                   }
  90.                   else
  91.                   {
  92.                      document.getElementById(details_id+"_image").src = "expand.jpg";
  93.                      collapse(details_id);
  94.                   }
  95.                           }
  96.             ]]></script>
  97.         </head>
  98.         <body>
  99.        
  100.             <xsl:call-template name="pageHeader" />
  101.            
  102.             <xsl:call-template name="testOptions" />
  103.            
  104.             <xsl:call-template name="summary" />
  105.             <hr size="1" width="95%" align="left" />
  106.            
  107.             <xsl:call-template name="pagelist" />
  108.             <hr size="1" width="95%" align="left" />
  109.            
  110.             <xsl:call-template name="detail" />
  111.  
  112.         </body>
  113.     </html>
  114. </xsl:template>
  115.  
  116. <xsl:template name="pageHeader">
  117.     <h1>Load Test Results</h1>
  118.     <table width="100%">
  119.         <tr>
  120.             <td align="left"></td>
  121.             <td align="right">Designed for use with <a href="http://jakarta.apache.org/jmeter">JMeter</a> and <a href="http://ant.apache.org">Ant</a>.</td>
  122.         </tr>
  123.     </table>
  124.     <hr size="1" />
  125. </xsl:template>
  126.    
  127. <xsl:template name="testOptions">
  128.     <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
  129.         <tr valign="top">
  130.             <th align="left">userType</th>
  131.             <th align="left">numberOfThreads</th>
  132.         </tr>
  133.         <tr>
  134.             <td>customer</td>
  135.             <td>2</td>
  136.         </tr>
  137.         <tr>
  138.             <td>admin</td>
  139.             <td>5</td>
  140.         </tr>
  141.     </table>
  142.     <hr size="1" />
  143. </xsl:template>
  144.  
  145. <xsl:template name="summary">
  146.     <h2>Summary</h2>
  147.     <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
  148.         <tr valign="top">
  149.             <th>Tests</th>
  150.             <th>Failures</th>
  151.             <th>Success Rate</th>
  152.             <th>Average Time</th>
  153.             <th>Min Time</th>
  154.             <th>Max Time</th>
  155.         </tr>
  156.         <tr valign="top">
  157.             <xsl:variable name="allCount" select="count(/testResults/sampleResult)" />
  158.             <xsl:variable name="allFailureCount" select="count(/testResults/sampleResult[attribute::success='false'])" />
  159.             <xsl:variable name="allSuccessCount" select="count(/testResults/sampleResult[attribute::success='true'])" />
  160.             <xsl:variable name="allSuccessPercent" select="$allSuccessCount div $allCount" />
  161.             <xsl:variable name="allTotalTime" select="sum(/testResults/sampleResult/@time)" />
  162.             <xsl:variable name="allAverageTime" select="$allTotalTime div $allCount" />
  163.             <xsl:variable name="allMinTime">
  164.                 <xsl:call-template name="min">
  165.                     <xsl:with-param name="nodes" select="/testResults/sampleResult/@time" />
  166.                 </xsl:call-template>
  167.             </xsl:variable>
  168.             <xsl:variable name="allMaxTime">
  169.                 <xsl:call-template name="max">
  170.                     <xsl:with-param name="nodes" select="/testResults/sampleResult/@time" />
  171.                 </xsl:call-template>
  172.             </xsl:variable>
  173.             <xsl:attribute name="class">
  174.                 <xsl:choose>
  175.                     <xsl:when test="$allFailureCount &gt; 0">Failure</xsl:when>
  176.                 </xsl:choose>
  177.             </xsl:attribute>
  178.             <td>
  179.                 <xsl:value-of select="$allCount" />
  180.             </td>
  181.             <td>
  182.                 <xsl:value-of select="$allFailureCount" />
  183.             </td>
  184.             <td>
  185.                 <xsl:call-template name="display-percent">
  186.                     <xsl:with-param name="value" select="$allSuccessPercent" />
  187.                 </xsl:call-template>
  188.             </td>
  189.             <td>
  190.                 <xsl:call-template name="display-time">
  191.                     <xsl:with-param name="value" select="$allAverageTime" />
  192.                 </xsl:call-template>
  193.             </td>
  194.             <td>
  195.                 <xsl:call-template name="display-time">
  196.                     <xsl:with-param name="value" select="$allMinTime" />
  197.                 </xsl:call-template>
  198.             </td>
  199.             <td>
  200.                 <xsl:call-template name="display-time">
  201.                     <xsl:with-param name="value" select="$allMaxTime" />
  202.                 </xsl:call-template>
  203.             </td>
  204.         </tr>
  205.     </table>
  206. </xsl:template>
  207.  
  208. <xsl:template name="pagelist">
  209.     <h2>Pages</h2>
  210.     <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
  211.         <tr valign="top">
  212.             <th>URL</th>
  213.             <th>Tests</th>
  214.             <th>Failures</th>
  215.             <th>Success Rate</th>
  216.             <th>Average Time</th>
  217.             <th>Min Time</th>
  218.             <th>Max Time</th>
  219.             <th></th>
  220.         </tr>
  221.         <xsl:for-each select="/testResults/sampleResult[not(@label = preceding::*/@label)]">
  222.             <xsl:variable name="label" select="@label" />
  223.             <xsl:variable name="count" select="count(../sampleResult[@label = current()/@label])" />
  224.             <xsl:variable name="failureCount" select="count(../sampleResult[@label = current()/@label][attribute::success='false'])" />
  225.             <xsl:variable name="successCount" select="count(../sampleResult[@label = current()/@label][attribute::success='true'])" />
  226.             <xsl:variable name="successPercent" select="$successCount div $count" />
  227.             <xsl:variable name="totalTime" select="sum(../sampleResult[@label = current()/@label]/@time)" />
  228.             <xsl:variable name="averageTime" select="$totalTime div $count" />
  229.             <xsl:variable name="minTime">
  230.                 <xsl:call-template name="min">
  231.                     <xsl:with-param name="nodes" select="../sampleResult[@label = current()/@label]/@time" />
  232.                 </xsl:call-template>
  233.             </xsl:variable>
  234.             <xsl:variable name="maxTime">
  235.                 <xsl:call-template name="max">
  236.                     <xsl:with-param name="nodes" select="../sampleResult[@label = current()/@label]/@time" />
  237.                 </xsl:call-template>
  238.             </xsl:variable>
  239.             <tr valign="top">
  240.                 <xsl:attribute name="class">
  241.                     <xsl:choose>
  242.                         <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
  243.                     </xsl:choose>
  244.                 </xsl:attribute>
  245.                 <td>
  246.                 <xsl:if test="$failureCount > 0">
  247.                   <a><xsl:attribute name="href">#<xsl:value-of select="$label" /></xsl:attribute>
  248.                   <xsl:value-of select="$label" />
  249.                   </a>
  250.                 </xsl:if>
  251.                 <xsl:if test="0 >= $failureCount">
  252.                   <xsl:value-of select="$label" />
  253.                 </xsl:if>
  254.                 </td>
  255.                 <td>
  256.                     <xsl:value-of select="$count" />
  257.                 </td>
  258.                 <td>
  259.                     <xsl:value-of select="$failureCount" />
  260.                 </td>
  261.                 <td>
  262.                     <xsl:call-template name="display-percent">
  263.                         <xsl:with-param name="value" select="$successPercent" />
  264.                     </xsl:call-template>
  265.                 </td>
  266.                 <td>
  267.                     <xsl:call-template name="display-time">
  268.                         <xsl:with-param name="value" select="$averageTime" />
  269.                     </xsl:call-template>
  270.                 </td>
  271.                 <td>
  272.                     <xsl:call-template name="display-time">
  273.                         <xsl:with-param name="value" select="$minTime" />
  274.                     </xsl:call-template>
  275.                 </td>
  276.                 <td>
  277.                     <xsl:call-template name="display-time">
  278.                         <xsl:with-param name="value" select="$maxTime" />
  279.                     </xsl:call-template>
  280.                 </td>
  281.                 <td align="center">
  282.                    <a href="">
  283.                       <xsl:attribute name="href"><xsl:text/>javascript:change('page_details_<xsl:value-of select="position()" />')</xsl:attribute>
  284.                       <img src="expand.jpg" alt="expand/collapse"><xsl:attribute name="id"><xsl:text/>page_details_<xsl:value-of select="position()" />_image</xsl:attribute></img>                  
  285.                    </a>
  286.                 </td>
  287.             </tr>
  288.            
  289.                         <tr class="page_details">
  290.                            <xsl:attribute name="id"><xsl:text/>page_details_<xsl:value-of select="position()" /></xsl:attribute>
  291.                            <td colspan="8" bgcolor="#FF0000">
  292.                               <div align="center">
  293.                      <b>Details for Page "<xsl:value-of select="$label" />"</b>
  294.                      <table bordercolor="#000000" border="1"  cellpadding="0" cellspacing="0" width="95%">
  295.                      <tr>
  296.                         <th>Thread</th>
  297.                         <th>Iteration</th>
  298.                         <th>Time</th>
  299.                         <th>Success</th>
  300.                         <!--
  301.                         itterations = position() - thread stuff
  302.                         time="312"
  303.                         timeStamp="1053622047640"
  304.                         responseMessage="OK"
  305.                         threadName="Thread Group-1"
  306.                         dataType="text"
  307.                         label="/CansysAandA/processAuthentication.do"
  308.                         success="true"
  309.                         -->
  310.                      </tr>
  311.                                      
  312.                      <xsl:for-each select="../sampleResult[@label = $label and @threadName != $label]">                                        
  313.                         <tr>
  314.                            <td><xsl:value-of select="@threadName" /></td>
  315.                            <td><xsl:value-of select="position()" /></td>
  316.                            <td><xsl:value-of select="@time" />ms</td>
  317.                            <td><xsl:value-of select="@success" /></td>
  318.                         </tr>
  319.                      </xsl:for-each>
  320.                      
  321.                      </table>
  322.                   </div>
  323.                            </td>
  324.                         </tr>
  325.            
  326.         </xsl:for-each>
  327.     </table>
  328. </xsl:template>
  329.  
  330. <xsl:template name="detail">
  331.     <xsl:variable name="allFailureCount" select="count(/testResults/sampleResult[attribute::success='false'])" />
  332.  
  333.     <xsl:if test="$allFailureCount > 0">
  334.         <h2>Failure Detail</h2>
  335.  
  336.         <xsl:for-each select="/testResults/sampleResult[not(@label = preceding::*/@label)]">
  337.  
  338.             <xsl:variable name="failureCount" select="count(../sampleResult[@label = current()/@label][attribute::success='false'])" />
  339.  
  340.             <xsl:if test="$failureCount > 0">
  341.                 <h3><xsl:value-of select="@label" /><a><xsl:attribute name="name"><xsl:value-of select="@label" /></xsl:attribute></a></h3>
  342.  
  343.                 <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
  344.                 <tr valign="top">
  345.                     <th>Response</th>
  346.                     <th>Failure Message</th>
  347.                     <xsl:if test="$showData = 'y'">
  348.                        <th>Response Data</th>
  349.                     </xsl:if>
  350.                 </tr>
  351.            
  352.                 <xsl:for-each select="/testResults/sampleResult[@label = current()/@label][attribute::success='false']">
  353.                     <tr>
  354.                         <td><xsl:value-of select="@responseCode" /> - <xsl:value-of select="@responseMessage" /></td>
  355.                         <td><xsl:value-of select="assertionResult/@failureMessage" /></td>
  356.                         <xsl:if test="$showData = 'y'">
  357.                             <td><xsl:value-of select="./binary" /></td>
  358.                         </xsl:if>
  359.                     </tr>
  360.                 </xsl:for-each>
  361.                
  362.                 </table>
  363.             </xsl:if>
  364.  
  365.         </xsl:for-each>
  366.     </xsl:if>
  367. </xsl:template>
  368.  
  369. <xsl:template name="min">
  370.     <xsl:param name="nodes" select="/.." />
  371.     <xsl:choose>
  372.         <xsl:when test="not($nodes)">NaN</xsl:when>
  373.         <xsl:otherwise>
  374.             <xsl:for-each select="$nodes">
  375.                 <xsl:sort data-type="number" />
  376.                 <xsl:if test="position() = 1">
  377.                     <xsl:value-of select="number(.)" />
  378.                 </xsl:if>
  379.             </xsl:for-each>
  380.         </xsl:otherwise>
  381.     </xsl:choose>
  382. </xsl:template>
  383.  
  384. <xsl:template name="max">
  385.     <xsl:param name="nodes" select="/.." />
  386.     <xsl:choose>
  387.         <xsl:when test="not($nodes)">NaN</xsl:when>
  388.         <xsl:otherwise>
  389.             <xsl:for-each select="$nodes">
  390.                 <xsl:sort data-type="number" order="descending" />
  391.                 <xsl:if test="position() = 1">
  392.                     <xsl:value-of select="number(.)" />
  393.                 </xsl:if>
  394.             </xsl:for-each>
  395.         </xsl:otherwise>
  396.     </xsl:choose>
  397. </xsl:template>
  398.  
  399. <xsl:template name="display-percent">
  400.     <xsl:param name="value" />
  401.     <xsl:value-of select="format-number($value,'0.00%')" />
  402. </xsl:template>
  403.  
  404. <xsl:template name="display-time">
  405.     <xsl:param name="value" />
  406.     <xsl:value-of select="format-number($value,'0 ms')" />
  407. </xsl:template>
  408.    
  409. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement