Comparative test method, device and storage medium
By diverting the write data traffic of the target module to the baseline module and the module to be tested, and comparing the input parameters in real time, the problems of difficulty in covering business scenarios and poor accuracy in testing new systems in the existing technology are solved, and efficient and accurate comparison and testing are achieved .
Patent Information
- Application Number
- CN202011249973.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-10
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2040-11-10
AI Technical Summary
In the prior art, testing all business scenarios of a new system is difficult and time-consuming, and the test accuracy is poor, making it difficult to fully cover before going online.
By diverting the write data traffic of the target module to the reference module and the module to be tested, and comparing the input parameters of the corresponding functions called when the reference module and the module to be tested perform the corresponding operation based on the write data traffic, the comparison result is output.
Avoid field omissions, improve the real-time and efficiency of comparison tests, and enhance the accuracy of test results.
Smart Images

Figure CN113742209B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to a comparative testing method, device and storage medium. Background Art
[0002] Technology is developing rapidly. With the continuous updating of technology and business, the old system will be gradually replaced by the new system. At the same time, all functions of the new system need to be fully tested before going online to avoid online problems of the new system. However, it is very difficult to make manual testing cover all business scenarios of the new system. The workload is very large and there may be problems with poor test accuracy. Summary of the invention
[0003] To solve the related technical problems, the embodiments of the present application provide a comparative test method, device and storage medium.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present application embodiment provides a comparative test method, including:
[0006] Directing the first write data traffic of the target module to the reference module and the module to be tested; the target module runs in a first online environment; the reference module and the module to be tested run in a second offline environment; the second environment is the same as the first environment; the business logic of the reference module is the same as the business logic of the target module; the business logic of the module to be tested is different from the business logic of the target module;
[0007] Acquire first information and second information; the first information includes input parameters of a first type of function called when the benchmark module performs a first operation based on the first write data flow; the second information includes input parameters of a second type of function called when the module to be tested performs a second operation based on the first write data flow; the function of the first type of function is the same as the function of the second type of function;
[0008] The second information is compared with the first information to obtain a comparison result; and the obtained comparison result is output.
[0009] In the above scheme, the method further includes:
[0010] The third type of function called when the benchmark module performs the first operation is simulated (Mock); the third type of function includes all functions used for data writing; the third type of function includes the first type of function; and the fourth type of function called when the module to be tested performs the second operation is mocked; the fourth type of function includes all functions used for data writing; the fourth type of function includes the second type of function.
[0011] In the above scheme, the method further includes:
[0012] According to the first configuration information, a first type of function in the reference module and a second type of function in the module to be tested are determined.
[0013] In the above solution, the step of directing the first write data flow of the target module to the reference module and the module to be tested includes:
[0014] Based on a first function, directing the first write data traffic to the reference module and the module to be tested;
[0015] When the first function reports an error, the drainage is stopped.
[0016] In the above solution, the step of directing the first write data flow to the reference module and the module to be tested based on the first function includes:
[0017] Based on the first function, directing the first write data traffic to the reference module and the module to be tested by synchronously directing traffic;
[0018] or,
[0019] Based on the first function, the first write data traffic is directed to the reference module and the module to be tested by asynchronously directing the traffic.
[0020] In the above solution, comparing the second information with the first information includes:
[0021] filtering the second information and the first information according to second configuration information; wherein the second configuration information includes fields that do not need to be compared;
[0022] The filtered second information is compared with the filtered first information.
[0023] In the above scheme, the method further includes:
[0024] classifying the comparison results using a first strategy;
[0025] The comparison results after classification are presented on the visualization page.
[0026] The present application also provides a comparative test device, including:
[0027] A flow diversion unit, used for diverting the first write data flow of the target module to the reference module and the module to be tested; the target module runs in a first online environment; the reference module and the module to be tested run in a second offline environment; the second environment is the same as the first environment; the business logic of the reference module is the same as the business logic of the target module; the business logic of the module to be tested is different from the business logic of the target module;
[0028] an acquisition unit, configured to acquire first information and second information; the first information comprising input parameters of a first type of function called when the reference module performs a first operation based on the first write data flow; the second information comprising input parameters of a second type of function called when the module to be tested performs a second operation based on the first write data flow; a function of the first type of function is the same as a function of the second type of function;
[0029] A processing unit is used to compare the second information with the first information to obtain a comparison result; and output the obtained comparison result.
[0030] The embodiment of the present application also provides a comparative test device, comprising: a processor and a memory for storing a computer program that can be run on the processor; wherein:
[0031] The processor is used to execute the steps of any of the above methods when running the computer program.
[0032] An embodiment of the present application further provides a storage medium, wherein the medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0033] The comparative test method, device and storage medium provided in the embodiments of the present application direct the first write data traffic of the target module to the reference module and the module to be tested; the target module runs in the first online environment; the reference module and the module to be tested run in the second offline environment; the second environment is the same as the first environment; the business logic of the reference module is the same as the business logic of the target module; the business logic of the module to be tested is different from the business logic of the target module; first information and second information are obtained; the first information includes the input parameters of the first type of function called when the reference module performs the first operation based on the first write data traffic; the second information includes the input parameters of the second type of function called when the module to be tested performs the second operation based on the first write data traffic; the function of the first type of function is the same as the function of the second type of function; the second information is compared with the first information to obtain a comparison result; and the comparison result is output. The solution of the embodiment of the present application directs the write data traffic of the online target module to the offline benchmark module and the module to be tested, and compares in real time the input parameters of the corresponding functions called when the benchmark module and the module to be tested perform corresponding operations based on the write data traffic. In this way, field omissions can be avoided, the real-time and efficiency of the comparison test can be improved, and the accuracy of the comparison test results can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A flow chart of a comparative test method for an embodiment of the present application;
[0035] Figure 2 This is a schematic diagram of the structure of a comparative test device for an application example of the present application;
[0036] Figure 3 A flow chart of a comparative test method for an application example of the present application;
[0037] Figure 4 This is a schematic diagram of the structure of a comparative test device according to an embodiment of the present application;
[0038] Figure 5 Schematic diagram of the hardware structure of the comparative test device according to the embodiment of the present application. DETAILED DESCRIPTION
[0039] The technical solution of the present application is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0040] In the related art, when realizing the automatic comparison between the new system and the old system, on the one hand, it is necessary to improve the accuracy of the comparison test results and reduce the manual workload; on the other hand, since developers are prone to change the original business logic in the new demand development project, causing online problems, it is necessary to verify whether the new demand development has an impact on the original business logic during the comparison test. Based on this, the benchmark module and the module to be tested are usually placed in the same test environment, and the same test data is used as the input of the benchmark module and the module to be tested respectively. The outputs of the benchmark module and the module to be tested are compared, and the difference in the output is used to verify whether the module to be tested meets the expected design. Among them, the benchmark module is a module used to compare with the module to be tested. For example, when the system is upgraded and the new system is compared with the old system, the module to be tested is the new system after the upgrade, and the benchmark module is the old system before the upgrade.
[0041] Specifically, the comparison test can be performed using the data playback method: the sample log is captured by the log acquisition module and sent to the benchmark module and the module to be tested, and the outputs of the benchmark module and the module to be tested are converted into their respective feature matrices; according to the pre-configured difference rule, the difference matrix between the feature matrix of the module to be tested and the feature matrix of the benchmark module is obtained; the elements in the difference matrix are generalized and the units are merged; and finally the comparison result is output. Alternatively, the comparison test can be performed using the data source reading method: the same test data is used as the input parameter of the benchmark module and the module to be tested respectively, and the benchmark module and the module to be tested write the data to the data source; wherein, if the benchmark module and the module to be tested are connected to different data sources (for example: two database instances with the same database and table structure), the data written by the benchmark module and the module to be tested are read and compared respectively; if the benchmark module and the module to be tested are connected to the same data source, the data written by the benchmark module and the module to be tested are read and compared respectively.
[0042] However, the comparative test method in the related art has the following disadvantages:
[0043] First, the module or data isolation environment for obtaining test data is relied on, resulting in inaccurate comparison test results. Here, the module for obtaining test data can be a log acquisition module, a data reading module, a data conversion module, etc. For example, the log acquisition module captures the log of the target environment as the input parameter of the benchmark module and the module to be tested, or the data reading module and the data conversion module are used to determine the input parameter of the benchmark module and the module to be tested. Since the modules for obtaining test data such as the log acquisition module, the data reading module, and the data conversion module are prone to program errors and other problems, the comparison test results are directly inaccurate. In addition, when performing comparison tests based on the data isolation environment, such as when replaying the data update operation directly in the online environment, it may affect the online data (for example, an error occurs when the data is written to the server), which cannot meet the real application scenario, resulting in inaccurate comparison test results.
[0044] Secondly, it is usually difficult to compare the output parameters of the benchmark module and the module to be tested. This can easily lead to field omissions, that is, ignoring the comparison fields. For example, fields that are not currently used by the upstream and downstream systems are easily ignored in the comparison, but these fields may be enabled at some time in the future, which may cause system problems.
[0045] Third, data comparison has poor real-time performance and is complex to implement.
[0046] Based on this, in various embodiments of the present application, the write data traffic of the online target module is directed to the offline benchmark module and the module to be tested, and the input parameters of the corresponding functions called when the benchmark module and the module to be tested perform corresponding operations based on the write data traffic are compared in real time. In this way, field omissions can be avoided, the real-time and efficiency of the comparison test can be improved, and the accuracy of the comparison test results can be improved.
[0047] At the same time, in various embodiments of the present application, the write data traffic of the online target module is directly diverted, without relying on modules such as log acquisition modules for acquiring test data, and without relying on a data isolation environment for replaying the online environment. Comparative tests are performed based on real application scenarios, which is simple and convenient to implement with higher accuracy.
[0048] The present application embodiment provides a comparative test method, such as Figure 1 As shown, the method includes:
[0049] Step 101: directing the first write data traffic of the target module to the reference module and the module to be tested;
[0050] Here, the target module runs in a first online environment; the reference module and the module to be tested run in a second offline environment; the second environment is the same as the first environment; the business logic of the reference module is the same as the business logic of the target module; the business logic of the module to be tested is different from the business logic of the target module;
[0051] Step 102: Acquire first information and second information;
[0052] Here, the first information includes input parameters of a first type of function called when the reference module performs a first operation based on the first write data flow; the second information includes input parameters of a second type of function called when the module to be tested performs a second operation based on the first write data flow; the function of the first type of function is the same as the function of the second type of function;
[0053] Step 103: Compare the second information with the first information to obtain a comparison result; and output the obtained comparison result.
[0054] Here, the user can perform corresponding operations on the output comparison results according to needs, for example, using the output comparison results to determine whether the module to be tested meets the expected design; for example, storing the output comparison results for troubleshooting after the module to be tested is put online.
[0055] It should be noted that, in various embodiments of the present application, the first environment in which the target module runs online means that the target module is an online module that is actually providing services to users, such as a shopping website. The first write data traffic is generated when the user actually performs corresponding operations on the target module, such as the write data traffic generated by the corresponding operation when the user puts a new product on the shopping website. The second environment is an offline simulation environment that is the same as the first environment, that is, a simulation environment that simulates a real business scenario (which can be achieved by setting the same environment code), and the process of the benchmark module executing the write data operation is exactly the same as the process of the target module executing the write data operation. The benchmark module is equivalent to the old system before the above-mentioned upgrade, and the module to be tested is equivalent to the new system after the above-mentioned upgrade.
[0056] In actual application, the formats of the first information and the second information obtained can be set according to requirements, such as JavaScript Object Notation (JSON).
[0057] In actual application, the user can pre-set the first type of function and the second type of function according to needs, such as setting one or more functions with the same function in all write data functions (i.e., write data methods) called when the benchmark module and the module to be tested perform corresponding operations based on the first write data traffic to the first type of function or the second type of function.
[0058] Based on this, in one embodiment, the method may further include:
[0059] According to the first configuration information, a first type of function in the reference module and a second type of function in the module to be tested are determined.
[0060] Exemplarily, the first write data flow corresponds to an operation of modifying the basic data of a product (that is, the first operation and the second operation are operations of modifying the basic data of a product). In the process of the benchmark module performing the operation of modifying the basic data of a product based on the first write data flow and the module to be tested performing the operation of modifying the basic data of a product based on the first write data flow, a function for modifying the large field of a product and a function for modifying the image of a product are respectively called. Then, the function for modifying the large field of a product and / or the function for modifying the image of a product can be selected as the first type of function and the second type of function. By comparing the differences in the input parameters of the first type of function and the second type of function, it is possible to verify whether the module to be tested meets the expected design.
[0061] In actual application, the storage format of the first configuration information can be set according to requirements, such as a script file.
[0062] In actual application, during the drainage process, in order to avoid affecting the normal business process of the target module, it is necessary to do a good job of program exception protection, that is, to pre-set the exception protection function and stop the drainage when an error occurs in the drainage process.
[0063] Based on this, in one embodiment, directing the first write data traffic of the target module to the reference module and the module to be tested may include:
[0064] Based on a first function, directing the first write data traffic to the reference module and the module to be tested;
[0065] When the first function reports an error, the drainage is stopped.
[0066] Here, the first function is a preset program exception protection function, and an error reported by the first function indicates that an error occurs in the drainage process.
[0067] In actual application, the synchronous or asynchronous method can be selected for traffic diversion according to user needs or the application scenario of the target module.
[0068] Based on this, in one embodiment, directing the first write data traffic to the reference module and the module to be tested based on the first function may include:
[0069] Based on the first function, directing the first write data traffic to the reference module and the module to be tested by synchronously directing traffic;
[0070] or,
[0071] Based on the first function, the first write data traffic is directed to the reference module and the module to be tested by asynchronously directing the traffic.
[0072] In actual application, the programming method for implementing data drainage can be determined according to the needs. For example, in a development environment based on Java 2 Platform Enterprise Edition (J2EE, Java 2Platform Enterprise Edition), data drainage can be implemented by writing aspects of data functions.
[0073] In actual application, in order to further improve the efficiency of comparative testing, before comparing the second information with the first information, the first information and the second information can be filtered based on preset fields that do not need to be compared, and then the filtered second information can be compared with the filtered first information.
[0074] Based on this, in one embodiment, comparing the second information with the first information may include:
[0075] filtering the second information and the first information according to second configuration information; wherein the second configuration information includes fields that do not need to be compared;
[0076] The filtered second information is compared with the filtered first information.
[0077] In actual application, the storage format of the second configuration information can be set according to requirements, such as a script file.
[0078] In actual application, in order to avoid conflicts between the data written to the server when the benchmark module performs the first operation based on the first write data flow and / or the data written to the server when the module to be tested performs the second operation based on the first write data flow and the data written to the server when the target module performs the operation corresponding to the first write data flow, the benchmark module and the module to be tested can be prevented from actually performing the operation corresponding to the first write data flow, that is, the benchmark module and the module to be tested are prevented from writing data to the server.
[0079] Based on this, in one embodiment, the method may further include:
[0080] Mock processing is performed on the third type of function called when the benchmark module performs the first operation; the third type of function includes all functions used for data writing; the third type of function includes the first type of function; and mock processing is performed on the fourth type of function called when the module to be tested performs the second operation; the fourth type of function includes all functions used for data writing; the fourth type of function includes the second type of function.
[0081] Specifically, in actual application, the third type of function is all the write data functions (including remote write data functions and / or local write data functions) called when the benchmark module performs the first operation, and the fourth type of function is all the write data functions (including remote write data functions and / or local write data functions) called when the module to be tested performs the second operation; the way of performing Mock processing on the third type of function and the fourth type of function can be to insert a pre-set second function for calling the Mock service interface into the third type of function and the fourth type of function, so that the third type of function and the fourth type of function directly return a preset value (such as 1) when being called, without performing the corresponding operation of writing data to the server; in this way, it is possible to avoid conflicts between the data written to the server when the benchmark module performs the first operation based on the first write data flow and / or the data written to the server when the module to be tested performs the second operation based on the first write data flow and the data written to the server when the target module performs the operation corresponding to the first write data flow. Of course, other methods can also be used to mock the third and fourth types of functions as needed. For example, the bytecode can be dynamically modified through Java Agent and JAVAssist to mock the local data writing function in a zero-code intrusion manner, ensuring that the code of the benchmark module is consistent with the code of the target module, so that the online environment business code is clean and tidy; for another example, the bytecode of the local data writing function can be dynamically modified by configuring the startup parameters of the Java virtual machine (JVM, Java VirtualMachine).
[0082] In actual application, in order to improve user experience and intuitively display the obtained comparison results to users, the obtained comparison results can be presented to users on a visualization page. Of course, the comparison results can also be classified according to user needs and then the classified comparison results can be presented.
[0083] Based on this, in one embodiment, the method may further include:
[0084] classifying the comparison results using a first strategy;
[0085] The comparison results after classification are presented on the visualization page.
[0086] Here, the first strategy can be preset by the user according to needs, such as classifying according to the field type in the comparison result, and the presented comparison result can be conveniently viewed and troubleshooted by the user.
[0087] The comparative test method provided in the embodiment of the present application directs the first write data flow of the target module to the reference module and the module to be tested; the target module runs in the first online environment; the reference module and the module to be tested run in the second offline environment; the second environment is the same as the first environment; the business logic of the reference module is the same as the business logic of the target module; the business logic of the module to be tested is different from the business logic of the target module; obtain first information and second information; the first information includes the input parameters of the first type of function called when the reference module performs the first operation based on the first write data flow; the second information includes the input parameters of the second type of function called when the module to be tested performs the second operation based on the first write data flow; the function of the first type of function is the same as the function of the second type of function; compare the second information with the first information to obtain a comparison result; and output the obtained comparison result. The scheme of the embodiment of the present application directs the write data flow of the online target module to the offline reference module and the module to be tested, and compares the input parameters of the corresponding functions called when the reference module and the module to be tested perform the corresponding operations based on the write data flow in real time, so that field omissions can be avoided, the real-time and efficiency of the comparative test can be improved, and the accuracy of the comparative test results can be improved.
[0088] At the same time, in various embodiments of the present application, the write data traffic of the online target module is directly diverted, without relying on modules such as log acquisition modules for acquiring test data, and without relying on a data isolation environment for replaying the online environment. Comparative tests are performed based on real application scenarios, which is simple and convenient to implement with higher accuracy.
[0089] The present application is further described in detail below in conjunction with application examples.
[0090] In order to solve the problems of low accuracy, complex implementation and poor real-time performance of data comparison in the comparative test method in the related art, the present application embodiment provides a comparative test device, such as Figure 2 As shown, the device comprises:
[0091] The online write data diversion unit 201 is used to send the online write data traffic to the module to be tested and the reference module respectively; wherein, the online write data diversion unit 201 can configure whether to divert and start the comparison test through a dynamic switch controllable by the user, and can adopt an asynchronous diversion method or a synchronous diversion method according to the actual usage scenario corresponding to the online write data traffic; in this way, close to real-time data comparison can be achieved. In actual application, the implementation method of the online write data diversion unit 201 can be determined according to the needs. For example, based on the J2EE development environment, the online write data diversion unit 201 can be implemented through the aspect of a specific write data method (i.e., write data function), and the online write data traffic is diverted to the reference module and the module to be tested in the aspect, and exception protection needs to be done to ensure that the data comparison does not affect the normal business process online.
[0092] The data writing method Mock unit 202 is used to mock the remote data writing method and the local data writing method to ensure that the benchmark module and the module to be tested cannot actually write data to the server. In actual application, the implementation method of the data writing method Mock unit 202 can be determined according to the needs. For example, based on the J2EE development environment, the remote data writing method can be implemented by means of the Mock remote service interface to provide a separate group of Mock services for the benchmark module and the module to be tested to call; the local data writing method can be implemented by using the JavaAgent and JAVAssist technology to dynamically modify the bytecode to mock the local data writing method in a code-zero intrusion manner, ensuring that the benchmark module code is consistent with the online environment code, making the online environment business code clean and tidy; for another example, the bytecode of the local data writing method can be dynamically modified by configuring the JVM startup parameters.
[0093] Field filtering unit 203: used to filter data fields that do not need to be compared. In actual application, data fields that do not need to be compared can be filtered by file configuration, such as filtering fields that do not need to be compared by JavaScript (JS for short).
[0094] Data comparison unit 204 is used to compare the target data writing method (ie, the first type of function and the second type of function) called by the benchmark module and the module under test.
[0095] The comparison difference display unit 205 is used to classify and display the comparison differences of the input parameters of the target data writing method called by the benchmark module and the module to be tested, so as to facilitate the review and troubleshooting.
[0096] The following describes in detail the comparative test method provided by this application embodiment based on the above comparative test device.
[0097] like Figure 3As shown, the comparative test method provided by this application embodiment includes:
[0098] Step 301: directing online traffic to the reference module and the module to be tested; then executing step 302.
[0099] Specifically, the benchmark module and the module to be tested are set in a simulated online environment to ensure that the data comparison scenario is a real environment, which can cover all data writing business scenarios and improve the accuracy of data comparison; the benchmark module is the module before the upgrade, and the code of the benchmark module is the same as the online environment code, ensuring that the benchmark module executes the data writing operation in full consistency with the online process, and the module to be tested is the upgraded module; the online write data diversion unit 201 is used to divert the online write data traffic to the benchmark module and the module to be tested respectively, and asynchronous or synchronous diversion methods can be used according to the actual usage scenario, so that close to real-time data comparison can be achieved.
[0100] Step 302: Mock all data writing methods called by the reference module and the module under test in the corresponding write operation; then execute step 303.
[0101] Specifically, all the data writing methods called by the reference module and the module to be tested in the corresponding write operation are mocked through the data writing method Mock unit 202, and all the data writing methods of the Mock include remote data writing methods and local data writing methods; the data writing method Mock unit 202 can provide separately grouped Mock services for the reference module and the module to be tested to call, to ensure that the reference module and the module to be tested cannot actually write data remotely; at the same time, the data writing method Mock unit 202 can ensure that the reference module and the module to be tested cannot actually write local data; here, when the remote interface of the data writing method Mock unit 202 for providing the separately grouped Mock services is called by the reference module and the module to be tested respectively, the corresponding write process stops.
[0102] Step 303: filter the fields that do not need to be compared; then execute step 304.
[0103] Specifically, the fields that do not need to be compared are filtered by the field filtering unit 203; in addition, the data fields that do not need to be compared can be filtered by file configuration, for example, filtering the fields that do not need to be compared by JS script configuration.
[0104] Step 304: Compare the target data writing method input called by the benchmark module and the module under test; then execute step 305.
[0105] Specifically, the user can pre-select the target data writing method, and one or more target data writing methods can be selected in a data writing operation. The target data writing method can be used as a reference method for data comparison, and the difference in the input parameters of the target data writing method can be compared to verify whether the module to be tested meets the expected design. The reference module and the module to be tested must call the target data writing method with the same function in the same data writing operation. For example, the reference module and the module to be tested respectively call the method for modifying the large field of the product and the method for modifying the product image in the operation of modifying the basic data of the product. Then, the method for modifying the large field of the product and / or the method for modifying the product image can be selected as the target data writing method. The data comparison unit 204 can intercept the input parameters of the target data writing method from the reference module and the module to be tested respectively, use the field filtering unit 203 to filter the fields that do not need to be compared, and compare the results filtered by the field filtering unit 203; here, the input parameters of the target data writing method intercepted by the data comparison unit 204 can be in JSON format.
[0106] Step 305: Classify and display the comparison differences.
[0107] The comparative test device and method provided by the present application embodiment are applied to comparative tests in scenarios of system upgrade and new demand launch. The benchmark module and the module to be tested are set in a simulated online environment, the target data writing method that needs to be compared and tested is selected, and the online data writing traffic is directed to the benchmark module and the module to be tested. All data writing methods called by the benchmark module and the module to be tested in the mock data writing operation are compared, and the input parameters of the target data writing method called by the benchmark module and the module to be tested are compared respectively, and the comparison differences are classified and displayed through the interface, so that the data difference is controlled from the source of data writing, and all data writing business scenarios and all fields of write data can be covered at the same time. The implementation is simple, and the data accuracy is ensured while the real-time performance of data comparison is improved, so that real-time data comparison is achieved, which helps users (including testers and developers) to find problems in a timely manner and improves user experience.
[0108] In order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a comparative test device, such as Figure 4 As shown, the device comprises:
[0109] A flow diversion unit 401 is used to divert the first write data traffic of the target module to the reference module and the module to be tested; the target module runs in a first online environment; the reference module and the module to be tested run in a second offline environment; the second environment is the same as the first environment; the business logic of the reference module is the same as the business logic of the target module; the business logic of the module to be tested is different from the business logic of the target module;
[0110] The acquisition unit 402 is used to acquire first information and second information; the first information includes input parameters of a first type of function called when the benchmark module performs a first operation based on the first write data flow; the second information includes input parameters of a second type of function called when the module to be tested performs a second operation based on the first write data flow; the function of the first type of function is the same as the function of the second type of function;
[0111] The processing unit 403 is used to compare the second information with the first information to obtain a comparison result; and output the obtained comparison result.
[0112] In one embodiment, the processing unit 403 is used to:
[0113] Mock processing is performed on the third type of function called when the benchmark module performs the first operation; the third type of function includes all functions used for data writing; the third type of function includes the first type of function; and mock processing is performed on the fourth type of function called when the module to be tested performs the second operation; the fourth type of function includes all functions used for data writing; the fourth type of function includes the second type of function.
[0114] In one embodiment, the processing unit 403 is used to determine the first type of function in the reference module and the second type of function in the module to be tested according to the first configuration information.
[0115] In one embodiment, the drainage unit 401 is used to:
[0116] Based on a first function, directing the first write data traffic to the reference module and the module to be tested;
[0117] When the first function reports an error, the drainage is stopped.
[0118] In one embodiment, the drainage unit 401 is used to:
[0119] Based on the first function, directing the first write data traffic to the reference module and the module to be tested by synchronously directing traffic;
[0120] or,
[0121] Based on the first function, the first write data traffic is directed to the reference module and the module to be tested by asynchronously directing the traffic.
[0122] In one embodiment, the processing unit 403 is configured to:
[0123] filtering the second information and the first information according to second configuration information; wherein the second configuration information includes fields that do not need to be compared;
[0124] The filtered second information is compared with the filtered first information.
[0125] In one embodiment, the processing unit 403 is used to classify the comparison result using a first strategy;
[0126] The comparison test device further comprises a visualization unit, and the visualization unit is used to present the classified comparison results on a visualization page.
[0127] Here, the function of the drainage unit 401 is equivalent to the function of the online data writing drainage unit 201 in the application embodiment of the present application; the function of the acquisition unit 402 is equivalent to part of the function of the data comparison unit 204 in the application embodiment of the present application; the function of the processing unit 403 is equivalent to other functions of the data comparison unit 204 in the application embodiment of the present application and the functions of the data writing method Mock unit 202 and the field filtering unit 203; the function of the visualization unit is equivalent to the function of the comparison difference display unit 205 in the application embodiment of the present application.
[0128] In actual application, the drainage unit 401 and the acquisition unit 402 can be implemented by a processor in a comparative test device in combination with a communication interface; the processing unit 403 and the visualization unit can be implemented by a processor in a comparative test device.
[0129] It should be noted that: when the comparative test device provided in the above embodiment performs comparative tests, only the division of the above program modules is used as an example for illustration. In actual application, the above processing can be assigned to different program modules as needed, that is, the internal structure of the comparative test device is divided into different program modules to complete all or part of the processing described above. In addition, the comparative test device provided in the above embodiment and the comparative test method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0130] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a comparative test device, such as Figure 5 As shown, the comparative test device 500 includes:
[0131] Communication interface 501, capable of exchanging information with other electronic devices;
[0132] A processor 502, connected to the communication interface 501 to implement information interaction with other electronic devices, and used to execute the method provided by one or more of the above technical solutions when running a computer program;
[0133] The memory 503 is used to store a computer program that can be executed on the processor 502 .
[0134] Specifically, the processor 502 is configured to perform the following operations:
[0135] Directing the first write data traffic of the target module to the reference module and the module to be tested; the target module runs in a first online environment; the reference module and the module to be tested run in a second offline environment; the second environment is the same as the first environment; the business logic of the reference module is the same as the business logic of the target module; the business logic of the module to be tested is different from the business logic of the target module;
[0136] Acquire first information and second information; the first information includes input parameters of a first type of function called when the benchmark module performs a first operation based on the first write data flow; the second information includes input parameters of a second type of function called when the module to be tested performs a second operation based on the first write data flow; the function of the first type of function is the same as the function of the second type of function;
[0137] The second information is compared with the first information to obtain a comparison result; and the obtained comparison result is output.
[0138] In one embodiment, the processor 502 is configured to perform the following operations:
[0139] Mock processing is performed on the third type of function called when the benchmark module performs the first operation; the third type of function includes all functions used for data writing; the third type of function includes the first type of function; and mock processing is performed on the fourth type of function called when the module to be tested performs the second operation; the fourth type of function includes all functions used for data writing; the fourth type of function includes the second type of function.
[0140] In one embodiment, the processor 502 is configured to perform the following operations:
[0141] According to the first configuration information, a first type of function in the reference module and a second type of function in the module to be tested are determined.
[0142] In one embodiment, the processor 502 is configured to perform the following operations:
[0143] Based on a first function, directing the first write data traffic to the reference module and the module to be tested;
[0144] When the first function reports an error, the drainage is stopped.
[0145] In one embodiment, the processor 502 is configured to perform the following operations:
[0146] Based on the first function, directing the first write data traffic to the reference module and the module to be tested by synchronously directing traffic;
[0147] or,
[0148] Based on the first function, the first write data traffic is directed to the reference module and the module to be tested by asynchronously directing the traffic.
[0149] In one embodiment, the processor 502 is configured to perform the following operations:
[0150] filtering the second information and the first information according to second configuration information; wherein the second configuration information includes fields that do not need to be compared;
[0151] The filtered second information is compared with the filtered first information.
[0152] In one embodiment, the processor 502 is configured to perform the following operations:
[0153] classifying the comparison results using a first strategy;
[0154] The comparison results after classification are presented on the visualization page.
[0155] It should be noted that: the specific process of the processor 502 performing the above operations is detailed in the method embodiment, which will not be repeated here.
[0156] Of course, in actual application, the various components in the comparison test device 500 are coupled together through the bus system 504. It can be understood that the bus system 504 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 504 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 5 Various buses are labeled as bus system 504 .
[0157] The memory 503 in the embodiment of the present application is used to store various types of data to support the operation of the comparison test device 500. Examples of such data include: any computer program used to operate on the comparison test device 500.
[0158] The method disclosed in the above embodiment of the present application can be applied to the processor 502, or implemented by the processor 502. The processor 502 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 502. The above processor 502 may be a general processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 502 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 503, and the processor 502 reads the information in the memory 503 and completes the steps of the above method in combination with its hardware.
[0159] In an exemplary embodiment, the comparison test device 500 can be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to execute the aforementioned method.
[0160] It can be understood that the memory 503 of the embodiment of the present application can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAMbus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory described in the embodiments of the present application is intended to include, but is not limited to, these and any other suitable types of memory.
[0161] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, a memory 503 storing a computer program, and the computer program can be executed by a processor 502 of a comparison test device 500 to complete the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0162] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0163] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.
[0164] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A comparative test method, characterized in that: include: Directing the first write data traffic of the target module to the reference module and the module to be tested; The target module runs in a first online environment; The reference module and the module to be tested are run in a second offline environment; The second environment is the same as the first environment; the business logic of the reference module is the same as the business logic of the target module; the business logic of the module to be tested is different from the business logic of the target module; Acquire first information and second information; the first information includes input parameters of a first type of function called when the benchmark module performs a first operation based on the first write data flow; the second information includes input parameters of a second type of function called when the module to be tested performs a second operation based on the first write data flow; the function of the first type of function is the same as the function of the second type of function; The second information is compared with the first information to obtain a comparison result; and the obtained comparison result is output.
2. The method according to claim 1, characterized in that The method further comprises: The third type of function called when the benchmark module performs the first operation is simulated and Mocked; the third type of function includes all functions used for data writing; the third type of function includes the first type of function; and the fourth type of function called when the module to be tested performs the second operation is simulated and Mocked; the fourth type of function includes all functions used for data writing; the fourth type of function includes the second type of function.
3. The method according to claim 1, characterized in that The method further comprises: According to the first configuration information, a first type of function in the reference module and a second type of function in the module to be tested are determined.
4. The method according to claim 1, characterized in that: The step of directing the first write data flow of the target module to the reference module and the module to be tested includes: Based on a first function, directing the first write data traffic to the reference module and the module to be tested; When the first function reports an error, the drainage is stopped.
5. The method according to claim 4, characterized in that The step of directing the first write data flow to the reference module and the module to be tested based on the first function includes: Based on the first function, directing the first write data traffic to the reference module and the module to be tested by synchronously directing traffic; or, Based on the first function, the first write data traffic is directed to the reference module and the module to be tested by asynchronously directing the traffic.
6. The method according to any one of claims 1 to 5, characterized in that: The comparing the second information with the first information includes: filtering the second information and the first information according to second configuration information; wherein the second configuration information includes fields that do not need to be compared; The filtered second information is compared with the filtered first information.
7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: classifying the comparison results using a first strategy; The comparison results after classification are presented on the visualization page.
8. A comparative test device, characterized in that: include: A flow diversion unit, used for diverting the first write data flow of the target module to the reference module and the module to be tested; The target module runs in a first online environment; The reference module and the module to be tested are run in a second offline environment; The second environment is the same as the first environment; the business logic of the reference module is the same as the business logic of the target module; the business logic of the module to be tested is different from the business logic of the target module; an acquisition unit, configured to acquire first information and second information; the first information comprising input parameters of a first type of function called when the reference module performs a first operation based on the first write data flow; the second information comprising input parameters of a second type of function called when the module to be tested performs a second operation based on the first write data flow; a function of the first type of function is the same as a function of the second type of function; A processing unit is used to compare the second information with the first information to obtain a comparison result; and output the obtained comparison result.
9. A comparative test device, characterized in that: include: A processor and a memory for storing a computer program capable of running on the processor; wherein, When the processor is used to run the computer program, the steps of the method according to any one of claims 1 to 7 are performed.
10. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Automatic testing method and device and server
CN108170612A
Code vulnerability detection method, apparatus and device, and storage medium
CN110929267A