加特林公司;Scala:如何在循环中分割值?

加特林公司;Scala:如何在循环中分割值?,scala,performance-testing,load-testing,gatling,Scala,Performance Testing,Load Testing,Gatling,我想在循环中拆分一些值。我在check中使用了split方法,它对我很有效。但是,有两种不同类型的25个以上的值。 所以,我正在scala中实现循环,并且正在努力。 考虑下面的场景: import scala.concurrent.duration._ import io.gatling.core.Predef._ import io.gatling.http.Predef._ class testSimulation extends Simulation { val httpPro

我想在循环中拆分一些值。我在check中使用了split方法,它对我很有效。但是,有两种不同类型的25个以上的值。 所以,我正在scala中实现循环,并且正在努力。 考虑下面的场景:

import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._

class testSimulation extends Simulation {

    val httpProtocol = http
    .baseURL("https://website.com")
    .doNotTrackHeader("1")
    .disableCaching

val uri1 = "https://website.com"

val scn = scenario("EditAttribute")
    .exec(http("LogIn")
        .post(uri1 + "/web/guest/")
        .headers(headers_0)
    .exec(http("getPopupData")
        .post("/website/getPopupData")
        .check(jsonPath("$.data[0].pid").transform(_.split('#').toSeq).saveAs("pID")))  // Saving splited value
    .exec(http("Listing")
        .post("/website/listing")
        .check(jsonPath("$.data[*].AdId").findAll.saveAs("aID"))                        // All values are collected in vector 
//      .check(jsonPath("$.data[*].AdId").transform(_.split('#').toSeq).saveAs("aID"))  // Split method Not working for batch
//      .check(jsonPath("$.data[*].AdId").findAll.saveAs("aID"))                        // To verify the length of array (vector)
        .check(jsonPath("$.data[0].RcId").findAll.saveAs("rID")))
    .exec(http("UpdatedDataListing")
        .post("/website/search")
        .formParam("entityTypeId", "${pId(0)}")                                 // passing splited value,  perfectly done
        .formParam("action_id", "${aId(0)},${aId(1)},${aId(2)},..and so on)      // need to pass splitted values which is not happening
        .formParam("userId", "${rID}")
// To verify values on console (What value I m getting after splitting)...
    .exec(  session =>  {
            val abc = session("pID").as[Seq[String]]
            val xyz = session("aID").as[Seq[String]]
            println("Separated pId ===>  "   +abc(0))               // output - first splitted value
            println("Separated pId ===>  "   +abc(1))               // split separater
            println("Separated pId ===>  "   +abc(2))               // second splitted value
            println("Length  ===>   "   +abc.length)                // output - 3
            println("Length  ===>   "   +xyz.length)                // output - 25
            session
                        }
         )
    .exec(http("logOut")
        .get("https://" + uri1 + "/logout")
        .headers(headers_0))

        setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
我想实现一个循环,在会话中执行所有(25)个值的拆分。我不想做硬编码。
我也是scala和Gatling的新手。

因为它是一个会话函数,下面的代码片段将给出继续的方向,使用split就像在Java中一样:-

  exec { session =>
    var requestIdValue = new scala.util.Random().nextInt(Integer.MAX_VALUE).toString();
    var length = jobsQue.length
    try {
      var reportElement = jobsQue.pop()
      jobData = reportElement.getData;
      xml = Configuration.XML.replaceAll("requestIdValue", requestIdValue);

      println(s"For Request Id : $requestIdValue  .Data Value from feeder is : $jobData Current size of jobsQue : $length");
    } catch {
      case e: NoSuchElementException => print("Erorr")
    }

    session.setAll(
      "xmlRequest" -> xml)
  }

由于它是一个会话函数,下面的代码段将给出继续的方向,请像在Java中一样使用split:-

  exec { session =>
    var requestIdValue = new scala.util.Random().nextInt(Integer.MAX_VALUE).toString();
    var length = jobsQue.length
    try {
      var reportElement = jobsQue.pop()
      jobData = reportElement.getData;
      xml = Configuration.XML.replaceAll("requestIdValue", requestIdValue);

      println(s"For Request Id : $requestIdValue  .Data Value from feeder is : $jobData Current size of jobsQue : $length");
    } catch {
      case e: NoSuchElementException => print("Erorr")
    }

    session.setAll(
      "xmlRequest" -> xml)
  }