How do we use localAddress ? I would like to submit a request with different IP address so load balancer will route the request to all servers instead of one server. Server configuration is sticky IP and so if I use 200 user load test it goes to single server. Need to distribute the load on each server.
I have 10 Ip address in my data file(csv/txt file)
val httpProtocol = http
.baseURL("https://applicationurl.com")
// .inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.(t|o)tf""", """.*\.png"""), WhiteList())
.acceptHeader("*/*")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.8")
.connection("keep-alive")
.contentTypeHeader("application/x-www-form-urlencoded; charset=UTF-8")
.doNotTrackHeader("1")
.userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36")
.disableCaching
.localAddress(????)
Thank you.
localAddress currently takes a static java.net.InetAddress value, so you can’t have a per virtual user value.
Please open a feature request.
Until then, you can have as many populations as you have cluster nodes, and have each of them use a different value:
val commonProtocol = http…
val http1 = http.localAddress(address1)
val http2 = http.localAddress(address2)
val scn = scenario…
setUp(scn.inject(…).protocols(http1),
scn.inject(…).protocols(http2))
This is a must needed feature. So far, I have been “Scaling out” to simulate multiple IPs.
Ticket created https://github.com/gatling/gatling/issues/2725
I found the changes that implements InetAddress as an expression. Will you be kind enough to show how to use it.
Is it something like the following:
val address = "192.3.4.5"
val address2 = "192.3.4.9"
setUp(scn.inject(rampUsers(1) over (0 seconds)).protocols(httpProtocol.localAddress(address)),
scn.inject(rampUsers(1) over (0 seconds)).protocols(httpProtocol.localAddress(address2))
)
Thanks,
Abhinav
In Java, you build a InetAddress with a static factory method.
Instead of duplicating the scenarios, I would load balance manually:
val address1 = java.net.InetAddress.getByName(“192.3.4.5”)
val address2 = java.net.InetAddress.getByName(“192.3.4.9”)
httpProtocol.localAddress("${localAddress}")
def randomLocalAddress = if (ThreadLocalRandom.current.nextBoolean) address1 else address2
val localAddressFeeder = Iterator.continually(Map(“localAddress” → randomLocalAddress))
feed(localAddressFeeder)
Note that, of course, you won’t be able to do IP spoofing, but only use valid IP aliases.
We tried this way :
val address1 = java.net.InetAddress.getByName("202.168.223.60")
val address2 = java.net.InetAddress.getByName("202.168.223.63")
def randomLocalAddress = if (ThreadLocalRandom.current.nextBoolean) address1 else address2
val localAddressFeeder = Iterator.continually(Map("localAddress" -> randomLocalAddress))
feed(localAddressFeeder)
val httpProtocol1 = http
.baseURL("https://abc.com")
Stephane, Pierre? Anyone?
The change to take an Expression there is in master, not in 2.1.