python3接口性能測試-創(chuàng)新互聯(lián)

# coding=utf-8
import requests, json
import  hashlib, time
import base64
from locust import HttpLocust,TaskSet,task
IP_server = "192.168.1.25"
def md5_int(vale):
    md5_int = vale
    str_md5 = hashlib.md5(md5_int.encode()).hexdigest()
    return str_md5

def getsession():
    url = "https://{}/login".format(IP_server)
    token = {}
    data = json.dumps({
        "name": "admin",
        "password": md5_int('123456'),
                       })
    url = requests.post(url=url, data=data)
    token["session_id"] = url.json()["session_id"]
    token["cluster_id"] = token["session_id"].split('@')[1]
    return token

token = getsession()
class MyBlogs(TaskSet):

    data = json.dumps({
        "cameid": "3",
        "limit": 20,
    })
    @task(1)
    def post_test(self):
        # 定義請求
       with self.client.post("/cick/weibocke/", headers=token, data=self.data, catch_response=True) as response:
            if response.status_code == 200:
                print("success")
            else:
                print("fails")

class websitUser(HttpLocust):
    task_set = MyBlogs
    min_wait = 3000  # 單位為毫秒
    max_wait = 6000  # 單位為毫秒

if __name__ == "__main__":
    import os
    os.system("locust -f test.py ")

python3接口性能測試

創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設、高性價比開平網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式開平網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設找我們,業(yè)務覆蓋開平地區(qū)。費用合理售后完善,10余年實體公司更值得信賴。

python3接口性能測試

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

新聞標題:python3接口性能測試-創(chuàng)新互聯(lián)
URL標題:http://muchs.cn/article34/pscse.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供虛擬主機、云服務器網(wǎng)站改版、域名注冊、用戶體驗、網(wǎng)站營銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化