0

I am using the code from https://github.com/alexromanov/gatling-grpc-tests-sample i have added new protobuf under src/main and added a newSimulation.scala under src/test/scala/load. The code works fine and able to run. Now the problem i want a jar that can execute the newSimulation.scala

so my 2 questions?

  1. is there a way we can create a jar using which i can run the load test script
  2. If not how can i write a main class which may invoke the tests from there

Thanks

i tried sbt assembly and sbt test:assembly dont think that it worked, as it kept asking me for a main class.

sivadas j
  • 41
  • 3

2 Answers2

0

Did you try to specify

assembly / mainClass := Some("com.example.Main")

?

See https://github.com/sbt/sbt-assembly

I can't see that in their build.sbt https://github.com/alexromanov/gatling-grpc-tests-sample/blob/main/build.sbt

(Just in case, what are your versions of sbt and sbt-assembly?)

Multiple main classes with SBT assembly

How to set main class in build?

How to pass mainClass argument using sbt assembly

sbt-assembly - can not find main class in jar

why sbt-assembly failed to auto detect main class?

Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66
  • Hey, i tried mentioning the main class on the build.sbt, but did not work sbt version : 1.4.3 sbt-assembly version : 0.15.0 – sivadas j Apr 11 '23 at 15:37
0

is there a way we can create a jar using which i can run the load test script

If you want to create a executable jar, this is not supported usage.

Gatling has a set of official launchers: zip bundle, maven, sbt, gradle and FrontLine.

However, if you want to, it's doable. There's already another question asking for the exact same thing. Gatling sbt assembly- jar file cannot created?


If you upgrade your Gatling SBT plugin, you can simply run sbt Gatling/enterprisePackage. That task creates a fat jar in the target/gatling directory.

Move that jar to lib/ in the Gatling bundle.
You can start the simulation by calling ./bin/gatling.sh -s load.GrpcSimulation.

Since the sample repo is pretty old, you will have to also upgrade quite a lot of things (e.g. sbt, other sbt plugin(s), libraries versions) to upgrade the Gatling SBT plugin.

George Leung
  • 1,209
  • 1
  • 7
  • 11
  • i placed the jar inside lib/ and on running i am getting this error Exception in thread "main" java.lang.NoSuchMethodError: io.gatling.core.cli.CommandLineConstant.(Ljava/lang/String;Ljava/lang/String;)V at io.gatling.recorder.cli.CommandLineConstants$.(CommandLineConstants.scala:23) at io.gatling.recorder.cli.CommandLineConstants$.(CommandLineConstants.scala) at io.gatling.bundle.GatlingCLI$$anon$1.(GatlingCLI.scala:61) at io.gatling.bundle.GatlingCLI$.main(GatlingCLI.scala:54) at io.gatling.bundle.GatlingCLI.main(GatlingCLI.scala) – sivadas j Apr 11 '23 at 07:27
  • 2
    Looks like a version mismatch. – George Leung Apr 11 '23 at 17:00
  • thanks George, yes gatling bundle was of different version. fixed it but now running into new issue ---- io.grpc.NameResolverRegistry getDefaultRegistry WARNING: No NameResolverProviders found via ServiceLoader, including for DNS. This is probably due to a broken build. Any idea on this? tried this [https://github.com/grpc/grpc-java/issues/2149] but didnt help – sivadas j Apr 11 '23 at 18:56
  • 1
    I think that should be a different question. Include your `sbt` settings in the new question. Also try unzipping the `.jar` and see if there is `io/grpc/internal/DnsNameResolverProvider.class`. – George Leung Apr 11 '23 at 19:35