Config parameters

1,031 צפיות
מעבר להודעה הראשונה שלא נקראה

Amar Pawar

לא נקראה,
26 בפבר׳ 2015, 5:07:0426.2.2015
עד gat...@googlegroups.com
Hi All,

I have passed environment variables in my simulation.
I have succeeded in passing them using
Through shell file:
: ${Users:=1}
export Users=$Users
: ${Ramp:=1}
export Ramp=$Ramp

And accessing them in config file:
var totalUsers:Int = if (System.getenv("Users") != null) System.getenv("Users").toInt else 1
var rampOverSeconds:Int = if (System.getenv("Ramp") != null) System.getenv("Ramp").toInt else 1

Now I want to pass scenario names using config parameters.
val foo = exec(bar.foobar_function)

Can anyone help me understanding, how to pass and access config parameters for above scenario.

Thanks

John Arrowwood

לא נקראה,
26 בפבר׳ 2015, 9:17:4626.2.2015
עד gat...@googlegroups.com
Scenario names are not passed through the environment.  For that, you need a command line parameter if you are using gatling.sh or gatling.bat.  See http://gatling.io/docs/2.1.4/general/configuration.html#command-line-options

If you are using maven or sbt, someone else will have to tell you how to do that.  :)

empty account

לא נקראה,
26 בפבר׳ 2015, 9:53:2426.2.2015
עד gat...@googlegroups.com
If you are using maven or sbt, someone else will have to tell you how to do that

I'd be interested to know if we can pass parameters through sbt. I was thinking, it'd just be: 

$ SBT_OPTS="-Dfoo=bar" sbt

// Script 
println("value: " + System.getProperty("foo"))

But I am getting null. 

Many Thanks

Adrian


--
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.
For more options, visit https://groups.google.com/d/optout.

Pierre DAL-PRA

לא נקראה,
26 בפבר׳ 2015, 10:11:5626.2.2015
עד gat...@googlegroups.com

Even if Gatling SBT Plugin provides System properties propagation to Gatling itself, this won’t work as-is if you override javaOptions (which you do in your load tests published on Github).

To re-enable system properties propagation to Gatling : 

import io.gatling.sbt.PropertyUtils._

javaOptions
in Gatling := /* your javaOptions */ ++
propagatedSystemProperties

Cheers,

Pierre

empty account

לא נקראה,
26 בפבר׳ 2015, 10:31:4926.2.2015
עד gat...@googlegroups.com
Hi Pierre

> import io.gatling.sbt.PropertyUtils._

I am receiving the error: 
error: object PropertyUtils is not a member of package io.gatling.sbt




Pierre DAL-PRA

לא נקראה,
26 בפבר׳ 2015, 10:46:4026.2.2015
עד gat...@googlegroups.com
Woops….

import io.gatling.sbt.utils.PropertyUtils._

empty account

לא נקראה,
27 בפבר׳ 2015, 2:58:1227.2.2015
עד gat...@googlegroups.com
Hi Pierre, 

Thanks for getting back. 

Here is my set up:

// build.sbt

import io.gatling.sbt.utils.PropertyUtils._
javaOptions in Gatling := Seq("-Xms2G", "-Xmx5G") ++ propagatedSystemProperties

// Gatling Script 
println("value: " + System.getProperty("foo"))

// JAVA_OPTS passed to sbt
JAVA_OPTS="-Dfoo=bar" sbt

However, when I run the test, I still the value as null. 

Many Thanks

Adrian

Pierre DAL-PRA

לא נקראה,
27 בפבר׳ 2015, 5:40:5827.2.2015
עד gat...@googlegroups.com
Are you sure that JAVA_OPTS is used by SBT ?
For example, if you’re using Paul Philips’s script from sbt-extras, the env variable is JVM_OPTS, not JAVA_OPTS.

To be sure, try using your system property inside your build.sbt.
For example, add name := sys.props("foo”) to your build. And then run show name inside SBT. 
If you get a null, this means that SBT itself doesn’t have access to your system property and so there’s not a single chance it can propagate it to Gatling.
Double check SBT help (sbt -h) to get sure that you’re using the correct environment variable to pass your system properties.

Cheers,

Pierre

empty account

לא נקראה,
2 במרץ 2015, 12:06:202.3.2015
עד gat...@googlegroups.com
Hi Pierre, 

Thanks for the pointers. SBT_OPTS seem to work: 

$ SBT_OPTS="-Denv=test" sbt

// script
val env = System.getProperty("env")

Many Thanks

Aidy

Amar Pawar

לא נקראה,
4 במרץ 2015, 0:59:294.3.2015
עד gat...@googlegroups.com
Hi All,
 
Sorry for breaking in the discussion.

I am not using sbt or maven.

I have configured a shell file which passes config parameters through environment variables, and I am successful passing them as per mentioned in first post.

Now I want to pass scenario names through environment variables, which i am not able to pass using string parameters.
Can you help me with any way which can be used for passing scenario names.

Thanks

Amar Pawar

לא נקראה,
4 במרץ 2015, 6:37:184.3.2015
עד gat...@googlegroups.com
I am trying to pass parameters from shell file.

<content of shell file>

: ${SingleFilter:="Foo.getBarScenario"}

And fetch them in my simulation file.
<content of UI Simulation file>

val config_filter:String = if (System.getenv("SingleFilter") != null) System.getenv("SingleFilter") else "Foo1.getBar1"
// if I print value of config_filter here, it displays Foo.getBarScenario

val singleFiltrScns = exec(s"config_filter")

val fooUIScenario = scenario("Foo UI Simulation")
  .exec(loginScns)
  .exec(singleFiltrScns)

//but when I execute simulation gatling gives me following error 

// 17:04:16.567 [ERROR] i.g.c.a.b.SessionHookBuilder$$anonfun$build$1$$anon$1 - 'sessionHook-1' failed to execute

John Arrowwood

לא נקראה,
4 במרץ 2015, 12:45:184.3.2015
עד gat...@googlegroups.com
You can't set the scenario name via an environment variable.  You use a command line parameter.  Read the docs on startup parameters, and then build an appropriate shell script wrapper.

--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/IhgMGVDDMCA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
John Arrowwood,
Consulting Hypnotist / Hypnotherapist
http://www.JohnArrowwood.com
503.863.4823
השב לכולם
השב למחבר
העבר לנמענים
0 הודעות חדשות