Deepika T
Deepika T

Reputation: 25

Cannot use gatling conf values in scala class.

I have a gatling project where I set up cert locations using gatling.conf for 2-way ssl connection. I need to use these certificates in a helper function in the same project. I am unable to specify conf variables gatling.http.ssl.trustStore.file and gatling.http.ssl.keyStore.file in my scala class as it errors with the following error. Note that I can use application.conf variables in my code with out any issues

Code that errors:

   val trustStoreLoc = config.getString("gatling.http.ssl.trustStore.file")

Error is:

[error] Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'gatling'
[error]         at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124)
[error]         at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:147)
[error]         at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:159)
[error]         at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:164)
[error]         at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:206)
[error]         at oncue.gatling.authbe.benchmarks.auth.userOpsSimulation.<init>(userOpsSimulation.scala:21)
[error]         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error]         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[error]         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error]         at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
[error]         at java.lang.Class.newInstance(Class.java:379)
[error]         at io.gatling.core.runner.Runner.run(Runner.scala:37)
[error]         at io.gatling.app.Gatling.start(Gatling.scala:235)
[error]         at io.gatling.app.Gatling$.fromMap(Gatling.scala:54)
[error]         at io.gatling.app.Gatling$.runGatling(Gatling.scala:79)
[error]         at io.gatling.app.Gatling$.runGatling(Gatling.scala:58)
[error]         at io.gatling.app.Gatling$.main(Gatling.scala:50)
[error]         at io.gatling.app.Gatling.main(Gatling.scala)

Upvotes: 1

Views: 2317

Answers (1)

Pierre DAL-PRA
Pierre DAL-PRA

Reputation: 966

Gatling uses Typesafe Config's withFallback mechanism to allow to have :

  • system properties overriding...
  • ...gatling.conf values overriding...
  • ... gatling-defaults.conf values

This mechanism is implemented here : https://github.com/gatling/gatling/blob/master/gatling-core/src/main/scala/io/gatling/core/config/GatlingConfiguration.scala#L73-77

My guess is that you only use gatling.conf and in this case, if the line is commented, the value is simply not defined.

Either uncomment that property in your gatling.conf or reuse GatlingConfiguration logic to take gatling.conf values into account.

Upvotes: 2

Related Questions