我用clojure写了一个测试网站压力的工具

说明:

网站压力测试工具有很多,ab,jmeter等等。但是当你真正测试自己的系统时,特别是动态的系统,比如oa系统,那些工具似乎都不好使了。(可能是我研究不深)。

面临的问题:

1、用户需要登陆

2、按照用户的操作习惯,按序访问一系列url

源代码:

https://github.com/jianglibo/pressure-it

如何使用:

(defn oa-user-login
  [cs]
  (let [login-url "http://someappurl.cc/Login"]
    (client/post login-url {:form-params {:fLoginVerification 1
                                          :Username "username"
                                          :Password "password"
                                          :DBPath "/domcfg.nsf"
                                          :Path_Info "/index.nsf"
                                          :Path_Info_Decoded "/index.nsf"
                                          :SaveOptions 1
                                          :$PublicAccess 1}
                            :cookie-store cs})))

(def oa-user-request-urls
  ["http://someurl.cc"
   "http://someurl.cc/RndStr={{rand}}"])

(pressure-it/benchmark [oa-user-login oa-user-request-urls 20 5])

oa-user-login是登陆代码,oa-user-request-urls是通过观察用户打开网页时请求后台的路径,不管是iframe还是ajax都可以。

benchmark的参数是:登陆函数,访问url列表,用户数(线程数),重复几次。

你得到的报告如下:

7361549 [nREPL-worker-19] INFO  pressure-it.core  - total time costs:  46086
nil
user=> (require '[pressure-it.pressure-this :as pmy] :reload)
7593807 [nREPL-worker-20] INFO  pressure-it.core  - thread number:  30
7593865 [nREPL-worker-20] INFO  pressure-it.core  - ({"http:///db_publicaffair.nsf/Toppic?OpenForm&RndStr={{rand}}"
  {:request-num 150,
   :total-download 94734,
   :success
   {:request-num 18, :slowest 3055, :fastest 2882, :average 2997.5},
   :failure {:request-num 132}}}
 {"http:///TopBottomFrameSetWin?Open
Form&path=/db_mqhb.nsf&fTitle=%E6%B0%91%E6%83%85%E4%BC%9A%E5%
8A%9E&RndStr={{rand}}"
  {:request-num 150,
   :total-download 0,
   :success {:request-num 0, :slowest nil, :fastest nil, :average -1},
   :failure {:request-num 150}}}
 {"http:///db_printview.nsf/PeoplePrintView?O
penAgent&infoid=mqhb_Info&path=app&dbname=db_mqhb.nsf"
  {:request-num 150,
   :total-download 512424,
   :success
   {:request-num 44, :slowest 3060, :fastest 239, :average 2214.068},
   :failure {:request-num 106}}})

7593865 [nREPL-worker-20] INFO  pressure-it.core  - total time costs:  46266
nil

可以看到,在30个并发用户的时候,这个oa基本不可用了。


TODO:

在有验证码的情况下,必须将验证码图片保存在磁盘上,并提示用户输入验证码。

转载于:https://my.oschina.net/jianglibo/blog/350985

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值