trouble calling 280 rest services randomly, this example uses Basic Auth

I need to randomly invoke up to 280 services 40 different transaction servers each with 7 different programs to invoke.
If I hardcode 1 URI into the .post(…) it works for that one program.

If I try the code below, it does not work, Can I call the method createURL() inside the scenario definition and expect it to be different for each injection for each simulated browser?.
The URIs look like this:



import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import scala.util.Random
class RTWBasicx extends Simulation {
val browsers = 400
val rampUp = 100
val howManyTimes = 167
val regions = 20
val r = Random
val inuris = “https://x.x.x.x:9443” // x’s so i do not give away any IP addresses

val httpConf = http

.baseURL(inuris) // Here is the root for all relative URLs
.acceptHeader(“application/xml,application/jsonq=0.9,/;q=0.8”) // Here are the common headers
.acceptEncodingHeader(“gzip, deflate”)
.userAgentHeader(“Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0”)

val headers_10 = Map(“Content-Type” → “”“application/x-www-form-urlencoded”"")

var scn = scenario(“RTWServlet4”).repeat(howManyTimes) { // A scenario is a chain of requests and pauses

.basicAuth(“xxxxxx”, “xxxxxx”)) // x’s so i do not give away userid and password
setUp(scn.inject(rampUsers(browsers) over(rampUp seconds)).protocols(httpConf))

def createURL() : String = {
var URL = “/zosConnect/services/RTWService” + (r.nextInt(regions) + 1) + “p” + r.nextInt(7)+ “?action=invoke”
return URL

Thank You
H. Michael Everett

Hi Harold,

The problem is that you’re passing a String to post, not a function, so createURL() is only called once, when the Simulation is created.
If you want createURL() to be invoked on every request, you have to pass a function:

What you want is .post(session => createURL())