Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1586002
  • 博文数量: 399
  • 博客积分: 8508
  • 博客等级: 中将
  • 技术积分: 5302
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-14 09:28
个人简介

能力强的人善于解决问题,有智慧的人善于绕过问题。 区别很微妙,小心谨慎做后者。

文章分类

全部博文(399)

文章存档

2018年(3)

2017年(1)

2016年(1)

2015年(69)

2013年(14)

2012年(17)

2011年(12)

2010年(189)

2009年(93)

分类: 架构设计与优化

2015-04-15 16:49:52

理论原型

http://blog.csdn.net/fengxinze/article/details/7319262


Async.pptx


使用 Gatling Scala 进行性能测试,生成的报告比Jmeter好看

http://callistaenterprise.se/blogg/teknik/2014/04/16/a-first-look-at-gatling-a-dsl-based-load-test-tool/


import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._


import java.util.concurrent.TimeUnit


class StreamSimulation extends Simulation {


val httpProtocol = http
.baseURL("")


val headers = Map("Content-Type" -> "application/json")


val requestBodyForAlert = StringBody("""{"providers":{"bb_ach_stream":{"sp_settings":null,"sp_flushAll":null,"sp_provider":"bb_ach_stream","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0},"bb_deployment":{"sp_settings":null,"sp_flushAll":null,"sp_provider":"bb_deployment","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":1426757262373},"bb-evidence-collection":{"sp_settings":null,"sp_flushAll":null,"sp_provider":"bb-evidence-collection","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0},"bb-announcement":{"sp_settings":null,"sp_flushAll":null,"sp_provider":"bb-announcement","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0},"bb-nautilus":{"sp_settings":[{"value":"TE:TE_AVAIL_RESEND","id":"bb-nautilus_TE:TE_AVAIL_RESEND","checked":true,"attrib":"event_type","displayText":"Assessment Attempt Available Resent"},{"value":"AS:AS_GA_LATE_ATTEMPT","id":"bb-nautilus_AS:AS_GA_LATE_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Group Assignment Needs Grading (Submitted Late)"},{"value":"TE:TE_SUBMIT_LATE","id":"bb-nautilus_TE:TE_SUBMIT_LATE","checked":true,"attrib":"event_type","displayText":"Assessment Needs Grading (Submitted Late)"},{"value":"AS:DUE","id":"bb-nautilus_AS:DUE","checked":true,"attrib":"event_type","displayText":"Assignment Due"},{"value":"DF:DF_ATTEMPT","id":"bb-nautilus_DF:DF_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Forum Needs Grading"},{"value":"AS:AS_GA_AVAIL_RESEND","id":"bb-nautilus_AS:AS_GA_AVAIL_RESEND","checked":true,"attrib":"event_type","displayText":"Assignment Group Assignment Available Resend"},{"value":"GB:OVERDUE","id":"bb-nautilus_GB:OVERDUE","checked":true,"attrib":"event_type","displayText":"Item Overdue"},{"value":"DT:DT_GR_ATTEMPT","id":"bb-nautilus_DT:DT_GR_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Group Thread Needs Grading"},{"value":"GB:GB_NEEDS_RECON","id":"bb-nautilus_GB:GB_NEEDS_RECON","checked":true,"attrib":"event_type","displayText":"Column Needs Reconciliation"},{"value":"AS:AS_LATE_ATTEMPT","id":"bb-nautilus_AS:AS_LATE_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Assignment Needs Grading (Submitted Late)"},{"value":"JN:JN_ATTEMPT","id":"bb-nautilus_JN:JN_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Journal Needs Grading"},{"value":"WK:WK_GR_ATTEMPT","id":"bb-nautilus_WK:WK_GR_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Group Wiki Needs Grading"},{"value":"AS:OVERDUE","id":"bb-nautilus_AS:OVERDUE","checked":true,"attrib":"event_type","displayText":"Assignment Overdue"},{"value":"AS:AS_ATTEMPT","id":"bb-nautilus_AS:AS_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Assignment Needs Grading"},{"value":"TE:TE_AVAIL","id":"bb-nautilus_TE:TE_AVAIL","checked":true,"attrib":"event_type","displayText":"Assessment Available"},{"value":"GB:DUE","id":"bb-nautilus_GB:DUE","checked":true,"attrib":"event_type","displayText":"Item Due"},{"value":"GB:GB_GRA_UPDATED","id":"bb-nautilus_GB:GB_GRA_UPDATED","checked":true,"attrib":"event_type","displayText":"Manual Grade Updated"},{"value":"SU:OVERDUE","id":"bb-nautilus_SU:OVERDUE","checked":true,"attrib":"event_type","displayText":"Survey Overdue"},{"value":"UA:DUE","id":"bb-nautilus_UA:DUE","checked":true,"attrib":"event_type","displayText":"Ultra Assignment Due"},{"value":"AS:AS_GA_AVAIL","id":"bb-nautilus_AS:AS_GA_AVAIL","checked":true,"attrib":"event_type","displayText":"Assignment Group Assignment Available"},{"value":"CO:CO_AVAIL","id":"bb-nautilus_CO:CO_AVAIL","checked":true,"attrib":"event_type","displayText":"Content Available"},{"value":"AS:AS_GA_ATTEMPT","id":"bb-nautilus_AS:AS_GA_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Group Assignment Needs Grading"},{"value":"SU:SU_SUBMIT","id":"bb-nautilus_SU:SU_SUBMIT","checked":true,"attrib":"event_type","displayText":"Survey Submitted"},{"value":"BL:BL_ATTEMPT","id":"bb-nautilus_BL:BL_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Blog Needs Grading"},{"value":"BL:BL_GR_ATTEMPT","id":"bb-nautilus_BL:BL_GR_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Group Blog Needs Grading"},{"value":"SU:DUE","id":"bb-nautilus_SU:DUE","checked":true,"attrib":"event_type","displayText":"Survey Due"},{"value":"JN:JN_GR_ATTEMPT","id":"bb-nautilus_JN:JN_GR_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Group Journal Needs Grading"},{"value":"AN:AN_AVAIL","id":"bb-nautilus_AN:AN_AVAIL","checked":true,"attrib":"event_type","displayText":"Announcement Available"},{"value":"QU:QU_AVAIL","id":"bb-nautilus_QU:QU_AVAIL","checked":true,"attrib":"event_type","displayText":"Quota Available"},{"value":"SU:SU_AVAIL","id":"bb-nautilus_SU:SU_AVAIL","checked":true,"attrib":"event_type","displayText":"Survey Available"},{"value":"AS:AS_AVAIL_RESEND","id":"bb-nautilus_AS:AS_AVAIL_RESEND","checked":true,"attrib":"event_type","displayText":"Assignment Available Resend"},{"value":"DF:DF_GR_ATTEMPT","id":"bb-nautilus_DF:DF_GR_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Group Forum Needs Grading"},{"value":"GB:GB_GRA_CLEARED","id":"bb-nautilus_GB:GB_GRA_CLEARED","checked":true,"attrib":"event_type","displayText":"Manual Grade Cleared"},{"value":"CM:CM_RCVD","id":"bb-nautilus_CM:CM_RCVD","checked":true,"attrib":"event_type","displayText":"Course Message Received"},{"value":"GB:GB_ATT_UPDATED","id":"bb-nautilus_GB:GB_ATT_UPDATED","checked":true,"attrib":"event_type","displayText":"Attempt Grade Updated"},{"value":"TE:TE_SUBMIT","id":"bb-nautilus_TE:TE_SUBMIT","checked":true,"attrib":"event_type","displayText":"Assessment Needs Grading"},{"value":"AS:AS_AVAIL","id":"bb-nautilus_AS:AS_AVAIL","checked":true,"attrib":"event_type","displayText":"Assignment Available"},{"value":"UA:OVERDUE","id":"bb-nautilus_UA:OVERDUE","checked":true,"attrib":"event_type","displayText":"Ultra Assignment Overdue"},{"value":"UA:UA_AVAIL_RESEND","id":"bb-nautilus_UA:UA_AVAIL_RESEND","checked":true,"attrib":"event_type","displayText":"Ultra Assignment Attempt Available Resent"},{"value":"CR:CR_AVAIL","id":"bb-nautilus_CR:CR_AVAIL","checked":true,"attrib":"event_type","displayText":"Course or Organization Available"},{"value":"UA:UA_SUBMIT","id":"bb-nautilus_UA:UA_SUBMIT","checked":true,"attrib":"event_type","displayText":"Ultra Assignment Needs Grading"},{"value":"UA:UA_SUBMIT_LATE","id":"bb-nautilus_UA:UA_SUBMIT_LATE","checked":true,"attrib":"event_type","displayText":"Ultra Assignment Needs Grading (Submitted Late)"},{"value":"DT:DT_ATTEMPT","id":"bb-nautilus_DT:DT_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Thread Needs Grading"},{"value":"TE:DUE","id":"bb-nautilus_TE:DUE","checked":true,"attrib":"event_type","displayText":"Assessment Due"},{"value":"UA:UA_AVAIL","id":"bb-nautilus_UA:UA_AVAIL","checked":true,"attrib":"event_type","displayText":"Ultra Assignment Available"},{"value":"TE:OVERDUE","id":"bb-nautilus_TE:OVERDUE","checked":true,"attrib":"event_type","displayText":"Assessment Overdue"},{"value":"WK:WK_ATTEMPT","id":"bb-nautilus_WK:WK_ATTEMPT","checked":true,"attrib":"event_type","displayText":"Wiki Needs Grading"}],"sp_flushAll":null,"sp_provider":"bb-nautilus","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0},"mbs-announcement":{"sp_settings":null,"sp_flushAll":null,"sp_provider":"mbs-announcement","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0}},"forOverview":false,"retrieveOnly":true}""")


val requestBodyForStream = StringBody("""{"providers":{"bb_message":{"sp_flushAll":null,"sp_settings":null,"sp_provider":"bb_message","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0},"bb_calendar":{"sp_flushAll":null,"sp_settings":null,"sp_provider":"bb_calendar","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0},"bb_blog":{"sp_flushAll":null,"sp_settings":null,"sp_provider":"bb_blog","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0},"bb_disc":{"sp_flushAll":null,"sp_settings":null,"sp_provider":"bb_disc","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0},"bb_Wiki":{"sp_flushAll":null,"sp_settings":null,"sp_provider":"bb_Wiki","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0}},"forOverview":false,"retrieveOnly":true}""")


val requestBodyForMyGrades_d = StringBody("""{"providers":{"bb_mygrades":{"sp_flushAll":null,"sp_settings":null,"sp_provider":"bb_mygrades","sp_newest":-1,"sp_oldest":9007199254740992,"sp_refreshDate":0}},"forOverview":false,"retrieveOnly":true}""")


val login = scenario("ultra_login")



val scn = scenario("ultra_rest_stress_test")


.exec(
http("login")
.post("/webapps/login/")
.check(status.is(200))
.formParam("user_id", "administrator")
.formParam("password", "changeme")
.formParam("login", "Login")
.formParam("action", "login")
.formParam("new_loc", "")
)


.exec(
http("get_token")
.get("/learn/api/v1/utilities/xsrfToken")
.check(status.is(200), jsonPath("$.xsrfToken").saveAs("token"))
)


.repeat(100) {
exec(
http("get_alerts")
.post("/learn/api/v1/streams/alerts")
.headers(Map("X-Blackboard-XSRF" -> "${token}") ++ headers)
.body(requestBodyForAlert)
.asJSON
)


.exec(
http("get_mygrades_d")
.post("/learn/api/v1/streams/mygrades_d")
.headers(Map("X-Blackboard-XSRF" -> "${token}") ++ headers)
.body(requestBodyForMyGrades_d)
.asJSON
)

.exec(
http("get_stream")
.post("/learn/api/v1/streams/stream")
.headers(Map("X-Blackboard-XSRF" -> "${token}") ++ headers)
.body(requestBodyForStream)
.asJSON
)


.exec(
http("get_alerts")
.post("/learn/api/v1/streams/alerts")
.headers(Map("X-Blackboard-XSRF" -> "${token}") ++ headers)
.body(requestBodyForAlert)
.asJSON
)

.exec(
http("get_stream")
.post("/learn/api/v1/streams/stream")
.headers(Map("X-Blackboard-XSRF" -> "${token}") ++ headers)
.body(requestBodyForStream)
.asJSON
)
}


setUp(scn.inject(atOnceUsers(1000))).protocols(httpProtocol)
}
阅读(942) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~