使用Loadrunner12进行http接口性能测试

时间:2025-04-08 20:12:48
Action() { lr_start_transaction("zion_setvlan"); web_set_timeout(STEP, "45"); lr_rendezvous("下发流表的集合点"); web_add_header("Authorization", "Basic YWRtaW46YWRtaW4="); web_add_header("Content-Type", "json/application"); web_reg_find("Search=Body", "SaveCount=RecordSave", "Text=OK", LAST); web_custom_request("web_custom_request", "URL=http://172.16.1.184:8181/zion/restconf/config/zion-inventory:nodes/node/openflow:79/table/0/flow/{flowid}", "Method=PUT", "TargetFrame=", "Resource=0", "Referer=", "EncType=json/application", "Body={\"flow\":[{\"id\":\"{flowid}\",\"flow-name\":\"{flowid}\",\"priority\":{flowid},\"table_id\":0,\"hard-timeout\":0,\"idle-timeout\":0,\"match\":{\"ethernet-match\":{\"ethernet-type\":{\"type\":2048}},\"vlan-match\":{\"vlan-id\":{\"vlan-id\":{flowid},\"vlan-id-present\":true}}},\"instructions\":{\"instruction\":[{\"order\":0,\"apply-actions\":{\"action\":[{\"set-vlan-id-action\":{\"vlan-id\":1024},\"order\":0},{\"output-action\":{\"output-node-connector\":\"10\"},\"order\":0}]}}]}}]}", LAST); if(atoi(lr_eval_string("{RecordSave}"))>0){ lr_end_transaction("zion_setvlan",LR_PASS); lr_output_message("流表%s下发成功!",lr_eval_string("{flowid}")); } else{ lr_end_transaction("zion_setvlan",LR_FAIL); lr_error_message("流表%s下发失败!",lr_eval_string("{flowid}")); } return 0; }