Wilson Mar bio photo

Wilson Mar

Hello!

Calendar YouTube Github

LinkedIn

Sample Java Spring app for your abuse and amusement

US (English)   Norsk (Norwegian)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Estonian   اَلْعَرَبِيَّةُ (Egypt Arabic)   Napali   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

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

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.

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.

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

  1. Get it downloaded and installed:

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

    --depth=1 cannot be specified with git clone because different branches are used.

    A whole lot of message should flow by until the last message like this:

               |\      _,,,--,,_
              /,`.-'`'   ._  \-;;,_
      _______ __|,4-  ) )_   .;.(__`'-'__     ___ __    _ ___ _______
     |       | '---''(_/._)-'(_\_)   |   |   |   |  |  | |   |       |
     |    _  |    ___|_     _|       |   |   |   |   |_| |   |       | __ _ _
     |   |_| |   |___  |   | |       |   |   |   |       |   |       | \ \ \ \
     |    ___|    ___| |   | |      _|   |___|   |  _    |   |      _|  \ \ \ \
     |   |   |   |___  |   | |     |_|       |   | | |   |   |     |_    ) ) ) )
     |___|   |_______| |___| |_______|_______|___|_|  |__|___|_______|  / / / /
     ==================================================================/_/_/_/
     
    :: Built with Spring Boot :: 2.1.6.RELEASE
     
    INFO 16859 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
    INFO 16859 --- [  restartedMain] o.s.s.petclinic.PetClinicApplication     : Started PetClinicApplication in 7.809 seconds (JVM running for 8.257)
    

  2. Switch to a Chrome browser to see the “Landing” page:

    http://localhost:8080
    

    spring-jpetstore-776x482-11626

    A version previous to 2.1.6.RELEASE looked like this:

    jpetclinic-landing-591x361

    “Home” highlighted among tabs means this page is also reached by clicking “Home”.

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

    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.

    JMeter test file?

  3. Click “Error”.

     [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: Expected: controller used to showcase what happens when an exception is thrown] with root cause
     
    java.lang.RuntimeException: Expected: controller used to showcase what happens when an exception is thrown
     at org.springframework.samples.petclinic.system.CrashController.triggerException(CrashController.java:33) ~[classes/:na]
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
    
  4. Stop the app by pressing control+C.

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 -

### 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.

  1. “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

  2. “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.

  3. “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.

  4. “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.

  5. 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?

  6. 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.

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

  8. “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 on Quizlet

  2. IoT Home Assistant system

  3. IoT Apprentice school curriculum
  4. IoT use cases
  5. IoT reminders prevent dead mobile battery
  6. IoT barn feeder

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

  12. IoT Clouds
  13. Samsung IoT Cloud

NOTE: Pages about GE’s Predix have been removed.