Apache JMeter is a widely used testing tool preferred by testers due to its support for multiple protocols and extensibility. JMeter script needs to be authored in the JMeter GUI, which means that developers must switch from their IDE. Developers might prefer authoring tests in their preferred programming language, using their developer IDE. The XML format of the script makes it difficult to make modifications quickly.
Abstracta has developed JMeter DSL, a developer-friendly way of creating JMeter test plans. JMeter DSL, or "jmeter-java-dsl," is a domain-specific language (DSL) for creating JMeter test plans programmatically using Java code. JMeter DSL provides a high-level API that simplifies the process of creating JMeter elements such as thread groups, samplers, and listeners. It also supports advanced features such as variable substitution, loops, and conditionals, allowing for more complex scenarios to be tested. By using JMeter DSL, developers can write concise and readable code that is easier for developers to maintain and update than XML-based test plans.
One of the benefits of using JMeter DSL is that it seamlessly with popular IDEs like Visual Studio Code, providing code completion, syntax highlighting, and other helpful features. This makes it easier for developers to write and debug JMeter test plans without having to switch between different tools and environments.
Abstracta has developed JMeter DSL for Azure Load Testing, which enables seamlessly running tests written in Java code on Azure Load Testing. Azure Load Testing is a managed service which enables running JMeter test at scale and provides insights and recommendations to fix performance bottlenecks.
You can get started with JMeter DSL from your development environment by following the steps mentioned here. With the new Azure Load Testing integration, you can easily run a JMeter test at scale in Azure Load Testing and get deep actionable insights for your test run. We’ll look at the steps on how to achieve it.
<dependency>
<groupId>us.abstracta.jmeter</groupId>
<artifactId>jmeter-java-dsl-azure</artifactId>
<version>1.10-SNAPSHOT</version>
<scope>test</scope>
</dependency>
public void testPerformance() throws Exception {
TestPlanStats stats = testPlan(
threadGroup(100, 100,
httpSampler("https://my.service")
)
).runIn(new AzureEngine((System.getenv("AZURE_CREDS"))
.location("eastus")
.subscriptionId("")
.resourceGroupName("cool-test-rg")
.testResourceName("cool-test")
.testName("jmeter-java-dsl")
.engines(20)
.testTimeout(Duration.ofMinutes(2)));
assertThat(stats.overall().samplesCount()).isGreaterThanOrEqualTo(1);
}
The code snippet above generates 100 threads (representing concurrent users) that send 100 HTTP GET requests each to http://my.service. The Azure engine requires input parameters such as location, subscription ID, resource group name, and test resource name. If the specified resource already exists, the test is created within that resource. If the resource does not exist, a new resource is created. The number of engines can be specified to determine the load generation. In this case, 20 engines are used, resulting in a total of 2,000 users (20 engines * 100 concurrent users) sending 100 requests each to the provided endpoint.
Azure Load Testing enables you to run load tests at scale with real-time reporting of client-side and server-side metrics. You can identify the performance bottlenecks for your application and correlate the same with the load on a single dashboard.
Overall, JMeter DSL provides a powerful and flexible way to create and manage JMeter test plans that is well-suited for modern software development practices such as continuous integration and delivery. By using JMeter DSL, developers can achieve a higher level of automation and efficiency in their testing processes, without sacrificing the flexibility and power of JMeter.
What else are you waiting for? Try it out and let us know if you were able to test your system using JMeter DSL with Azure Load Testing. If you have any feedback, please share it here for JMeter DSL and Azure Load Testing.
Happy Load Testing!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.