Performance test for Hibernate Validator
The tests are written as JUnit tests. They can be developed and executed as usual in your IDE. However, they are not run as unit tests during a mvn test. Instead, to execute the performance tests Apache JMeter and the chronos-jmeter-maven-plugin is used.
To allow performance testing of different Hibernate Validator versions there are multiple profiles configured. Choosing a profile executes the tests against the specified Hibernate Validator version. The defined profiles are:
- hv-5.0 (Hibernate Validator 5.0.0-SNAPSHOT)
- hv-4.3 (Hibernate Validator 4.3.0.Final)
- hv-4.2 (Hibernate Validator 4.2.0.Final)
- hv-4.1 (Hibernate Validator 4.1.0.Final)
Executing the performance tests
Some tips before you start:
- When running the test for the first time (either via the GUI or the command line), the specified JMeter version is downloaded and extracted into the performance module.
- For JMeter to execute JUnit tests they have to be copied to <jmeter_install_dir>/lib/junit. This happens automatically when chronos-jmeter:jmetergui or chronos-jmeter:jmeter is executed. After the execution the artifacts are removed.
- You need to specify a profile!
Using the JMeter GUI
To run or configure a test via the GUI you run:
> mvn chronos-jmeter:jmetergui -P hv-5.0 &
Then open a JMeter test file from src/jmx and run the test.
Using the maven build
The following command line will run all performance tests found under src/jmx/ (*.jmx files):
> mvn clean package chronos-jmeter:jmeter -P hv-5.0
To generate a report from the test execution run:
> mvn chronos-jmeter:jmeteroutput chronos-report:report
After the completion of the report generation open:
> open target/site/performancetest.html
The pom contains an example on how you can run the tests while attaching a profiler. You will need to uncomment and adjust the property profilingOptions and make sure it is used in the chronos-report-maven-plugin configuration.
Creating reports for all major Validator versions
> for i in "hv-4.3" "hv-4.2" "hv-4.1" "hv-5.0" > do > mvn -P $i clean package chronos-jmeter:jmeter ; mvn chronos-jmeter:jmeteroutput chronos-report:report; open target/site/performancetest.html; > done
Existing tests (work in progress)
At the moment the following tests are defined
A simple bean with a random number of failing constraints gets initalized and validated. The test is once executed with a shared ValidatorFactory and once the factory is recreated on each invocation.
Simple bean with cascaded validation ...
A number of TestEntity_s is created where each entity contains a property for each built-in constraint type and also a reference to another _TestEntity. All constraints are evaluated by a single ConstraintValidator implementation which fails a specified percentage of the validations.