Personal notes on software development.
For Java technologies check my dedicated site

Pages

Load Testing and Stress Testing

Is the process of putting demand on a system or device and measuring its response. Load testing is performed to determine a system’s behavior under both normal and anticipated peak load conditions. It helps to identify the maximum operating capacity of an application as well as any bottlenecks and determine which element is causing degradation. When the load placed on the system is raised beyond normal usage patterns, in order to test the system's response at unusually high or peak loads, it is known as stress testing.

Tools:

Unit Tests

  • JUnit

Official site/manual: Apache JMeter site
Installation: Note: if you use NetBeans you can install JMeter by going to Tools -> Plugins -> Searcg for "JMeter" plug in.
Tutorial: "The NetBeans E-commerce Tutorial - Testing and Profiling" demonstrates JMeter usage.

Keep in mind that when running JMeter in the same machine (Client and Server), your local server is competing with JMeter for the computer's resources. Eventually, you'll want to test your production server remotely to get more accurate results. See the following resources for more information:



Configuration Variables

  • ramp-up period: tells JMeter how long to take to "ramp-up" to the full number of threads chosen. If 10 threads are used, and the ramp-up period is 100 seconds, then JMeter will take 100 seconds to get all 10 threads up and running. Each thread will start 10 (100/10) seconds after the previous thread was begun.
    Ramp-up needs to be long enough to avoid too large a work-load at the start of a test, and short enough that the last threads start running before the first ones finish (unless one wants that to happen). 
  • interleave:  " is used in the user delay Test Action that we created, and represents the duration of a pause in milliseconds. Therefore, the test will pause for 5 seconds between each user-initiated request."[1]

Results/Graphs

In JMeter, you require a listener to record and display the results of your test plan. Most of the listeners perform several roles in addition to "listening" to the test results. They also provide means to view, save, and read saved test results. There are multiple listener types, for example:
  • The Summary Report displays a table, with each row corresponding to each differently named request in your test;
  • The View Results Tree shows a tree of all sample responses, allowing you to view response details for any sample. 
  • The Graph Results listener displays a simple graph that plots all sample times. The graph includes:
    • The throughput number: represents the actual number of requests/minute the server handled. This calculation includes any delays you added to your test and JMeter's own internal processing time
NOTE: This listeners consume system resources and therefore JMeter can run out of memory and crash. So, when stress testing, keep the number of listeners to a minimum (remove the unnecessary ones from the test).

    Troubleshooting:

    • "When testing for 500 users, JMeter became unresponsive and it was necessary to shut it down from the task manager. It is likely that JMeter was running out of memory to record and display results for the Graph Results and View Results Tree listeners. These two listeners were removed from the test plan, and results for 500 - 1000 users were then recorded using the Summary Report listener only."[1]

    References

    [1] - The NetBeans E-commerce Tutorial - Testing and Profiling

    • Non incremental cell reference
      Imagine you have a constant in cell A1 and want to reference this cell in a table and automaticly expand the formula to adjacent cells. By default the A1 cell will be iterated but you can fix it using the dollar sign ($), formula example:
      =$A$1 * B1
      you can also use the $ to fix the Columns and Lines independently (ie.: $A1 or A$1)

    Documentation

    Download a project with the plugin incorporated to test it jQuery test project (download).


    Internationalization notes

    This info was found here.
    The plugin has localization, just add/import your language file in the <head> tag and all error messages will be displayed in that language.
    <script type="text/javascript" src="lib/jquery-validate/jquery.validate.js"></script>
    <script type="text/javascript" src="lib/jquery-validate/localization/messages_pt.js"></script>

    where "messages_pt.js" contains translations of the original english messages of "jquery.validate.js":
    /*
     * Translated default messages for the jQuery validation plugin.
     * Language: PT
     */
    jQuery.extend(jQuery.validator.messages, {
    
        required: "Campo obrigatório",
        remote: "Corrigir campo",
        email: "Endereço inválido",
        url: "URL inválido",
        date: "Data inválida",
        dateISO: "Data inválida (ISO).",
        number: "Número inválido",
        digits: "Apenas dígitos",
        creditcard: "Número de cartão inválido",
        equalTo: "Reintroduza o mesmo valor",
        accept: "Please enter a value with a valid extension.",
        maxlength: $.validator.format("Limite max. de caracteres: {0}"),
        minlength: $.validator.format("Introduza pelo menos {0} caracteres"),
        rangelength: $.validator.format("O número de caracteres deverá estar compreendido entre {0} e {1}"),
        range: $.validator.format("Introduza valor entre {0} e {1}"),
        max: $.validator.format("Valor deverá ser inferior ou igual a {0}."),
        min: $.validator.format("Valor deverá ser superior ou igual a {0}.")
    });
    So if your app has a language toggle option you can import the respective language file using server side script.

    jQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML. It was released in January 2006. Used by over 52% of the 10,000 most visited websites, jQuery is the most popular JavaScript library in use today.

    Plugins: There are multiple plugins to use side by side with jQuery core libraries (like the validation plugin that aids you on validating web forms).

    Tutorials and references

    Validation plugin

    IDE