Gatling DB tests

I know gatling currently does not support database performance tests yet but I came across this repo https://github.com/senkadam/gatlingsql on github. Was wondering if anyone used it or have any suggestions?

Thanks,
Abhi

This project looks like a good start. Kudos to Adam!

IMHO, it lacks 2 things:

  • transaction support. It seems update support assumes auto-commit.
  • fixing coordinated omission as JDBC is a blocking protocol : https://github.com/senkadam/gatlingsql/issues/1. I suspect most load test SQL support suffers from this too.

Stephane,

Thanks for your input. We have a need for DB performance test (all select statements). Do you think this can be used as is for some smaller simulations (20-30 users)? I emailed Adam to get some pointers. Waiting for his response.

Thanks,
Abhinav

The coordinated omission issue is a structural one. It’s not related to the load.

Thanks Stephane. I am having little trouble implementing this protocol. I don’t know how to get the response object. Also, I tried it with incorrect credentials but the test still passed. Can you tell how I can fix this. Here is the simulation code:

package cz.senkadam.gatlingsql.requests

import akka.actor.{ActorRef, Props}
import io.gatling.core.Predef._
import io.gatling.core.action.Chainable
import io.gatling.core.action.builder.ActionBuilder
import io.gatling.core.config.Protocols
import io.gatling.core.result.message.{KO, OK}
import io.gatling.core.result.writer.{DataWriter, RequestMessage}
import scala.concurrent.duration._

class DBSimulation extends Simulation{

  val mine = new ActionBuilder {
    def build(next: ActorRef, protocols: Protocols) = {
      system.actorOf(Props(new RunSql(next)))
    }
  }

  val scn = scenario("SQL load test")
    .repeat(2) {
    exec(mine)
  }

  setUp(scn.inject(atOnceUsers(1)))

  class RunSql (val next: ActorRef) extends Chainable {
    def begin(session: Session) {
      val delegate = new SqlBuilderSpec
    }

    def execute(session: Session) {
      var start: Long = 0L
      var end: Long = 0L
      var status: Status = OK
      var errorMessage: Option[String] = None
      try {
        start = System.currentTimeMillis;
        begin(session)
        end = System.currentTimeMillis;
      } catch {
        case e: Exception =>
          status = KO
          errorMessage = Some(e.getMessage)
          logger.error("ERROR", e)
      } finally {
        val requestStartDate, requestEndDate = start
        val responseStartDate, responseEndDate = end
        val requestName = "Test Scenario"
        val message = errorMessage
        val extraInfo = Nil
        DataWriter.dispatch(RequestMessage(
          session.scenarioName,
          session.userId,
          session.groupHierarchy,
          requestName,
          requestStartDate,
          requestEndDate,
          responseStartDate,
          responseEndDate,
          status,
          message,
          extraInfo))
        next ! session
      }
    }
  }
}

So Adam helped me with this. He has updated hit github repo with new commits that also include default simulation. I am using it on couple of my projects and so far have not found any issues. If anyone wants to use Gatling for DB tests, this is a very handy library.

Please spread the word. :slight_smile: