背景:
系统多个用户实名认证为同个时间点同一认证信息,前后端按正常流程操作会提示:“认证失败,证件信息重复”,猜测为直接调用实名认证接口进行认证操作,场景模拟使用jmeter工具来实现。环境/工具配置:
jmeter 5.4.1
pycharm 2018.3(python3.7)
anaconda 1.9.6
操作步骤:
1、系统已注册用户信息接口获取用户id/手机号并存到csv文件中(go接口直接获取,不需要登录态)
import requests
import csv
import codecs
def get_memberlist(t_code):
r = requests.get(
'http://gxxxx.cn/xxxer/search?t_code='+ t_code+')
total = r.json().get('data').get('total')
print(total)
list = r.json().get('data').get('items')
list_id = []
list_phone = []
for i in range(0, total):
list_id.append(list[i]['id'])
list_phone.append(list[i]['mobile'])
member_list = zip(list_id, list_phone)
return member_list
def write_csv(member_list):
f = codecs.open('memberlist.csv', 'w', 'gbk')
writer = csv.writer(f)
for i in member_list:
writer.writerow(i)
f.close()
if __name__ == '__main__':
memberlist=get_memberlist('hcode')
write_csv(memberlist)
2、jmeter:新增csv文件配置5、添加结果树