Repeat Scenario Functionality for typeahead search

已查看 94 次
跳至第一个未读帖子

Sanjaya Kapoor

未读,
2015年11月20日 20:17:302015/11/20
收件人 Gatling User Group
Hi All,

I am trying to build a scenario for a typeahead search. The typeahead doesn't kick in till 3 characters are typed. I have following code written for it. 
val typeaheadparam = csv("SearchTermUS.csv")
val typeaheadservice = scenario("Typeahead Service")
.feed(typeaheadparam)
exec( session => { 
repeat((session("SearchTermUS").as[String]).length() - 3,"Counter") {
println("Search Term : " + (session("SearchTermUS").as[String]))
println("Search Term Length : " + (session("SearchTermUS").as[String]).length())
println("Inside the Long Loop, Count Value : " + session("Counter").as[Int])
exec(http("Typeahead Service")
.headers(common_header)
.queryParam("term",(session("SearchTermUS").as[String]).substring(0,session("Counter").as[Int]+3))
.queryParam("lang_locale","en_US")
.queryParam("limit","4")
.check(status.is(200))) }
// println( "Search with term : " + (session("SearchTermUS").as[String]).substring(0,session("Counter").as[Int] +3))
// pause(1)
session } )

The code does compile. The problem is when it is being executed using the following command
searchServiceScenario.typeaheadservice.inject(rampUsersPerSec(1) to(peakRPSScenario1) during (rampTime seconds), constantUsersPerSec(peakRPSScenario1) during(steadyTime seconds))

It goes in repeat loop but is not in the executing any request. 

What's wrong in the above code?

Regards,
Sanjaya

Stéphane LANDELLE

未读,
2015年11月21日 02:47:122015/11/21
收件人 gat...@googlegroups.com
You can't use Gatling DSL inside functions.
Gatling DSL components are builders that are only built once, when the Simulation is loaded.
So, what you've done just creates new builders at runtime and discard them, they're not par of the scenario chain.
You have to pass functions:

repeat(session => session("SearchTermUS").as[String].length() - 3,"Counter") {


Stéphane Landelle
GatlingCorp CEO


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sanjaya Kapoor

未读,
2015年11月23日 13:40:582015/11/23
收件人 gat...@googlegroups.com
Thanks Stephane,

I did try the above way. It is still not resulting in any request being sent to server. Below is the modified code


    val typeaheadservice = scenario("Typeahead Service")
                    .feed(typeaheadparam)
                    repeat(session => session("SearchTermUS").as[String].length() - 3,"Counter") {
                            exec(http("Typeahead Service")
                                        .get("""http://search.abc.com/onestore/store/typeahead.json""")
                                        .headers(common_header)
                                        .queryParam("callback","nike.gadget.OneNikeNav.typeAheadCallback")
                                        .queryParam("term","""${SearchTermUS}.as[String].substring(0,session("Counter").as[Int]+3)""")

                                        .queryParam("lang_locale","en_US")
                                        .queryParam("limit","4")
                                        .check(status.is(200)))
                         }


Regards,
Sanjaya

--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/FUAYM6pbW3Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+u...@googlegroups.com.

Pierre DAL-PRA

未读,
2015年11月23日 13:59:192015/11/23
收件人 gat...@googlegroups.com
You're missing a dot before the call to repeat :)

Sanjaya Kapoor

未读,
2015年11月23日 14:08:592015/11/23
收件人 gat...@googlegroups.com
Opps, thanks.

It's now sending the request.
unfortunately it's not the parameterization isn't working. I tried below two ways to extract the value in query param.


.queryParam("term","""${SearchTermUS}.as[String].substring(0,session("Counter").as[Int]+3)""")
 - Compiled fine, but not replacing the parameter value.

.queryParam("term","""${SearchTermUS}""".substring(0,session("Counter").as[Int]+3)) - compile error - error: not found: value session

What am I missing here?


Thanks,
Sanjaya
回复全部
回复作者
转发
0 个新帖子