Gatling pluging problems during compilation

187 views
Skip to first unread message

Wouter Dekker

unread,
Aug 30, 2021, 4:55:08 AM8/30/21
to Gatling User Group
I have a problem with running my Gatling test via mvn Gatling:test in the commandline. The following ERRORS are posted in the commandline:
09:09:25.302 [main][ERROR][ZincCompiler.scala:183] i.g.c.ZincCompiler$ - /Feeders.scala:14:5: identifier expected but 'val' found.
val sqlLocation: String
^
09:09:25.306 [main][ERROR][ZincCompiler.scala:183] i.g.c.ZincCompiler$ - /Feeders.scala:32:1: ':' expected but '}' found.
}
^
09:09:25.318 [main][WARN ][ZincCompiler.scala:185] i.g.c.ZincCompiler$ - /Feeders.scala:30:6: procedure syntax is deprecated: instead, add `: Unit` to ex
plicitly declare `getSqlQuery`'s return type
}

The compiler in the Gatling plugin seems to change my code by adding a "var" in the function I've coded. The first codeblock is my written code and the second block is the compile code.

Written code:
def getSqlFeeder(sqlLocation:String): Feeder[Any] = {
var sqlQuery: String = "";
Using(Source.fromFile(sqlLocation)) { source =>
sqlQuery = source.getLines().toString();
};


return jdbcFeeder(databaseUrl, username, password, sqlQuery).circular();
}

Compile code:
def getSqlQuery(val sqlLocation: String ): String {
   val sqlQuery = fromFile(sqlLocation).getLines
   return jdbcFeeder(databaseUrl, username, password,
   queryOpvragenNatuurlijkePersonenWeinigAdressen).circular()
}

I've read that you can't use "val" in a function definition in Scala. The problem is, that I've not added this on my own accord, but the compiler adds it. https://stackoverflow.com/questions/53226748/why-cant-i-put-val-in-function-definition-arguments-error-expected-but

As far as I can see, the compiler comes from Gatling itself. I'm using io.gatling:gatling-maven-plugin version 3.1.2 and io.gatling.highcharts:gatling-charts-highcharts version 3.6.0 while using scala 2.13.6

Is there something I'm mising or is this a bug?

Wouter Dekker

unread,
Aug 30, 2021, 5:00:43 AM8/30/21
to Gatling User Group
P.S. These errors occured after I've done some refactoring to make the code more reusable. For full clarity, this is the first function written in this project. Before making the function I've met no problems in running the Gatling tests.

Op maandag 30 augustus 2021 om 10:55:08 UTC+2 schreef Wouter Dekker:

Stéphane LANDELLE

unread,
Aug 30, 2021, 5:03:44 AM8/30/21
to gat...@googlegroups.com
This is not a bug, neither in Gatling nor in the Scala compiler.
You've broken your code and most likely have unmatched opening and closing parens or curly braces.

--

Stéphane Landelle

Chief Technical Officer

   

slan...@gatling.io
gatling.io
   
facebook twitter linkedin 


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gatling/afea7f32-a291-40fa-80ef-fed16980decan%40googlegroups.com.

Wouter Dekker

unread,
Aug 30, 2021, 5:43:38 AM8/30/21
to Gatling User Group
Thank you for your response Stéphane,

Sadly neither me nor my IDE (Intellij Idea Ultimate 2021) can find unmatched opening and closing parens or curly braches. I'll post my full object down below. Please enlighten me what I've done wrong and thank you for your patience.

package org.some.package

import io.gatling.core.Predef.configuration
import io.gatling.core.feeder.{Feeder, Record}
import io.gatling.jdbc.Predef.jdbcFeeder

import java.util.{Properties, UUID}
import scala.io.Source
import scala.util.Using
object Feeders {
    val properties = new Properties()
    properties.load(getClass.getResourceAsStream("/performance.properties"))

    val databaseUrl: String = properties.getProperty("databaseUrl")
    val username: String = properties.getProperty("username")
    val password: String = properties.getProperty("password")



    def getSqlFeeder(sqlLocation: String): Feeder[Any] = {
       var sqlQuery: String = "";
       Using(Source.fromFile(sqlLocation)) { source =>
       sqlQuery = source.getLines().toString();
       };

       return jdbcFeeder(databaseUrl, username, password, sqlQuery).circular();
    };

   def getUuidFeeder(): Iterator[Record[String]] = {
       val uuidFeeder: Iterator[Record[String]] = new Feeder[String] {
          override def hasNext = true;

         override def next: Map[String, String] = {
             Map("uuid" -> UUID.randomUUID.toString);
          };
       };

       return uuidFeeder;
       };
   }
Op maandag 30 augustus 2021 om 11:03:44 UTC+2 schreef Stéphane Landelle:

Stéphane LANDELLE

unread,
Aug 30, 2021, 5:50:58 AM8/30/21
to gat...@googlegroups.com
Are you sure you don't have multiple files named Feeders? 

In 09:09:25.302 [main][ERROR][ZincCompiler.scala:183] i.g.c.ZincCompiler$ - /Feeders.scala:14:5: identifier expected but 'val' found.

it's /Feeders and /org/some/package/Feeders.scala

Try also cleaning the target directory.

--

Stéphane Landelle

Chief Technical Officer

   

slan...@gatling.io
gatling.io
   
facebook twitter linkedin 

Wouter Dekker

unread,
Aug 30, 2021, 6:01:50 AM8/30/21
to Gatling User Group
Thank you for you quick replies Stéphane! I found the problem, and it's indeed the problem that you suggest. I had two projects that have very similear names that both use gatling. The commandline I used was in the wrong project that I hadn't changed yet. Sorry for the inconvenience and many thanks for your time. I'll take my walk of shame now...

Op maandag 30 augustus 2021 om 11:50:58 UTC+2 schreef Stéphane Landelle:
Reply all
Reply to author
Forward
0 new messages