This is a demo project that contains a Selenium test for Retail Store demo app and generates and run performance tests using JMeter DSL.
- Docker + Docker compose
- Maven 3.5+
- Java 19+
Path | Description |
---|---|
retailstore-test | Selenium Test project |
retailstore-test/docker-compose.yml | Provisioning of Retail Store demo app |
RetailStoreTest | Selenium Test for Retail Store app |
.env | Configuration file for Selenium Test |
selenium-jmeter-dsl | Module contains main logic for recording and executing performance test. Including integration with Jmeter DSL |
JmeterDslSeleniumRecorder | JUnit extension which generates JMeter DSL test plan from a Selenium Test. |
docker-compose.yml | Provisioning for Grafana & InfluxDB |
To start Retail Store demo app, go to retailstore-test folder and run:
docker-compose up
Set local hosts file so retailstore.test
points to localhost:
echo '127.0.0.1 retailstore.test' >> /private/etc/hosts
You can run RetailStoreTest either using an IDE or using:
mvn clean test
To see the actual flow running you can remove "--headless=new"
chrome option and set THINK_TIME_MILLIS
to a value like 1000 in .env file.
Remember resetting THINK_TIME_MILLIS
to 0, and re-adding "--headless=new"
chrome option before running performance test.
-
Add
selenium-jmeter-dsl
dependency to retailstore-test/pom.xml:<dependency> <groupId>us.abstracta</groupId> <artifactId>selenium-jmeter-dsl</artifactId> <version>${project.version}</version> </dependency>
-
Register JmeterDslSeleniumRecorder JUnit extension in RetailStoreTest.
@RegisterExtension public final JmeterDslSeleniumRecorder recorder = new JmeterDslSeleniumRecorder() .basePageObject(BasePage.class);
-
Add
JmeterDslSeleniumRecorder
as proxy in WebDriver options.options.setProxy(recorder.getProxy());
-
Run
RetailStoreTest
& review generatedPerformanceTest.java
. -
Add InfluxDB listener config to
.env
:INFLUX_URI=http://localhost:8086 INFLUX_ORG=abstracta INFLUX_BUCKET=selenium INFLUX_TOKEN=token
-
Add correlation rule to
JmeterDslSeleniumRecorder
. For fixed values in test plan,productId
for instance, look intotarget/recordings
generated XML files for responses containing the ID and define extraction and replacement regexes.@RegisterExtension private final JmeterDslSeleniumRecorder recorder = new JmeterDslSeleniumRecorder() .correlationRule("productId", "name=\"productId\" value=\"([^\"]+)\"", "productId=(.*)") .basePageObject(BasePage.class);
-
Re-run
RetailStoreTest
and reviewPerformanceTest.java
. -
Run
PerformanceTest
test method and review calls (replacing just for this runinfluxDbListener
withresultsTreeVisualizer
, and then restoringinfluxDbListener
). -
Tune thread group configuration in
PerformanceTest.java
threadGroup() .rampToAndHold(10, Duration.ZERO, Duration.ofMinutes(1)) .rampToAndHold(20, Duration.ZERO, Duration.ofMinutes(1)) .rampToAndHold(50, Duration.ZERO, Duration.ofMinutes(3)) .children(...)
-
Remove JUnit extension & proxy from
RetailStoreTest.java
. -
Start InfluxDB & Grafana running at root location of this project:
docker-compose up
-
Start
PerformanceTest
main method. -
Review results in Grafana at
http://localhost:3000
withadmin
&1234
.