Where to put config files

I am running multiple Gatling projects in a setting where we have multiple environments. I would like to create a .conf file for each environment, and then specify which configuration file to read on the command line. I want these conf files to be shared, not duplicated per project.

My layout should be something like this:

/src /common (libraries) /conf /project1 /project2 /project3

Where each project folder looks like this

`
/project
/archive - saved results
/data
/results
/simulations
run.sh

`

I want my config files to be found when I do ConfigFactory.load( “env-name.conf” )

If the .conf file is in the project root, which is the active directory when I launch run.sh, then it works.

If I put the full path to the file in my code, e.g. ConfigFactory.load( “/src/common/conf/env-name.conf” ) then it also works.

But if I try to load “env-name.conf” by adding /src/common/conf to my classpath, that does NOT work.

But supposedly, I could put all my configuration into a single “resources.conf” and put that on the classpath, and that would work. The primary reason I do not is because I do not want a giant config file. Generally speaking, I only need a subset of the config. And I am paranoid about having everything in one file, where the whole thing could get corrupted by a careless edit.

I’d like the advice of the Scala experts out there. What would you do if you were me?

  • Would you just put them all into one config, and trust people not to screw it up?
  • Would you keep them in separate files, and pass the full path to the files?
  • Or is there another option I have not thought of?

Thanks for your input.

For reference, you’re using Typesafe’s config library (Java lib shipped with Gatling).

load method loads a resource from class loader, so assuming you didn’t mess up and src/common/conf is in the classpath, env-name.conf should be picked up. What’s strange is that /src/… does work. It shouldn’t, and that makes me think that . (project root) is in the classpath, which is probably wrong. Also, you shouldn’t have a leading /, this is a class loader path.

For more information, see ConfigFactory java doc.

I don’t use the leading slash, technically. I have a symlink to the conf directory in my project/simulations directory, and I use a relative path.

Maybe the problem is the use of “.conf” at the end. Maybe that forces it to use the file loader instead of the class loader… Nope!

Found the problem…

I was setting CLASSPATH prior to launching gatling.sh, thinking that was the way to set the class path in Java. Which seems to work when invoking java or scala directly.

However, gatling.sh was blowing away the environment variable I had just set, in favor of one called JAVA_CLASSPATH. As soon as I modified the name of the environment variable to JAVA_CLASSPATH, suddenly everything started working properly.

Mind if I ask why Gatling expects the classpath in JAVA_CLASSPATH instead of CLASSPATH?

Mostly to get isolated from whatever weird stuff people could have added in their CLASSPATH env var.
IMHO, there’s more people messing with this than people properly doing things…