Automatic traffic playback method and device, program and electronic equipment
By identifying and comparing the request data and response data of the system to be tested, traffic playback test is automatically completed, and cumbersome and error-prone problems in the existing technology are solved, and the simplification and accuracy of the test process are achieved.
Patent Information
- Application Number
- CN202510396497.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-07-11
AI Technical Summary
In the prior art, the traffic replay steps are cumbersome and prone to errors, requiring a lot of manpower and time, and there are human errors.
By obtaining the traffic data of the system to be tested and identifying it, sending the request data with the identification to the system to be tested for processing, intercepting and comparing the output data to be generated to generate comparison results, automated traffic playback testing is realized.
Automatic traffic playback testing is implemented, the testing process is simplified, the testing accuracy is improved, and the correct matching of requests and response data and the processing results of each request can be accurately tracked.
Smart Images

Figure CN120295920A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automated testing technologies, and in particular, to an automatic traffic playback method, a playback device, a computer program product, and an electronic device. Background Art
[0002] With the continuous evolution and development of systems, the functions of systems are becoming increasingly rich. Any modification to the common part may lead to an expansion of the modification scope. Each time the system is modified, regression testing needs to be performed on all transactions. The traditional traffic playback method requires manual regression testing for each transaction that may be affected one by one. Moreover, due to the interaction between multiple systems, a large amount of manpower and time are required, and human errors are likely to occur. Summary of the Invention
[0003] The main purpose of this application is to provide an automatic traffic playback method, a playback device, a computer program product, and an electronic device, so as to at least solve the problem that the traffic playback steps in the prior art are cumbersome and error-prone.
[0004] To achieve the above object, according to one aspect of this application, an automatic traffic playback method is provided, including: obtaining target traffic data, where the target traffic data is at least part of the traffic data in the system to be tested, and the target traffic data includes a plurality of request data received by the system to be tested and first data output by the system to be tested according to the request data; identifying the target traffic data so that each of the request data and the first data in the target traffic data has an identifier, and the identifiers of any two request data are different, and the request data and the corresponding first data have the same identifier; sending at least part of the request data with identifiers to the system to be tested for processing, so that the system to be tested outputs second data; intercepting the second data with identifiers, and comparing the first data and the second data with the same identifier to generate a comparison result, where the second data with identifiers is the data output by the system to be tested according to the request data with identifiers, and the comparison result at least includes a result indicating whether the first data and the second data with the same identifier are consistent.
[0005] Optionally, obtaining target traffic data includes: receiving a task time period, where the task time period is the task time period preset by the user; according to the task time period, obtaining the traffic data within the task time period from the log center of the system to be tested to obtain the target traffic data, where the log center includes all the request data received by the system to be tested and the data output by the system to be tested in response to each request data, and the task time period includes at least one time period.
[0006] Optionally, the request data with an identifier is target request data. Sending at least part of the request data with an identifier to the system under test for processing includes: receiving the number of concurrent requests, which is the number of concurrent requests preset by the user. The number of concurrent requests is the number of the target request data sent to the system under test simultaneously, and the number of concurrent requests is less than or equal to the total number of the target request data; sending the target request data with the number of concurrent requests to the system under test for processing.
[0007] Optionally, the method further includes: monitoring the resource utilization rate of the system under test in real time; reducing the number of concurrent requests when the resource utilization rate is greater than a first preset threshold, and increasing the number of concurrent requests when the resource utilization rate of the system under test is less than or equal to a second preset threshold, where the first preset threshold is greater than or equal to the second preset threshold.
[0008] Optionally, after obtaining the target traffic data and before identifying the target traffic data, the method further includes: performing a predetermined process on the traffic data to at least remove duplicate data in the traffic data.
[0009] Optionally, generating a comparison result includes: generating the comparison result indicating success when the first data and the second data with the same identifier are consistent; generating the comparison result indicating failure when the first data and the second data with the same identifier are inconsistent; outputting the comparison result.
[0010] Optionally, intercepting the second data with an identifier includes: intercepting the second data output by the system under test; screening out the second data with an identifier from the second data; sending the second data without an identifier to a second system, where the second system is a system communicating with the output end of the system under test.
[0011] According to another aspect of the present application, an automatic traffic playback device is provided, including: an acquisition unit for acquiring target traffic data, where the target traffic data is traffic data of at least part of a system to be tested, and the target traffic data includes a plurality of request data received by the system to be tested and first data output by the system to be tested according to the request data; an identification unit for identifying the target traffic data so that each of the request data and the first data in the target traffic data has an identification, and the identifications of any two request data are different, and the request data and the corresponding first data have the same identification; a sending unit for sending at least part of the identified request data to the system to be tested for processing so that the system to be tested outputs second data; an interception unit for intercepting the identified second data and comparing the first data and the second data with the same identification to generate a comparison result, where the identified second data is data output by the system to be tested according to the identified request data, and the comparison result at least includes a result indicating whether the first data and the second data with the same identification are consistent.
[0012] According to still another aspect of the present application, a computer program product is provided, including computer instructions that, when executed by a processor, implement any of the above methods.
[0013] According to yet another aspect of the present application, an electronic device is provided, including: one or more processors, a memory, and one or more programs, where the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include those for executing any of the above methods.
[0014] Applying the technical solution of the present application, first, at least part of the traffic data in the system to be tested is obtained as target traffic data. The target traffic data includes multiple request data received by the system to be tested and first data output by the system to be tested according to the request data. Then, the obtained target traffic data is marked so that each of the request data and the first data in the target traffic data has a unique identifier, and the request data and the corresponding first data have the same identifier. Then, part or all of the marked request data is sent to the system to be tested for processing, so that the system to be tested outputs second data. Finally, the marked second data is intercepted, and the first data and the second data with the same identifier are compared to generate a comparison result. The marked second data is the data output by the system to be tested according to the marked request data, and the comparison result at least includes the result indicating whether the first data and the second data with the same identifier are consistent. By obtaining and marking the request data of the system to be tested, sending at least part of the marked request data to the system to be tested for processing, and then comparing whether the two output results of the system to be tested for processing the same request data are consistent, the whole process realizes an automated traffic playback test, without the need for manual regression testing of the processing flow of the system one by one, thus simplifying the test process, improving the test accuracy rate, and solving the problem of cumbersome and error-prone traffic playback steps in the prior art. In addition, by assigning the same identifier to the request data and the response data of the request data, it can be ensured that the request and the response can be correctly matched when comparing the results. At the same time, the identifiers of different request data are different, so that the processing results of each request can be accurately traced. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings forming a part of this application are used to provide a further understanding of this application. The schematic embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation to this application. In the drawings:
[0016] Figure 1 FIG. shows a hardware structure block diagram of a mobile terminal for implementing an automatic traffic playback method according to an embodiment of the present application;
[0017] Figure 2 FIG. shows a schematic flowchart of an automatic traffic playback method according to an embodiment of the present application;
[0018] Figure 3 FIG. shows a flowchart of an automatic traffic playback method according to an embodiment of the present application;
[0019] Figure 4A schematic diagram of an automatic traffic playback method provided according to an embodiment of the present application is shown;
[0020] Figure 5 A structural block diagram of an automatic traffic playback device provided according to an embodiment of the present application is shown.
[0021] Among them, the above-mentioned drawings include the following reference numerals:
[0022] 102, processor; 104, memory; 106, transmission device; 108, input / output device; 22, system to be tested; 24, second system; 26, traffic playback device. Detailed implementation manners
[0023] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the drawings and in combination with the embodiments.
[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present application.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances for the embodiments of the present application described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily need to be limited to those clearly listed steps or units, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0026] As introduced in the background art, the traffic playback steps in the prior art are cumbersome and error-prone. To solve the above technical problems, the embodiments of the present application provide an automatic traffic playback method, a playback device, a computer program product and an electronic device.
[0027] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention.
[0028] The method embodiments provided in the embodiments of the present application may be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 is a hardware structure block diagram of a mobile terminal for an automatic traffic playback method according to an embodiment of the present invention. As Figure 1 shown, the mobile terminal may include one or more ( Figure 1 only one is shown in the figure) processors 102 (the processors 102 may include, but are not limited to, processing devices such as a microprocessor MCU or a field programmable gate array FPGA) and a memory 104 for storing data. Among them, the mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the mobile terminal. For example, the mobile terminal may further include more or fewer components than Figure 1 shown in the figure, or have a different configuration from Figure 1 shown in the figure.
[0029] The memory 104 can be used to store computer programs. For example, software programs and modules of application software, such as the computer program corresponding to the automatic traffic playback method in the embodiments of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the described method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely set relative to the processor 102, and these remote memories may be connected to the mobile terminal through a network. Examples of the network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the network may include a wireless network provided by a communication provider of the mobile terminal. In one instance, the transmission device 106 includes a network interface controller (abbreviated as NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0030] In this embodiment, an automatic traffic playback method running on a mobile terminal, a computer terminal or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0031] Figure 2 It is a flowchart of the automatic traffic playback method according to an embodiment of the present application. As Figure 2 shown, the method includes the following steps:
[0032] Step S201, obtain target traffic data, where the target traffic data is at least part of the traffic data in the system to be tested, and the target traffic data includes a plurality of request data received by the system to be tested and first data output by the system to be tested according to the request data;
[0033] Specifically, the request data includes transaction request data, user authentication request data, etc.
[0034] Step S202, identify the target traffic data, so that each of the request data and the first data in the target traffic data has an identifier, any two of the request data have different identifiers, and the request data and the corresponding first data have the same identifier;
[0035] Specifically, different request data have different identifiers, and the first data output after a request data is processed by the system to be tested has the same identifier as the request data.
[0036] Step S203, send at least part of the request data with identifiers to the system to be tested for processing, so that the system to be tested outputs second data;
[0037] Specifically, the request data with identifiers is test data. The second data includes both the data output by the system to be tested in response to the request data with identifiers and the data output by the system to be tested in response to the request data without identifiers (i.e., non-test data, that is, the request data received by the system to be tested during normal operation). Part of the second data has identifiers and part does not.
[0038] Step S204, intercept the second data with identifiers, and compare the first data and the second data with the same identifier to generate a comparison result. The second data with identifiers is the data output by the system to be tested according to the request data with identifiers, and the comparison result at least includes the result indicating whether the first data and the second data with the same identifier are consistent.
[0039] Through the above embodiments, at least part of the traffic data in the system to be tested is first obtained as target traffic data. The target traffic data includes a plurality of request data received by the system to be tested and first data output by the system to be tested according to the request data. Then, the obtained target traffic data is identified so that each of the request data and the first data in the target traffic data has a unique identifier, and the request data and the corresponding first data have the same identifier. Then, part or all of the identified request data is sent to the system to be tested for processing, so that the system to be tested outputs second data. Finally, the identified second data is intercepted, and the first data and the second data with the same identifier are compared to generate a comparison result. The identified second data is the data output by the system to be tested according to the identified request data. The comparison result at least includes a result indicating whether the first data and the second data with the same identifier are consistent. In this application, by obtaining and identifying the request data of the system to be tested, sending at least part of the identified request data to the system to be tested for processing, and then comparing whether the two output results of the system to be tested for processing the same request data are consistent, the whole process realizes an automated traffic playback test, without the need for manual regression testing of the processing flow of the system one by one, thus simplifying the test process, improving the test accuracy, and solving the problem of cumbersome and error-prone traffic playback steps in the prior art. In addition, by assigning the same identifier to the request data and the response data of the request data, it can be ensured that the request and the response can be correctly matched when comparing the results. At the same time, the identifiers of different request data are different, so that the processing results of each request can be accurately traced.
[0040] In an alternative solution, obtaining the target traffic data includes: receiving a task time period, which is the task time period preset by the user; according to the task time period, obtaining the traffic data within the task time period from the log center of the system to be tested to obtain the target traffic data. The log center includes all the data of the requests received by the system to be tested and the data output by the system to be tested in response to each request data. The task time period includes at least one time period.
[0041] In the described embodiment, the user can select traffic data within a specific time period to perform a traffic playback test according to actual needs. There is no need to organize the traffic data set, and only the relevant time period needs to be selected, thereby saving processing time and further simplifying the test process. In addition, the log center contains all the traffic data of the system to be tested. Therefore, obtaining the target traffic data from the log center of the system to be tested can ensure that the comprehensive traffic data of the system to be tested is obtained, which helps to more comprehensively evaluate the performance of the system to be tested and further improve the accuracy of the test.
[0042] Specifically, the system under test will generate a globally unique tracking number when a request is initiated. This tracking number will be passed in the subsequent request processing process. The log center can obtain the transaction flow of the entire link of the system under test through the global tracking number.
[0043] In another optional scheme, the request data with an identifier is target request data, and at least part of the request data with an identifier is sent to the system to be tested for processing, including: receiving a concurrent request number, wherein the concurrent request number is the concurrent request number pre-set by a user, the concurrent request number is the number of target request data sent to the system to be tested at the same time, and the concurrent request number is less than or equal to the total number of target request data; and sending the target request data of the concurrent request number to the system to be tested for processing.
[0044] In the described embodiment, by presetting the number of concurrent requests by the user, it is possible to simulate scenarios in which multiple users simultaneously access the system to be tested and a user simultaneously initiates multiple requests to the system to be tested, thereby being able to accurately evaluate the performance and stability of the system to be tested under high transaction processing pressure and helping to discover potential concurrent access issues.
[0045] Specifically, the number of concurrent users may be gradually increased to identify the bottleneck of the performance of the system under test.
[0046] In some other exemplary embodiments, the method also includes: monitoring the resource utilization of the system to be tested in real time; reducing the number of concurrent requests when the resource utilization is greater than a first preset threshold, and increasing the number of concurrent requests when the resource utilization of the system to be tested is less than or equal to a second preset threshold, wherein the first preset threshold is greater than or equal to the second preset threshold.
[0047] In the described embodiments, by monitoring the resource utilization rate of the system under test in real time, it is possible to dynamically evaluate the performance of the system under test under the current load. When the resource utilization rate exceeds the set first preset threshold, it indicates that the system under test is approaching the limit of its performance. At this time, reducing the number of concurrent requests can avoid overloading the system under test and protect the stability of the system under test. When the resource utilization rate is lower than the second preset threshold, increasing the number of concurrent requests can further test the performance potential of the system under test, which helps to more comprehensively evaluate the concurrent processing ability of the system under test.
[0048] Specifically, the resource utilization rate includes CPU usage, memory occupancy, etc.
[0049] According to some further optional solutions of the present application, after obtaining the target traffic data and before identifying the target traffic data, the method further includes: performing a predetermined process on the traffic data to at least remove duplicate data from the traffic data.
[0050] In the described embodiments, when there are performance defects in the system under test, these defects will be triggered multiple times when processing duplicate data, thus masking other problems existing in the system under test. Removing duplicate data helps to further improve the accuracy of the traffic playback test.
[0051] Specifically, to remove duplicate data from the traffic in the predetermined process, it is necessary to first determine the fields for identifying duplicate data. The fields include timestamps, user identification numbers, etc. After identifying the duplicate data, delete the duplicate data or mark the duplicate data as invalid. After removing the duplicate data, compare the traffic data before and after the process to ensure that no important information is accidentally deleted or omitted.
[0052] Specifically, the predetermined process further includes data cleaning and data formatting. Data cleaning is used to remove or correct errors and anomalies in the traffic data, and data formatting is used to convert the traffic data into a format suitable for subsequent processing and analysis.
[0053] In another optional solution, generating a comparison result includes: generating the comparison result indicating success when the first data and the second data with the same identifier are consistent; generating the comparison result indicating failure when the first data and the second data with the same identifier are inconsistent; and outputting the comparison result.
[0054] In the described embodiments, the output of the comparison result enables testers to quickly understand the situation of the system under test processing request data, which helps testers to further process the system under test according to the comparison result.
[0055] Specifically, the first data and the second data generated by the system under test after processing the same request data are exactly the same, indicating that the system under test is performing normally. If the first data and the second data with the same identifier output by the system under test are inconsistent, it means that problems such as data loss, processing errors, or tampering of response data occur when the system under test processes the request data.
[0056] Specifically, after generating the comparison result, record the comparison result, the request data corresponding to the comparison result, the first data, and the second data into a predetermined directory. For the failed comparison results, locate the problems and take corresponding measures for repair, such as modifying the code, optimizing the algorithm, or adjusting the system configuration, etc. After the repair is completed, perform traffic playback and comparison analysis again to verify whether the problems have been solved.
[0057] In some other exemplary solutions of this application, intercepting the second data with an identifier includes: intercepting the second data output by the system under test; screening out the second data with an identifier from the second data; sending the second data without an identifier to a second system, where the second system is a system communicating with the output end of the system under test.
[0058] In the above embodiment, screening out the test data with an identifier from the intercepted second data and sending the second data without an identifier, that is, normal service data, to the second system communicating with the system under test ensures that only relevant test data is used in the test process, and the test data will not flow to other systems except the system under test, and the continuity of the normal business process is not disturbed, realizing playback testing and analysis of the system under test without affecting the normal business operation.
[0059] Among them, the second system is the target system of the second data when the system under test does not perform the interception operation.
[0060] In order to enable those skilled in the art to more clearly understand the technical solutions of this application, the implementation process of the automatic traffic playback method of this application will be described in detail below with specific embodiments.
[0061] This embodiment relates to a specific automatic traffic playback method, as Figure 3 shown, including the following steps:
[0062] Step S1: Obtain and identify target traffic data;
[0063] Step S2: Send the request data with an identifier to the system under test for processing, so that the system under test outputs the second data;
[0064] Step S3: Determine whether the second data has an identifier. If the second data does not have an identifier, send the second data to the second system. If the second data has an identifier, execute Step S4;
[0065] Step S4: Compare the first data and the second data with the same identifier and generate a comparison result.
[0066] Exemplarily, such as Figure 4As shown, by collecting traffic in the log center, all traffic of the system under test 22 can be collected. During the traffic replay process, the system under test 22 is regarded as a black box. By comparing the results output by the system under test 22 based on the same request data, the correctness of the system under test 22 can be reflected. The traffic replay device 26 is integrated in the log center. Through the global tracking number carried by the traffic data itself, the transaction traffic of the entire link of the system under test 22 can be obtained. After screening and parsing, all information of the traffic data can be obtained, including the request data of the traffic data and the data after the traffic data is processed by the system under test 22. After collecting the traffic, the traffic replay device 26 intercepts the output data with an identifier, and finds the input data with the same identifier as the output data through the identifier, so as to obtain the parameters of the original service. Without analyzing and sorting out the interface call order, traffic replay can be carried out under high concurrency. High concurrency means that the traffic in a certain period of time is sent to the system under test 22 in a concurrent manner within a short period of time. The test traffic has a specific identifier bit, indicating that the traffic is test traffic. The interceptor in the traffic replay device 26 determines whether the second data output by the system under test 22 is sent to the target system of the second data (i.e., the second system 24) or intercepted for the second data according to whether the second data has an identifier. By intercepting the test data with an identifier, the normal business of the system under test 22 is not affected. Since this application directly obtains data from the log center, it avoids dirty data caused by incomplete data collection, imperfect data collection tools or methods, resulting in data loss or inaccuracy. The traffic replay device 26 can automatically compare the data status of the original traffic with the data status of the replayed traffic according to the output data of the system under test 22, and determine whether the system under test 22 is running normally. By comparing the processing time of the original traffic and the processing time of the replayed traffic, the running performance of the system under test 22 can be observed. After completing the traffic replay and result analysis, the results of the traffic replay are persisted, that is, the process of transferring the results of the traffic replay from the temporary storage state to a persistent storage medium such as a hard disk, a database, a cloud service, etc. It ensures that the traffic data can still be retrieved and used after the system under test 22 is restarted or fails, so as to optimize and rectify the system under test 22. In addition, in channel-based systems, the interactions between classes are frequent and complex. This application is particularly applicable to channel-based systems by identifying the input data and output data and comparing the output data of the system under test 22 based on the same request data in different situations.
[0067] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0068] The embodiments of the present application also provide an automatic traffic playback device. It should be noted that the automatic traffic playback device of the embodiments of the present application can be used to execute the automatic traffic playback method provided by the embodiments of the present application. The device for implementing the above embodiments and preferred implementation manners has been described and will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0069] The following introduces the automatic traffic playback device provided by the embodiments of the present application.
[0070] Figure 5 is a schematic diagram of the automatic traffic playback device according to the embodiments of the present application. As Figure 5 shown, the device includes:
[0071] An acquisition unit 20, configured to acquire target traffic data, where the target traffic data is at least part of the traffic data in the system to be tested, and the target traffic data includes a plurality of request data received by the system to be tested and first data output by the system to be tested according to the request data;
[0072] Specifically, the request data includes transaction request data, user authentication request data, etc.
[0073] An identification unit 30, configured to identify the target traffic data, so that each of the request data and the first data in the target traffic data has an identification, any two of the request data have different identifications, and the request data and the corresponding first data have the same identification;
[0074] Specifically, different request data have different identifications, and the first data output after a request data is processed by the system to be tested has the same identification as the request data.
[0075] A sending unit 40, configured to send at least part of the identified request data to the system to be tested for processing, so that the system to be tested outputs second data;
[0076] Specifically, the identified request data is test data, and the second data includes both the data output by the system to be tested in response to the identified request data and the data output by the system to be tested in response to the non-identified request data (i.e., non-test data, that is, the request data received by the system to be tested during normal operation). Part of the second data has an identification, and part of the data does not have an identification.
[0077] An interception unit 50 is configured to intercept the second data with an identifier, compare the first data and the second data with the same identifier, and generate a comparison result. The second data with an identifier is the data output by the system under test according to the request data with an identifier. The comparison result at least includes a result indicating whether the first data and the second data with the same identifier are consistent.
[0078] Through the above embodiments, first, an acquisition unit acquires at least part of the traffic data in the system under test as target traffic data. The target traffic data includes a plurality of request data received by the system under test and first data output by the system under test according to the request data. Then, an identification unit identifies the acquired target traffic data, so that each request data and the first data in the target traffic data carry a unique identifier, and the request data and the corresponding first data carry the same identifier. Then, a sending unit sends part or all of the request data with an identifier to the system under test for processing, so that the system under test outputs second data. Finally, an interception unit intercepts the second data with an identifier, compares the first data and the second data with the same identifier, and generates a comparison result. The second data with an identifier is the data output by the system under test according to the request data with an identifier. The comparison result at least includes a result indicating whether the first data and the second data with the same identifier are consistent. In this application, by acquiring and identifying the request data of the system under test, sending at least part of the request data with an identifier to the system under test for processing, and then comparing whether the two output results of the system under test for processing the same request data are consistent, the entire process realizes an automated traffic playback test, without the need for manual regression testing of the system's processing flow one by one, thereby simplifying the test process, improving the test accuracy, and solving the problem that the traffic playback steps in the prior art are cumbersome and error-prone. In addition, by assigning the same identifier to the request data and the response data of the request data, it can be ensured that the request and the response can be correctly matched during the result comparison. At the same time, the identifiers of different request data are different, so that the processing results of each request can be accurately traced.
[0079] In an alternative solution, the acquisition unit includes:
[0080] A first receiving module, configured to receive a task time period, where the task time period is the task time period preset by the user;
[0081] An acquisition module is used to obtain the traffic data within the task time period from the log center of the system to be tested according to the task time period to obtain the target traffic data. The log center includes data of all requests received by the system to be tested and data output by the system to be tested in response to each of the requests. The task time period includes at least one time period.
[0082] In the described embodiment, the user can select traffic data within a specific time period to perform a traffic playback test according to actual needs. There is no need to organize the traffic data set, and only the relevant time period needs to be selected, thereby saving processing time and further simplifying the test process. In addition, the log center contains all the traffic data of the system to be tested. Therefore, obtaining the target traffic data from the log center of the system to be tested can ensure that the comprehensive traffic data of the system to be tested is obtained, which helps to more comprehensively evaluate the performance of the system to be tested and further improve the accuracy of the test.
[0083] Specifically, the system under test will generate a globally unique tracking number when a request is initiated. This tracking number will be passed in the subsequent request processing process. The log center can obtain the transaction flow of the entire link of the system under test through the global tracking number.
[0084] In another optional solution, the sending unit includes:
[0085] A second receiving module is used to receive a concurrent request number, where the concurrent request number is the concurrent request number preset by a user, the concurrent request number is the number of target request data sent to the system to be tested at the same time, and the concurrent request number is less than or equal to the total number of target request data;
[0086] The first sending module is used to send the target request data of the concurrent request number to the system to be tested for processing.
[0087] In the described embodiment, by presetting the number of concurrent requests by the user, it is possible to simulate scenarios in which multiple users simultaneously access the system to be tested and a user simultaneously initiates multiple requests to the system to be tested, thereby being able to accurately evaluate the performance and stability of the system to be tested under high transaction processing pressure and helping to discover potential concurrent access issues.
[0088] Specifically, the number of concurrent users may be gradually increased to identify the bottleneck of the performance of the system under test.
[0089] In some other exemplary embodiments, the device further comprises:
[0090] A monitoring unit, used for monitoring the resource utilization of the system to be tested in real time;
[0091] A reduction unit is used to reduce the number of concurrent requests when the resource utilization rate is greater than a first preset threshold, and increase the number of concurrent requests when the resource utilization rate of the system under test is less than or equal to a second preset threshold, where the first preset threshold is greater than or equal to the second preset threshold.
[0092] In the embodiment, by monitoring the resource utilization rate of the system under test in real time, the performance of the system under test under the current load can be dynamically evaluated. When the resource utilization rate exceeds the set first preset threshold, it indicates that the system under test is approaching the limit of its performance. At this time, reducing the number of concurrent requests can prevent the system under test from being overloaded and protect the stability of the system under test. When the resource utilization rate is lower than the second preset threshold, increasing the number of concurrent requests can further test the performance potential of the system under test, which helps to more comprehensively evaluate the concurrent processing ability of the system under test.
[0093] Specifically, the resource utilization rate includes CPU usage, memory occupancy, etc.
[0094] In some other alternative solutions of the present application, the device further includes:
[0095] A processing unit is used to perform a predetermined process on the traffic data to at least remove duplicate data from the traffic data.
[0096] In the embodiment, when there are performance defects in the system under test, these defects will be triggered multiple times when processing duplicate data, thus masking other problems existing in the system under test. Removing duplicate data helps to further improve the accuracy of the traffic playback test.
[0097] Specifically, to remove duplicate data from the traffic in the predetermined process, it is necessary to first determine the fields used to identify duplicate data. The fields include timestamps, user identity numbers, etc. After identifying the duplicate data, delete the duplicate data or mark the duplicate data as invalid. After removing the duplicate data, compare the traffic data before and after the process to ensure that no important information is accidentally deleted or omitted.
[0098] Specifically, the predetermined process further includes data cleaning and data formatting. Data cleaning is used to remove or correct errors and anomalies in the traffic data, and data formatting is used to convert the traffic data into a format suitable for subsequent processing and analysis.
[0099] In another alternative solution, the interception unit includes:
[0100] A first generation module is used to generate the comparison result indicating success when the first data and the second data with the same identifier are consistent.
[0101] A second generation module, configured to generate the comparison result indicating failure when the first data and the second data with the same identifier are inconsistent;
[0102] An output module, configured to output the comparison result.
[0103] In the embodiment, the output of the comparison result enables the tester to quickly understand the situation of the system under test processing the request data, which helps the tester to further process the system under test according to the comparison result.
[0104] Specifically, if the first data and the second data generated by the system under test after processing the same request data are completely consistent, it indicates that the system under test performs normally. If the first data and the second data with the same identifier output by the system under test are inconsistent, it means that problems such as data loss, processing errors, or tampering of response data occur when the system under test processes the request data.
[0105] Specifically, after generating the comparison result, record the comparison result, the request data corresponding to the comparison result, the first data, and the second data into a predetermined directory. For the failed comparison result, locate the problem and take corresponding measures for repair, such as modifying the code, optimizing the algorithm, or adjusting the system configuration, etc. After the repair is completed, perform traffic playback and comparison analysis again to verify whether the problem has been solved.
[0106] In some other exemplary solutions of the present application, the interception unit includes:
[0107] An interception module, configured to intercept the second data output by the system under test;
[0108] A screening module, configured to screen out the second data with an identifier from the second data;
[0109] A second sending module, configured to send the second data without an identifier to a second system, where the second system is a system communicating with the output end of the system under test.
[0110] In the embodiment, screen out the test data with an identifier from the intercepted second data, and send the second data without an identifier, that is, the normal service data, to the second system communicating with the system under test, ensuring that only relevant test data is used for the test process, the test data will not flow to other systems except the system under test, and the continuity of the normal business process is not disturbed, realizing the playback test and analysis of the system under test without affecting the normal business operation.
[0111] Wherein, the second system is the target system of the second data when the system under test does not perform the interception operation.
[0112] The automatic traffic playback device includes a processor and a memory. The acquisition unit, the identification unit, the sending unit, the interception unit, etc. are all stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions. All the modules are located in the same processor; alternatively, the respective modules are located in different processors in any combined form.
[0113] The processor contains a kernel, and the kernel retrieves the corresponding program units from the memory. One or more kernels can be set, and by adjusting the kernel parameters, at least the problems of cumbersome traffic playback steps and easy errors in the prior art can be solved.
[0114] The memory may include non-permanent memory in a computer-readable medium, forms such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip.
[0115] This application provides a computer program product, including computer instructions, and when the computer instructions are executed by a processor, a program for at least implementing the following method steps is realized:
[0116] Step S201, acquire target traffic data, where the target traffic data is at least part of the traffic data in the system to be tested, and the target traffic data includes a plurality of request data received by the system to be tested and first data output by the system to be tested according to the request data;
[0117] Specifically, the request data includes transaction request data, user authentication request data, etc.
[0118] Step S202, identify the target traffic data, so that each of the request data and the first data in the target traffic data has an identifier, and any two of the request data have different identifiers, and the request data and the corresponding first data have the same identifier;
[0119] Specifically, different request data have different identifiers, and the first data output after a request data is processed by the system to be tested has the same identifier as the request data.
[0120] Step S203, send at least part of the request data with identifiers to the system to be tested for processing, so that the system to be tested outputs second data;
[0121] Specifically, the request data with an identifier is test data. The second data includes both the data output by the system under test in response to the request data with an identifier and the data output by the system under test in response to the request data without an identifier (i.e., non-test data, i.e., the request data received by the system under test during normal operation). Some of the second data has an identifier, and some does not have an identifier.
[0122] Step S204: Intercept the second data with an identifier, and compare the first data and the second data with the same identifier to generate a comparison result. The second data with an identifier is the data output by the system under test according to the request data with an identifier. The comparison result at least includes a result indicating whether the first data and the second data with the same identifier are consistent.
[0123] Optionally, obtaining the target traffic data includes: receiving a task time period, which is the task time period preset by the user; according to the task time period, obtaining the traffic data within the task time period from the log center of the system under test to obtain the target traffic data. The log center includes all the request data received by the system under test and the data output by the system under test in response to each request. The task time period includes at least one time period.
[0124] Optionally, the request data with an identifier is target request data. Sending at least part of the request data with an identifier to the system under test for processing includes: receiving the number of concurrent requests, which is the number of concurrent requests preset by the user. The number of concurrent requests is the number of target request data sent to the system under test simultaneously, and the number of concurrent requests is less than or equal to the total number of target request data; sending the target request data with the number of concurrent requests to the system under test for processing.
[0125] Optionally, the method further includes: real-time monitoring the resource utilization rate of the system under test; when the resource utilization rate is greater than a first preset threshold, reducing the number of concurrent requests; when the resource utilization rate of the system under test is less than or equal to a second preset threshold, increasing the number of concurrent requests. The first preset threshold is greater than or equal to the second preset threshold.
[0126] Optionally, after obtaining the target traffic data and before identifying the target traffic data, the method further includes: performing a predetermined process on the traffic data to at least remove duplicate data from the traffic data.
[0127] Optionally, generate a comparison result, including: generating the comparison result indicating success when the first data and the second data with the same identifier are consistent; generating the comparison result indicating failure when the first data and the second data with the same identifier are inconsistent; and outputting the comparison result.
[0128] Optionally, intercept the second data with an identifier, including: intercepting the second data output by the system under test; screening out the second data with an identifier from the second data; and sending the second data without an identifier to a second system, where the second system is a system communicating with the output end of the system under test.
[0129] An embodiment of the present invention further provides an electronic device, including a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, it implements at least the following steps:
[0130] Step S201, obtain target traffic data, where the target traffic data is at least part of the traffic data in the system under test, and the target traffic data includes a plurality of request data received by the system under test and first data output by the system under test according to the request data;
[0131] Specifically, the request data includes transaction request data, user authentication request data, etc.
[0132] Step S202, identify the target traffic data, so that each request data and the first data in the target traffic data have an identifier, any two request data have different identifiers, and the request data and the corresponding first data have the same identifier;
[0133] Specifically, different request data have different identifiers, and the first data output after a request data is processed by the system under test has the same identifier as the request data.
[0134] Step S203, send at least part of the request data with an identifier to the system under test for processing, so that the system under test outputs second data;
[0135] Specifically, the request data with an identifier is test data, and the second data includes both the data output by the system under test in response to the request data with an identifier and the data output by the system under test in response to the request data without an identifier (i.e., non-test data, i.e., the request data received by the system under test during normal operation). Part of the second data has an identifier and part of the data does not have an identifier.
[0136] Step S204, intercept the second data with an identifier, compare the first data and the second data with the same identifier, and generate a comparison result. The second data with an identifier is the data output by the system under test according to the request data with an identifier. The comparison result at least includes a result indicating whether the first data and the second data with the same identifier are consistent.
[0137] Optionally, obtaining target traffic data includes: receiving a task time period, where the task time period is the task time period preset by the user; according to the task time period, obtaining the traffic data within the task time period from the log center of the system under test to obtain the target traffic data. The log center includes all the data of requests received by the system under test and the data output by the system under test in response to each request. The task time period includes at least one time period.
[0138] Optionally, the request data with an identifier is target request data. Sending at least part of the request data with an identifier to the system under test for processing includes: receiving the number of concurrent requests, where the number of concurrent requests is the number of concurrent requests preset by the user, and the number of concurrent requests is the number of target request data sent to the system under test simultaneously, and the number of concurrent requests is less than or equal to the total number of target request data; sending the target request data with the number of concurrent requests to the system under test for processing.
[0139] Optionally, the method further includes: monitoring the resource utilization rate of the system under test in real time; when the resource utilization rate is greater than a first preset threshold, reducing the number of concurrent requests; when the resource utilization rate of the system under test is less than or equal to a second preset threshold, increasing the number of concurrent requests, where the first preset threshold is greater than or equal to the second preset threshold.
[0140] Optionally, after obtaining the target traffic data and before identifying the target traffic data, the method further includes: performing a predetermined process on the traffic data to at least remove duplicate data from the traffic data.
[0141] Optionally, generating a comparison result includes: when the first data and the second data with the same identifier are consistent, generating a comparison result indicating success; when the first data and the second data with the same identifier are inconsistent, generating a comparison result indicating failure; outputting the comparison result.
[0142] Optionally, intercepting the second data with an identifier includes: intercepting the second data output by the system under test; screening out the second data with an identifier from the second data; and sending the second data without an identifier to a second system, where the second system is a system communicating with the output end of the system under test.
[0143] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0144] Obviously, those skilled in the art should understand that the various modules or steps of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module to implement. In this way, the present invention is not limited to any specific combination of hardware and software.
[0145] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0146] This application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the specified functions in Figure 1 one or more flows Figure 1 or multiple flows and / or blocks
[0147] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the functions in the flowFigure 1 one or more processes and / or blocks Figure 1 the functions specified in one or more blocks.
[0148] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide for implementing in the process Figure 1 one or more processes and / or blocks Figure 1 the steps of the functions specified in one or more blocks.
[0149] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0150] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer-readable media.
[0151] Computer-readable media includes permanent and non-permanent, removable and non-removable media and can store information by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.
[0152] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or also includes elements inherent in such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.
[0153] From the above description, it can be seen that the embodiments described in this application achieve the following technical effects:
[0154] 1) In the automatic traffic replay method of this application, first, at least part of the traffic data in the system to be tested is obtained as target traffic data. The target traffic data includes multiple request data received by the system to be tested and first data output by the system to be tested according to the request data. Then, the obtained target traffic data is marked so that each of the request data and the first data in the target traffic data has a unique identifier, and the request data and the corresponding first data have the same identifier. Then, part or all of the marked request data is sent to the system to be tested for processing, so that the system to be tested outputs second data. Finally, the marked second data is intercepted, and the first data and the second data with the same identifier are compared to generate a comparison result. The marked second data is the data output by the system to be tested according to the marked request data, and the comparison result at least includes the result indicating whether the first data and the second data with the same identifier are consistent. By obtaining and marking the request data of the system to be tested, sending at least part of the marked request data to the system to be tested for processing, and then comparing whether the two output results of the system to be tested for processing the same request data are consistent, the whole process realizes an automated traffic replay test, without the need for manual regression testing of the processing flow of the system one by one, thus simplifying the test process, improving the test accuracy rate, and solving the problem that the traffic replay steps in the prior art are cumbersome and error-prone. In addition, by assigning the same identifier to the request data and the response data of the request data, it can be ensured that the request and the response can be correctly matched when comparing the results. At the same time, the identifiers of different request data are different, so that the processing results of each request can be accurately traced.
[0155] 2) The automatic traffic playback device of the present application first obtains at least part of the traffic data in the system to be tested as target traffic data through an acquisition unit. The target traffic data includes multiple request data received by the system to be tested and first data output by the system to be tested according to the request data. Then, through an identification unit, the obtained target traffic data is identified, so that each of the request data and the first data in the target traffic data has a unique identifier, and the request data and the corresponding first data have the same identifier. Then, through a sending unit, part or all of the identified request data is sent to the system to be tested for processing, so that the system to be tested outputs second data. Finally, through an interception unit, the identified second data is intercepted, and the first data and the second data with the same identifier are compared to generate a comparison result. The identified second data is the data output by the system to be tested according to the identified request data, and the comparison result at least includes a result indicating whether the first data and the second data with the same identifier are consistent. The present application realizes an automated traffic playback test by obtaining and identifying the request data of the system to be tested, sending at least part of the identified request data to the system to be tested for processing, and then comparing whether the two output results of the system to be tested for processing the same request data are consistent. The whole process simplifies the test process, improves the accuracy of the test, and solves the problem that the traffic playback steps in the prior art are cumbersome and error-prone. In addition, by assigning the same identifier to the request data and the response data of the request data, it can be ensured that the request and the response can be correctly matched when comparing the results. At the same time, the identifiers of different request data are different, so that the processing results of each request can be accurately traced.
[0156] The foregoing are only the preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.
Claims
1. An automatic flow replay method, characterized in that, Including: Obtain target traffic data, where the target traffic data is traffic data of at least a part of the system to be tested, and the target traffic data includes multiple request data received by the system to be tested and first data output by the system to be tested according to the request data; Identify the target traffic data, so that each of the request data and the first data in the target traffic data has an identifier, and any two request data have different identifiers, and the request data and the corresponding first data have the same identifier; Send at least part of the request data with identifiers to the system to be tested for processing, so that the system to be tested outputs second data; Intercept the second data with identifiers, and compare the first data and the second data with the same identifier to generate a comparison result. The second data with identifiers is the data output by the system to be tested according to the request data with identifiers, and the comparison result at least includes a result indicating whether the first data and the second data with the same identifier are consistent.
2. The method according to claim 1, characterized in that, Obtain target traffic data, including: Receive a task time period, where the task time period is the task time period preset by the user; According to the task time period, obtain the traffic data within the task time period from the log center of the system to be tested to obtain the target traffic data. The log center includes all request data received by the system to be tested and data output by the system to be tested in response to each request data, and the task time period includes at least one time period.
3. The method according to claim 1, wherein The request data with identifiers is target request data. Sending at least part of the request data with identifiers to the system to be tested for processing includes: Receive the number of concurrent requests, where the number of concurrent requests is the number of concurrent requests preset by the user. The number of concurrent requests is the number of target request data sent to the system to be tested at the same time, and the number of concurrent requests is less than or equal to the total number of target request data; Send the target request data with the number of concurrent requests to the system to be tested for processing.
4. The method according to claim 3, wherein The method further includes: Real-time monitor the resource utilization rate of the system to be tested; When the resource utilization rate is greater than a first preset threshold, reduce the number of concurrent requests. When the resource utilization rate of the system to be tested is less than or equal to a second preset threshold, increase the number of concurrent requests. The first preset threshold is greater than or equal to the second preset threshold.
5. The method according to claim 1, characterized in that, After obtaining the target traffic data and before identifying the target traffic data, the method further includes: Perform a predetermined process on the traffic data to at least remove duplicate data in the traffic data.
6. The method according to claim 1, wherein Generate a comparison result, including: When the first data and the second data with the same identifier are consistent, generate a comparison result indicating success; When the first data and the second data with the same identifier are inconsistent, generate a comparison result indicating failure; Output the comparison result.
7. The method according to claim 1, wherein Intercept the second data with identifiers, including: Intercept the second data output by the system to be tested; Filter out the second data with identifiers from the second data; Send the second data without identifiers to a second system, where the second system is a system communicating with the output end of the system to be tested.
8. An automatic flow playback device, characterized in that, Comprising: An acquisition unit, configured to acquire target traffic data, where the target traffic data is at least part of the traffic data in the system to be tested, and the target traffic data includes a plurality of request data received by the system to be tested and first data output by the system to be tested according to the request data; An identification unit, configured to identify the target traffic data, so that each of the request data and the first data in the target traffic data has an identifier, any two of the request data have different identifiers, and the request data and the corresponding first data have the same identifier; A sending unit, configured to send at least part of the request data with identifiers to the system to be tested for processing, so that the system to be tested outputs second data; An interception unit, configured to intercept the second data with identifiers, and compare the first data and the second data with the same identifier to generate a comparison result. The second data with identifiers is the data output by the system to be tested according to the request data with identifiers, and the comparison result at least includes a result indicating whether the first data and the second data with the same identifier are consistent.
9. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by a processor, the method described in any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that, Comprising: One or more processors, a memory, and one or more programs, where the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include the method for executing any one of claims 1 to 7.