python3接口性能测试,,# coding=u
python3接口性能测试,,# coding=u
# coding=utf-8import requests, jsonimport hashlib, timeimport base64from locust import HttpLocust,TaskSet,taskIP_server = "192.168.1.25"def md5_int(vale): md5_int = vale str_md5 = hashlib.md5(md5_int.encode()).hexdigest() return str_md5def 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 tokentoken = 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接口性能测试
相关内容
- Python输入输出练习,运算练习,turtle初步练习,,一、输
- Python OpenCV 用摄像头捕获视频,,为了捕获视频,首先要
- Python的魔法函数系列 __getattrbute__和__getattr__,,#!/usr/b
- python基础爬虫的框架和运行流程,,网络爬虫是什么?网
- python中 from xx import,import几种导包的情况,,简单的统
- python中的 sql语句用法,,函数中应用sql语句
- 查看python和NumPy版本和安装路径,,记录查看Python
- 人生苦短,我用Python---Python学习笔记之四,,人生苦短,
- python系统学习4——多个爬虫测试案例,,通过几天学习
- Python3.x基础学习-函数用法,,函数用法函数的参数类
评论关闭