Linux-based performance testing tool

Linux-based performance testing tool

Introduction

In the process of performance testing, many performance acquisition tools were investigated, but because some functions in the business did not match, the cost of testing still increased greatly, so the test team decided to develop a performance testing tool suitable for the current work , the test team used time outside of work to carry out training, functional design, development, etc., and the final tool was completed. The current tool is an open architecture, and more functional modules can be added later.

Engineering introduction

The project uses python3.7 as the basic language, combined with pyqt5 and BeautifulReport (refactoring), the structure separates the UI interface from the function code, and separates each pop-up dialog, and interacts with the main window through inheritance. The main operation is placed in the main In the file, make the UI, function, and operation independent.

engineering structure

insert image description here

Environment build

The built-in python environment does not depend on the user's host environment, so there is no need to specially build the environment.
insert image description here

reference library

PyQt5、traceback、paramiko、threading、datetime、time、os、sys、re、socket、pynput、ctypes、inspect、json。

UI composition

The main body of the UI interface is built with PyQt5 as the core, and the signal is bound to the slot function through the built-in function (toggled.connect).insert image description here

Configuration file composition

The user's operating habits are recorded through the configuration file, and a tool configuration dialog is provided to visually display the variables in the tool in front of the user.
The configuration file is divided into user operation records and initialization data. We store the user operation record configuration in the ini file, and store the initialization data in config.py, which reduces the running time when the tool is initialized.
insert image description here

report structure

The report reads the template file, specifies the generation location, fills the data obtained by the algorithm into the template, and finally forms a report file.insert image description here
insert image description here
insert image description here

Features

Performance testing tool, which integrates performance collection, multiple log sending modes, performance parameter calculation, performance threshold alarm, CPU peak EPS estimation, timed task, screenshot, performance automation test, text conversion tool, automatic generation of performance report, system Settings and other functions, and tool modules can be taken out separately to form an independent tool.

Main interface

insert image description here

Performance Collection-Setting

Before performance collection, you need to set the alarm threshold first. The default is 0%, which means that when the collected CPU and memory usage exceeds 0%, a performance alarm message will be generated. You can set the alarm threshold by sliding the progress bar, and the maximum value is 99. %.
insert image description here

new connection

To create a new connection, click New-New Connection in the menu bar, and the interface for creating a new connection will pop up.
insert image description here
Enter the host ip, port, account, and password to be collected, and click the test button. If it fails, it will prompt that the connection failed. If it succeeds, it will prompt that the test is successful. After the test is successful, click Save, and the machine information configured this time will be collected when the collection performance is executed. At the same time, the newly created connection information will also be synchronized to the system settings.
insert image description here

Log sending

There is a check box for sending logs in the system column. When this check box is checked, the log with the local machine as the source will be sent to the newly connected IP via UDP when the collection is running.
Log sending supports three modes, 1. Fixed sending rate 2. Interval sending rate 3. Specified sending rate.
insert image description here

fixed sending rate

If the fixed sending rate is checked, the user can manually slide the progress bar to set the fixed sending rate, up to 20000. For example, dragging the progress bar to the position of 3000 means that the sending rate will continue at 3000 per second.
insert image description here

Interval sending rate

Check the interval sending rate, the user selects the initial sending rate and the ending sending rate, the minimum is 1000, and the maximum is 20000. For example: the initial sending rate is selected as 1000, and the ending sending rate is selected as 20000, which means that it starts from 1000 and increases by 100 each time for 10 seconds , until the sending reaches 20000, it will stop automatically. If the continuous sending in the system column is checked, when the sending rate has reached 20000, it will not stop until the manual end or the scheduled task start ends.
insert image description here
insert image description here

Specify sending rate

Select the specified sending rate, the input box is highlighted and can be input, and the input format is separated by English commas. For example: input [1000,2000,3000], which means that the sending will be sent according to 1000, 2000, and 3000, and it will last for 10 seconds at a time. After 3000 sending is completed, the sending log will end. If the continuous sending in the system column is checked, when the sending rate has reached 3000, it will not stop until the manual end or the scheduled task start ends.
insert image description here

timed end

Tick ​​the checkbox of Set Termination Task Time to check whether the time is legal before running, and give a corresponding prompt. When the end time is triggered, performance collection and log sending will stop.
insert image description here

system settings

The system setting entry is in the menu bar - setting, click the setting to pop up the setting pop-up box, the system setting is divided into new connection, tool UI, file path, sending setting, with functions such as saving, canceling, restoring, and testing.
The test button in the system settings is consistent with the principle in the new connection. It tests whether the collection IP can be connected, and the background color of the window status will take effect the next time the tool is run.
insert image description here

Operating position

Run can be seen in two places, the first is the start button of the system bar, and the second is the run control - run of the menu bar.
insert image description here

Before running

Before running, you need to configure the correct collection IP, port, account, password and other configuration items, set the CPU and memory alarm thresholds, choose whether to send logs, and refer to the previous settings.
insert image description here

start operation

After the operation starts, the system bar will display the running status, for example: reading configuration, sorting data, starting to run, sending failed, performance collection is normal, log sending failed, etc.
insert image description here
insert image description here

performance curve

After starting to collect performance, the middle area of ​​the tool will display curve fluctuations. The blue line is the CPU fluctuation, and the green is the memory fluctuation. state.
insert image description here

Performance Collection - Alarm Details

Set the threshold. When the occupancy rate of the collected performance data is greater than this threshold, an alarm will be generated. Click the alarm details to see the time when the alarm occurred, CPU information, memory information, CPU detailed information, memory detailed information, SWAP information, and process information. etc., the interface is displayed in a list form, displaying the top ten data.
insert image description here
insert image description here
insert image description here

Performance Collection - Peak Details

During the performance collection process, the peak value of CPU and memory will be calculated, and other data information when the peak value occurs will be taken out and displayed. The data includes occurrence time, CPU information, memory information, CPU detailed information, memory detailed information, SWAP information, process information, etc. .
insert image description here

Performance automated testing

Click Tools-Automatic Test in the menu bar, and a prompt box will pop up. Because of the tool settings, when the automated test starts, it cannot be interrupted until the test is completed, which lasts about 15 minutes.
insert image description here
The automated test will start from 100EPS, and the log will be automatically sent and the log volume will increase. During the automated test, the state changes and the tool performance line chart will be dynamically refreshed until the test is completed and finally a report is generated.
insert image description here

performance report

After the performance collection is finished, the performance report and performance text will be generated according to the location of the storage report defined in the system settings. The text is in txt format, and the report is in html format. Double-click the report to view the report content. The report content includes: test IP, startup time , CPU peak value and details, CPU average value, memory peak value and details, memory average value, CPU alarm number and details, sending cycle, memory alarm number and details, total data sent, CPUMAXEPS and other data.
insert image description here
insert image description here
You can view the corresponding detailed information on CPU memory peak value and alarms.

CPU, memory peak details

insert image description here

CPU and memory alarm details

insert image description here

Full screen\Non-full screen display

The test tool has the functions of full-screen display and cancellation of full-screen display. After full-screen display, the window cannot be closed or reduced. After clicking Cancel Full Screen, the window exits the full-screen state, and the window can be closed or reduced.
insert image description here

screenshot

Click Tools-Screenshot Tool in the system bar to start capturing the current screen, and the screenshot interface turns gray and white, and you can get a screenshot by dragging the area with the mouse, and you can choose to save it or cancel it.
insert image description here

text conversion tool

Click Tools-Text Conversion Tool in the menu bar, the text conversion tool interface will pop up, and the interface contains.
The original text input box, which is used to place the original string.
The replacement method list box is used to store the selected text and the corresponding replacement method, which is easy to check.
insert image description here
In the operation area, there are three kinds of setting information, the time setting is used for time replacement, the text setting is used for replacing text content, and the number setting is used for replacing integers, decimals, and IP.
insert image description here
Generate a text path, if not set, it defaults to the current root directory.
The number of repetitions, the number of times new generated text is inserted into the document.
insert image description here
Replacement steps: Input the original text before conversion
insert image description here
into the operation area in advance, because the replacement methods are divided into three ways, so you need to set the time setting in advance before each selection of replacement
: if you check the time format of the first line, follow the input format to generate a random time, if not checked, it will be generated according to the default format (2021-9-12-1-1), supports two rules for time generation (1) Interval time, you need to enter the start and end time, and The end time must be greater than the start time, and the generated random time will be between the two times (2) Define the time. After checking the defined time, you need to check the previous time and the later time. If you check the previous time, a time before the current time will be generated. A random time, if checked, the time will generate a random time after the current time, if both are checked, an arbitrary time will be randomly generated.
Text setting: Select Chinese random, it will generate a string of Chinese character strings with the same length as the selected original text Text random, select English random, it will generate a string of English character strings with the same length as the selected original text Alphabet random, select the specified text , enter any content, and the input content will replace the selected text.
Number setting: select integer random, and do not enter Start and End to generate an arbitrary random integer, otherwise, enter Start and End to generate an integer in the interval, select decimal random, and do not enter Start and End to generate Generate an arbitrary random decimal, otherwise a decimal within the interval will be generated if Start and End are entered, and a random IP address will be generated if random IP is selected.
insert image description here
Select any segment in the original text string, right-click to select the replacement method.
insert image description here
Select the generated text path and the number of repetitions to have default values ​​and you can leave it blank. The path defaults to the root directory where the tool is located, and the number of times defaults to 1.
insert image description here
Click the Extract button
insert image description here
insert image description here
to view the generated text
insert image description here
insert image description here
insert image description here

Contract tool

The contract sending tool supports local IP and simulated IP sending logs, sending through UDP, and supports the adjustment of sending rate and the setting of sending times.
insert image description here
Sending steps: Select the sending method, simulate IP sending and local IP sending, the simulated IP will use the input source IP address as the source IP to send, if you choose the local IP, the current computer IP will be used as the source IP to send , to send to the input destination IP address, the input IP must be legal, the default input port is 514, and modification is supported.
Select the log, support the selection of three types of logs
Send a line of logs, input the sent logs into the drop-down box Select the file to send
, click the button to select the file on the right, split it with a new line after selection, traverse the document
to select the folder to send, click the right The select folder button on the side, after selection, the text in the folder is convenient, and then divided by newlines, traverse the document
to select the sending rate and input the number of sending times, the sending rate is a drop-down box, supporting up to 20000EPS, but due to network card, hardware and other factors, there is something wrong Not so much can be sent, depending on the actual situation, you can choose to run multiple contract sending tools independently, or you can increase the sending rate.
Running in the background, after clicking the running in the background, the sending log tool is hidden, and it will be displayed again when clicking the tool - sending tool again.
Run, click Run to start sending logs, and automatically stop sending when the number of runs is reached.
Reset the count. After running, it will record the sent quantity. After clicking reset count, the sent quantity will be cleared, and the program will continue to run.

Support tools running in the background

insert image description here

help menu

A help menu is provided that describes the functionality of the tool.
insert image description here

Guess you like

Origin blog.csdn.net/qq_36616956/article/details/128922247