当前位置:网站首页>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 .
边栏推荐
猜你喜欢

How to back up the configuration before the idea when reinstalling the idea

Dynamic extensible representation for category incremental learning -- der

简易打包工具的安装与使用

MySQL优化

STM32疑难杂症之ST-LINK Connection error INVALID ROM TABLE

Use the kaggle training model and download your own training model

类和对象(类和类的实例化,this,static关键字,封装)

Vs code configuration problem

Rotating linked list (illustration)

cve_ 2019_ 0708_ bluekeep_ Rce vulnerability recurrence
随机推荐
Web安全--核心防御机制
On the back door of deep learning model
Vs code configuration problem
Summary of one question per day: String article (continuously updated)
Global and Chinese market of tillage finishing machines 2022-2028: Research Report on technology, participants, trends, market size and share
Use the kaggle training model and download your own training model
C language implements XML generation and parsing library (XML extension)
稀疏矩阵存储
使用wireshark抓取Tcp三次握手
CarSim learning experience - rough translation 1
多站点高可用部署
Carsim problem failed to start Solver: Path Id Obj (X) was set to y; Aucune valeur de correction de xxxxx?
Linked list classic interview questions (reverse the linked list, middle node, penultimate node, merge and split the linked list, and delete duplicate nodes)
11月24号,我们为“满月”庆祝
Array and string processing, common status codes, differences between PHP and JS (JS)
静态库和动态库
How to back up the configuration before the idea when reinstalling the idea
MySQL优化
Matlab数学建模工具
W10 is upgraded to W11 system, but the screen is black, but the mouse and desktop shortcuts can be used. How to solve it