# Cleaner method to pass parameters to a simulation from a command invocation using SBT

**URL:** <https://community.gatling.io/t/cleaner-method-to-pass-parameters-to-a-simulation-from-a-command-invocation-using-sbt/2369>\
**Category:** Gatling (Open-Source)\
**Created:** [June 19, 2015, 5:37pm UTC](https://community.gatling.io/t/cleaner-method-to-pass-parameters-to-a-simulation-from-a-command-invocation-using-sbt/2369 "2015-06-19T17:37:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_Torres1](https://avatars.discourse-cdn.com/v4/letter/c/47e85d/32.png) [@Carlos\_Torres1](https://community.gatling.io/u/Carlos_Torres1)\
**Post date:** [June 19, 2015, 5:37pm UTC](https://community.gatling.io/t/cleaner-method-to-pass-parameters-to-a-simulation-from-a-command-invocation-using-sbt/2369/1 "2015-06-19T17:37:14Z")

</div>

Hi,

Currently I use this approach to define and pass in simulation parameters:

`

val RAMP\_UP\_START : Double =  
System.getProperty(“loadbalancedworkload.rampUpUsersPerSecStart”).toDouble

val RAMP\_UP\_END : Double =  
System.getProperty(“loadbalancedworkload.rampUpUsersPerSecEnd”).toDouble

val RAMP\_UP\_TIME\_SECS: Int =  
Integer.getInteger(“loadbalancedworkload.rampUpDurationSecs”)

val STEADY\_STATE: Double =  
System.getProperty(“loadbalancedworkload.steadyStateUsersPerSec”).toDouble

val STEADY\_TIME\_SECS: Int =  
Integer.getInteger(“loadbalancedworkload.steadyStateDurationSecs”)

…

`

I use the SBT project structure, with the gatling-sbt plugin, I haven’t found a convenient way to pass the parameters, so I do it this way, using a bash script:

`

export JVM\_OPTS="  
-XX:+CMSClassUnloadingEnabled   
-XX:PermSize=512M -XX:MaxPermSize=1024M   
-Dsbt.log.noformat=true"

HTTP\_METHOD=‘GET’  
HTTP\_URLS=‘[http://localhost:8080](http://localhost:8080),[http://localhost:8080](http://localhost:8080)’ # Comma separated baseURls  
HTTP\_RESOURCE\_PATH=’/json’  
RUN\_NAME=‘HelloGoLoadBalanced’  
PAGE\_NAME=‘json’

RAMP\_UP\_USERS\_PER\_SEC\_START=‘1.0’ # Must be a floating-point number string  
RAMP\_UP\_USERS\_PER\_SEC\_END=‘1000.0’ # Must be a floating-point number string  
RAMP\_UP\_DURATION\_SECS=‘30’ # Must be an integer string. No decimal point  
STEADY\_STATE\_USERS\_PER\_SEC=‘1000.0’ # Must be a floating-point number string  
STEADY\_STATE\_DURATION\_SECS=‘300’ # Must be an intenger string. No decimal point  
RAMP\_DOWN\_USERS\_PER\_SEC\_START=‘1000.0’ # Must be a floating-point number string  
RAMP\_DOWN\_USERS\_PER\_SEC\_END=‘1.0’ # Must be a floating-point number string  
RAMP\_DOWN\_DURATION\_SECS=‘1’ # Must be an integer string. No decimal point

if [-z “$HTTP\_URLS”]  
then  
echo “HTTP\_URLs is unset. Open start.sh and set a valid URL”  
exit 1  
fi

SBT\_CMD="; set javaOptions ++= Seq("-XX:PermSize=512M",   
“-XX:MaxPermSize=1024M”,   
“-Xms4096m”, “-Xmx7224m”,   
“-Dsun.net.inetaddr.ttl=0”,   
“-Djava.net.preferIPv4Stack=true”,   
“-Djava.net.preferIPv6Addresses=false”,   
“-Dloadbalancedworkload.method=${HTTP\_METHOD}”,   
“-Dloadbalancedworkload.baseURLs=${HTTP\_URLS}”,   
“-Dloadbalancedworkload.resourcePath=${HTTP\_RESOURCE\_PATH}”,   
“-Dloadbalancedworkload.scenarioName=${RUN\_NAME}”,   
“-Dloadbalancedworkload.pageName=${PAGE\_NAME}”,   
“-Dloadbalancedworkload.rampUpUsersPerSecStart=${RAMP\_UP\_USERS\_PER\_SEC\_START}”,   
“-Dloadbalancedworkload.rampUpUsersPerSecEnd=${RAMP\_UP\_USERS\_PER\_SEC\_END}”,   
“-Dloadbalancedworkload.rampUpDurationSecs=${RAMP\_UP\_DURATION\_SECS}”,   
“-Dloadbalancedworkload.steadyStateUsersPerSec=${STEADY\_STATE\_USERS\_PER\_SEC}”,   
“-Dloadbalancedworkload.steadyStateDurationSecs=${STEADY\_STATE\_DURATION\_SECS}”,   
“-Dloadbalancedworkload.rampDownUsersPerSecStart=${RAMP\_DOWN\_USERS\_PER\_SEC\_START}”,   
“-Dloadbalancedworkload.rampDownUsersPerSecEnd=${RAMP\_DOWN\_USERS\_PER\_SEC\_END}”,   
“-Dloadbalancedworkload.rampDownDurationSecs=${RAMP\_DOWN\_DURATION\_SECS}”,   
“-Dgatling.core.outputDirectoryBaseName=${RUN\_NAME}”) ; testOnly meteorfox.benchmarks.LoadBalancedOpenModelWorkload"

sbt “${SBT\_CMD}”

`

As you can see this is really verbose, I’m looking for a more cleaner approach, where perhaps, I could define these parameters in a file, but are overwritten by the environment variables.

Does anybody has figured out a cleaner way to achieve this? Ideally I want to keep using SBT.

Thanks,  
Carlos Torres

---

<div class="post-metadata">

**Author:** ![Alex\_R](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Alex\_R](https://community.gatling.io/u/Alex_R)\
**Post date:** [June 22, 2015, 12:37am UTC](https://community.gatling.io/t/cleaner-method-to-pass-parameters-to-a-simulation-from-a-command-invocation-using-sbt/2369/2 "2015-06-22T00:37:38Z")

</div>

HI Carlos,

You can use typesafe config library for this, it allows to override static values with env variables if they set.  
Just add this lib to your project.  
Then create application.conf in src\test\resourses

`loadbalancedworkload {`

`rampUpUsersPerSecStart = 1.0`  
`rampUpUsersPerSecStart = ${?`````````RAMP_UP_USERS_PER_SEC_START`}`

`}`

And read them in your simulation:

val config = ConfigFactory.load()  
val `RAMP_UP_START `= config.getDouble("`loadbalancedworkload.rampUpUsersPerSecStart`")

Regards,  
Alex.

---

<div class="post-metadata">

**Author:** ![Carlos\_Torres](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Carlos\_Torres](https://community.gatling.io/u/Carlos_Torres)\
**Post date:** [June 22, 2015, 6:13am UTC](https://community.gatling.io/t/cleaner-method-to-pass-parameters-to-a-simulation-from-a-command-invocation-using-sbt/2369/3 "2015-06-22T06:13:25Z")

</div>

Beautiful, this is exactly what I was looking for.

Thanks Alex!
