chain and loop

For my tests I like to add a loop around all chain execs :

Recorder produce :

    val chain_0 = chain
      .exec(
        http("request_1")
          .get(extWebapp + "/libs-release/com/me/parent/parent/3/parent-3.pom")
          .headers(headers_1)
      )
      .exec(
        http("request_2")
          .get(extWebapp + "/libs-release/com/me/parent/parent/3/parent-3.pom.sha1")
          .headers(headers_1)
      )
      .pause(extPause, MILLISECONDS)
      .exec(
        http("request_3")
          .get(extWebapp + "/libs-release/com/me/web/1.0.0-12/web-1.0.0-12.pom")
          .headers(headers_1)
      )

...

and then

    val scn = scenario("me-mvn-clean")
      .insertChain(chain_0)
      .insertChain(chain_1)

What's the normal way to add loop around chains ?

Thanks.

PS: Still Scala noob on board :slight_smile:

Tss tss, you’d better read the doc… 328.png

https://github.com/excilys/gatling/wiki/Scenario-Components#wiki-loop

2012/9/5 Henri Gomez <henri.gomez@gmail.com>

I read this doc, just wonder how to add loop in scala in construct :frowning:

val chain_0 = chain(...)

-->

val chain_0 = loop (chain(...)).times(20)

or

val scn = scenario("me-mvn-clean")
                        .insertChain(chain_0)
                        .insertChain(chain_1)

--->

val scn = scenario("me-mvn-clean")
                        .insertChain(loop(chain_0).times(20))
                        .insertChain(loop(chain_1).times(20))

Remember, Scala noob on board :slight_smile:

Actually, that’s not Scala, that’s our DSL (which is written in Scala, but here, you’re just doing method chaining like you would with a Java or Groovy DSL).

Our DSL has 2 entry points: scenario and chain, so you can’t call loop from scratch.

So you can write:

  • val chain_0 = chain.loop(anotherChain).times(20)

  • val scn = scenario(“me-mvn-clean”)

    .loop(chain_0).times(20)
    .loop(chain_1).times(20)

Hope it help.

2012/9/5 Henri Gomez <henri.gomez@gmail.com>

Actually, that's not Scala, that's our DSL (which is written in Scala, but
here, you're just doing method chaining like you would with a Java or Groovy
DSL).

Ok, it's still a bit unclear where end DSL and where start Scala.

Our DSL has 2 entry points: scenario and chain, so you can't call loop from
scratch.

So you can write:

val chain_0 = chain.loop(anotherChain).times(20)
val scn = scenario("me-mvn-clean")
                        .loop(chain_0).times(20)
                        .loop(chain_1).times(20)

Hope it help.

Perfect.

Thanks

Don’t fear, you’ll be fine :wink:

2012/9/5 Henri Gomez <henri.gomez@gmail.com>

Don't fear, you'll be fine :wink:

Thanks

How could I apply loop to whole scenario ?

I’ve just deprecated some instructions in the DSL, so my response would depend on the version you use.
1.2.5 or 1.3.0-SNAPSHOT?

2012/9/6 Henri Gomez <henri.gomez@gmail.com>

I've just deprecated some instructions in the DSL, so my response would
depend on the version you use.
1.2.5 or 1.3.0-SNAPSHOT?

1.2.5, I'll wait 1.3.0 release to switch

OK, so in 1.2.5, you have insert a loop in your scenario and pass it a chain. Things will be more simple in 1.3.0.

So if you have:

val scn = scenario(“foo”)
.insertChain(chain1)
.insertChain(chain1)

you can write:

val scn = scenario(“foo”)
.loop(
chain

.insertChain(chain1)
.insertChain(chain1)

).times(100) // or during(10, TimeUnit.MINUTE) for example

2012/9/6 Henri Gomez <henri.gomez@gmail.com>

Good

Thanks !

By curiosity, how will it turn in 1.3.0 ?

In about 2 weeks I hope.

2012/9/6 Henri Gomez <henri.gomez@gmail.com>

In about 2 weeks I hope.

Good :slight_smile:

Question was, how did this code (loop for scenario) would be in 1.3.0 :wink:

Current loop DSL will be here in 1.3.0, but issue deprecation warnings, and will be removed in 1.4.0.

The new way of writing loops will be:

val scn = scenario(“foo”)
.repeat(100) { // or during(10 minutes)
chain1
.insertChain(chain2)
}

I realize we might have a better name for “insertChain” like “chainWith”.

2012/9/6 Henri Gomez <henri.gomez@gmail.com>

Hi,
I have a problem with this syntax, I wrote :

repeat(15){home.insertChain(rollover)},processcmd
/* home, rollover and processcmd are 3 chains */

And gatling says : value insertChain is not a member of io.gatling.core.structure.ChainBuilder

:frowning: :frowning:

This thread is more than 1 year old, syntax has changed since.
use exec

My entire code is there :

val scn = scenario(“myscenar”).exec(
repeat(15){chain.insertChain(home).insertChain(rollover)},processcmd

)

Where am I wrong ?

As I said: home.exec(rollover).exec(processcmd)

Ok, thank you for your help.