randomSwitch example

Hi,

I have a Galting load test with a number of get requests

val scn = scenario(“Radio Player”)

.feed(liveStreamData)

.exec(http(“Live Stream”)

.get("${stationId}")

.headers(flagpoleHeaders)

.check(status.is(200)))

.exec(http(“On Demand Stream”)

.get(“b04gk6kv”) // episodePID

.headers(flagpoleHeaders)

.check(status.is(200)))

full test: https://github.com/BBC/gatling-load-tests/blob/master/src/test/scala/radioplayer/RadioPlayer.scala

I’d like to weight each of these get requests. The first request, I’d like to weight by 17%

There is a chunk of code here:
https://github.com/gatling/gatling/blob/1a32c4051304461fd6f8d665c9cf34a0410aa678/gatling-http/src/test/scala/io/gatling/http/HttpCompileTest.scala

That gives me an example:

.randomSwitch(
40d → exec(http(“Catégorie Poney”).get("/")),
50d → exec(http(“Catégorie Licorne”).get("/"))

So, I have tried to do this

val scn = scenario(“Radio Player”)
.feed(liveStreamData)
.randomSwitch(17d → exec(http(“Live Stream”).get("${stationId}"))
.headers(flagpoleHeaders)
.check(status.is(200)))

I wondered if someone could point me in the right direction?

Many Thanks

Aidy

What’s your problem exactly?

Hi Stephane,

It is the unfamiliarity with the syntax that throws me, but I now have a working example:

val scn = scenario(“Radio Player”)
.feed(liveStreamData)
.randomSwitch(
90d → exec(http(“Live Stream”).get("${stationId}")
.headers(flagpoleHeaders)
.check(status.is(200))),

10d → exec(http(“On Demand Stream”).get(“b04gk6kv”) // episodePID
.headers(flagpoleHeaders)
.check(status.is(200))))

I’ll write all this stuff up.

Many Thanks

Aidy