Automatic test method of network security equipment and related device
Through the splitting and reorganization of custom traffic and the automated processing of the tester, the problems of low network security equipment testing efficiency and poor accuracy are solved, automated testing is realized, and testing efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202410981225.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-10-11
AI Technical Summary
The testing efficiency of existing network security equipment is low, the testing environment is complex and testing is easy to miss, resulting in inaccurate test results.
Through the splitting and reorganization of custom traffic, benchmark test traffic is generated and imported into the tester. Based on the test goals, instructions are sent to the tester to convert it into actual test traffic, which is sent to the device under test, and test indicators are counted to achieve automated testing. .
It improves testing efficiency and accuracy, can test multiple devices at the same time, covers different test scenarios, reduces manual intervention, and improves resource utilization.
Smart Images

Figure CN118764422A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software technology, and in particular to an automated testing method and related apparatus for network security equipment. Background Art
[0002] At present, network security equipment testing usually requires testers to construct and send network traffic through testers or packet sending tools. Testers need to pay attention to the task status of the tester, the various resource indicators of the equipment, and the real-time changes of the process status. At the same time, they also need to record the test results in various test scenarios, which leads to low test efficiency. In addition, due to the complex test environment and the interlaced test tasks, testers may miss tests.
[0003] Therefore, there is an urgent need for an automated solution to cover different test scenarios, improve test efficiency, and achieve accurate testing. Summary of the invention
[0004] In view of the above problems, the present application provides an automated testing method and related devices for network security equipment to improve testing efficiency and achieve accurate testing. The specific scheme is as follows:
[0005] A first aspect of the present application provides an automated testing method for a network security device, the automated testing method for a network security device comprising:
[0006] By splitting and reorganizing the custom traffic, the test cases that can generate the benchmark test traffic are imported into the tester;
[0007] Determine a device under test that has established a communication link with the tester;
[0008] Sending a test instruction to the tester based on the test target, so that the tester converts the benchmark test traffic into actual test traffic by executing the test case, and sends the actual test traffic to the device under test;
[0009] The test index of the device under test under the actual test flow is counted.
[0010] In a possible implementation, sending a test instruction to the tester based on the test target so that the tester converts the benchmark test traffic into actual test traffic by executing the test case and sends the actual test traffic to the device under test includes:
[0011] Obtain a first test configuration corresponding to a performance test target;
[0012] A change instruction is sent to the tester based on the first test configuration, so that the tester changes the test case to a performance test case based on the change instruction, changes the benchmark test traffic to a performance test traffic by executing the performance test case, and sends it to the device under test.
[0013] In a possible implementation, the first test configuration includes a main task configuration and a subtask configuration, and sending a change instruction to the tester based on the first test configuration includes:
[0014] Generate multiple subtasks based on the subtask configuration, and register main task threads corresponding to the multiple subtasks based on the main task configuration;
[0015] The main task thread is run, the plurality of subtasks are executed serially through the main task thread, and, for the target subtask currently being executed, the change instruction is sent to the tester according to the configuration information of the target subtask in the subtask configuration.
[0016] In a possible implementation, the counting of test indicators of the device under test under the actual test traffic includes:
[0017] The execution status of the target subtask is monitored, and when the execution status is successful, the performance test index of the device under test under the performance test flow corresponding to the target subtask is counted.
[0018] In a possible implementation, sending a test instruction to the tester based on the test target so that the tester converts the benchmark test traffic into actual test traffic by executing the test case and sends the actual test traffic to the device under test includes:
[0019] Based on the stability test target, an execution instruction is sent to the tester so that the tester uses the test case as a stability test case and sends the benchmark test traffic as stability test traffic to the device under test by executing the stability test case.
[0020] In a possible implementation, the counting of test indicators of the device under test under the actual test traffic includes:
[0021] Obtain a second test configuration corresponding to the stability test target, where the second test configuration includes monitoring items;
[0022] Establishing an SSH connection pool corresponding to the device under test, wherein the connections in the SSH connection pool correspond one-to-one to the monitoring items;
[0023] A monitoring thread is started, and a connection in the SSH connection pool is called through the monitoring thread, so as to obtain monitoring information of the device under test under the corresponding monitoring item through the called connection as a stability test indicator.
[0024] In a possible implementation, the monitoring configuration further includes an alarm item, and the automated testing method for the network security device further includes:
[0025] The stability test indicator is detected based on the alarm item to determine whether to issue an alarm.
[0026] A second aspect of the present application provides an automated testing device for a network security device, the automated testing device for a network security device comprising:
[0027] The use case import module is used to import test cases that can generate benchmark test traffic into the tester by splitting and reorganizing custom traffic;
[0028] The flow test module is used to determine the device under test that has established a communication link with the tester; send a test instruction to the tester based on the test target, so that the tester converts the benchmark test flow into actual test flow by executing the test case and sends it to the device under test; and count the test indicators of the device under test under the actual test flow.
[0029] A third aspect of the present application provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the automated testing method for a network security device according to the first aspect or any implementation of the first aspect.
[0030] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0031] The memory is used to store computer programs;
[0032] The processor is used to execute the computer program so that the electronic device can implement the automated testing method for the network security device of the first aspect or any implementation manner of the first aspect.
[0033] A fifth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the automated testing method for the network security device of the above-mentioned first aspect or any implementation method of the first aspect.
[0034] By means of the above technical scheme, the present application provides an automated testing method for network security equipment, which imports test cases that can generate benchmark test traffic into the tester through the splitting and reorganization of custom traffic; determines the device to be tested that has established a communication link with the tester; sends test instructions to the tester based on the test target, so that the tester converts the benchmark test traffic into actual test traffic by executing the test case and sends it to the device to be tested; and counts the test indicators of the device to be tested under the actual test traffic. In the present application, test cases are imported into the tester through the splitting and reorganization of custom traffic to generate benchmark test traffic. In order to adapt to different test scenarios, test traffic is flexibly defined based on different test targets. The present application makes full use of the resources of the tester, and the tester executes the test case to convert the benchmark test traffic into actual test traffic. Based on this, the test indicators of the device to be tested are counted, which can realize automated testing in different test scenarios, improve test efficiency, ensure test accuracy, and can test multiple network security devices at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0036] Figure 1 An automated testing method for a network security device provided in an embodiment of the present application;
[0037] Figure 2 A partial method flow chart of an automated testing method for a network security device provided in an embodiment of the present application;
[0038] Figure 3 A flowchart of another part of a method for automated testing of a network security device provided in an embodiment of the present application;
[0039] Figure 4 This is another part of the method flow chart of the automated testing method for network security equipment according to an embodiment of the present application;
[0040] Figure 5 This is a schematic diagram of the structure of an automated testing device for network security equipment according to an embodiment of the present application;
[0041] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.
[0043] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0044] The terms "first", "second" etc. in the specification of the application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable in appropriate circumstances, and this is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0045] The embodiment of the present application provides an automated testing method for a network security device. The automated testing method for a network security device in the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0046] See also Figure 1 , Figure 1 An automated testing method for a network security device is provided in an embodiment of the present application. Figure 1 As shown, an automated testing method for a network security device provided in an embodiment of the present application may include the following steps S10 to S40, which are described in detail below.
[0047] S10, by splitting and reorganizing the custom traffic, the test case capable of generating the benchmark test traffic is imported into the tester.
[0048] In the embodiment of the present application, the custom traffic is split and reorganized as the benchmark test traffic, and the corresponding test cases are imported into the tester. Compared with the traffic of the built-in protocol of the tester, the present application supports almost all application layer protocols, and the tester can control the bias and complexity of the traffic more freely. Compared with replaying packets with tools such as tcpreplay, the performance is higher and the network traffic with a higher rate can be constructed.
[0049] In actual applications, testers use packet capture tools such as wireshark to capture custom network traffic (i.e., custom traffic), and the tracking session of the packet capture tool can convert the captured packets into files in C arrays format and then upload them to the test platform. The test platform converts the packet information in the file into client and server dat files, and generates the bpt template file of the tester according to the flow configuration. Finally, the dat file and bpt file are imported into the tester, and the test case is imported into the tester to generate benchmark test traffic.
[0050] S20, determining the device under test that has established a communication link with the tester.
[0051] In the embodiment of the present application, the tester can establish a communication link with one or more devices under test. Specifically, the tester connects the tester and the device under test according to the network topology of the test scenario. The device under test can be directly connected to the tester or connected to the tester through a traffic replicator / switch. By configuring the traffic replicator / switch, the network traffic of the tester can be sent to multiple devices under test.
[0052] S30, sending a test instruction to the tester based on the test target, so that the tester converts the benchmark test traffic into actual test traffic by executing the test case, and sends the actual test traffic to the device under test.
[0053] In the embodiment of the present application, different test targets can be configured according to different test scenarios. For example, the test target of the performance test (i.e., the performance test target) is to flexibly define the test flow, while the test target of the stability test (i.e., the stability test target) is to accurately record the device and flexibly identify anomalies and issue alarms. In this regard, based on different test targets, test instructions can be sent to the tester to control the tester to process its test cases, adjust the benchmark test flow to the actual test flow, and send it to the device under test.
[0054] S40, collecting statistics on test indicators of the device under test under actual test traffic.
[0055] In the embodiment of the present application, the device under test can provide the test platform with SSH (Secure Shell) remote login permission for the operating system. Based on this, the test platform completes the monitoring of the device under test and the statistics of test indicators through remote login.
[0056] In one possible implementation, the test cases can be changed according to the performance test objectives. Figure 2 , Figure 2 This is a partial method flow chart of an automated testing method for a network security device provided in an embodiment of the present application. Figure 2As shown, step S30 in the embodiment of the present application "sending test instructions to the tester based on the test target, so that the tester converts the benchmark test traffic into actual test traffic by executing the test case and sends it to the device under test" may include the following steps S301 to S302, and these steps are described in detail below.
[0057] S301, obtaining a first test configuration corresponding to a performance test target.
[0058] S302, sending a change instruction to the tester based on the first test configuration, so that the tester changes the test case to a performance test case based on the change instruction, changes the benchmark test traffic to the performance test traffic by executing the performance test case, and sends it to the device under test.
[0059] In the embodiment of the present application, the corresponding test configuration (i.e., the first test configuration) can be obtained for the performance test target, and the first test configuration includes the test scheme related parameters of this performance test. Based on the first test configuration, a change instruction can be sent to the tester to instruct the tester to change the test case to obtain the network traffic that meets the requirements.
[0060] In this regard, the tester can change the test case based on the change instruction to obtain a performance test case, change the benchmark test traffic to the performance test traffic by executing the performance test case, and send the performance test traffic to the device under test.
[0061] In actual applications, testers can set up a main task and multiple subtasks to complete them collaboratively during performance testing, thereby supporting parallel tasks on multiple devices and in multiple scenarios. Figure 3 , Figure 3 Another part of the method flow chart of the automated testing method of a network security device provided by the embodiment of the present application. The first test configuration includes a main task configuration and a subtask configuration, such as Figure 3 As shown, in step S302, "sending a change instruction to the tester based on the first test configuration" may include the following steps S3021 to S3022, which are described in detail below.
[0062] S3021, generating multiple subtasks based on the subtask configuration, and registering main task threads corresponding to the multiple subtasks based on the main task configuration.
[0063] S3022, running the main task thread, executing multiple subtasks in series through the main task thread, and, for the currently executed target subtask, sending a change instruction to the tester according to the configuration information of the target subtask in the subtask configuration.
[0064] Specifically, in an embodiment of the present application, the tester can add test case information (including case name and sub-item name, etc.) that references custom traffic in the test platform, and at the same time configure the library table information of the device to be tested corresponding to the custom traffic and the session information of the custom traffic, etc.
[0065] The tester adds a new test task on the test platform. The test task selects the test case that contains custom traffic, and configures parameters such as test type, tester name, device name to be tested, monitoring configuration, execution mode, new value, concurrency value, number of repetitions, monitoring frequency, calculation delay, execution front shell, notification method, test report, etc. Among them, the test types include various performance test scenarios such as single-machine single protocol, multiple-machine single protocol, separated single protocol, single-machine multiple protocols, throughput and background flow, which affect the acquisition and calculation of performance test results; the name of the device to be tested can be selected in multiple ways, in line with the deployment scenario of the performance test; the monitoring configuration can select multiple monitoring plans defined under the performance test; the execution mode includes single execution and multiple executions, and the execution mode, together with the new value, concurrency value, and number of repetitions, controls the trend of the tester generating traffic; the monitoring frequency is used to control the interval time of the monitoring task; the calculation delay is used to control the start time of the statistical test indicators after the tester task is completed, reducing the impact of the equipment warehousing delay; the execution front shell is used to perform some operations on the device to be tested by the tester before starting each subtask, such as restarting the process, releasing resources, etc.; the notification method can be selected from Feishu robots, or defined links and email groups, etc.; the test report can select multiple defined chart sets.
[0066] After the tester starts the performance test task, the test platform first verifies the connectivity between the tester and the device under test. After the connectivity verification is passed, the above configuration parameters are written into the YAML configuration file, and then the chart SQL is generated according to the YAML configuration file and the parameterized configuration of the chart to form a new dashboard for reference by the system dashboard and test report.
[0067] After the configuration is updated, the test platform can obtain the main task configuration and subtask configuration according to the parameter configuration, where the main task configuration can be the default configuration of the thread, and the subtask configuration can include the above execution mode, number of repetitions, new value, concurrency value, etc. The test platform generates multiple subtasks according to the subtask configuration. The subtasks and the main task need to maintain coordination, and also have execution states such as waiting for execution, executing, successful execution, and failed execution.
[0068] After the subtasks are split and persisted, the test platform can register a main task thread for immediate execution through the flask_apscheduler task framework, and then execute the subtasks serially in the main task thread. For the currently executed subtask (i.e., the target subtask), a change instruction is sent to the tester based on the subtask configuration and the configuration information related to the target subtask to modify the test case of the tester, and then execute the execution front shell of the target subtask to start the scheduled monitoring of the device under test. The tester changes the test case to the performance test case corresponding to the target subtask based on the change instruction, and changes the benchmark test traffic to the performance test traffic corresponding to the target subtask by executing the performance test case, and sends it to the device under test.
[0069] Therefore, the embodiments of the present application can support the execution of performance tests with multiple devices and task splitting, split the main task into subtasks according to the configuration of new concurrency and other configurations required by the minimum execution unit, and more flexibly control the local state and overall progress of the task. At the same time, it can also persist finer-grained test data to provide a more accurate data source for subsequent bottleneck analysis. Compared with manually modifying the tester configuration and starting the tester, the tester no longer needs manual intervention during the test process, and only needs to pay attention to abnormal notifications such as network interruptions, which greatly liberates manpower and improves the utilization rate of the tester.
[0070] On this basis, in step S40 of the embodiment of the present application, “counting the test indicators of the device under test under the actual test flow”, the following steps can be adopted:
[0071] Monitor the execution status of the target subtask, and if the execution status is successful, count the performance test indicators of the device under test under the performance test flow corresponding to the target subtask.
[0072] In the embodiment of the present application, after the performance test case corresponding to the target subtask is started, the test platform will continuously monitor the key data such as the execution progress, flow rate, number of sessions, number of frames sent, etc. of the performance test case to determine the execution status of the target subtask. When the target subtask is executed abnormally, the target subtask is deemed to have failed to execute. On the contrary, when the target subtask is executed successfully, the device monitoring is stopped, and the test data of the device under test is counted after the configured calculation delay, and calculated into the performance test index for persistence.
[0073] Specifically, the test platform can calculate the test data according to the test type of the performance test, and automatically determine the type of device under test, and calculate key indicators such as the resolution rate, storage rate, resolution storage rate, throughput, storage rate, and resolution rate of the device under test based on the execution results of the performance test case.
[0074] In addition, after the test platform stores the performance test indicators of the target subtask, it will clear the configuration information of the target subtask, obtain the configuration information of the next subtask waiting to be executed, and then start to execute the next subtask. When all subtasks are completed, the test platform will update the status of the main task, and then start to assemble the test results of this performance test task, obtain the test report link, and send the corresponding notification information through the configured notification method.
[0075] Therefore, the embodiment of the present application supports the statistics of test results of multiple devices and multiple scenarios, and can automatically calculate and store performance test indicators according to the device type and scenario needs, support the calculation of performance test indicators such as resolution rate, storage rate, resolution storage rate, throughput rate, packet loss rate, etc., and adapt to the test scenarios such as foreground flow, background flow, throughput, single protocol, multiple protocols, and long time. Compared with manual calculation of performance indicators, it is more efficient, more accurate, and more conducive to statistics and forming test reports.
[0076] In another possible implementation, the test case can be executed regularly according to the stability test target. In the embodiment of the present application, step S30 "sends a test instruction to the tester based on the test target, so that the tester converts the benchmark test traffic into actual test traffic by executing the test case and sends it to the device under test" can be implemented in the following steps, which are described in detail below.
[0077] Based on the stability test target, an execution instruction is sent to the tester so that the tester uses the test case as a stability test case and sends the benchmark test traffic as stability test traffic to the device under test by executing the stability test case.
[0078] In the embodiment of the present application, an execution instruction can be sent to the tester regularly for the stability test target, instructing the tester to regularly output stability test traffic. In this regard, the tester can regularly execute test cases based on the execution instruction and send the benchmark test traffic as stability test traffic to the device under test.
[0079] Based on this, see Figure 4 , Figure 4 This is another part of the method flow chart of the automated testing method of a network security device according to an embodiment of the present application. Figure 4 As shown, in the embodiment of the present application, step S40 "counting test indicators of the device under test under actual test traffic" can adopt the following steps S401 to S403, and these steps are described in detail below.
[0080] S401, obtaining a second test configuration corresponding to a stability test target, wherein the second test configuration includes monitoring items.
[0081] S402, establishing an SSH connection pool corresponding to the device under test, where the connections in the SSH connection pool correspond to the monitoring items one by one.
[0082] S403, start the monitoring thread, call the connection in the SSH connection pool through the monitoring thread, and obtain the monitoring information of the device under test under the corresponding monitoring item through the called connection as the stability test indicator.
[0083] In an embodiment of the present application, the tester can customize the test configuration (i.e., the second test configuration) corresponding to the stability test target in the test platform, and the second test configuration contains at least monitoring items. Specifically, the types of monitoring items are divided into process monitoring, system monitoring, and file monitoring, among which process monitoring and system monitoring can define the shell command to obtain the returned number, string, or Boolean value for further threshold judgment or expectation judgment; file monitoring can define file paths and file keywords for log identification and crash debugging. At the same time, additional configuration thresholds and expectations can be added to the monitoring items for alarm judgment.
[0084] After defining the monitoring items, testers can bind the equipment to be tested and the monitoring items, and then reference them in the test tasks. At the same time, you can also select alarm detectors, such as threshold alarms, crash alarms, restart (null value) alarms, log alarms, replacement alarms, and disappointment alarms. Among them, the threshold alarm is an alarm when the value of the monitoring item exceeds the custom threshold; the crash alarm is an alarm when a crash file is generated under the custom path; the restart (null value) alarm is an alarm when the monitoring item returns an empty result, and when the process pid changes compared to the last time; the log alarm is an alarm when the custom log file recognizes the configuration keyword; the replacement alarm is an alarm when the md5 value of the monitoring item file changes; the disappointment alarm is an alarm when the monitoring item result does not meet expectations.
[0085] When starting the stability test task, the test platform can construct a separate monitoring configuration dictionary for each device under test according to the second test configuration, and write it into the YAML configuration file for easy reading by the subsequent monitoring thread.
[0086] Furthermore, the test platform generates a corresponding SSH connection pool according to the monitoring item configuration of the device under test, and also initializes different numbers of long connections and short connections according to the shell command execution mode of the monitoring item.
[0087] After the SSH connection pool is initialized successfully, the test platform can start the scheduled monitoring thread for the device under test through the flask_apscheduler task framework, and pass the connection pool object as a parameter. The interval trigger of the task framework can ensure that the monitoring tasks are executed simultaneously, ensuring the comparability of the monitoring data.
[0088] When the test platform performs scheduled monitoring tasks, it can form different execution steps according to the type, data type and execution method of the monitoring item. Specifically, when the data type is a Boolean value, it only needs to determine whether the command execution result is empty; when the type of the monitoring item is a process or system, call the long connection or short connection execution method of the command; when the type of the monitoring item is a file, first determine whether the file path is a folder or a file. If it is a folder, call the crash file check method. If it is a file, determine whether the data type is md5 or string. If it is md5, call the file md5 verification method, otherwise call the log file check method.
[0089] Specifically, when calling a short connection to execute a shell command, the test platform first takes out a connection from the short connection pool and executes it through the exec_command() method. If the connection is successful, the short connection is put back into the connection pool. If the connection fails, a new connection is created and put back into the connection pool after execution. Finally, the execution result is judged and returned. When calling a long connection to execute a shell command, a connection is first taken out from the long connection pool and executed through the invoke_shell() method. If the connection is successful, it is put back into the connection pool. If the connection fails, a new connection is created and put back into the connection pool. After the invoke_shell() method sends the shell command, it is necessary to loop to take out the string from the terminal, and judge whether the command has been executed based on the blank line and the shell string match, and judge whether the command has been executed incorrectly based on characters such as "-sh:". Finally, the execution result is returned.
[0090] It should be noted that the execution result returned by the monitoring thread calling the long connection or short connection in the SSH connection pool is the monitoring information of the monitoring item, which is used as a stability test indicator and stored in the database.
[0091] On this basis, the embodiment of the present application also supports an alarm function for monitoring items. In this regard, the monitoring configuration also includes an alarm item, and accordingly, the automated testing method for network security equipment also includes the following steps:
[0092] The stability test indicators are tested based on the alarm items to determine whether an alarm should be issued.
[0093] Specifically, in an embodiment of the present application, for monitoring items whose return data type is a Boolean value, determine whether a restart (null value) alarm is required; for monitoring items whose type is a process or system, first determine whether a threshold alarm is required, and then determine whether a disappointment alarm is required; for monitoring items whose type is a file and whose path is a folder, determine whether a crash alarm is required; for monitoring items whose type is a file, whose path is a file, and whose data type is md5, determine whether a replacement alarm is required; for monitoring items whose type is a file, whose path is a file, and whose data type is a string, determine whether a log alarm is required.
[0094] For crash alarms, testers need to associate the crash folder and the crash process path. When the monitoring process detects a new crash file in the crash folder, it first needs to use the minidump-2-core tool to convert the dmp file into a core file, and then use the gdb tool to obtain the stack information based on the crash process. For log alarms, testers need to define the log path and alarm keywords when defining monitoring items. The monitoring process uses the scp client or sftp server to periodically download or receive log files from the device under test, and then compares them with the previously obtained log files at the line level, extracts the newly added logs to match the keywords, and then overwrites the old log files.
[0095] In order to reduce repeated alarms, the embodiment of the present application can also calculate the frequency of restart (null value) alarms, threshold alarms, and disappointment alarms. When the device under test exceeds the set frequency within the set time period, only statistics are performed without alarming. At the same time, string comparison is performed on log alarms and crash alarms. When the similarity in the log information or crash information of the device under test exceeds the set value within the set time period, only statistics are performed without alarming.
[0096] In addition, the test platform can first store the stability test indicators according to the alarm results of the monitoring items, then assemble different alarm information according to the alarm type, and add directional information according to the set responsible person uid, and finally send the alarm to the specified group through the Feishu robot's API link or custom email group. When the stability test task stops, the test platform can stop the scheduled monitoring task of the device under test through flask_apscheduler, and clear the SSH connection pool of each device and close the SSH connection in time;
[0097] Therefore, the embodiment of the present application can dynamically establish and dynamically update the SSH connection pool, and initialize and share it according to the connection information of the device under test and the type and number of corresponding monitoring items when each task starts to execute. Compared with the SSH connection that is established and dismantled at the same time, this technology can save network IO overhead and improve the efficiency of monitoring task execution. In addition, each device under test maintains an independent SSH connection pool, which can effectively avoid the impact of device anomalies and network anomalies on the overall monitoring task. Establishing the connection pool in a minimized manner can minimize the use of the resources of the device under test itself;
[0098] In addition, command-based monitoring and file-based monitoring are supported through custom monitoring items. Digital types, character types, Boolean types, and unique pid types, md5 types, and text file types are supported. Customized or built-in shell commands are executed from the device under test at a frequency of seconds through the SSH connection pool. Compared with the tester manually accessing the device background to execute commands to obtain results, the advantages are that multiple devices can be monitored at the same time, device status can be obtained at fixed time intervals, data errors can be reduced, status data can be persisted to the database, and test reports can be generated directly. Compared with the method of built-in shell script monitoring in the device under test, the advantages are that the potential impact on the device is smaller, the definition of monitoring items is more free, and theoretically all shell commands on the device under test are supported, with strong compatibility. Compared with the node_exporter component or custom component of the prometheus monitoring platform for monitoring, it can avoid repeated deployment processes, is more suitable for the test environment of agile development and rapid deployment, and reduces the difficulty of custom monitoring items.
[0099] Moreover, through customized alarm items, it supports threshold alarms, log alarms, expected alarms, restart (null value) alarms, replacement alarms, and crash alarms. It has a deduplication function, and testers can customize the thresholds, log keywords, expected values, and debugging commands of monitoring items. Compared with manual inspection of equipment anomalies, it can significantly improve inspection efficiency, increase the exposure rate of abnormal phenomena, and have a significant auxiliary effect on problem tracing. Compared with relying on the alarm log of the device itself, the alarm items that can be defined have higher coverage and more timely notifications to the responsible person.
[0100] Therefore, the monitoring alarms of the embodiments of the present application are based on dynamic SSH connection pools, custom monitoring items, and custom alarm items, which can reduce the impact of monitoring tasks on the devices under test, and improve the compatibility of monitoring items on devices under test with different architectures. It can also cover common stability defects of the devices under test, and complete real-time troubleshooting through notification linkage.
[0101] In practical applications, in order to realize the data visualization requirements of intuitively analyzing performance bottlenecks and quickly tracing historical data, the embodiment of the present application can also provide a visualization analysis system based on parameterized charts and built-in charts, including a MySQL database, a Grafana platform, a LayUI component, and a chart generation component;
[0102] The MySQL database is the data source for data visualization analysis. During the test, monitoring information, result information, and alarm information will be persisted in the database. The Grafana platform generates display charts and instruments based on the JSON data constructed by the chart generation module and provides accessible API links. The LayUI component includes components such as tables, pop-ups, and carousels to form visualization functions such as monitoring data query, test result query, historical report query and jump, and real-time dashboard. The chart generation component generates charts and chart collections based on system-built-in or user-defined chart templates and chart groups.
[0103] In this way, customized dynamic generation of charts and reports can be realized. For parameterized chart configuration, the values corresponding to the keys in the parameterized configuration can be read from the yaml configuration file, and then the SQL statements in the template configuration can be reconstructed, and then the chart json can be generated to realize dynamic reconstruction of the chart template. Compared with charts with fixed SQL statements, this method has stronger reusability and compatibility. Compared with reports with fixed charts, customized reports can better meet the differences in test reports in various scenarios.
[0104] In actual use, this application can be written as a whole using Python code, and the test platform can be built using the BS architecture, which can be deployed on both Windows and Linux environments. The front-end components use the layui framework that is friendly to back-end development, and the back-end uses the flask framework with good scalability. The test report uses the grafana framework with rich charts and friendly interfaces.
[0105] In summary, the automated testing method for network security devices provided in the embodiments of the present application has the following advantages:
[0106] 1) Supports performance testing of multiple devices and task splitting. It significantly improves resource utilization and test efficiency. In the past, it took one working day to test the performance of a single protocol of a model of equipment. Now, one working day can test the performance of two protocols of at least five models of equipment. Resource utilization and test efficiency have been improved by 10 times. At the same time, it meets the construction requirements of network traffic. Testers can customize the protocol, port, request statement, response content, etc. of network traffic, and complete the coverage of test scenarios such as single protocol, multiple protocols, pure foreground flow, foreground flow + background flow, complex requests, and large response packets.
[0107] 2) Support dynamic SSH connection pool and custom monitoring items. It can adapt to all devices that support SSH remote login, and realize the monitoring of system resources, process resources, logs and files, such as system CPU usage, system memory usage, system CPU usage (including core binding and core isolation), process CPU usage, process memory usage, disk IO rate, network card packet loss, process logs, configuration files, etc. The monitoring information calculated by reading data from system files with shell commands is more accurate and consumes less resources than the data displayed by tools such as top, iostat, and pidstat. After the monitoring information is persisted in the database, R&D personnel can more easily trace back the various resource status and log records of the device at a certain moment, providing reference and ideas for auxiliary troubleshooting.
[0108] 3) Support for custom alarm items. Support for identification and alarm of some special faults is of great help for fault discovery and analysis of stability testing. During the test process, the exposure rate of serious problems such as abnormal binding core, memory leak, process crash, process restart, network card packet loss, file corruption, table transfer failure, and disk cleanup failure is significantly improved, reducing the possibility of serious stability problems flowing into the market.
[0109] 4) Supports custom dynamically generated charts and reports. This effectively improves the tester's ability to analyze bottlenecks in performance testing, while reducing the workload of writing test reports. The dynamically generated resource curves and bar charts can clearly analyze the overall resource situation of the device under test at a certain rate of network traffic, quickly find the shortcomings of the CPU or memory, and then analyze the optimization space of the device in parsing and warehousing, providing reference and troubleshooting direction for performance optimization.
[0110] An automated testing method for a network security device provided in an embodiment of the present application is introduced above. A device for executing the automated testing method for a network security device is introduced below.
[0111] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of an automated testing device for network security equipment according to an embodiment of the present application. Figure 5 As shown, the automated testing device of the network security device includes:
[0112] A case import module 10 is used to import a test case capable of generating a benchmark test flow into the tester by splitting and reassembling the custom flow;
[0113] The traffic test module 20 is used to determine the device under test that has established a communication link with the tester; send test instructions to the tester based on the test target, so that the tester converts the benchmark test traffic into actual test traffic by executing the test case and sends it to the device under test; and count the test indicators of the device under test under the actual test traffic.
[0114] In a possible implementation, the flow test module 20 is used to send a test instruction to the tester based on the test target so that the tester converts the benchmark test flow into the actual test flow by executing the test case and sends it to the device under test, specifically for:
[0115] Obtain a first test configuration corresponding to the performance test target; send a change instruction to the tester based on the first test configuration, so that the tester changes the test case to a performance test case based on the change instruction, changes the benchmark test traffic to the performance test traffic by executing the performance test case, and sends it to the device under test.
[0116] In a possible implementation, the first test configuration includes a main task configuration and a subtask configuration, and the flow test module 20 for sending a change instruction to the tester based on the first test configuration is specifically used to:
[0117] Generate multiple subtasks based on the subtask configuration, and register the main task threads corresponding to the multiple subtasks based on the main task configuration; run the main task thread, execute multiple subtasks serially through the main task thread, and, for the target subtask currently being executed, send a change instruction to the tester according to the configuration information of the target subtask in the subtask configuration.
[0118] In a possible implementation, the flow test module 20 for counting the test indicators of the device under test under the actual test flow is specifically used for:
[0119] Monitor the execution status of the target subtask, and if the execution status is successful, count the performance test indicators of the device under test under the performance test flow corresponding to the target subtask.
[0120] In a possible implementation, the flow test module 20 is used to send a test instruction to the tester based on the test target so that the tester converts the benchmark test flow into the actual test flow by executing the test case and sends it to the device under test, specifically for:
[0121] Based on the stability test target, an execution instruction is sent to the tester so that the tester uses the test case as a stability test case and sends the benchmark test traffic as stability test traffic to the device under test by executing the stability test case.
[0122] In a possible implementation, the flow test module 20 for counting the test indicators of the device under test under the actual test flow is specifically used for:
[0123] Obtain a second test configuration corresponding to the stability test target, wherein the second test configuration includes monitoring items; establish an SSH connection pool corresponding to the device under test, wherein the connections in the SSH connection pool correspond one-to-one to the monitoring items; start a monitoring thread, and call the connection in the SSH connection pool through the monitoring thread to obtain the monitoring information of the device under test under the corresponding monitoring item through the called connection as a stability test indicator.
[0124] In a possible implementation, the monitoring configuration further includes an alarm item, and the flow test module 20 is further used to:
[0125] The stability test indicators are tested based on the alarm items to determine whether an alarm should be issued.
[0126] It should be noted that the detailed functions of each module in the embodiment of the present application can be found in the corresponding disclosed part of the embodiment of the automated testing method for the network security device mentioned above, and will not be repeated here.
[0127] The present application also provides an electronic device in an embodiment. Figure 6 , Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, notebook computers, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0128] like Figure 6 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0129] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0130] An embodiment of the present application also provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any automated testing method for network security devices provided in the embodiments of the present application.
[0131] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any automated testing method for a network security device provided in an embodiment of the present application.
[0132] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0133] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0134] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0135] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. An automated testing method for network security equipment, characterized in that: The automated testing method for network security equipment comprises: By splitting and reorganizing the custom traffic, the test cases that can generate the benchmark test traffic are imported into the tester; Determine a device under test that has established a communication link with the tester; Sending a test instruction to the tester based on the test target, so that the tester converts the benchmark test traffic into actual test traffic by executing the test case, and sends the actual test traffic to the device under test; The test index of the device under test under the actual test flow is counted.
2. The automated testing method for network security equipment according to claim 1, characterized in that: The sending of a test instruction to the tester based on the test target, so that the tester converts the benchmark test traffic into actual test traffic by executing the test case, and sends the actual test traffic to the device under test, includes: Obtain a first test configuration corresponding to a performance test target; A change instruction is sent to the tester based on the first test configuration, so that the tester changes the test case to a performance test case based on the change instruction, changes the benchmark test traffic to a performance test traffic by executing the performance test case, and sends it to the device under test.
3. The automated testing method for network security equipment according to claim 2, characterized in that: The first test configuration includes a main task configuration and a subtask configuration, and sending a change instruction to the tester based on the first test configuration includes: Generate multiple subtasks based on the subtask configuration, and register main task threads corresponding to the multiple subtasks based on the main task configuration; The main task thread is run, the plurality of subtasks are executed serially through the main task thread, and, for the target subtask currently being executed, the change instruction is sent to the tester according to the configuration information of the target subtask in the subtask configuration.
4. The automated testing method for network security equipment according to claim 3, characterized in that: The counting of test indicators of the device under test under the actual test flow rate includes: The execution status of the target subtask is monitored, and when the execution status is successful, the performance test index of the device under test under the performance test flow corresponding to the target subtask is counted.
5. The automated testing method for network security equipment according to claim 1, characterized in that: The sending of a test instruction to the tester based on the test target, so that the tester converts the benchmark test traffic into actual test traffic by executing the test case, and sends the actual test traffic to the device under test, includes: Based on the stability test target, an execution instruction is sent to the tester so that the tester uses the test case as a stability test case and sends the benchmark test traffic as stability test traffic to the device under test by executing the stability test case.
6. The automated testing method for network security equipment according to claim 5, characterized in that: The counting of test indicators of the device under test under the actual test flow rate includes: Obtain a second test configuration corresponding to the stability test target, where the second test configuration includes monitoring items; Establishing an SSH connection pool corresponding to the device under test, wherein the connections in the SSH connection pool correspond one-to-one to the monitoring items; A monitoring thread is started, and a connection in the SSH connection pool is called through the monitoring thread, so as to obtain monitoring information of the device under test under the corresponding monitoring item through the called connection as a stability test indicator.
7. The automated testing device for network security equipment according to claim 6, characterized in that: The monitoring configuration also includes an alarm item, and the automated testing method for the network security device also includes: The stability test indicator is detected based on the alarm item to determine whether to issue an alarm.
8. An automated testing device for network security equipment, characterized in that: The automated testing device for network security equipment comprises: The use case import module is used to import test cases that can generate benchmark test traffic into the tester by splitting and reorganizing custom traffic; The flow test module is used to determine the device under test that has established a communication link with the tester; send a test instruction to the tester based on the test target, so that the tester converts the benchmark test flow into actual test flow by executing the test case and sends it to the device under test; and count the test indicators of the device under test under the actual test flow.
9. A computer program product, characterized in that It comprises computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the automated testing method for a network security device as claimed in any one of claims 1 to 7.
10. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the automated testing method for the network security device according to any one of claims 1 to 7.
Citation Information
Cited By
Automatic test system and method compatible with multiple AT instructions
CN120692187A
