how to repeat a scenario

4,843 views
Skip to first unread message

Zique Sousa

unread,
May 29, 2013, 11:46:51 AM5/29/13
to gat...@googlegroups.com
I created a scenario that I need to repeat several iterations, I tried using .repeat(5), but I keep on getting error message

Error message
11:42:34,365 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@33ae93c5 - Registering current configuration as sa
fe fallback point
Exception in thread "main" Compilation failed
        at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:76)
        at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:35)
        at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:29)
        at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:71)
        at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:71)
        at sbt.compiler.AggressiveCompile$$anonfun$4$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:71)


My Code:


.repeat(2){
   
    val scn = scenario("NMLSubmitMonthlyMiles")
   
    .feed(BiotronikUserCredentials)
   
    .repeat(2)
        .exec(http("Landing Page")
                    .get("https://zsousa-vm.crsinc.local/")
           
        .pause(15)
       
        .exec(http("login User")
                    .post("https://zsousa-vm.crsinc.local/system/login.php")
                    .headers(headers_2)
                        .param("""username""", """${username}""")
                        .param("""password""", """${password}""")
                        .param("""ajaxLogin""", """1""")
            )
        .pause(530 milliseconds)
       
      }

           
    setUp(scn.users(1).ramp(60).protocolConfig(httpConf))
   

}

Stéphane Landelle

unread,
May 29, 2013, 11:52:37 AM5/29/13
to gat...@googlegroups.com
What is this outer .repeat(2) doing here?
repeat is a method on chains and scenarios.




2013/5/29 Zique Sousa <zique1...@gmail.com>

--
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/groups/opt_out.
 
 

Zique Sousa

unread,
May 29, 2013, 11:58:29 AM5/29/13
to gat...@googlegroups.com
sorry, ignore the outer repeat

Stéphane Landelle

unread,
May 29, 2013, 12:07:34 PM5/29/13
to gat...@googlegroups.com
val scn = scenario("NMLSubmitMonthlyMiles")
    
    .feed(BiotronikUserCredentials)
    
    .repeat(2) { // add missing curly brace
        exec(http("Landing Page") // remove wrong leading point
                    .get("https://zsousa-vm.crsinc.local/")
         ) // add missing bracket

        .pause(15)
        
        .exec(http("login User")
                    .post("https://zsousa-vm.crsinc.local/system/login.php")
                    .headers(headers_2)
                        .param("""username""", """${username}""")
                        .param("""password""", """${password}""")
                        .param("""ajaxLogin""", """1""")
            )
        .pause(530 milliseconds)
        
      }

            
    setUp(scn.users(1).ramp(60).protocolConfig(httpConf))


2013/5/29 Zique Sousa <zique1...@gmail.com>

Zique Sousa

unread,
May 29, 2013, 12:28:49 PM5/29/13
to gat...@googlegroups.com
didnt work.

I am including the entire program
package BMLSubmitMilesClearMiles
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import com.excilys.ebi.gatling.http.Headers.Names._
import akka.util.duration._
import bootstrap._
import assertions._

class NMLSubmitMiles extends Simulation {

    val httpConf = httpConfig
            .baseURL("https://zsousa-vm:443")
            .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
            .acceptEncodingHeader("gzip, deflate")
            .acceptLanguageHeader("en-US,en;q=0.5")
            .connection("keep-alive")
            .userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0")


    val headers_2 = Map(
            "Cache-Control" -> """no-cache""",
            "Content-Type" -> """application/x-www-form-urlencoded; charset=UTF-8""",
            "Pragma" -> """no-cache""",
            "X-Requested-With" -> """XMLHttpRequest"""
    )

    val headers_4 = Map(
            "Content-Type" -> """application/x-www-form-urlencoded"""
    )

    val headers_11 = Map(
            "X-Requested-With" -> """XMLHttpRequest"""
    )

    val headers_17 = Map(
            "Accept" -> """text/javascript, text/html, application/xml, text/xml, */*""",
            "Cache-Control" -> """no-cache""",
            "Content-Type" -> """application/x-www-form-urlencoded; charset=UTF-8""",
            "Pragma" -> """no-cache""",
            "X-Prototype-Version" -> """1.6.0.3""",
            "X-Requested-With" -> """XMLHttpRequest"""
    )

    val BiotronikUserCredentials = csv("biotronik_user_data.csv").queue

   
   
   
   
    val scn = scenario("NMLSubmitMonthlyMiles")
 
   
    .feed(BiotronikUserCredentials)
        .repeat(2) {
   
        .exec(http("Landing Page")
                    .get("https://zsousa-vm")

            )
        .pause(15)
       
        .exec(http("login User")
                    .post("https://zsousa-vm.crsinc.local/system/login.php")
                    .headers(headers_2)
                        .param("""username""", """${username}""")
                        .param("""password""", """${password}""")
                        .param("""ajaxLogin""", """1""")
            )
        .pause(530 milliseconds)
        }
        .exec(http("Mileage Entry Page")
                    .get("https://zsousa-vm.crsinc.local/system/enterMileage.php")
                    .check(currentLocation.is("https://zsousa-vm.crsinc.local/system/enterMileage.php"))
                    )
       
        .exec(http("Submit Miles and Odometer Reading")
                    .post("https://zsousa-vm.crsinc.local/system/enterMileage.php")
                    .headers(headers_4)
                        .param("""miles""", """${miles}""")
                        .param("""month""", """201305""")
                        .param("""odometer_reading""", """333333""")
                        .param("""save_current""", """Submit May 2013 business miles""")
                        .param("""last_daily_odometer""", """""")
            )
        .pause(3)
        .exec(http("Confirm Submission")
                    .post("https://zsousa-vm.crsinc.local/system/enterMileage.php")
                    .headers(headers_4)
                        .param("""month""", """201305""")
                        .param("""confirm_current""", """1""")
            )
        .pause(4)
        .exec(http("logout user")
                    .get("https://zsousa-vm.crsinc.local/system/logout.php")
            )
        .pause(6)
        .exec(http("login CRS Admin")

                    .post("https://zsousa-vm.crsinc.local/system/login.php")
                    .headers(headers_2)
                        .param("""username""", """zsousa""")
                        .param("""password""", """1""")

                        .param("""ajaxLogin""", """1""")
            )

       
        .pause(10)
        .exec(http("Go to Driver")
                    .post("https://zsousa-vm.crsinc.local/system/driverSearch.php")
                    .headers(headers_4)

                        .param("""username""", """${username}""")
                        .param("""x""", """40""")
                        .param("""y""", """5""")
            )
        .pause(2)
       
        .exec(http("viewMileageHistory")
                    .post("https://zsousa-vm.crsinc.local/system/groupadmin/viewMileageHistory.php")
                    .headers(headers_4)
                    .queryParam("""id""", """${driverid}""")
                    .queryParam("""modify_mileage_entry""", """${monthlymileageid}""")
                        .param("""miles""", """${miles}""")
                        .param("""odometer""", """333333""")
                        .param("""entered_timestamp""", """2013-05-22 08:50AM""")
                        .param("""id""", """${driverid}""")
                        .param("""modify_mileage_entry""", """${monthlymileageid}""")
                        .param("""clear""", """Clear""")
                        .param("""change_explain""", """""")
            )
        .pause(2)
        .exec(http("Confirm clear mileage")
                    .post("https://zsousa-vm.crsinc.local/system/groupadmin/viewMileageHistory.php")
                    .headers(headers_4)
                    .queryParam("""id""", """${driverid}""")
                    .queryParam("""modify_mileage_entry""", """${monthlymileageid}""")
                        .param("""confirm_clear""", """Submit""")
            )
        .pause(5)
        .exec(http("CRS Admin logout.php")
                    .get("https://zsousa-vm.crsinc.local/system/logout.php")
            )

           
    setUp(scn.users(1).ramp(60).protocolConfig(httpConf))

   
 

}

On Wednesday, May 29, 2013 11:52:37 AM UTC-4, Stéphane Landelle wrote:

Stéphane Landelle

unread,
May 29, 2013, 12:32:19 PM5/29/13
to gat...@googlegroups.com
Didn't work because you didn't remove this wrong leading dot on "Landing Page" as instructed.


2013/5/29 Zique Sousa <zique1...@gmail.com>

Zique Sousa

unread,
May 29, 2013, 1:03:19 PM5/29/13
to gat...@googlegroups.com
worked. one more question. If I wanted to repeat the entire scenario would I remove the dot from every single ".exec"?

Stéphane Landelle

unread,
May 29, 2013, 4:00:45 PM5/29/13
to gat...@googlegroups.com
What do you mean? Repeat the sequence, or repeat every step of the scenario?


2013/5/29 Zique Sousa <zique1...@gmail.com>

Zique Sousa

unread,
May 31, 2013, 9:49:01 AM5/31/13
to gat...@googlegroups.com
repeat the step of every scenario

Stéphane Landelle

unread,
May 31, 2013, 10:38:39 AM5/31/13
to gat...@googlegroups.com
You'll have to add a repeat on each action.


2013/5/31 Zique Sousa <zique1...@gmail.com>

Firmo19

unread,
Jan 12, 2015, 8:22:56 AM1/12/15
to gat...@googlegroups.com
If a repeat is added to each action can you advise how they are expected. For example will action 1 be repeated twice then Action 2?

John Arrowwood

unread,
Jan 13, 2015, 10:41:31 AM1/13/15
to gat...@googlegroups.com
Gatling DSL is a programming language.  It will do what you tell it to do.  So the answer to your question is, it depends on how you code it.  And you know, you can always code things up and run them to see what they do.
Reply all
Reply to author
Forward
0 new messages