codecentric / gatling-jdbc

JDBC support for Gatling
Apache License 2.0
23 stars 18 forks source link

Is gatling-jdbc compatible with Gatling 3.0? #5

Closed shorn closed 5 years ago

shorn commented 5 years ago

Hi,

I'm a bit a of a newb to Gatling / Scala - but I do have my scenario working such that it can make http() calls, but my gatling-jdbc jdbc() call fails.

As per the example code below, using the sqlSelect scenario, I get an UnsupportedOperationException. The httpGet scenario works as expected.

Code:

import io.gatling.http.Predef._
import io.gatling.core.Predef._
import de.codecentric.gatling.jdbc.Predef._

class DatabaseSimulation extends Simulation {

  private val httpConf = http
  private val jdbcConfig = jdbc
    .url("jdbc:postgresql://...")
    .username("postgres")
    .password("password")
    .driver("org.postgresql.Driver")

  private val httpGet =
    scenario("getF5VersionScenario").exec(
      http("getF5Version").
        get("https://...") )

  private val sqlSelect =
    scenario("f5JdbcServerVersionScenario").exec(
      jdbc("selectVersion").select("*").from("dual")
    )

  setUp(
//    httpGet.inject(atOnceUsers(1))
    sqlSelect.inject(atOnceUsers(1))
  ).
    protocols(jdbcConfig).
    protocols(httpConf)

}

Exception:

java.lang.UnsupportedOperationException: empty.reduceLeft
    at scala.collection.LinearSeqOptimized.reduceLeft(LinearSeqOptimized.scala:135)
    at scala.collection.LinearSeqOptimized.reduceLeft$(LinearSeqOptimized.scala:134)
    at scala.collection.immutable.List.reduceLeft(List.scala:85)
    at scala.collection.TraversableOnce.reduce(TraversableOnce.scala:207)
    at scala.collection.TraversableOnce.reduce$(TraversableOnce.scala:207)
    at scala.collection.AbstractTraversable.reduce(Traversable.scala:104)
    at io.gatling.core.protocol.ProtocolComponentsRegistry.onStart(Protocol.scala:76)
    at io.gatling.core.structure.PopulationBuilder.build(ScenarioBuilder.scala:102)
    at io.gatling.core.scenario.SimulationParams.$anonfun$scenarios$1(Simulation.scala:194)
    at scala.collection.immutable.List.map(List.scala:282)
    at io.gatling.core.scenario.SimulationParams.scenarios(Simulation.scala:194)
    at io.gatling.app.Runner.run0(Runner.scala:92)
    at io.gatling.app.Runner.run(Runner.scala:61)
    at io.gatling.app.Gatling$.start(Gatling.scala:74)
    at io.gatling.app.Gatling$.fromMap(Gatling.scala:42)
    at myorg.sim.OneOffSysProp$.delayedEndpoint$myorg$sim$OneOffSysProp$1(OneOffSysProp.scala:27)
    at myorg.sim.OneOffSysProp$delayedInit$body.apply(OneOffSysProp.scala:11)
    at scala.Function0.apply$mcV$sp(Function0.scala:34)
    at scala.Function0.apply$mcV$sp$(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App.$anonfun$main$1$adapted(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:388)
    at scala.App.main(App.scala:76)
    at scala.App.main$(App.scala:74)
    at myorg.sim.OneOffSysProp$.main(OneOffSysProp.scala:11)
    at myorg.sim.OneOffSysProp.main(OneOffSysProp.scala)
Exception in thread "main" java.lang.UnsupportedOperationException: empty.reduceLeft
    at scala.collection.LinearSeqOptimized.reduceLeft(LinearSeqOptimized.scala:135)
    at scala.collection.LinearSeqOptimized.reduceLeft$(LinearSeqOptimized.scala:134)
    at scala.collection.immutable.List.reduceLeft(List.scala:85)
    at scala.collection.TraversableOnce.reduce(TraversableOnce.scala:207)
    at scala.collection.TraversableOnce.reduce$(TraversableOnce.scala:207)
    at scala.collection.AbstractTraversable.reduce(Traversable.scala:104)
    at io.gatling.core.protocol.ProtocolComponentsRegistry.onStart(Protocol.scala:76)
    at io.gatling.core.structure.PopulationBuilder.build(ScenarioBuilder.scala:102)
    at io.gatling.core.scenario.SimulationParams.$anonfun$scenarios$1(Simulation.scala:194)
    at scala.collection.immutable.List.map(List.scala:282)
    at io.gatling.core.scenario.SimulationParams.scenarios(Simulation.scala:194)
    at io.gatling.app.Runner.run0(Runner.scala:92)
    at io.gatling.app.Runner.run(Runner.scala:61)
    at io.gatling.app.Gatling$.start(Gatling.scala:74)
    at io.gatling.app.Gatling$.fromMap(Gatling.scala:42)
    at myorg.sim.OneOffSysProp$.delayedEndpoint$myorg$sim$OneOffSysProp$1(OneOffSysProp.scala:27)
    at myorg.sim.OneOffSysProp$delayedInit$body.apply(OneOffSysProp.scala:11)
    at scala.Function0.apply$mcV$sp(Function0.scala:34)
    at scala.Function0.apply$mcV$sp$(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App.$anonfun$main$1$adapted(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:388)
    at scala.App.main(App.scala:76)
    at scala.App.main$(App.scala:74)
    at myorg.sim.OneOffSysProp$.main(OneOffSysProp.scala:11)
    at myorg.sim.OneOffSysProp.main(OneOffSysProp.scala)

Process finished with exit code 1

I'm using a Gatling 3.0.0-RC4 "maven archetype" project.

Using gatling-jdbc by adding this to the pom.xml:

    <dependency>
      <groupId>de.codecentric</groupId>
      <artifactId>gatling-jdbc_2.12</artifactId>
      <version>1.0.1</version>
    </dependency>

As per the title, should gatling-jdbc work with the new version of gatling-jdbc? Or am I doing something else wrong?

rbraeunlich commented 5 years ago

Hi @shorn so far, I didn't manage to check/upgrade Gatling JDBC to Gatling version 3. I don't know if there are any breaking changes that affect my extension. Regarding your scenarion and the exception here I wonder if the problem is really about the version. How do you execute your simulation? Those lines

    at scala.collection.immutable.List.map(List.scala:282)
    at io.gatling.core.scenario.SimulationParams.scenarios(Simulation.scala:194)

Indicate that something happens with the simulation parameters and the exception shows that a list is empty that shouldn't be. Cheers, Ronny

shorn commented 5 years ago

I've pasted in my launcher class below. But note that if I comment out the sqlSelect scenario and enable the httpGet scenario, the simulation executes correctly.

object OneOffSysProp extends App {
  val simClassProp = "simulationToRun"
  val simClassName = System.getProperty(simClassProp, "")

  if( simClassName.isEmpty ){
    println(s"must provide a simulation to run in sysprop $simClassProp")
    sys.exit(1)
  }

  val props = new GatlingPropertiesBuilder().
    resourcesDirectory(IDEPathHelper.resourcesDirectory.toString).
    resultsDirectory(IDEPathHelper.resultsDirectory.toString).
    binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)

  props.simulationClass(simClassName)

  Gatling.fromMap(props.build)
}
rbraeunlich commented 5 years ago

Hi @shorn sorry for letting you wait. I'll check this problem asap. Most probably I'll directly migrate the project completely to Gatling 3.0.0. Cheers, Ronny

shorn commented 5 years ago

No worries. Feel free to close the issue whenever you want.

Might be a good idea to put a "supported / tested versions" in your readme.