在MacOS中使用AB测试工具

发表于:2020-2-19 14:23

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:Dorole    来源:Dorole's Blog

  一直以来都是用JMeter来做压力测试,GUI界面功能虽然强大,报表齐全,但有时候只是想简单测试下,启动JMeter过于繁琐,于是想到用ab来测试,一条命令搞定。MacOS自带了ab,却因版本问题无法正常使用,需要升级到最新版,本文简单记录下过程。
  1,先下载httpd、apr、apr-util、pcre,若有已安装的可以忽略
  http://httpd.apache.org/download.cgi
  http://apr.apache.org/download.cgi
  https://ftp.pcre.org/pub/pcre/
  2,由于httpd依赖apr、pcre,所以先安装apr、apr-util、pcre
$ cd apr-1.5.2/
$ ./configure
$ make
$ make test
$ sudo make install
$ cd apr-util-1.5.4/
$ ./configure --with-apr=../apr-1.5.2/
$ make
$ sudo make install
$ cd pcre-8.40/
$ ./configure
$ make
$ sudo make install
$ cd ../httpd-2.4.25/
$ make
$ sudo make install
  3,在恢复模式下替换系统ab,关闭MacOS Rootless,开机按住Cmd+R键,进入恢复模式,打开终端执行:
  $ csrutil disable
  Successfully disabled System Integrity Protection. Please restart the machine for the changes to take effect.
  重启
  $ reboot
  4,备份并替换,以下路径是httpd默认安装位置
$ cd /usr/local/apache2/bin/
$ sudo mv /usr/sbin/ab /usr/sbin/ab.bak
$ sudo cp ab /usr/sbin/
  5,重新进入恢复模式,开启Rootless
$ csrutil enable
Successfully enabled System Integrity Protection. Please restart the machine for the changes to take effect.
  重启
  $ reboot
  到此,工具算是准备好了,但MacOS对文件打开有限制,无法满足ab需求,通过以下命令临时调整:(重启后需重新执行)
$ sysctl kern.maxfiles
kern.maxfiles: 12288
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 10240
$ sudo sysctl -w kern.maxfiles=1048600
kern.maxfiles: 12288 -> 1048600
$ sudo sysctl -w kern.maxfilesperproc=1048576
kern.maxfilesperproc: 10240 -> 1048576
$ ulimit -n
256
$ ulimit -n 1048576
$ ulimit -n
1048576
  搞定!

    上文内容不用于商业目的,如涉及知识产权问题,请权利人联系博为峰小编(021-64471599-8017),我们将立即处理。
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号