当前位置:网站首页>Locust performance test 2 (interface request)
Locust performance test 2 (interface request)
2022-07-07 09:08:00 【Song_ Lun】
Have been to Loust With a basic understanding of , Next, you can make an interface request
One 、 Post request
The user login
According to business needs , The login interface is executed only once , stay on_start() Function to write login information
class MyTasks(TaskSet):
url = '/login'
headers = {
'Content-Type': 'application/json'}
def on_start(self):
self.data = {
"username":"admin","password":"123456"}
respon = self.client.post(self.url, headers = self.headers, data=json.dumps(self.data), name=' The user login ', verify=False, timeout=10)
resp_dict = respon.json()
# print(f' The response data is :{resp_dict}')
if respon.status_code == 200:
# Interface success
print(resp_dict['msg'])
else:
# request was aborted
respon.failure(resp_dict['msg'])
class User(HttpUser):
tasks = [MyTasks]
host = 'https://www.baidu.com'
wait_time = between(2,2) # Every time 2 Once per second
Two 、 Get request
Send mobile phone verification code
from locust import HttpUser, TaskSet, task
''' get Request interface '''
class MyTasks(TaskSet):
url = '/xxx/xxx/sendAuthCode'
headers = {
'Content-Type': 'application/json',
'Authorization': 'xxxxx'
}
def on_start(self):
print(" User initialization -- Sign in ")
@task
def get_login(self):
print(' Send verification code ...')
# Define an object property
self.query_data = {
'mobile': 1579715000}
respon = self.client.get(self.url, params = self.query_data, headers = self.headers, name=' Send verification code ', verify=False, timeout=10)
resp_dict = respon.json()
print(f' The response data is :{
resp_dict}')
边栏推荐
- UnityShader入门精要个人总结--基础篇(一)
- Analysis of abnormal channel number information before and after AGC re signature service
- Leetcode question brushing record (array) combination sum, combination sum II
- Calculation s=1+12+123+1234+12345 C language
- Troublesome problem of image resizing when using typora to edit markdown to upload CSDN
- Original collection of hardware bear (updated on June 2022)
- 年薪50w阿里P8亲自下场,教你如何从测试进阶
- 面板显示技术:LCD与OLED
- 测试人一定要会的技能:selenium的三种等待方式解读,清晰明了
- C语言指针(特别篇)
猜你喜欢
PMP Exam Preparation experience systematically improve project management knowledge through learning
Do you have any certificates with high gold content?
Three updates to build applications for different types of devices | 2022 i/o key review
【Istio Network CRD VirtualService、Envoyfilter】
What are the conditions for applying for NPDP?
Digital triangle model acwing 1027 Grid access
C语言指针(上篇)
MySQL master-slave delay solution
Output all composite numbers between 6 and 1000
Interview question: general layout and wiring principles of high-speed PCB
随机推荐
数字三角形模型 AcWing 1027. 方格取数
selenium自动化集成,八年测试经验软测工程师,一篇文章带你学懂
OpenGL帧缓冲
2022-07-06 unity core 9 - 3D animation
C语言指针(习题篇)
Panel display technology: LCD and OLED
Common short chain design methods
Do you have any certificates with high gold content?
RuntimeError: Calculated padded input size per channel: (1 x 1). Kernel size: (5 x 5). Kernel size c
2021 year end summary
LeetCode 736. LISP syntax parsing
Summary of PMP learning materials
Several methods of calculating the average value of two numbers
With an annual salary of 50W, Alibaba P8 will come out in person to teach you how to advance from testing
Digital triangle model acwing 1027 Grid access
What are the conditions for applying for NPDP?
How to count the number of project code lines
9c09730c0eea36d495c3ff6efe3708d8
C语言指针(下篇)
How to realize sliding operation component in fast application