0
私のスクリプトを実行すると、アプリケーションへのログインは成功します。私はすべてのクッキーを取得し、次のリクエストで送信します(リクエストはブラウザと同じように見えますが)。次のステップは失敗します。失敗するステップは、リクエスト "user"です。私は200の代わりに302を取得します。私のシナリオでは何が間違っているのでしょうか?たぶんクッキーポリシーの問題です。たとえばJMeterでは、クッキーポリシーと実装を指定できます。 JMeterの類似のシナリオが動作します。私のシナリオ:ギャトリングがアプリケーションにログインできません
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class TestScenario extends Simulation {
val httpProtocol = http
.baseURL("https://test.test.net")
.inferHtmlResources(BlackList(""".*\.css""", """.*\.js""", """.*\.jpg""", """.*\.png""", """.*\.gif""", """.*\.ico"""), WhiteList())
.acceptHeader("application/json, text/plain, */*")
.acceptEncodingHeader("gzip, deflate, br")
.acceptLanguageHeader("en-US,en;q=0.5")
.connectionHeader("close")
.userAgentHeader("Mozilla/5.0 (Windows NT 6.3; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0")
//.disableAutomaticReferer
val headers_standard = Map(
"Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Encoding" -> "gzip,deflate,sdch",
"Accept-Language" -> "pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4",
"User-Agent" -> "Mozilla/5.0(WindowsNT6.3;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/48.0.2564.116Safari/537.36")
val headers_referer = Map(
"Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Encoding" -> "gzip,deflate,sdch",
"Accept-Language" -> "pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4",
"User-Agent" -> "Mozilla/5.0(WindowsNT6.3;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/48.0.2564.116Safari/537.36",
"Referer" -> "https://test.test.net")
val headers = Map("Content-Type" -> "application/json;charset=utf-8")
val uri1 = "https://test.test.net:443"
val uri2 = "https://test.test.net:443"
val scn = scenario("Test scenario")
.exec(
http("First step")
.get("/main").headers(headers_standard)
.disableFollowRedirect
.check(
status.is(302)
)
)
.exec(
http("Login Service")
.get(uri1 + "/login?service= https%3A%2F%test.test.net")
.headers(headers_standard)
.disableFollowRedirect
.check(
status.is(401),
regex("""input type="hidden" name="execution" value=""").exists,
regex("""input type="hidden" name="execution" value="(.+?)"""").saveAs("execution")
)
)
.exec(
http("Log in")
.post(uri1 + "/login?service=https%3A%2F%test.test.net")
.headers(headers_referer)
.disableFollowRedirect
.formParam("username", """user""")
.formParam("password", "pass")
.formParam("execution", "${execution}")
.formParam("_eventId", "submit")
.check(
status.is(302),
headerRegex("Location", "ticket=(.+).dev").saveAs("ticket")
)
)
.exec(
http("Ticket")
.get("/")
.queryParam("ticket","${ticket}.dev")
.headers(headers_referer)
.check(
status.is(200),
regex("""<meta name="generator" content="HTML Tidy for HTML5""").exists
)
)
.exec(
http("user")
.get("/user")
.headers(headers)
.disableFollowRedirect
.check(
status.is(200),
regex("""Work in the""").exists
)
)
.exec(
http("Log out")
.get(uri1 + "/logout")
.headers(headers)
.check(
status.is(200),
regex("""Successful log out""").exists
)
)
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
デバッグモードで実行し、エラーが何であるかを確認します。これはGatlingの問題のようには見えません...リクエストを送信すると、ログは何を通知するのですか..アプリケーションログ – user666