当前位置:网站首页>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 .
边栏推荐
- Matlab - autres
- MySQL优化
- Carsim-问题Failed to start Solver: PATH_ID_OBJ(X) was set to Y; no corresponding value of XXXXX?
- On the confrontation samples and their generation methods in deep learning
- SQL server如何卸载干净
- Static library and dynamic library
- Jupyter Notebook常用快捷键(在命令模式中按H也可查看)
- Several methods of image enhancement and matlab code
- 旋转链表(图解说明)
- 力扣每日一题刷题总结:栈与队列篇(持续更新)
猜你喜欢

VS Code配置问题

Simple implementation scheme of transcoding and streaming (I)

Matlab数学建模工具

A brief analysis of graph pooling

Fundamentals of music theory (brief introduction)

How to build the alliance chain? How much is the development of the alliance chain

When a custom exception encounters reflection

C语言实现XML生成解析库(XML扩展)

Array and string processing, common status codes, differences between PHP and JS (JS)

Web安全--核心防御机制
随机推荐
STL速查手册
Dynamic extensible representation for category incremental learning -- der
Carsim-问题Failed to start Solver: PATH_ID_OBJ(X) was set to Y; no corresponding value of XXXXX?
Chinese garbled code under vscade
简易打包工具的安装与使用
Summary of one question per day: stack and queue (continuously updated)
Force deduction method summary: find classes
Using super ball embedding to enhance confrontation training
Comparison between setTimeout and requestanimationframe (page refresh)
install.img制作方式
MySQL optimization
乐理基础(简述)
Animation synchronization of CarSim real-time simulation
cve_ 2019_ 0708_ bluekeep_ Rce vulnerability recurrence
Global and Chinese market of snow sweepers 2022-2028: Research Report on technology, participants, trends, market size and share
When a custom exception encounters reflection
Matlab - autres
方法递归(斐波那契数列,青蛙跳台阶,汉诺塔问题)
One of the reasons for WCF update service reference error
Smart agriculture solutions smart agriculture system development