Giter VIP home page Giter VIP logo

massive-attack's Introduction

massive-attack

License Maven Central

image

massive-attack is a simple and configurable load generator test tool written in Scala originally to test Apache Thrift endpoints, but it can be used to benchmark any method that returns a Scala or Twitter Future.

Why?

Because I needed to load test a Thrift endpoint in one of my APIs, and could not find an easy to use tool after looking around for days, at least not one that did not require me to develop JMeter plugins, or one that has been updated in the past few years.

How?

So I decided to create one which is easy to use:

  1. It can easily be added as a dependency to your API or application
  2. It is configurable as much or as little as you need it to be
  3. It is extensible

Usage

  1. Add it as a dependency to build.sbt:

libraryDependencies ++= Seq("com.delprks" %% "massive-attack" % "1.0.0" % "test")

  1. Create your test in ScalaTest or Specs2 (this library might change to be a testing framework in future)

To test a long running method that returns a Future:

"long running method should have average response times of less than 40ms" in {
  val testProperties = MethodPerformanceProps(
    invocations = 10000,
    threads = 50,
    duration = 35,
    report = true,
    reportName = Some("scala_future_performance_test")
  )

  val methodPerformance = new MethodPerformance(testProperties)

  val testResultF: Future[MethodPerformanceResult] = methodPerformance.measure(() => method())
  val testResult = Await.result(testResultF, futureSupportTimeout)
  
  testResult.responseTimeAvg should be < 40
}

Which will result in:

image

And (if enabled) generate a report containing the test results:

image

Test properties

Following properties are available and configurable through MassiveAttackProperties:

invocations

Specifies how many times the method should be invoked.

threads

You can set how many threads you want to run the load test on - beware that Thrift clients can run only on single threads.

duration

Specifies how long the method should be tested for in seconds - whichever comes first (duration or invocations) determines the length of the test.

warmUp

This is by default set to true to avoid cold start times affecting the test results - set it to false if you want to test cold starts.

warmUpInvocations

If warmUp is set to true, warmUpInvocations determines how many times the method should be invoked before the load test starts.

spikeFactor

This is used to decide which response times should be considered as spikes, by multiplying the average response time and spikeFactor. It has the default value of 3.0.

verbose

Set this to true if you want to see invocation times when the load test is in progress.

report

Set this to true if you want to save test results in a CSV file.

reportName

If report is set to true, results will be saved to this file. If no reportName is specified, one will be generated.

License

massive-attack is open source software released under the Apache 2 License.

massive-attack's People

Contributors

delprks avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

bbc

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.