Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ví dụ sử dụng Gatling.io Cloud365
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class RecordedSimulation extends Simulation {
val httpProtocol = http
.baseUrl("http://10.10.10.86")
.inferHtmlResources()
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.9")
.upgradeInsecureRequestsHeader("1")
.userAgentHeader("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36")
val headers_0 = Map(
"Proxy-Connection" -> "keep-alive",
"Purpose" -> "prefetch")
val headers_2 = Map(
"Origin" -> "http://10.10.10.86",
"Proxy-Connection" -> "keep-alive")
val scn = scenario("RecordedSimulation")
.exec(http("truy_cap_trang_chu")
.get("/")
.headers(headers_0))
.pause(2)
.exec(http("chuyen_sang_trang_admin")
.get("/admin/")
.check(css("input[name=csrfmiddlewaretoken]", "value").saveAs("stoken"))
.headers(headers_0))
.pause(7)
.exec(http("dang_nhap_admin")
.post("/admin/login/?next=/admin/")
.headers(headers_2)
.formParam("csrfmiddlewaretoken", "${stoken}")
.formParam("username", "admin")
.formParam("password", "Cloud365a@123")
.formParam("next", "/admin/"))
.pause(7)
.exec(http("dang_xuat_trang_admin")
.get("/admin/logout/")
.headers(headers_0))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment