gatling、scala、svn 测试案例
来源:互联网 发布:资产配置贡献率算法 编辑:程序博客网 时间:2024/06/06 21:42
package svnperformance
import akka.actor.Props
import akka.actor.ActorRef
import io.gatling.core.scenario.configuration.Simulation
import io.gatling.core.action.builder.ActionBuilder
import io.gatling.core.structure.ChainBuilder
import io.gatling.core.config.ProtocolConfigurationRegistry
import io.gatling.core.Predef._
import io.gatling.core.action.Action
import io.gatling.core.action.system
import io.gatling.core.result.writer.DataWriter
import io.gatling.core.result.message.RequestMessage
import io.gatling.core.result.message.{ KO, OK }
import org.tmatesoft.svn.core.SVNURL
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory
import org.tmatesoft.svn.core.wc.SVNWCUtil
import org.tmatesoft.svn.core.io.SVNRepositoryFactory
import org.tmatesoft.svn.core.wc.SVNClientManager
import org.tmatesoft.svn.core.wc.SVNRevision
import org.tmatesoft.svn.core.ISVNLogEntryHandler
import java.io.File
import java.util.Date
import scala.util.Random
class SVNTest extends Simulation {
val checkout = new ActionBuilder {
override def build(next: ActorRef, protocolConfigurationRegistry: ProtocolConfigurationRegistry) = system.actorOf(Props(new CheckoutAction(next)))
}
val checkoutList = List(checkout)
val checktry = new ChainBuilder(checkoutList)
val importfiles = new ActionBuilder {
override def build(next: ActorRef, protocolConfigurationRegistry: ProtocolConfigurationRegistry) = system.actorOf(Props(new ImportAction(next)))
}
val importfilesList = List(importfiles)
val importtry = new ChainBuilder(importfilesList)
val logcheck = new ActionBuilder {
override def build(next: ActorRef, protocolConfigurationRegistry: ProtocolConfigurationRegistry) = system.actorOf(Props(new LogAction(next)))
}
val logcheckList = List(logcheck)
val logtry = new ChainBuilder(logcheckList)
//val scn_checkout = scenario("checkout").during(60,"",false){checktry} // error!
//val scn_checkout = scenario("checkout").tryMax(10) { checktry } // cant stop!
//val scn_checkout = scenario("checkout").exitBlockOnFail(checktry) // cant stop!
//val scn_checkout = scenario("checkout").repeat(5){checktry}.exitHereIfFailed
val scn_checkout = scenario("checkout").repeat(10) { checktry } //repeat 5 times
val scn_import = scenario("importfiles").repeat(10) { importtry } //repeat 5 times
val scn_log = scenario("logcheck").repeat(10) { logtry } //repeat 5 times
setUp(scn_checkout.inject(ramp(20 users).over(10)),
scn_import.inject(ramp(20 users).over(10)),
scn_log.inject(ramp(10 users).over(10))
)
}
class CheckoutAction(val next: ActorRef) extends Action() {
/*val svnhost = "http://svn-dr.paic.com.cn/svn/svntest/trunk/smallDir2/"
val user = "svntest002"
val pass = "Paic1234"*/
val svnhost = "https://192.168.1.199/svn/projects/trunk/Data2/"
val user = "orj"
val pass = "123"
override def execute(session: Session) {
try {
var start = new Date().getTime
val aa = new Random().nextInt(10) + 1
val bb = new Random().nextInt(10) + 1
val url0 = svnhost + "tmp" + aa.toString + "/tmp" + bb.toString //
println(url0)
val url = SVNURL.parseURIEncoded(url0) //svnurl
val cc = new Random().nextInt(100000) + 1
val desDir0 = "D:/tmp/tmp00/tmp" + start + cc.toString //
println(desDir0)
val desDir = new File(desDir0) //local path
DAVRepositoryFactory.setup
val options = SVNWCUtil.createDefaultOptions(true)
val authManager = SVNWCUtil.createDefaultAuthenticationManager(user, pass)
val repos = SVNRepositoryFactory.create(url)
repos.setAuthenticationManager(authManager)
val svnclient = SVNClientManager.newInstance
val updateclient = svnclient.getUpdateClient
updateclient.setIgnoreExternals(false)
val revision = repos.getLatestRevision
println(revision);
println("checkout")
val checkout = updateclient.doCheckout(url, desDir, SVNRevision.UNDEFINED, SVNRevision.HEAD, true)
println(checkout.toString());
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "checkout", start, end, end, end, OK, None, Nil))
} catch {
case e: Throwable => {
var start = new Date().getTime
e.printStackTrace
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "checkout", start, end, end, end, KO, None, Nil))
}
}
next ! session
}
}
class ImportAction(val next: ActorRef) extends Action() {
/*val svnhost = "http://svn-dr.paic.com.cn/svn/svntest/trunk/commit/tmp0/"
val user = "svntest002"
val pass = "Paic1234"*/
val svnhost = "https://192.168.1.199/svn/projects/trunk/Data3/"
val user = "orj"
val pass = "123"
override def execute(session: Session) {
try {
var start = new Date().getTime
val aa = new Random().nextInt(100000) + 1
val svnurl0 = svnhost + "tmp" + start + aa.toString //
println(svnurl0)
val svnurl = SVNURL.parseURIEncoded(svnurl0) //svnurl
val bb = new Random().nextInt(10) + 1
val localDir0 = "D:/tmp/Data/tmp" + bb.toString //
println(localDir0)
val localDir = new File(localDir0)
DAVRepositoryFactory.setup
val options = SVNWCUtil.createDefaultOptions(true)
val authManager = SVNWCUtil.createDefaultAuthenticationManager(user, pass)
val repos = SVNRepositoryFactory.create(svnurl)
repos.setAuthenticationManager(authManager)
val svnClient = SVNClientManager.newInstance
val importClient = svnClient.getCommitClient()
importClient.setIgnoreExternals(false)
val revision = repos.getLatestRevision
println(revision);
println("importFiles")
val importFiles = importClient.doImport(localDir, svnurl, "", true)
println(importFiles.toString());
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "importFiles", start, end, end, end, OK, None, Nil))
} catch {
case e: Throwable => {
var start = new Date().getTime
e.printStackTrace
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "importFiles", start, end, end, end, KO, None, Nil))
}
}
next ! session
}
}
class LogAction(val next: ActorRef) extends Action() {
/*val svnhost = "http://svn-dr.paic.com.cn/svn/svntest/trunk/commit/tmp0/"
val user = "svntest002"
val pass = "Paic1234"*/
val svnhost = "https://192.168.1.199/svn/projects/trunk/Data3/"
val user = "orj"
val pass = "123"
override def execute(session: Session) {
try {
var start = new Date().getTime
val svnurl = SVNURL.parseURIEncoded(svnhost) //svnurl
val bb = new Random().nextInt(10) + 1
val localDir0 = "D:/tmp/"
println(localDir0)
val localDir = new File(localDir0)
DAVRepositoryFactory.setup
val options = SVNWCUtil.createDefaultOptions(true)
val authManager = SVNWCUtil.createDefaultAuthenticationManager(user, pass)
val repos = SVNRepositoryFactory.create(svnurl)
repos.setAuthenticationManager(authManager)
val svnClient = SVNClientManager.newInstance
val logClient = svnClient.getLogClient()
logClient.setIgnoreExternals(false)
val revision = repos.getLatestRevision
println(revision);
val r = SVNRevision.create(revision)
println("importFiles")
val logCheck = logClient.doLog(svnurl, new Array[String](0), r, r, r, false, false, true, 1, new Array[String](0), null)
println(logCheck.toString());
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "logCheck", start, end, end, end, OK, None, Nil))
} catch {
case e: Throwable => {
var start = new Date().getTime
e.printStackTrace
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "logCheck", start, end, end, end, KO, None, Nil))
}
}
next ! session
}
}
import akka.actor.Props
import akka.actor.ActorRef
import io.gatling.core.scenario.configuration.Simulation
import io.gatling.core.action.builder.ActionBuilder
import io.gatling.core.structure.ChainBuilder
import io.gatling.core.config.ProtocolConfigurationRegistry
import io.gatling.core.Predef._
import io.gatling.core.action.Action
import io.gatling.core.action.system
import io.gatling.core.result.writer.DataWriter
import io.gatling.core.result.message.RequestMessage
import io.gatling.core.result.message.{ KO, OK }
import org.tmatesoft.svn.core.SVNURL
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory
import org.tmatesoft.svn.core.wc.SVNWCUtil
import org.tmatesoft.svn.core.io.SVNRepositoryFactory
import org.tmatesoft.svn.core.wc.SVNClientManager
import org.tmatesoft.svn.core.wc.SVNRevision
import org.tmatesoft.svn.core.ISVNLogEntryHandler
import java.io.File
import java.util.Date
import scala.util.Random
class SVNTest extends Simulation {
val checkout = new ActionBuilder {
override def build(next: ActorRef, protocolConfigurationRegistry: ProtocolConfigurationRegistry) = system.actorOf(Props(new CheckoutAction(next)))
}
val checkoutList = List(checkout)
val checktry = new ChainBuilder(checkoutList)
val importfiles = new ActionBuilder {
override def build(next: ActorRef, protocolConfigurationRegistry: ProtocolConfigurationRegistry) = system.actorOf(Props(new ImportAction(next)))
}
val importfilesList = List(importfiles)
val importtry = new ChainBuilder(importfilesList)
val logcheck = new ActionBuilder {
override def build(next: ActorRef, protocolConfigurationRegistry: ProtocolConfigurationRegistry) = system.actorOf(Props(new LogAction(next)))
}
val logcheckList = List(logcheck)
val logtry = new ChainBuilder(logcheckList)
//val scn_checkout = scenario("checkout").during(60,"",false){checktry} // error!
//val scn_checkout = scenario("checkout").tryMax(10) { checktry } // cant stop!
//val scn_checkout = scenario("checkout").exitBlockOnFail(checktry) // cant stop!
//val scn_checkout = scenario("checkout").repeat(5){checktry}.exitHereIfFailed
val scn_checkout = scenario("checkout").repeat(10) { checktry } //repeat 5 times
val scn_import = scenario("importfiles").repeat(10) { importtry } //repeat 5 times
val scn_log = scenario("logcheck").repeat(10) { logtry } //repeat 5 times
setUp(scn_checkout.inject(ramp(20 users).over(10)),
scn_import.inject(ramp(20 users).over(10)),
scn_log.inject(ramp(10 users).over(10))
)
}
class CheckoutAction(val next: ActorRef) extends Action() {
/*val svnhost = "http://svn-dr.paic.com.cn/svn/svntest/trunk/smallDir2/"
val user = "svntest002"
val pass = "Paic1234"*/
val svnhost = "https://192.168.1.199/svn/projects/trunk/Data2/"
val user = "orj"
val pass = "123"
override def execute(session: Session) {
try {
var start = new Date().getTime
val aa = new Random().nextInt(10) + 1
val bb = new Random().nextInt(10) + 1
val url0 = svnhost + "tmp" + aa.toString + "/tmp" + bb.toString //
println(url0)
val url = SVNURL.parseURIEncoded(url0) //svnurl
val cc = new Random().nextInt(100000) + 1
val desDir0 = "D:/tmp/tmp00/tmp" + start + cc.toString //
println(desDir0)
val desDir = new File(desDir0) //local path
DAVRepositoryFactory.setup
val options = SVNWCUtil.createDefaultOptions(true)
val authManager = SVNWCUtil.createDefaultAuthenticationManager(user, pass)
val repos = SVNRepositoryFactory.create(url)
repos.setAuthenticationManager(authManager)
val svnclient = SVNClientManager.newInstance
val updateclient = svnclient.getUpdateClient
updateclient.setIgnoreExternals(false)
val revision = repos.getLatestRevision
println(revision);
println("checkout")
val checkout = updateclient.doCheckout(url, desDir, SVNRevision.UNDEFINED, SVNRevision.HEAD, true)
println(checkout.toString());
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "checkout", start, end, end, end, OK, None, Nil))
} catch {
case e: Throwable => {
var start = new Date().getTime
e.printStackTrace
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "checkout", start, end, end, end, KO, None, Nil))
}
}
next ! session
}
}
class ImportAction(val next: ActorRef) extends Action() {
/*val svnhost = "http://svn-dr.paic.com.cn/svn/svntest/trunk/commit/tmp0/"
val user = "svntest002"
val pass = "Paic1234"*/
val svnhost = "https://192.168.1.199/svn/projects/trunk/Data3/"
val user = "orj"
val pass = "123"
override def execute(session: Session) {
try {
var start = new Date().getTime
val aa = new Random().nextInt(100000) + 1
val svnurl0 = svnhost + "tmp" + start + aa.toString //
println(svnurl0)
val svnurl = SVNURL.parseURIEncoded(svnurl0) //svnurl
val bb = new Random().nextInt(10) + 1
val localDir0 = "D:/tmp/Data/tmp" + bb.toString //
println(localDir0)
val localDir = new File(localDir0)
DAVRepositoryFactory.setup
val options = SVNWCUtil.createDefaultOptions(true)
val authManager = SVNWCUtil.createDefaultAuthenticationManager(user, pass)
val repos = SVNRepositoryFactory.create(svnurl)
repos.setAuthenticationManager(authManager)
val svnClient = SVNClientManager.newInstance
val importClient = svnClient.getCommitClient()
importClient.setIgnoreExternals(false)
val revision = repos.getLatestRevision
println(revision);
println("importFiles")
val importFiles = importClient.doImport(localDir, svnurl, "", true)
println(importFiles.toString());
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "importFiles", start, end, end, end, OK, None, Nil))
} catch {
case e: Throwable => {
var start = new Date().getTime
e.printStackTrace
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "importFiles", start, end, end, end, KO, None, Nil))
}
}
next ! session
}
}
class LogAction(val next: ActorRef) extends Action() {
/*val svnhost = "http://svn-dr.paic.com.cn/svn/svntest/trunk/commit/tmp0/"
val user = "svntest002"
val pass = "Paic1234"*/
val svnhost = "https://192.168.1.199/svn/projects/trunk/Data3/"
val user = "orj"
val pass = "123"
override def execute(session: Session) {
try {
var start = new Date().getTime
val svnurl = SVNURL.parseURIEncoded(svnhost) //svnurl
val bb = new Random().nextInt(10) + 1
val localDir0 = "D:/tmp/"
println(localDir0)
val localDir = new File(localDir0)
DAVRepositoryFactory.setup
val options = SVNWCUtil.createDefaultOptions(true)
val authManager = SVNWCUtil.createDefaultAuthenticationManager(user, pass)
val repos = SVNRepositoryFactory.create(svnurl)
repos.setAuthenticationManager(authManager)
val svnClient = SVNClientManager.newInstance
val logClient = svnClient.getLogClient()
logClient.setIgnoreExternals(false)
val revision = repos.getLatestRevision
println(revision);
val r = SVNRevision.create(revision)
println("importFiles")
val logCheck = logClient.doLog(svnurl, new Array[String](0), r, r, r, false, false, true, 1, new Array[String](0), null)
println(logCheck.toString());
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "logCheck", start, end, end, end, OK, None, Nil))
} catch {
case e: Throwable => {
var start = new Date().getTime
e.printStackTrace
var end = new Date().getTime
DataWriter.tell(RequestMessage(session.scenarioName, session.userId, Nil, "logCheck", start, end, end, end, KO, None, Nil))
}
}
next ! session
}
}
- gatling、scala、svn 测试案例
- Gatling-基于Scala,Akka&Netty的性能测试框架
- 性能测试工具Gatling介绍
- 新一代服务器性能测试工具Gatling
- 新一代服务器性能测试工具Gatling
- 新一代服务器性能测试工具Gatling
- 使用Gatling服务器性能测试工具
- 压力测试工具gatling安装和介绍
- scala基础知识学习(基于Gatling源码)1_mutale.map,case class
- SVN案例
- 不靠谱的benchmark测试,关于Gatling和JMeter的测试结果验证
- updateStateByKey案例(Scala版本)
- Eclipse+scala+maven+svn
- scala spark hbase 操作案例
- SVN案例2
- Scala Specs2 测试入门教程
- Scala中的测试
- scala入门测试
- Struts2爆高危漏洞
- C++11特性--auto,decltype,返回类型后置,using=,nullptr
- SQL Transcation的一些总结
- java网页静态化
- ocx引用另一ocx
- gatling、scala、svn 测试案例
- 程序员自我学习自我培训指南
- 【2013Esri全球用户大会精彩案例】Urban Observatory -- 城市瞭望台
- 【js学习笔记039】-- 创建数组
- jsessionid
- Android DDMS如何使用?
- 【js学习笔记040】-- 稀疏数组
- Markdown语法
- mule示例分析