Giter Site home page Giter Site logo

vinipx / jmeter-java-dsl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abstracta/jmeter-java-dsl

0.0 0.0 0.0 3.85 MB

Simple JMeter performance tests API

Home Page: https://abstracta.github.io/jmeter-java-dsl/

License: Apache License 2.0

Java 99.97% PLpgSQL 0.03%

jmeter-java-dsl's Introduction

logo

Maven Central Reproducible Builds

Simple Java API to run performance tests, using JMeter as engine, in a Git and programmers friendly way.

If you like this project, please give it a star ⭐! This helps the project be more visible, gain relevance, and encourage us to invest more effort in new features.

Please join discord server or create GitHub issues and discussions to be part of the community and clear out doubts, get the latest news, propose ideas, report issues, etc.

Usage

If you use maven, just include the following dependency:

<dependency>
  <groupId>us.abstracta.jmeter</groupId>
  <artifactId>jmeter-java-dsl</artifactId>
  <version>1.3</version>
  <scope>test</scope>
</dependency>

Here is a simple example test in JUnit 5+ with 2 threads/users iterating 10 times each to send HTTP POST requests with a JSON body to http://my.service:

import static org.assertj.core.api.Assertions.assertThat;
import static us.abstracta.jmeter.javadsl.JmeterDsl.*;

import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import org.apache.http.entity.ContentType;
import org.junit.jupiter.api.Test;
import us.abstracta.jmeter.javadsl.core.TestPlanStats;

public class PerformanceTest {

  @Test
  public void testPerformance() throws IOException {
    TestPlanStats stats = testPlan(
      threadGroup(2, 10,
        httpSampler("http://my.service")
          .post("{\"name\": \"test\"}", ContentType.APPLICATION_JSON)
      ),
      //this is just to log details of each request stats
      jtlWriter("target/jtls")
    ).run();
    assertThat(stats.overall().sampleTimePercentile99()).isLessThan(Duration.ofSeconds(5));
  }
  
}

This example also uses AssertJ for assertions, but you can use whatever assertion library you choose.

More examples can be found in tests

Here is a sample project for reference or for starting new projects from scratch.

Tip 1: Check jmx2dsl provided tool, which allows easy conversion of JMX files to JMeter DSL code.

Tip 2: Since JMeter uses log4j2, if you want to control the logging level or output, you can use something similar to the tests included log4j2.xml.

Tip 3: When working with multiple samplers in a test plan, specify their names to easily check their respective statistics.

Check here for details on some interesting use cases, like running tests at scale in BlazeMeter or OctoPerf, saving and loading test plans from JMX, publishing test metrics to InfluxDB (and visualizing them from Grafana), and general usage guides.

Why?

Check more about the motivation and analysis of alternatives here

Articles & Talks

Ecosystem

  • pymeter: python API based on JMeter DSL that allows python devs to create and run JMeter test plans.

Contributing & Requesting features

Currently, the project covers the most used features required when implementing JMeter performance tests, but not everything the JMeter supports/provides.

We invest in the development of DSL according to the community's (your) interest, which we evaluate by reviewing GitHub stars' evolution, feature requests, and contributions.

To keep improving the DSL we need you to please create an issue for any particular feature or need that you have.

We also really appreciate pull requests. Check the CONTRIBUTING guide for an explanation of the main library components and how you can extend the library.

jmeter-java-dsl's People

Contributors

rabelenda-abstracta avatar rabelenda avatar kirillyu avatar dependabot[bot] avatar makssieve avatar andytarr avatar eldaduzman avatar hboutemy avatar mrthreepwood avatar anasoid avatar snyk-bot avatar ankugarg avatar luismartinez22 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.