GithubHelp home page GithubHelp logo

authorjapps / performance-tests Goto Github PK

View Code? Open in Web Editor NEW
41.0 5.0 22.0 241 KB

Sample Performance Testing setup for HTTP REST, SOAP APIs, JUnit4, JUnit5 tests - Generating Load and Stress On a Target Application

Home Page: https://zerocode.io

License: MIT License

Java 100.00%
java junit load performance testing easy simple jmeter tests assertion

performance-tests's Introduction

Visit our Knowledge Base to learn about load/stress testing and IDE based performance testing.

Table of Contents

Performance testing (Testing load and stress)

Sample Performance Tests - Banking (Using JUnit and Zerocode test framework)

Maven dependencies - JUnit5 Jupiter Tests

<dependency>
    <groupId>org.jsmart</groupId>
    <artifactId>zerocode-tdd-jupiter</artifactId>
    <version>1.3.23</version> <!-- or higher -->
</dependency>

Then follow this WikiPage.

For JUnit4 parallel-run or load testing, follow the samples in the below sections.

Maven dependencies - JUnit4

<dependency>
    <groupId>org.jsmart</groupId>
    <artifactId>zerocode-tdd</artifactId>
    <version>1.3.23</version> 
</dependency>

Prepare Scenario

Single scenario parallel load

See this GET load test in the repo e.g.

@LoadWith("load_generation.properties")
@TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
@RunWith(ZeroCodeLoadRunner.class)
public class LoadGetTest {

}

Where, the load_generation.properties has the below load e.g.
(100 requests in 100secs i.e. each request in 1 sec gap, looping twice, meaning 200 parallel requests)

number.of.threads=100
ramp.up.period.in.seconds=100
loop.count=2

It generates load for the below GET scenario:

@TargetEnv("screening_service_host.properties")
@RunWith(ZeroCodeUnitRunner.class)
public class GetScreeningServiceTest {

    @Test
    @JsonTestCase("load_tests/get/get_screening_details_by_custid.json")
    public void testGetScreeningLocalAndGlobal() throws Exception {
    }
}

Where the get_screening_details_by_custid.json with payload and assertions/validations :

{
    "scenarioName": "Screening API- Get Screening by customerId test",
    "steps": [
        {
            "name": "get_screening_details",
            "url": "/api/v1/screening/cust-ids/SINGAHV3033",
            "method": "GET",
            "request": {
            },
            "verify": {
                "status": 200,
                "body": {
                    "id" : "SINGAHV3033",
                    "localScreeningStatus" : "Green",
                    "globalScreeningStatus" : "Red"
                }
            }
        }

    ]
}

Combining single loads(GET, POST, PUT etc)

See the suite test firing different loads with single scenario each e.g. sample test-class: org.jsmart.zerocode.samples.load.LoadTestSuite

@Suite.SuiteClasses({

        LoadGetTest.class,
        LoadPostTest.class,
        LoadMultipleGetPostPutTest.class

})
@RunWith(Suite.class)
public class LoadTestSuite {

}

Multi scenario parallel load

See the test-class org.jsmart.zerocode.samples.load.parallelmulti.LoadMultipleGetPostPutTest

/**
 * What's new in ZeroCodeMultiLoadRunner.class ?
 * ---------------------------------------------
 * While running with "ZeroCodeMultiLoadRunner.class", each test mapping here is equivalent to one user,
 * that means there are 3 concurrent users below invoking their respective user operations as:
 *         User-1) POST,GET
 *         User-2) PUT,GET
 *         User-3) GET
 *         User-N) so on
 *
 * Note :
 * ------
 * All 3 users are running in parallel which resembles the production like scenario where each user
 * doing different jobs.
 *
 * You can keep feeding/adding as many tests by using @TestMapping(TestClassName.class, "testMethodName")
 *
 * Please make sure you set "number.of.threads" >= "number of test mappings(= 3 here)" giving chance for
 * each scenario to get executed at least once.
 *
 */
@LoadWith("load_generation.properties")
@TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
@TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations")
@TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
@RunWith(ZeroCodeMultiLoadRunner.class)
public class LoadMultipleGetPostPutTest {

}

(Optionally)Grouping the multiload tests

You can(optionally) group the @TestMappings as below for better readability and pretty looking too.

@LoadWith("load_generation.properties")
@TestMappings({
        @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal"),
        @TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations"),
        @TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
})
@RunWith(ZeroCodeMultiLoadRunner.class)
public class LoadMultipleGroupAnnotationTest {
}

Load with gradually increasing or decreasing

See the test-class org.jsmart.zerocode.samples.loadgradually.LoadGraduallyTestSuite

@Suite.SuiteClasses({

        LoadGet1Per5SecTest.class, // <-- Less load (5 sec gap)
        LoadGet1Per1SecTest.class, // <-- Bit more load (1 sec gap)
        LoadGet5Per1SecTest.class  // <-- Heavy load (0.2 sec gap)

})
@RunWith(Suite.class)
public class LoadGraduallyTestSuite {

}
  • Download this project to run using your local IDE

Maven library used

  • Latest release (includes Kafka testing):
<dependency>
    <groupId>org.jsmart</groupId>
    <artifactId>zerocode-tdd</artifactId>
    <version>1.3.x</version> 
</dependency>

Disabling long-running HTML Reports

The Interactive-Html-Report generation is enabled by default. For load testing this report may not be quite useful as we are mostly interested in load statistics which we can get from the CSV reports. Also the HTML interactive reports particularly takes bit longer to generate during load testing.

To disable this report generation please use the following flag in the host properties file annotated with @TargetEnv("app_host_sit.properties").

interactive.html.report.disabled=true

performance-tests's People

Contributors

authorjapps avatar dinesh76in avatar kanuku avatar siddhagalaxy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

performance-tests's Issues

Load tests - How to define pass/failed limit for response time

I'm looking for possibility to define criteria for pass/fail of response time during load tests. For example max response time. I didn't find it mentioned in documentation and it looks that evaluation should be done manually based on the report. What is then best approach to evaluate automatically ?

See, please reply.

Hello, your case is really not clear, can help write an interface test case no, to tell the truth, you write this is not very detailed, how to generate reports and so on, write is not very clear.

Not able to run sample tests

I've tried running the tests in the org.jsmart.zerocode.samples.load directory but most of them result in an error. I've tested the LoadGetTest, LoadMultipleGetPostPutTest and LoadDbParameterizedGetTest. I've pasted the error I got while running the LoadGetTest. The other errors were also similar. Please let me know if you need any other details.

2022-08-16 17:31:07,551 [main] ERROR org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner - org.jsmart.zerocode.samples.load.parallelget.LoadGetTest.testGetScreeningLocalAndGlobal Failed. See target/logs -or- junit granular failure report(csv) -or- fuzzy search and filter report(html) for details

java.lang.RuntimeException: org.jsmart.zerocode.samples.load.parallelget.LoadGetTest.testGetScreeningLocalAndGlobal Failed

	at org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner.runChild(ZeroCodeLoadRunner.java:63)
	at org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner.runChild(ZeroCodeLoadRunner.java:18)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner.run(ZeroCodeLoadRunner.java:70)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)


Process finished with exit code 255

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.