Repeat Scenario Functionality for typeahead search

94 դիտում
Անցնել առաջին չկարդացված հաղորդագրությանը

Sanjaya Kapoor

չկարդացված,
20 նոյ, 2015 թ., 20:17:3020.11.15
– 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

չկարդացված,
21 նոյ, 2015 թ., 02:47:1221.11.15
– 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

չկարդացված,
23 նոյ, 2015 թ., 13:40:5823.11.15
– 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

չկարդացված,
23 նոյ, 2015 թ., 13:59:1923.11.15
– gat...@googlegroups.com
You're missing a dot before the call to repeat :)

Sanjaya Kapoor

չկարդացված,
23 նոյ, 2015 թ., 14:08:5923.11.15
– 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 նոր հաղորդագրություն