vieyahn2017 / iBlog

44 stars 0 forks source link

11.20 Postman接口&压力测试 #372

Closed vieyahn2017 closed 3 months ago

vieyahn2017 commented 3 years ago

Postman接口&压力测试

https://www.cnblogs.com/yinjia/p/10122178.html

vieyahn2017 commented 3 months ago

var raw = pm.request.url.getRaw();
console.log("raw =============" + raw);
if (typeof(raw) != "undefined") {
    if(raw.indexOf("/VIID/") != -1) {
        var preffix_url = raw.substring(0, raw.indexOf("/VIID/") + 5);
        console.log("url=============" + preffix_url);
        postman.setEnvironmentVariable("url", preffix_url);
    } else {
        console.log("url is no need to set");
    }
}
vieyahn2017 commented 3 months ago

curl -k -v -X POST -H "Content-type: application/json" https://3.2.0.1:18531/loginInfo/login/v1.0 -d ' {"userName": "admin", "password": "super123" } '

vieyahn2017 commented 3 months ago

restful_ip_post=$(netstat -ano | grep 18531 | awk 'NR==1{print $4}') restful_ip=$(echo $restful_ip_post | awk -F ":" '{print $1}') restful_port=$(echo $restful_ip_post | awk -F ":" '{print $2}')

curl -k -v -X POST -H "Content-type: application/json" https://${restful_ip_post}/loginInfo/login/v1.0 -d ' {"userName": "admin", "password": "super123" } '

vieyahn2017 commented 3 months ago

直接键入 JSESSIONID=BCDE2C86F3057864BF7F005FE37915CAA7BD3EAFB78FBBDE0476DE34B375BEEE

curl -k -X GET --cookie 'JSESSIONID='$JSESSIONID'' -H "Content-type: application/json" https://${restful_ip_post}/productInfo/v1 && echo

vieyahn2017 commented 3 months ago

对于Python,一个元素在一个字符串中多次出现,如何比较简单的获取该元素所有的索引值

import re [i.start() for i in re.finditer("1", "123123")] # [0, 3]