加特勒重复动作

时间:2014-04-25 06:36:03

标签: scala gatling

我有一个gatling记录,现在我想要重复这个场景10次,但我遇到了一些问题,我的重复动作只在第一步触发,并且不会完成整个场景。我可以知道它有什么问题吗?我是否需要在每一步中添加repeat(10){}?下面是我的scala代码。

class Portal_Selfcare_TelephoneLine_Test1 extends Simulation {

    val httpConf = httpConfig
            .baseURL("http://10.14.24.29:7281")
            .acceptHeader("text/html, application/xhtml+xml, */*")
            .acceptEncodingHeader("gzip, deflate")
            .acceptLanguageHeader("en-US")
            .userAgentHeader("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; managedpc)")


    val headers_1 = Map(
            "Accept-Encoding" -> """gzip, deflate, peerdist""",
            "X-P2P-PeerDist" -> """Version=1.0"""
    )

    val headers_3 = Map(
            "Content-Type" -> """application/x-www-form-urlencoded""",
            "Pragma" -> """no-cache"""
    )


    val scn = scenario("New_Install_TelLine")
        .repeat(10)
        {
          exec(http("Browse_URL")
                    .get("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_1)
                    .queryParam("""_nfls""", """false""")
                    .queryParam("""_nfpb""", """true""")
                    .queryParam("""_pageLabel""", """selfcare_cus_bk""")
            )
         .pause(3)
         .exec(http("Click_ServiceRegistration")
                    .get("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_1)
                    .queryParam("""_nfls""", """false""")
                    .queryParam("""_nfpb""", """true""")
                    .queryParam("""_pageLabel""", """selfcare_consumer_serviceregistration""")
            )
        .pause(2)
        .exec(http("SelectProduct_TelLine")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/ordercapture/preorder/begin""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorder{pageFlow.userCategory}""", """Customer""")
                        .param("""s_con_registration_preorderwlw-select_key:{pageFlow.product}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{pageFlow.product}""", """Telephony - Home Line""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.quantityBField}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.quantityBField}""", """1""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.quantityRField}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.quantityRField}""", """1""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.quantityB3Field}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.quantityR3Field}OldValue""", """true""")
                        .param("""s_con_registration_preorderactionOverride:productCheck""", """Next""")
            )
        .pause(8)
        .exec(http("Fill_CustomerDetails")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/ordercapture/preorder/planCheck""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.customerCategory}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.customerCategory}""", """Personal""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.planName}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.planName}""", """No Call Plan""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.identityIdPrefix}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.identityIdPrefix}""", """New NRIC""")
                        .param("""s_con_registration_preorder{actionForm.identityID}""", """870609-10-8907""")
                        .param("""s_con_registration_preorder{actionForm.identityIDP}""", """""")
                        .param("""s_con_registration_preorder{actionForm.identityIDPo}""", """""")
                        .param("""s_con_registration_preorder{actionForm.identityIDM}""", """""")
                        .param("""s_con_registration_preorder{actionForm.oldNric}""", """""")
                        .param("""s_con_registration_preorder{actionForm.customerName}""", """""")
                        .param("""s_con_registration_preorderactionOverride:preServiceCheck""", """Submit""")
            )
        .pause(1)
        .exec(http("Choose_State")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/nisAddressSearch/changeState""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorder{actionForm.selectedState}""", """SELANGOR""")
                        .param("""s_con_registration_preorderactionOverride:changeState""", """SELANGOR""")
            )
        .pause(9)
        .exec(http("Search_Address")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/nisAddressSearch/searchAddressByStreet""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorder{actionForm.selectedState}""", """SELANGOR""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.streetType}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.streetType}""", """JALAN""")
                        .param("""s_con_registration_preorder{actionForm.streetName}""", """bunga""")
            )
        .pause(4)
        .exec(http("Select_Address")
                    .get("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_1)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorderaddressId""", """12""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/nisAddressSearch/selectAddress""")
                    .queryParam("""_nfpb""", """true""")
            )
        .pause(4)
        .exec(http("Proceed_ServiceCheck")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/nisAddressSearch/proceedWithServiceCheck""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorderactionOverride:proceedWithServiceCheck""", """Next""")
            )
        .pause(1)
        .exec(http("Show_Result")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/ordercapture/preorder/showResult""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorderactionOverride:goToTandCs""", """Proceed to Order""")
            )
        .pause(3)
        .exec(http("Proceed_Order")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/ordercapture/preorder/goToOC""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorderwlw-checkbox_key:{pageFlow.acceptTandCs}OldValue""", """false""")
                        .param("""s_con_registration_preorderwlw-checkbox_key:{pageFlow.acceptTandCs}""", """on""")
                        .param("""s_con_registration_preorderactionOverride:goToOC""", """Next""")
            )
        .pause(2)
        .exec(http("Pick_Number")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/ordercapture/verifyPickNumber""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorderwlw-checkbox_group_key:{actionForm.selectedServiceNumbers}""", """00390192953""")
                        .param("""s_con_registration_preorderwlw-checkbox_group_key:{actionForm.selectedServiceNumbers}OldValue""", """true""")
                        .param("""s_con_registration_preorderactionOverride:verifyPickNumber""", """Next""")
            )
        .pause(32)
        .exec(http("Fill_CustomerInfo")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/ordercapture/verifyOrderDetails""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorder{actionForm.fullName}""", """ROTAN""")
                        .param("""s_con_registration_preorder{actionForm.identityIdPrefix}""", """New NRIC""")
                        .param("""s_con_registration_preorder{actionForm.identityId}""", """870609-10-8907""")
                        .param("""s_con_registration_preorder{actionForm.countryCode}""", """""")
                        .param("""s_con_registration_preorder{actionForm.acctCategory}""", """Personal""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.gender}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.gender}""", """Male""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.religion}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.religion}""", """Christian""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.race}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.race}""", """Chinese""")
                        .param("""s_con_registration_preorder{actionForm.dateOfBirth}""", """""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.nationality}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.nationality}""", """Citizen""")
                        .param("""s_con_registration_preorder{actionForm.emailAddress}""", """""")
                        .param("""s_con_registration_preorderwlw-checkbox_key:{actionForm.enrollTMRewards}OldValue""", """false""")
                        .param("""s_con_registration_preorder{actionForm.hul}""", """L-4-52""")
                        .param("""s_con_registration_preorder{actionForm.floorNo}""", """""")
                        .param("""s_con_registration_preorder{actionForm.buildingName}""", """APT TERATAI BLOK L""")
                        .param("""s_con_registration_preorder{actionForm.streetType}""", """JALAN""")
                        .param("""s_con_registration_preorder{actionForm.streetName}""", """BUNGA RAYA""")
                        .param("""s_con_registration_preorder{actionForm.section}""", """TAMAN BUNGA RAYA""")
                        .param("""s_con_registration_preorder{actionForm.city}""", """SERENDAH""")
                        .param("""s_con_registration_preorder{actionForm.postcode}""", """48300""")
                        .param("""s_con_registration_preorder{actionForm.state}""", """SELANGOR""")
                        .param("""s_con_registration_preorder{actionForm.country}""", """MALAYSIA""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.homePhonePrefix}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.homePhonePrefix}""", """Please select""")
                        .param("""s_con_registration_preorder{actionForm.homePhone}""", """""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.officePhonePrefix}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.officePhonePrefix}""", """Please select""")
                        .param("""s_con_registration_preorder{actionForm.officePhone}""", """""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.mobilePhonePrefix}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.mobilePhonePrefix}""", """014""")
                        .param("""s_con_registration_preorder{actionForm.mobilePhone}""", """5678905""")
                        .param("""s_con_registration_preorder{actionForm.contactName}""", """Rotan""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.mobileNumberPrefix}OldValue""", """true""")
                        .param("""s_con_registration_preorderwlw-select_key:{actionForm.mobileNumberPrefix}""", """014""")
                        .param("""s_con_registration_preorder{actionForm.mobileNumber}""", """5678905""")
                        .param("""s_con_registration_preorder{actionForm.contactEmail}""", """rotan@gmail.com""")
                        .param("""s_con_registration_preorder{actionForm.orderRemarks}""", """""")
                        .param("""s_con_registration_preorderactionOverride:verifyOrderDetails""", """Next""")
            )
        .pause(5)
        .exec(http("Submit_Order")
                    .post("/iCarePrimePortal/selfcare.portal")
                    .headers(headers_3)
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/ordercapture/goToOrderSummary""")
                    .queryParam("""_nfpb""", """true""")
                        .param("""s_con_registration_preorderactionOverride:gotoSubmitOrderOrRewardsTnc""", """Submit""")
            )
        .pause(2)
        .exec(http("View_Confirmation")
                    .get("/iCarePrimePortal/portlets/ordercapture/preorder/PreOrderController.portlet")
                    .headers(headers_1)
                    .queryParam("""s_con_registration_preorder_netui:returnActionViewRenderer""", """org.apache.beehive.netui.tags.internal.ReturnActionViewRenderer""")
                    .queryParam("""s_con_registration_preorder_netui:returnActionCallback""", """Netui_OnPopupDone""")
                    .queryParam("""_portlet.themeAltSkeleton""", """true""")
                    .queryParam("""_portlet.title""", """Preordercontroller""")
                    .queryParam("""s_con_registration_preorder_actionOverride""", """/portlets/ordercapture/viewConfirmation""")
                    .queryParam("""_portlet.themeName""", """plain""")
                    .queryParam("""_portlet.contentType""", """text/html; charset=UTF-8""")
                    .queryParam("""s_con_registration_preorderjpfScopeID""", """s_con_registration_preorder""")
                    .queryParam("""_portlet.lafUniqueId""", """icareprime3DefinitionLabel_1""")
                    .queryParam("""_portlet.contentOnly""", """true""")
                    .queryParam("""_portlet.contentMode""", """FULL""")
                    .queryParam("""_portlet.portalId""", """selfcare_portal""")
                    .queryParam("""_windowLabel""", """s_con_registration_preorder""")
                    .queryParam("""_portlet.themeAltSkin""", """true""")
                    .queryParam("""_nfpsid""", """/portlets/ordercapture/viewConfirmation""")
                    .queryParam("""_portlet.portalUrl""", """/iCarePrimePortal/selfcare.portal""")
                    .queryParam("""_nfpb""", """true""")
                    .queryParam("""_portlet.asyncMode""", """compat_9_2""")
            )
        }
        setUp(scn.users(10).protocolConfig(httpConf))
}

2 个答案:

答案 0 :(得分:3)

我不确定您是否解决了问题。我有同样的问题,禁用缓存为我做了诀窍。

disableCaching param设置为httpProtocol配置,如下所示:

val httpConf = http
.acceptHeader("application/json") 
.acceptLanguageHeader("en-US,en;q=0.5")
.acceptEncodingHeader("gzip, deflate")
.disableWarmUp
.disableCaching

答案 1 :(得分:2)

在黑暗中进行一次拍摄:您确定第一个之后的请求不是简单地缓存吗?尝试停用caching