当前位置:网站首页>File upload and download performance test based on the locust framework
File upload and download performance test based on the locust framework
2022-07-02 08:24:00 【Testfan_ zhou】
Make a little progress every day , Pay attention to us , Share test technology articles every day
This article is from 【 Code classmate software test 】
Code student official account : Automated software testing
Tiktok : Small code brother talks about software testing
In many business scenarios , You need to test for file upload and download . When you want to test a business , We must first understand the essence of this business . Let's first look at the essence of uploading and downloading .
File upload process
1、 Select the local file on the browser , Click upload
2、 The browser reads local files , Put the contents of the file into HTTP Requested body in , And then in HTTP Request header , Mark request data type :
Content-type:multipart/form-data,
With post Submit the form to the server .
3、 After the server receives the requested data , Create a new file on the server , take body Write the data in to a file , One time file upload processing is completed .
File download process
1、 Click the download button on the browser , Initiate a HTTP get Type request
2、 After the server receives the request , Read out the contents of the corresponding file , Write to HTTP Response , And mark in the response header Content- Disposition: attachment; filename=xxx
3、 When the browser receives the response , According to the mark, it is recognized that this is a download request , According to the filename Create a file with the same name locally , Then write the data in the response to the file , One download file processing is completed .
It can be seen from the description of uploading and downloading , The so-called file upload and download , In fact, they all attach the contents of the file to HTTP Transmission in the request .
Free collection Code classmate software test Course notes + More learning materials + Full video + The latest interview questions , You can forward articles + Direct messages 「 Code classmate 666」 Get information
Use Locust Upload and download test files
First, let's take a look at the interface documents uploaded and downloaded by a project
File upload script writing
Execute the script , Request in your local browser http://localhost:8089/, Enter concurrent users , and ip port , Click to start execution
Can be in Pycharm Print the return result of each upload on the console
File download script writing
Execute the script , stay locust UI Start testing on the interface , Can be in Pycharm See the return value of the interface
matters needing attention
During file downloading , The server is only responsible for returning the file content to the client , The creation and saving of files should be done by the client . If you do the interface test of the server , There is no need to create files locally . The contents of the file are placed in the response body Medium , Just judge the response body The size of is the same as the file size , That means the download is successful .
I share a benefit with you ! Code scanning reply 【csdn Code group 】 Join the software testing self-study exchange group , Free technical lectures + Receive learning materials + Watch video lessons for free
author : Code classmate software test
The copyright of this article belongs to the author , For any reprint, please contact the author for authorization and indicate the source .
边栏推荐
- 顺序表基本功能函数的实现
- Method recursion (Fibonacci sequence, frog jumping steps, tower of Hanoi problem)
- 多站点高可用部署
- Global and Chinese market of snow sweepers 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese markets of tilting feeders 2022-2028: Research Report on technology, participants, trends, market size and share
- Summary of one question per day: String article (continuously updated)
- Get the width and height of the screen in real time (adaptive)
- 静态库和动态库
- [dynamic planning] p4170: coloring (interval DP)
- How to wrap qstring strings
猜你喜欢
MySQL优化
静态库和动态库
When a custom exception encounters reflection
Array and string processing, common status codes, differences between PHP and JS (JS)
文件上传-upload-labs
双向链表的实现(双向链表与单向链表的简单区别联系和实现)
Fundamentals of music theory (brief introduction)
Use of OpenCV 6.4 median filter
Carsim-实时仿真的动画同步问题
OpenCV 6.4 中值滤波器的使用
随机推荐
Installation and use of simple packaging tools
Carsim-路面3D形状文件参数介绍
Array and string processing, common status codes, differences between PHP and JS (JS)
When a custom exception encounters reflection
Causes of laptop jam
Force buckle method summary: sliding window
深入理解JVM
Use Matplotlib to draw a preliminary chart
Erase method in string
Vscode下中文乱码问题
Matlab other
Force deduction method summary: double pointer
OpenCV常用方法出处链接(持续更新)
Global and Chinese market of tillage finishing machines 2022-2028: Research Report on technology, participants, trends, market size and share
Summary of one question per day: linked list (continuously updated)
Matlab mathematical modeling tool
Using C language to realize MySQL true paging
In depth understanding of prototype drawings
Wang extracurricular words
最长等比子序列