postman 查看写入kafka topic的数据是否成功
postman Pre-req中代码 写topic的postman
var random_number = Math.random()*5
//设置环境变量
pm.environment.set("send_info",String(random_number))
postman test中代码
将json转换为object
var data = JSON.parse(responseBody);
// 设置环境变量token,供后面的接口引用
//新建一个数组
var msgs = new Array();
for (var index in data.partitions) {
var val = data.partitions[index].messages;
for(var v in val){
pm.environment.set("number",val[v])
if (val[v]==String(pm.environment.get("send_info"))){
pm.environment.set('flag',"sucess");
}
}
}