How execute different url with different headers?

I have a test scenario like this:
request 3 different url as load balance, and every url must with a different header.
How could I do this? Thank you.

scripts:

val httpProtocol = http.baseURLs(
    "http://127.0.0.132:8080/v1/AUTH_test2",
    "http://127.0.0.163:8080/v1/AUTH_test2",
    "http://127.0.0.72:8080/v1/AUTH_test2")

  val headers_1 = Map("X-Auth-Token" -> "AUTH_tkc3b4bbc0b8384a25b8f1ba03409893f2")
  val headers_2 = Map("X-Auth-Token" -> "AUTH_tkd998f7ce72e94f52bb03e93e2d7cf152")
         val headers_3 = Map("X-Auth-Token" -> "AUTH_tk88fd3003d5804d39af58b37d9d774251")

         val scn1 = scenario("swift")
          .repeat(3) {
               exec(
                   http("创建container")
                      .put("/myfiles1")
                      .headers(headers_1))
            .pause(2)
          }

       setUp(     
scn1.inject(atOnce(1 user))    
 ).protocols(httpProtocol)

Are you sure that your X-Auth-Token can be replayed like you do?

The round robin with multiple baseUrls is too simple for this.

If you want individual users to reach several IPs, you’ll have to use absolute URIs and use a switch:
https://github.com/excilys/gatling/wiki/Structure-Elements#wiki-randomSwitch

https://github.com/excilys/gatling/wiki/Structure-Elements#wiki-roundRobinSwitch

If you’re fine with individual users only reaching a single IP each (session affinity), you’ll have to either:

  • use different scenarios (you can reuse chains/parts of a scenario, you don’t have to duplicate everything).

  • or inject different populations, configured with different protocols (if you can set your header at protocol header, it will be send on every request)
    Cheers,

Stéphane

RandomSwitch is ok, It pretty work. Thank you.

在 2013年12月31日星期二UTC+8下午11时56分53秒,Stéphane Landelle写道: