1.数据准备
接口:spoor/dashboard/v1/query
post样例,参数化的部分已经被"参数化替代":
{
"domain": "test-online-hbase",
"lineSetting": {
"filterSetting": {
"aggMethod": 参数化,
"filterMethod":参数化,
"params": 参数化
},
"groupField": "server"
},
"metric": "hbase.server.get_num",
"metricType": "delta",
"tags": [
参数化
],
"valueType": "long",
"xSetting": {
"beginTime": 1497149372749,
"endTime": 1498149372749,
"interval": 参数化
},
"ySetting": {
"aggMethod": 参数化,
"selectedVal": "value"
}
}
headers必须包含的头文件信息为:
{"Content-Type": "application/json"}
post方法json数据样例:
{
"domain": "test-online-hbase",
"lineSetting": {
"filterSetting": {
"aggMethod": "max",
"filterMethod": "top",
"params": 2
},
"groupField": "server"
},
"metric": "hbase.server.get_num",
"metricType": "delta",
"tags": [
"table=hb_user_trait"
],
"valueType": "long",
"xSetting": {
"beginTime": 1497149372749,
"endTime": 1498149372749,
"interval": 500
},
"ySetting": {
"aggMethod": "avg",
"selectedVal": "value"
}
}
2.设计jmeter脚本
以上是各种数据准备,下面是设计脚本:
第一步
打开jmeter,创建线程,这里简单不做赘述!
第二步
在线程组中添加个HTTP请求默认值!
第三步
创建HTTP信息头管理器:
第四步
创建BeaShell PreProcessor,用来处理随机获取序列元素,关于上面参数化的值,在下图中给出:
在此给出一个脚本代码:
String[] tableNameList = new String[]{"table=hb_user_trait","table=hb_editor_rec_usr_feature",
"table=hb_filter_album_history","table=hb_user_play_history"};
Random random = new Random();
int i = random.nextInt(tableNameList.length);
vars.put("tableName",tableNameList[i])
第五步
创建用户自定义变量:
第六
创建逻辑控制器,我选择的是事务控制器,因为我需要查看TPS值:
第七步
创建http请求:
下面给出json参数化后的代码:
{
"domain": "test-online-hbase",
"lineSetting": {
"filterSetting": {
"aggMethod": "${aggMethod}",
"filterMethod": "${filterMethod}",
"params": ${params}
},
"groupField": "server"
},
"metric": "hbase.server.get_num",
"metricType": "delta",
"tags": [
"${tableName}"
],
"valueType": "long",
"xSetting": {
"beginTime": 1497149372749,
"endTime": 1498149372749,
"interval": ${interval}
},
"ySetting": {
"aggMethod": "${aggMethod}",
"selectedVal": "value"
}
}
最后一步
添加一个监听器,我这只是简单天哥监听结果树,给出运行结果: