Unable to get attributeName in a foreach loop

18 views
Skip to first unread message

Thomas Polaske

unread,
Aug 26, 2021, 3:33:10 PM8/26/21
to Gatling User Group

hello any help with this would be awesome!

What I am trying to achieve is the following: 

I am setting the following in session:

var rulesetUids:Seq[String] = Seq()

.exec(session => session.set("rulesetsTest", rulesetUids))

 which creates the following list in session - see below two string values 

rulesetsTest -> List(5fdbaa99-1ae9-4507-a1e7-7394df90e1ad, d80eac04-9371-4d20-b55c-10fff6ed50c2)

I then have the following  forEach loop.  But the string interpolation is not working on "${ruleset} or ${counter}??

  .foreach("${rulesetsTest}", "ruleset", "counter") {
     TestUtil.putRuleset2("${ruleset}", rulesetFilePath, "${counter}").pause(2)  // this is a HTTP PUT request but I need the rulesetName from the list.  This
  }

What is wrong with this code above?? 


NOTE:  If I run this with a print statement I see it is looping correctly

  .foreach("${rulesetsTest}", "ruleset", "counter") {
      exec {
        session => {
          Console.println(session.attributes("ruleset"));
          session
        }
      }
  }

It will print correctly as  ->   5fdbaa99-1ae9-4507-a1e7-7394df90e1ad and then d80eac04-9371-4d20-b55c-10fff6ed50c2 .  

But I try to print “${ruleset}” the string is NOT replaced.  It is displayed as “${ruleset}”

any suggestions on how to do?

Thanks!

Tom



Stéphane LANDELLE

unread,
Aug 26, 2021, 4:05:27 PM8/26/21
to gat...@googlegroups.com
First, don't use "session.attributes", use the correct API: https://gatling.io/docs/gatling/reference/current/session/session_api/

And then, you can't use Gatling Expression Language in session functions, also as explained in the doc: https://gatling.io/docs/gatling/reference/current/session/expression_el/

Now, we're playing riddles, as you don't provide any clue about what TestUtil.putRuleset2 does.
First try to build simple things and provide a full sample.

--

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/7807e626-c251-49dd-a3b6-566974c47261n%40googlegroups.com.

Thomas Polaske

unread,
Aug 27, 2021, 9:35:13 AM8/27/21
to Gatling User Group
Reply all
Reply to author
Forward
0 new messages