0
나는 BaseURL을 생성하는 두 번째 URL을 가지고 있으며, asLongAs 루프에있는 모든 사용자에게 암호를 설정하는 데 사용되는 두 번째 URL을 가지고있다. "Change_Password"인 두 번째 URL 요청에서 "counter"를 설정하는 데 문제가 있습니다. '카운터'라는 이름의 속성 'HttpRequest를 -4'실행 실패 - 그것은PUT 요청에서 카운터를 설정하는 방법은 무엇입니까?
9425 [GatlingSystem-akka.actor.default - 디스패처-11] ERROR 에러 아래 ighttp.action.HttpRequestAction 발생하지 않습니다
나는 카운터 여기서 설정할 수 없습니다입니다
,.exec(http("Change_Password")
.put(setPasswordURL + "/api/authentication/accounts/" + accountName + "https://stackoverflow.com/users/" + unm + "${counter}/actions/setPassword")
내가 .put 요청에 정적 값을 넣을 경우 잘 작동을 정의한다. 여기
는 코드import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class setPass extends Simulation {
val testServerUrl = System.getProperty("testServerUrl", "https://abcde.net")
val username = System.getProperty("username", "ma")
val password = System.getProperty("password", "ma")
val accntID = Integer.getInteger("accountID", 27280asd5).toInt
val rolID = Integer.getInteger("roleId", 272812506).toInt
val startNum = Integer.getInteger("startNum", 2).toInt
val endNum = Integer.getInteger("EndNum", 2).toInt
val userCount = Integer.getInteger("userCount", 1).toInt
val unm = System.getProperty("CreateUserName", "TestUser")
val FirstName = System.getProperty("FirstName", "Test")
val LastName = System.getProperty("LastName", "Yo")
val emailDomain = System.getProperty("EmailDomain", "@testdomain.com")
val accountName = System.getProperty("AccountName", "info")
val counter = new java.util.concurrent.atomic.AtomicInteger(startNum)
val setPasswordURL = "http://XYZ-differentURL.net:18101"
val httpProtocol = http
.baseURL(testServerUrl)
.basicAuth(username, password)
.inferHtmlResources()
.acceptHeader("""*/*""")
.acceptEncodingHeader("""gzip, deflate""")
.acceptLanguageHeader("""en-US,en;q=0.8""")
.contentTypeHeader("""application/json""")
.userAgentHeader("""Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.94 Safari/537.36""")
val headers_0 = Map(
"""Cache-Control""" -> """no-cache""",
"""Origin""" -> """chrome-extension://fhbjgbifasdsgdshghfdhdcbncdddomop""")
val headers_1 = Map(
"""Accept""" -> """application/json""",
"""Content-Type""" -> """application/json""")
val scn = scenario("sc1")
.asLongAs(session => counter.getAndIncrement() < endNum)
{
exec(http("req1")
.post("""/api/user""")
.headers(headers_0)
.body(StringBody(session =>s"""{"name": "$unm${counter.get()}" ,"roleId": $rolID, "accountId": $accntID, "firstName": "$FirstName${counter.get()}", "lastName": "$LastName${counter.get()}", "email": "$unm${counter.get()}$emailDomain"}"""))
.check(jsonPath("$.id").saveAs("UserID"))
)
.exec(http("Change_Password")
.put(setPasswordURL + "/api/authentication/accounts/" + accountName + "https://stackoverflow.com/users/" + unm + "${counter}/actions/setPassword")
.headers(headers_1)
.body(StringBody("""{"newPassword":"password"}"""))
)
}
.exec(session => session.set("count", counter.getAndIncrement))
setUp(scn.inject(atOnceUsers(userCount))).protocols(httpProtocol)
}
대신'val'을 사용하면'var counter ='를 시도 할 수 있습니까? –
'var'를 사용했지만 동일한 오류가 발생했습니다. "실행 실패 : 'counter'속성이 정의되지 않았습니다." – Peter
카운터를 설정하려면 http 요청 앞에 세션을 삽입해야합니다. –