本文介绍了Gatling Scala:无法使用会话变量将身份验证令牌发送到方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

似乎下面的代码中使用的会话变量无法传递令牌类型->使用会话变量的Bearer和access_token,这是完整的代码,您可以看看,这里提供了代码..no担心所有令牌都是虚拟令牌,因为我在粘贴代码之前没有更改过.Test希望先执行登录方法,然后再执行CreatePrivateEvent方法,因为后者从Login方法获取令牌,因此我已经写了

It seems session variable used in below code is not able to pass the Token Type --> Bearer and access_token using session variable,here is the full code ,is it possible with you to have a look ,here is code provided ..no worries all tokens are dummy tokens as i haven changed before pasting code here.Test expects the login method to be executed first and then the CreatePrivateEvent method as the latter takes tokens from Login method hence i have written

从日志中查找令牌类型->通过登录方法成功生成了Bearer和access_token,但同一令牌未传播到CreatePrivateEvent方法.

From Logs It looks Token Type --> Bearer and access_token are successfully generated by Login Method but the same token is not propagated to CreatePrivateEvent method.

您会建议使用其他任何建议使用会话变量的方式吗?

any other way you can suggest to use session variable would be highly welcomed?

val scenario4 = scenario("Create Private Events ").exec(login).exec(createPrivateEvent())

package simulations

import baseConfig.BaseSimulation
import com.jayway.jsonpath.JsonPath
import io.gatling.core.Predef._
import io.gatling.core.session
import io.gatling.http.Predef._

import scala.concurrent.duration._
import scala.concurrent.forkjoin.ThreadLocalRandom
import scala.language.postfixOps
import scala.math._
import scala.concurrent.duration.DurationInt
import scala.io.Source


class gamekeeper extends BaseSimulation {


  val uri2 = "https://api.platform.abc.com"


  val headers_3 = Map(
  "accept" -> "application/json, text/plain, */*",
  "cache-control" -> "no-cache",
   "origin" -> "https://myaccounts.wi.com",
   "pragma" -> "no-cache",
   "referer" -> "https://myaccounts.abc.com/login?redireretailer-   stage.abc.com%2F",
    "sec-fetch-mode" -> "cors",
  "sec-fetch-site" -> "same-site")


  val headers_10 = Map("Content-Type" -> "application/json","Authorization" -> "${token_type} +
  ${access_token}" )

  val headers_PrivateEvent = Map(
   "Content-Type" -> "application/json",
    "Authorization" -> "${token_type} + ${access_token}"

 )

val usersDataSource=jsonFile("C:/Gatling2/gatling3james/src/gatling/resources/data/input-
gamekeeper.json").circular
val nameDataSource=jsonFile("C:/Gatling2/gatling3james/src/gatling/resources/data/input-
gamekeeper-StringBody.json").random




 val source: String = Source.fromFile("C:/Gatling2/gatling3james/src/gatling/resources
 /data/input-gamekeeper.json").getLines.mkString
  def userCount: Int  = JsonPath.parse(source).read("$.[0].user")
 def testDuration: Int  = JsonPath.parse(source).read("$.[0].testDuration")
 def rampDuration: Int  = JsonPath.parse(source).read("$.[0].rampDuration")


  // print out the properties at the start of the test
  before {
  println(s"Running test with ${userCount} users")
    println(s"Ramping users over ${rampDuration} seconds")
  println(s"Total Test duration: ${testDuration} seconds")
  }



 def createPrivateEvent()={

    exec(http("Create Private Event")


      .post("https://api.tabletop-stage.tiamat-origin.cloud/dev/event-reservations-service
  /PrivateEvents")
      .headers(headers_PrivateEvent)


      .body(StringBody(
        """
          |{
          |  "eventId": 0,
          |  "name": "new Event",
          |  "description": "This event is gonna be uh-maaaazing",
          |  "format": "draft",
          |  "gamesToWin": 2
          |}
        """.stripMargin)).asJSON

      .check(status.in(200,201))
      .check(jsonPath(path="$.name").is("new Event"))
      .check(jsonPath(path="$.eventId").saveAs(key="eventId")))
      .exec{session=>println(session);session}
    .pause(1)

  }

  val login = exec( exec(http("PlatForm Auth Url")
  .post(uri2 + "/auth/oauth/token")
  .headers(headers_3)
  .formParam("grant_type", "password")
  .formParam("username", "[email protected]")
  .formParam("password", "c0Ba5PBdvVl2")
  .basicAuth("NznShwKmLPMErYkfuvyynfA9","r2Rgx89aCFTfjbj7TU59sL8q")
  .check(jsonPath("$.access_token").exists.saveAs("access_token"))
  .check(jsonPath("$.token_type").exists.saveAs("token_type")))



  )


  val scenario4 = scenario("Create Private Events ").exec(login).exec(createPrivateEvent())


 setUp(

scenario4.inject(
  nothingFor(5 seconds),
  rampUsers(userCount) over ( rampDuration ))
  .protocols(httpConf))
.maxDuration(testDuration)
}

以下是详细的加特林控制台日志:-

Here is detailed Gatling console logs:-

            Running test with 10 users
            Ramping users over 2 seconds
            Total Test duration: 20 seconds
            Simulation simulations.gamekeeper started...

            ================================================================================
            2020-01-24 13:53:33                                           5s elapsed
            ---- Requests ------------------------------------------------------------------
            > Global                                                   (OK=0      KO=0     )


            ---- Create Private Events  ----------------------------------------------------
            [                                                                          ]  0%
                      waiting: 10     / active: 0      / done:0
            ================================================================================

            13:53:35.197 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,3,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@65999bbf, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0NmM4YTY1NTBlZGI5MDRjM2IyNWI3ODlmOTllNjU3ODA4MGJiOTUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzQsImlhdCI6MTU3OTkwMjgxNCwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6IkY3VlNaWllEWkpHUk5EU1UzRlpRMjRLWFRZIiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.JiLiOolxFWWEg0Zz-lKMNrGrn2gLMGW3akuBREsiVfF09eITi768bZ9AbfgBHjH3Ubz2HQBFMu59597AefLiUH8cOwUjValp8Cf3ZjwqpkdrkQXAfYjs-8t2h-Xs6Df0uhEw3rit9XFqDvtudkw1JvdzCIqGFxO17spy9Nsd2sTFtVOkMh1nFyeBMTZfAVVHL3oy1b3FpgJqAvNqaDBxdkpIcQqVtJoxM5aYJ4o-GjeSDE9HPCSq1mM0Yww2yaj5GjHFbGDa9w_7G2xS7kHomHlRh20bw5FkFd0Sj70D_JpomD9ywYOHcWTFyQnZ2zeKBZCBhMk42Z8paR0YlOnKEQ, token_type -> Bearer),1579902814543,10,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)
            13:53:35.229 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,1,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@330ff641, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0NmM4YTY1NTBlZGI5MDRjM2IyNWI3ODlmOTllNjU3ODA4MGJiOTUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzQsImlhdCI6MTU3OTkwMjgxNCwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6IkxFVk1PN1NWWE5DVkRLTU1ZRUMzTVpLTENZIiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.plrBZLzb620EZ5e8dKH4xiBUJ0UkrtBUmE6gPU5HbsoC9JVchztWT4wFk-0TdQRXozMz70GifyPoGRzHhcIJllOIRr_y8BPppTpTcFRNAKp8GB2_x2PMiZmi8I37fnmIwhgTixZBiy_FTEcieJ7Ib47K7_aAZnx7sEs0wt39waUHoSdY8j8iAOO8EadzJCLPS_cH6bCZRl0vbNYLI2O0d3qVAwH3e4M_lznZtprBaNKNyVImKxCpM0a601DxrhjnJgEgyJvwNLJX_n2PxXHV9BPSUmF5V6yX_QHqnXmEmip3XQnJEYjYi1olyD1Uq3yn2vKy3X10W5YriMjSCSFq-w, token_type -> Bearer),1579902814144,123,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)
            13:53:35.230 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,2,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@3f4621ef, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0NmM4YTY1NTBlZGI5MDRjM2IyNWI3ODlmOTllNjU3ODA4MGJiOTUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzQsImlhdCI6MTU3OTkwMjgxNCwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6IlRFRUEyMlA2TFZDNlJNS1NTN0o2WTVTRTc0Iiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.V_EHIsy1d8012eeitMwFN12-57SiWqVW2QTsBZWnJm0kq-1hYe7XYZ7PvPXCsw0ZSmIrYuQCZtCXt2zKPmDEEAlJj3rRoD-SYAxVSyeNjFObn2VnvjXzv4iVwP9R1bU8Ufbysot2nQOCFVZ3u02hbWVkm-AJA9DWcJhgb03eaCyT4ZGsxBHr3PJtfG352ankjJg4ODTSuGMc1QvryrRwHRi-AbTyDt0Gz2hl77zURHAi09rEjmKn-my6CMCVGPC5kMNOZTeJUosF8TnIw4og-njL2Th1Z-vMy35Uv_uOiV883eIn3AupusX0o6OducEugPW_3F8SuAq2cMIHJYareA, token_type -> Bearer),1579902814342,43,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)
            13:53:35.294 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,4,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@4c762bfc, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0NmM4YTY1NTBlZGI5MDRjM2IyNWI3ODlmOTllNjU3ODA4MGJiOTUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzQsImlhdCI6MTU3OTkwMjgxNCwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6IlBERTZBRzQ0REJHVjVBNURRUEY2M1JRU1RJIiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.lq0zRb72CTU4YSuEG0fiLyuCtG1CGez3_aV3SUrtokGEdLDIw1EImztNH950CfABCQ6ngmxVZRzZdqJ5gm7gZLQcu4VTlS0uAFWfIN2vyejUJZuqbO3YJ9TfdNp4h49pLFTX52u6Xwi6r5f4K_FV0QnOitqhJtaKdxdA4Hll4pXr_V5J-fuV9l0Iw6tXrasTzzkIwXQQerCwk5AcsaA9oijQ-W2GS3eDdhtii4aJJKBWt0LGopD9-GlmJkpOPJ7MMVcNIN7m0gUILEhX2c8Ay3neVnbZjrVWSfQ2R5MIEyOczCQT9pVKordKmcGdp8VfCPoslg0_o3dp8xm9WAJVSw, token_type -> Bearer),1579902814743,3,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)
            13:53:35.514 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,5,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@56bbd1db, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0NmM4YTY1NTBlZGI5MDRjM2IyNWI3ODlmOTllNjU3ODA4MGJiOTUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzUsImlhdCI6MTU3OTkwMjgxNSwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6Ik42Q0NKQzNMRTVBRUZPMzQ1WElCS1JZV1ZRIiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.nP91KlPVDqiIl2yBaxXj_5YOuTJ_qegY7paeOl0mUOsRKo0orob-YwgS7is4beLur6grLlGZsV_BDOo5zbiMy3LKg-XNynq8Wr8k4yALDGuUP7T-SvbX_hGG8jP1-ZcLJ_GDA0_mFHEFy5O8wscM4Vmj0iPazqusSh7L1klP0KVcCpsHzq2OdFQZAV857qnEshWSd1J9UomSLQ496mnXx3sAnfVeCJmDoIOeln670TvJqOT2Fp5mO4ABqW8BRprZHF42bozCB6xiqjTA1E4oNVxCXegoFHG-zz2NcW7FbuJaQ0PRYkfPFnwRpbZaQPoMDdZp2ZWFAzT2hwV3O-V7zg, token_type -> Bearer),1579902814943,3,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)
            13:53:35.696 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,6,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@462648e4, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0NmM4YTY1NTBlZGI5MDRjM2IyNWI3ODlmOTllNjU3ODA4MGJiOTUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzUsImlhdCI6MTU3OTkwMjgxNSwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6Iks1S0NKVUlYVUZDUkRNRExUNE1CUlFLWlVRIiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.C6_ElcB9H8SbdfxcbGBdNA4qOlisFi9wuQnHO9F-_GHzG63GCM-cWHGxX1HF22Y3dhYO8iUvXYv2w0iFtJmi_jc-TZVKwsNbperZSUEPvZDZ2nxGQPbU8g7CqgW2a1Sb-NCsE_rt4TGOSmdVYyH5d2sjNMiiEDqjbTJ6CZVo5LLBngO2fzp3hoptQClEPI7a6Y3I18FTl3l3ghLsodKGNS272TQFT78vBd4JssNHlT3heKnIPLA0bmXvX0G2N6c7Qgbos2LB-C01rbAzGQOR_mIxhRJzxRmi7rVEup6WtjcPKmulAX0gfxumHiuY7bGs8tNK2BI6HAqfJp9arngfKA, token_type -> Bearer),1579902815143,2,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)
            13:53:35.866 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,7,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@1f5eb0d8, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6ImQwNGMxYzYxNTkwNDBmZGRhN2FlYjI0ODViOWU0MTBlZDM0ZDJkMDgiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzUsImlhdCI6MTU3OTkwMjgxNSwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6IjZTR0lBTVdaVkZDSUhIRzJQNjRRU0JQUlJZIiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.S2jvg1jLJAftEeOXzqKhY5XQxHwk6y3L6mRcNwBs8dgeZDEcZLNS7_k1SMgIcovd_-ud9NFqqT2pmnPGjvreOP0yNwP6fgzs7e_RiD1OTCD61yHlwJUEFEAwz8JhT0iR-PSH1wtygvrj4D3y0dYR5SJQkZal7ocq13gJGbIH_gOSbqkVgjB2Z6wHGyR31E8t54JpkPYOuQcu_ULb8O3f6L85gJRbql0ZyLOoUyNSWbwLWYkvgwlTbDOAtTVd07pnB0NzaECTtKuVLpD2Ci-s8w89LTbcAJ-fywS0A8k_ocr1Yiu-G_rX-fxNKGLnAv9z_kV9sQ-JuV5KnFfGFoNAZw, token_type -> Bearer),1579902815341,3,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)
            13:53:36.016 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,8,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@38dc8850, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0NmM4YTY1NTBlZGI5MDRjM2IyNWI3ODlmOTllNjU3ODA4MGJiOTUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzUsImlhdCI6MTU3OTkwMjgxNSwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6IkFWNlhHQkNDNjVDQlRDT0JIUkZLRDVOUkdJIiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.k4_bK6wP5fnTx2sF95lZr1PnX99u1vxYItsAOcDprsrbJwsWaEpgVZ_EJdPueb5JFsQwkgGlwLr0tx47YaBUP06z4sdbHEuCZsCeqogRLAk_W3AYGe6rkyJkBeyehVInyONm3y2ztMa9ZIOauaxN1aOYofjXXHfrUdIUXVxLP8UtyfZ6XYAVIm_c6_9j4NDq6meBzJ-NRAO2BRTusqm12yNdo9OWUybKIZi_A7ITAFpwcUp-NKy1rjdnUv6nT73D7EWEJ_c57tDdrmYgYPtFFFXi8UXwz9JD-U8YMCFM8j1rIgsi1MRX5IwvQ_rnKuMTk8uE-LqwZS0mSiLKLmd52g, token_type -> Bearer),1579902815542,3,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)
            13:53:36.204 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,9,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@1b480c45, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0NmM4YTY1NTBlZGI5MDRjM2IyNWI3ODlmOTllNjU3ODA4MGJiOTUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzUsImlhdCI6MTU3OTkwMjgxNSwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6IlpTVFo1RzRGMk5EM0ZLUEtPRzVBTEpCSDM0Iiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.mvi_WusCY2aqjnUaJkhCdZwS3e4RGmch2dFHdMTzPCsggrn5_Mhjhlee4WQZPIUVHqqxUKhUTrpThar9OKspb5O8qQOZ9xASkMtapxNS3dQH4lz5sN-dTTnuEgOjRFtXgap1W0XKiBGa1TjbDYQQ57Y9cXG0Zl-UF6g7kHTjybygAhOv3rOdOPzOutOu8Pljkc_Il0a_Sv_t1A2n2p_LBwAVZwldI5y9lY5nNpGV-E693d5eNd-NAc_CLnOyTvyQQ2K36psGFkP2Zhy9Re2oGsD1iouQJcuPnZFeOGFxaNQSaiyc8IBC84snVdPxM8uvcO_7kryTIj2huKwXdG85QA, token_type -> Bearer),1579902815742,3,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)
            13:53:36.412 [WARN ] i.g.h.a.ResponseProcessor - Request 'Create Private Event' failed: status.find.in(200,201), but actually found 401
            Session(Create Private Events ,10,Map(gatling.http.cache.dns -> io.gatling.http.resolver.ShuffleJdkNameResolver@61d1e6b7, access_token -> eyJhbGciOiJSUzI1NiIsImtpZCI6IjM0NmM4YTY1NTBlZGI5MDRjM2IyNWI3ODlmOTllNjU3ODA4MGJiOTUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJOem5TaHdLbUxQTUVyWWtmdXZ5eW5mQTkiLCJleHAiOjE1Nzk5MDM3NzYsImlhdCI6MTU3OTkwMjgxNiwiaXNzIjoiNENVNlRCUENSWkdSTkVXRkROQTZDRkRQNTQiLCJzdWIiOiJZSlJEQUc2SDNCRlRYSkE0RlJCRVhVSFE1TSIsIndvdGMtbmFtZSI6ImF1dG9tYXRpb25TdG9yZUFkbWluMSM4ODU3NCIsIndvdGMtZG9tbiI6IndpemFyZHMiLCJ3b3RjLWdhbWUiOiJwbGF0Zm9ybSIsIndvdGMtZmxncyI6MSwid290Yy1yb2xzIjpbXSwid290Yy1wcm1zIjpbXSwid290Yy1zY3BzIjpbImZpcnN0LXBhcnR5Il0sIndvdGMtcGRnciI6Ikc0NFVSVTNGS1ZCQ0RQTTNKNVhEWktGVzZZIiwid290Yy1zZ3RzIjpbXSwid290Yy1zb2NsIjp7fX0.WwzKSRj7YjY5j9QHvPNgcIc96Z0IvYmfJQ6526UPESpwceuvV-e_ItZYEAvj9-cCT7LdwzcROiuGDK1fTTjCilFdFTdb2HLHunscj9DEP6zS89JDi6QAsMjoLcVeMgbRDwotV12i-lByHQspMfLxjuB3jTY1YtSyFrHR7xgXCIELsZm2hAWwhr7cgaYugk8Va8PhUopgnqxrFQP4mssUZzraRz9G7FbKhmegrdhJ1dDuNGSKpnZCo3EeE2G5BJYsZpo7nAEVBWI5lN_8QikblLC-NUahyiEbG0UC_Gjt2pIqk9sgbzT-zGH2MwHVru8GQZ3yakZhATsvs0F0r-uuTA, token_type -> Bearer),1579902815939,5,KO,List(),io.gatling.core.protocol.ProtocolComponentsRegistry$$Lambda$450/657998502@582153b5)

            ================================================================================
            2020-01-24 13:53:37                                           9s elapsed
            ---- Requests ------------------------------------------------------------------
            > Global                                                   (OK=10     KO=10    )
            > PlatForm Auth Url                                        (OK=10     KO=0     )
            > Create Private Event                                     (OK=0      KO=10    )
            ---- Errors --------------------------------------------------------------------
            > status.find.in(200,201), but actually found 401                    10 (100.0%)

            ---- Create Private Events  ----------------------------------------------------
            [##########################################################################]100%
                      waiting: 0      / active: 0      / done:10
            ================================================================================

            Simulation simulations.gamekeeper completed in 8 seconds
            Parsing log file(s)...
            Parsing log file(s) done
            Generating reports...

            ================================================================================
            ---- Global Information --------------------------------------------------------
            > request count                                         20 (OK=10     KO=10    )
            > min response time                                    123 (OK=311    KO=123   )
            > max response time                                    546 (OK=546    KO=359   )
            > mean response time                                   297 (OK=371    KO=224   )
            > std deviation                                        108 (OK=73     KO=86    )
            > response time 50th percentile                        325 (OK=348    KO=201   )
            > response time 75th percentile                        356 (OK=357    KO=296   )
            > response time 95th percentile                        475 (OK=512    KO=359   )
            > response time 99th percentile                        532 (OK=539    KO=359   )
            > mean requests/sec                                      5 (OK=2.5    KO=2.5   )
            ---- Response Time Distribution ------------------------------------------------
            > t < 800 ms                                            10 ( 50%)
            > 800 ms < t < 1200 ms                                   0 (  0%)
            > t > 1200 ms                                            0 (  0%)
            > failed                                                10 ( 50%)
            ---- Errors --------------------------------------------------------------------
            > status.find.in(200,201), but actually found 401                    10 (100.0%)
            ================================================================================

            Reports generated in 1s.
            Please open the following file: C:\Gatling2\gatling3james\results\gamekeeper-1579902807997\index.html

            Process finished with exit code 0

推荐答案

您是否确定授权"->"$ {token_type} + $ {access_token}" 吗?

通常格式是这样的 Bearer eyJhbGciOiJSU .

因此,请尝试授权"->"$ {token_type} $ {access_token}"

这篇关于Gatling Scala:无法使用会话变量将身份验证令牌发送到方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:36