Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Google+ Youtube

Github Stackoverflow Pinterest

Sample Java Spring app for your abuse and amusement

Overview

This page describes the various ways to install and load test a sample application for learning and experimenting – a Java Spring application server program from SpringSource (now a division of VMWare) to explore the operation of utilities such as Jenkins and JVM tools.

See my tutorial on Spring server suite

Different versions

The canonical, most up-to-date version of the app is at
https://github.com/spring-projects/spring-petclinic

Its main contributor is paresian Antoine Rey (arey) of javaetmoi.com.

  1. Get it working:

    git clone https://github.com/spring-projects/spring-petclinic.git --depth=1
    cd spring-petclinic
    ./mvnw spring-boot:run -e
    

    BLAH: When I ran it on 2017-07-28 I got:

    [ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.2.2:revision (default) on project spring-petclinic: Could not complete Mojo execution... Unable to find commits until some tag: Walk failure. Missing commit ffa967c94b65a70ea6d3b44275632821838d9fd3 -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    

    Alternately, there are forks at
    https://github.com/spring-petclinic using Angular and
    https://github.com/spring-petclinic/spring-petclinic-microservices

    In the introduction of Spring PetClinic Spring Framework 2.5 at
    http://docs.spring.io/docs/petclinic.html
    the most recent update is 2007.

    Julian Dubois in 2013 blogged about his performance audit of the app he forked in 2013 at
    https://github.com/jdubois/spring-petclinic

    However, the 2012 repo references
    http://spring-petclinic.cloudfoundry.com which is no longer active.

    PROTIP: The version of the app you use should be of a static instance (in a your own fork) so that you have a consistent version to work and debug.

Start app

mvn clean tomcat7;run
   

Monitoring of the app

  • Network response time (Latency)
  • HTTP Requests per minute
  • Log entries per minute

  • App response time per request
  • Database response time per request

  • Thread State within app
  • Errors

  • Memory Allocation
  • Garbage Collection - time spent in GC

Online Solution http://demo.kieker-monitoring.net/

All Functionality

  1. Click FIND OWNERS.
  2. Click Find to list all.
  3. Type Betty and click find for a list pre-populated.
  4. For owner Betty Davis are pets and visits.
  5. Click Edit Owner
  6. Click Add New Pet.
  7. Click Edit Pet
  8. Click Add Visit.
  9. Select Veterinarian. Six have been pre-populated.

Artificial Load Run Types

Performance and load testing of this app is controlled by several values of “RunType” specified to impose artificial load. Keywords in quotes define the various run types.

RunType What it verifies
Landing Network variability (is network stable enough?)
MenuItems Logging verbosity
List Client Caching, Page Limits, Database Read Rates
Search -
NewData Data Variation, Database Writes
SignInOut Authentication Services (how quickly can users ramp up?)
Errors Recovery from error
All -

  1. “Landing” lands on the URL of the site.

    http://127.0.0.1/petclinic

    This page is also reached by clicking “Home”.

    jpetclinic-landing-591x361

    The PetClinic app is for a group of known vets who take care of pets owned by owners.

    Network viability

    This type of load test is run to detect network conditions (variability) between clients (load generators) and servers – measurements of response time to a single user clicking every 1-5 minutes over a 24 hour period to identify anomalies in network throughput and other disturbances. The expectation is consistent quick response.

    Are there spikes in response time? If so, it is probably due to network or some infrastructure conditions, since the app’s database is not involved.

    Since this is the first test run, issues with the load testing rig is exposed, such as the load test server being reset every day.

    The emulation script needs to detect and handle “Server unavailable” conditions.

  2. “MenuItems” browse through menu items without login or other activity that typically stresses the front-end web server rather than back-end database traffic.

    The PetClinic app has a limited menu, with the top menu bar remaining visible in all screens throughout the app.

    1. Click FIND OWNERS.
    2. Click VETERINARIAN.
    3. Click Errors.
    4. Click Home.

    The above actions are repeated over and over by each virtual user.

    Some automation scripts vary the frequency each specific item is invoked. Some emulation scripts use a data-driven approach where a file external to the code specifies the pattern of invocation.

    Rather than coding to click specific items, this activity may be specified by a control file which the test program reads to determine how to iterate through items.

    These runs identify issues with front-end caching.

    Logging verbosity

    This is the first opportunity to manage logging functionality and thus disk space growth, archival off the server, etc.

    Different logging levels are needed for different modes of running. Diagnostic runs use “debug” level for more verbose output. Productive runs use “error” level such that only errors are output.

    favicon.ico

  3. “List” lists all owners in the database to assess data retrieval.

    This is run to identify the maximum rate the system can accommodate additions to the database.

    The sequence of user actions in the PetClinic:

    1. Click Owners.
    2. Click Find button without entering anything in the search field.

    SpringSourceList

    Client Caching

    Client software (browsers such as Chrome) typically cache (store) files downloaded from the server and reuse them to avoid unnecessary retrievals.

    This may need to be varied artifically to induce additional load.

    Page limits

    Some UI optimize queries by retrieving only the maximum items displayed on each page. This reduces retrieval time, but would require additional calls activity and thus load on the system.

    Some apps provide a way for users to control how many items to display on a page.

    Some apps (call “Single Page Apps”), automatically retrieve additional pages (“pre-fetches”) the next set of data automatically without waiting for user input, which would inpose additonal load but provide user convenience.

    Alas, the PetClinic app does not provide user preferences in its UI.

    Database read rate

    This run type is the first stressing of reading data from the database.

    Measuring the time taken for individual database activities is useful to differentiate time incurred by different configurations of the database or use of different databases.

    This activity is used by “Transaction Tracing” utilities by programs such as Dynatrace and CA-APM.

  4. “Search” generates database calls if client software does not check its cache before performing a search.

    Examples are form fields that return an autocomplete list.

    The sequence of user actions in the PetClinic:

    1. Click FIND OWNERS in the top menu.
    2. Type in the search box a last name such as “Davis”.
    3. Click Find button without entering anything in the search field.

    The emulation script needs to identify and resolve errors such as “item not found”.

    Note that the PetClinic UI does not search by the first name of owners.

    The emulation script needs to handle error responses.

  5. “NewData” is done to identify the maximum rate the system can accommodate additions to the database.

    The sequence of user actions in the PetClinic:

    1. Click FIND OWNERS in the top menu.
    2. Click Edit Owner
    3. Click Add New Pet.
    4. Click Edit Pet
    5. Click Add Visit.

    The emulation scripts needs to recognize and handle error conditions such as invalid data, duplicate add attempts, etc.

    NOTE: The PetClinic app does not provide a UI to add Veterinarians. But the UI does provide a link to expose a file the app uses internally to populate the Veternarian screen. Such a link is not usually exposed in app end-user UIs.

    Data Variation

    Variations in registration data from a file is needed to load various users.

    Database writes

    This is the first stressing of writing of new data into the database.

    Measuring the time taken for individual database activities is useful to differentiate time incurred by different databases.

  6. SignInOut is not possible with the PetClinic.

    This identifies the maximum rate of users arriving at the same time (such as at a call center during start of shift).

    A load test of this measures how much memory servers take for each new user. If the app establishes a connection to the database for each user, memory use will increase for each additional user.

    Does memory get recovered from users who have logged off?

  7. External Process items are not possible with the PetClinic.

    In an e-commerce app such as the PetStore app, this would be purchase of pets in the cart and use of payment gateways, which is usually an external service. The JPetStore sample app does not connect with a payment gateway.

    The question answered by a load test of this type is:
    Can the app and external services keep up with a lot of people buying at once? What does “a lot” mean is the measurement.

  8. “All” means “all the above”, done to ensure that the system can handle a pattern of stress during scalability testing.

  9. “Errors” type runs purposely invokes the system’s response to “negative” tests:

    a. Server unavailable.

    b. Item not found during browsing.

    c. Registration error (such as bad email, user already defined, etc.).

    d. Login error, such as forgotten password change.

    e. Search not found.

    etc.

Reset data

QUESTION: How to reset the Orders data for a user?

This is often handled by Jenkins before each run to ensure the same starting conditions exist for each separate run.

Tuning

Back on 3 July 2014 Julien recorded a presentation (at SpringOne2GX in Santa Clara, CA) on tuning the Spring Petclinic sample application using JMeter.

Internals

Spring-Petclinic is a “classic” MVC-style application, with no REST API nor JavaScript front-end libraries such as Bootstrap.

Michael Isvy on March 20, 2013 presented diagrams and code samples describing the Spring MVC and Dandelion and WebJars used by the sample app.

petclinic-arch-650x493-85k

  • WebJars by https://twitter.com/_JamesWard

  • http://dandelion.github.io/blog/2013/04/24/Integrating-Dandelion-DataTables-in-the-Spring-Petclinic-app based on jQuery Datatables and Bootstrap

Aspect-oriented programming (AOP) is an approach to programming that allows global properties of a program to determine how it is compiled into an executable program. AOP can be used with object-oriented programming (“OOP”).

An aspect is a subprogram that is associated with a specific property of a program. As that property varies, the effect “ripples” through the entire program. The aspect subprogram is used as part of a new kind of compiler called an “aspect weaver”.

The conceptualizers of AOP compare aspect programming to the manufacturing of cloth in which threads are automatically interwoven. Without AOP, programmers must stitch the threads by hand.

Use case loops

https://graphwalker.github.io/petclinic uses the
yEd graph editor
and GraphStream to visualize tests as they run.

Options for performance testing apps

Because the PetClinic app was built for developers, missing are some features in the app for use as a sample app for performance testing.


More on IoT

This is one of a series on IoT:

  1. IoT Acronymns and Abbreviations

  2. IoT Apprentice school curriculum
  3. IoT use cases
  4. IoT reminders prevent dead mobile battery
  5. IoT ceiling dumper

  6. IoT text to speech synthesis
  7. IoT AWS button
  8. Intel IoT
  9. IoT Raspberry hardware
  10. IoT Raspberry installation

  11. IoT Clouds
  12. Samsung IoT Cloud

  13. Predix basics
  14. Predix installation
  15. Predix services
  16. Predix programming