此次分享使用的jmeter版本是:5.1
背景
在某项目的高可用测试过程中,有个case,要求针对某些节点频繁断开与重启的过程中,接口的调用是否正常;
但是手动来启动与关闭服务,非常的麻烦,可能还达不到预想的结果,手动执行毕竟还是没有机器快。
于是乎,就想到了jmeter可否执行linux命令呢?
下载及安装
下载相应的jar包,分别存入jmeter相应的目录,如下:
Copy the ApacheJMeter_ssh-1.2.0.jar to $JMETER_HOME/lib/ext directory
Copy the jsch-0.1.55.jar to $JMETER_HOME/lib directory
用法:
本次分享只使用到了:SSH Command
Usage
Using the plugin is simple (assuming familiarity with SSH and JMeter):
SSH Command
1.Create a new Test Plan
2.Add a Thread Group
3.Add a Sampler > SSH Command
4.Specify the host to connect to, port, username and password (unencrypted) or a key file, and a command to execute (such as date)
5.Add a Listener > View Results Tree
6.Run the test
SSH SFTP
1.Create a new Test Plan
2.Add a Thread Group
3.Add a Sampler > SSH SFTP
4.Specify the host to connect to, port, username and password (unencrypted) or a key file, and a SFTP command to execute (such as get)
5.Specify a source file to download, an output file or to print the content in the test
6.Add a Listener > View Results Tree
7.Run the test
展示:
下面的内容替换为真实内容即可
多个命令可以分号间隔,比如:cd /data;ls
结果