Batch comparison method, device and equipment based on bytecode enhancement, and storage medium
By using bytecode enhancement technology to parse sub-call results in batch program testing, the problems of low efficiency in manual testing and limited dimensions in automated testing in existing technologies are solved, enabling efficient automated testing and data discrepancy tracing analysis.
Patent Information
- Application Number
- CN202611559602.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-09
- Publication Date
- 2026-11-27
AI Technical Summary
Existing batch program testing suffers from problems such as low efficiency of manual testing, limited comparison dimensions in automated testing, and inability to trace and analyze data differences.
By using a bytecode enhancement method, the amount of preprocessed data in the benchmark and test environments is counted separately. When the data volume is consistent, batch nodes of the current production program and the program to be deployed are run. The sub-call results of the batch nodes are parsed, and the key values and call counts are compared according to the sub-call classification to generate a sub-call classification analysis report and automated test results.
It improves the automation and efficiency of batch testing, enriches the comparison dimensions of automated testing, and enables the source analysis of data differences.
Smart Images

Figure CN123178281A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a batch comparison method, apparatus, device and storage medium based on bytecode enhancement. Background Technology
[0002] Currently in the banking and financial industry, processing large volumes of data or repetitive tasks, such as handling business logic, daily accounting processing and summarizing, and report generation, is typically achieved through batch processing programs. These programs rely on batch scheduling frameworks to match batch nodes for execution. However, in a distributed microservice architecture, the open-source components used in banking systems iterate rapidly. When batch processing programs face component upgrades and require regression testing, traditional batch node testing methods suffer from the following problems:
[0003] First, test data needs to be prepared through extensive manual data collection or simulated pre-run transactions to ensure that the constructed test scenarios cover a wide range of code branches and business scenarios. However, due to the wide range of test scenarios, test data preparation is difficult and inefficient. Second, batch job plans need to be manually added to launch batch nodes. Database table checks are required before and after each batch node run to verify that the results meet expectations, resulting in lengthy batch testing times and cumbersome manual operations for test execution and result checking. Third, batch comparison tests typically only compare data tables before and after batch execution, with limited comparison dimensions. When the amount of data processed by batch nodes is large, the data comparison time will be significantly extended. When data differences exist, it is impossible to trace and analyze the causes of these differences, making it difficult to pinpoint the root cause of the problem. Automated comparison tests suffer from limited dimensions and lack of traceability.
[0004] In summary, existing batch program testing suffers from problems such as low efficiency of manual testing, limited comparative dimensions of automated testing, and inability to trace and analyze data differences. Summary of the Invention
[0005] In view of this, embodiments of this application provide a batch comparison method, apparatus, device, and storage medium based on bytecode enhancement to solve the problems of low efficiency in manual testing, limited comparison dimensions in automated testing, and inability to trace and analyze data differences in existing batch program testing.
[0006] To address the above problems, this application provides the following technical solutions:
[0007] In a first aspect, embodiments of this application disclose a batch comparison method based on bytecode enhancement, the method comprising:
[0008] The first data volume of the first preprocessed data in the benchmark environment and the second data volume of the second preprocessed data in the test environment are respectively counted; the first preprocessed data and the second preprocessed data are datasets obtained after de-identifying the production dataset or the production dataset from the last backup.
[0009] In response to the first data volume being consistent with the second data volume, a batch node of the current production program is run in the benchmark environment, and a batch node of the program to be put into production is run in the test environment.
[0010] During the execution of the batch nodes, the first sub-call parsing result generated by the benchmark environment and the second sub-call parsing result generated by the test environment are obtained based on bytecode enhancement. The first sub-call parsing result and the second sub-call parsing result both include the sub-call category, the key value corresponding to the sub-call category, and the number of calls corresponding to the key value. The sub-call is the call of a method inside the batch node to other methods.
[0011] According to the sub-call classification, the parsing results of the first sub-call and the parsing results of the second sub-call are compared to obtain a comparison result; the comparison includes comparing whether the key values under the same sub-call classification are the same, and whether the number of calls corresponding to the same key values are consistent;
[0012] Based on the comparison results, a sub-call classification analysis report and automated test results are generated.
[0013] Optionally, the method further includes:
[0014] In response to the inconsistency between the first data volume and the second data volume, the first preprocessed data and / or the second preprocessed data are calibrated, and the step of performing the first data volume of the first preprocessed data in the reference environment and the second data volume of the second preprocessed data in the test environment is returned until the first data volume and the second data volume are consistent.
[0015] Optionally, during the execution of the batch nodes, the first sub-call parsing result generated by the benchmark environment and the second sub-call parsing result generated by the test environment are parsed based on bytecode enhancement, including:
[0016] Based on the bytecode enhancement agent pre-configured in the benchmark environment and the test environment, call information collection logic is inserted at the call point of the sub-call;
[0017] In response to the triggering of the call point, the call information collection logic parses and collects the sub-call category, key value and call count corresponding to the sub-call;
[0018] The sub-call classification, key value, and call count collected in the benchmark environment are used as the first sub-call parsing result;
[0019] The sub-call classification, key value, and call count collected in the test environment are used as the second sub-call parsing result.
[0020] Optionally, in response to the triggering of the invocation point, the invocation information collection logic parses and collects the sub-invocation category, key value, and invocation count corresponding to the sub-invocation, including:
[0021] If the sub-call category includes remote procedure calls, in response to the triggering of the call point corresponding to the remote procedure call, the transaction code identifier and call count of the called microservice are parsed out through the call information collection logic;
[0022] The combination of the microservice identifier and the transaction code indicated by the transaction code identifier is used as the key value, and the number of calls is used as the number of calls corresponding to the key value;
[0023] If the sub-call category includes database access operations, in response to the triggering of the call point corresponding to the database access operation, the database access operation type, table identifier, and query conditions are parsed through the call information collection logic, and the number of calls to the database access operation is also used.
[0024] The combination of the database access operation type, table identifier, and query conditions is used as the key value, and the number of calls is used as the number of calls corresponding to the key value;
[0025] If the sub-call category includes error information, in response to the call point corresponding to the error information being triggered, the error code is parsed and the number of errors is counted through the call information collection logic;
[0026] The error code is used as the key, and the number of errors is used as the number of calls corresponding to the key.
[0027] Optionally, according to the sub-call classification, the parsing results of the first sub-call and the second sub-call are compared to obtain a comparison result, including:
[0028] For each sub-call category, determine whether the first key-value set of the first sub-call parsing result under the sub-call category is the same as the second key-value set of the second sub-call parsing result under the sub-call category;
[0029] If they are not the same, the comparison result of the sub-call classification is determined to be inconsistent with expectations;
[0030] If they are the same, for each key value in each key value set, determine whether the first call count of the key value in the first sub-call parsing result is consistent with the second call count in the second sub-call parsing result;
[0031] If the first and second call counts corresponding to a key value are inconsistent, the comparison result of the sub-call classification is determined to be unsatisfactory.
[0032] If the number of first and second calls corresponding to all key values are the same, the comparison result of the sub-call classification is determined to be in line with expectations.
[0033] Optionally, a sub-call classification analysis report and automated test results are generated based on the comparison results, including:
[0034] If the comparison result is as expected, a test result indicating that the automated test has passed is generated, as well as a first sub-call classification analysis report. The first sub-call classification analysis report includes the key values corresponding to the sub-call classifications of the benchmark environment and the test environment under the same production dataset, and the result that the number of calls corresponding to the key values are consistent.
[0035] The first preprocessed data of the benchmark environment and the second preprocessed data of the test environment are restored to their state before the batch nodes are run using the backup dataset. The backup dataset consists of the datasets imported into the benchmark environment and the test environment respectively before the batch nodes are run.
[0036] Optionally, a sub-call classification analysis report and automated test results are generated based on the comparison results, including:
[0037] If the comparison result is not as expected, a test result indicating that the automated test failed is generated, as well as a second sub-call classification analysis report. The second sub-call classification analysis report includes the results that at least one sub-call classification corresponding to the key value or the number of calls corresponding to the key value is inconsistent in the benchmark environment and the test environment under the same production dataset.
[0038] Based on the inconsistent sub-call categories and the key values corresponding to the sub-call categories, locate the call point information that generated the inconsistent sub-calls, wherein the call point information includes at least the class and the method;
[0039] Based on the call point information, analyze the reasons and program location for the inconsistency between the program to be put into production and the current production program;
[0040] The second preprocessed data of the test environment is restored to its state before the batch node is run using the backup dataset, and the batch node that is to be put into production is run in the test environment is returned to the step of running the batch node. The backup dataset is the dataset that was imported into the benchmark environment and the test environment respectively before running the batch node.
[0041] Secondly, embodiments of this application disclose a batch comparison device based on bytecode enhancement, the device comprising:
[0042] The statistics module is used to separately count the first data volume of the first preprocessed data in the benchmark environment and the second data volume of the second preprocessed data in the test environment; the first preprocessed data and the second preprocessed data are datasets obtained after de-identifying the production dataset or the production dataset from the last backup.
[0043] The running module is used to respond to the first data volume being consistent with the second data volume by running the batch nodes of the current production program in the benchmark environment and running the batch nodes of the program to be put into production in the test environment.
[0044] The parsing module is used to parse the first sub-call parsing result generated by the benchmark environment and the second sub-call parsing result generated by the test environment based on bytecode enhancement during the running of the batch nodes. The first sub-call parsing result and the second sub-call parsing result both include a sub-call category, a key value corresponding to the sub-call category, and the number of calls corresponding to the key value. The sub-call is a call from a method inside the batch node to another method.
[0045] The comparison module is used to compare the parsing results of the first sub-call and the parsing results of the second sub-call according to the sub-call category, and obtain a comparison result; the comparison includes comparing whether the key values under the same sub-call category are the same, and whether the number of calls corresponding to the same key values are consistent;
[0046] The generation module is used to generate a sub-call classification analysis report and automated test results based on the comparison results.
[0047] Thirdly, embodiments of this application disclose an electronic device, which includes at least one processor and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the bytecode enhancement-based batch comparison method disclosed in the first aspect.
[0048] Fourthly, embodiments of this application disclose a storage medium storing a program thereon, which, when executed by a controller, implements the batch comparison method based on bytecode enhancement as disclosed in the first aspect.
[0049] Based on the above embodiments of this application, a batch comparison method, apparatus, device, and storage medium based on bytecode enhancement are provided. The method involves statistically analyzing the first data volume of a first preprocessed data in a benchmark environment and the second data volume of a second preprocessed data in a test environment. The first and second preprocessed data are datasets obtained after de-identifying a production dataset or a previously backed-up production dataset. In response to the consistency between the first and second data volumes, batch nodes of the current production program are run in the benchmark environment, and batch nodes of the program to be put into production are run in the test environment. During the running of the batch nodes, the first sub-call parsing result generated in the benchmark environment and the second sub-call parsing result generated in the test environment are parsed based on bytecode enhancement. Both the first and second sub-call parsing results include a sub-call category, a key value corresponding to the sub-call category, and the number of calls corresponding to the key value. A sub-call is a call made by a method within a batch node to another method. The first and second sub-call parsing results are compared according to the sub-call category to obtain a comparison result. The comparison includes comparing whether the key values under the same sub-call category are the same and whether the number of calls corresponding to the same key value is consistent. A sub-call category analysis report and automated test results are generated based on the comparison results. In this embodiment, bytecode enhancement is used to parse sub-calls and set sub-call comparison rules to achieve automated comparison testing between the production version and the version to be deployed. This eliminates the need for manual data collection and initiation of batch nodes, thus improving the automation level and efficiency of batch testing. Simultaneously, comparing key values and call counts based on sub-call classification dimensions enriches the comparison dimensions of automated testing. Furthermore, data difference tracing analysis is achieved based on the generated sub-call classification analysis report and automated test results. In summary, the bytecode enhancement-based batch comparison method achieves the goals of improving batch testing efficiency, increasing automated comparison dimensions, and enabling data difference tracing analysis. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0051] Figure 1 This is a flowchart illustrating a batch comparison method based on bytecode enhancement disclosed in an embodiment of this application;
[0052] Figure 2 This is a flowchart illustrating another batch comparison method based on bytecode enhancement disclosed in an embodiment of this application;
[0053] Figure 3 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. Detailed Implementation
[0054] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0055] In this application, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0056] The following are the relevant technical terms used in the embodiments of this application:
[0057] Batch Node: In the batch scheduling framework, a batch node is matched for a batch program, and the batch program is run by scheduling the execution of the batch node.
[0058] Sub-calls: Through bytecode enhancement, intercept and enhance calls from internal methods to other methods, such as RPC calls, database calls, HTTP calls, etc.
[0059] Bytecode enhancement is a technique that dynamically modifies the .class bytecode during compilation, class loading, or runtime without altering the Java source code to extend functionality. It can automatically insert time consumption, exceptions, and call chain data into RPC calls, database calls, HTTP calls, and cached calls.
[0060] As is known from the background technology, existing batch program testing suffers from problems such as low efficiency of manual testing, limited comparative dimensions of automated testing, and inability to trace and analyze data differences. Therefore, this application discloses a batch comparison scheme based on bytecode enhancement. By separately statistically analyzing and comparing the preprocessed data volume of the benchmark environment and the test environment, and when the data volume is consistent, batch nodes of the current production program and the program to be deployed are run separately. Based on bytecode enhancement, the sub-calls generated during the execution of batch nodes are parsed, and the key values and call counts are compared according to the sub-call classification to generate a sub-call classification analysis report and automated test results. Based on this, the goal of improving batch testing efficiency, increasing the comparative dimensions of automated testing, and facilitating the traceability and analysis of data differences is achieved.
[0061] like Figure 1 The diagram shown is a flowchart of a batch comparison method based on bytecode enhancement disclosed in an embodiment of this application. The method includes the following steps:
[0062] S101: Calculate the first data volume of the first preprocessed data in the benchmark environment and the second data volume of the second preprocessed data in the test environment, respectively.
[0063] In S101, the first preprocessed data and the second preprocessed data are datasets obtained by de-identifying the production dataset or the production dataset from the last backup. These datasets are used to provide a consistent input baseline in both the benchmark environment and the test environment.
[0064] In some implementations, before calculating the first and second data volumes, the anonymized production dataset or the previously backed-up production dataset can be imported into the benchmark environment and the test environment, respectively, to obtain the first and second preprocessed data.
[0065] The desensitization process is used to remove or replace sensitive information in production data, such as customer identifiers, account numbers, and amounts, to ensure the authenticity of test data while meeting data security requirements. Optionally, the desensitization process may include at least one of the following methods: encryption, masking, replacement, and obfuscation.
[0066] For example, if the preprocessed data of the batch program is data with a status of 0 in table A, the way to count the first data volume or the second data volume can be: count the number of data rows with a status of 0 in table A, such as executing "select count(1) from A where status='0'".
[0067] It should be noted that, depending on the actual processing logic of the batch processing program, the preprocessed data can also be data limited by other tables, other fields, or other conditions, and this application is not limited to this.
[0068] S102: In response to the first data volume being consistent with the second data volume, run the batch node of the current production program in the baseline environment and run the batch node of the program to be put into production in the test environment.
[0069] In S102, the baseline environment is used to run the current production program, and the test environment is used to run the program to be put into production. The current production program can be understood as the production version of the batch program that is currently running online, and the program to be put into production can be understood as the production version of the batch program that is to be run online.
[0070] Batch nodes are nodes matched for batch programs under the batch scheduling framework. The execution of batch programs is achieved by scheduling and executing batch nodes.
[0071] In some implementations, after separately calculating the first and second data volumes, it is determined whether the first and second data volumes are consistent. If the first and second data volumes are consistent, it indicates that the preprocessed data volumes in the baseline environment and the test environment are the same, eliminating interference caused by different data volumes to subsequent sub-call parsing and comparison. At this point, the current production program is deployed to the baseline environment, and the program to be deployed to the test environment is deployed to the test environment, and batch nodes in both environments are run respectively.
[0072] In this embodiment of the application, running batch nodes in two environments with the same amount of data helps to ensure that the input data on which the comparative test is based is consistent.
[0073] S103: During the process of running batch nodes, the first sub-call parsing result generated by the benchmark environment and the second sub-call parsing result generated by the test environment are obtained based on bytecode enhancement.
[0074] In S103, both the first and second sub-call parsing results include the sub-call category, the key value corresponding to the sub-call category, and the number of calls corresponding to the key value.
[0075] This sub-call is a call from an internal method of a batch node to other methods.
[0076] In some implementations, bytecode enhancement can intercept and enhance calls from internal methods of batch nodes to other methods, i.e., sub-calls. Sub-calls can include, but are not limited to, remote procedure calls (RPC), database access operations (DAO), hypertext transfer protocol (HTTP) calls, cached calls, etc.
[0077] During the batch node execution, the baseline environment generates the first sub-call parsing result, and the test environment generates the second sub-call parsing result. Both the first and second sub-call parsing results include the sub-call category, the key value corresponding to the sub-call category, and the call count corresponding to the key value. The sub-call category is used to distinguish different types of sub-calls. For example, it can differentiate between RPC calls, database access operations, and error messages. The key value uniquely identifies the specific calling object within the same sub-call category, and the call count indicates the number of times the calling object corresponding to that key value is called during the batch node execution.
[0078] S104: According to the sub-call classification, compare the parsing results of the first sub-call and the second sub-call to obtain the comparison results.
[0079] In S104, the comparison includes comparing whether the key values under the same sub-call category are the same, and whether the number of calls corresponding to the same key value is consistent.
[0080] In some implementations, after obtaining the resolution results of the first and second sub-calls, the results are compared separately according to the sub-call categories. Specifically:
[0081] S1041: For each sub-call category, determine whether the first key-value set of the first sub-call parsing result under the sub-call category is the same as the second key-value set of the second sub-call parsing result under the same sub-call category; if they are different, execute S1042; if they are the same, execute S1043.
[0082] In some implementations, for each sub-call category, all key-value pairs of the first sub-call parsing result under that sub-call category are extracted to form a first key-value set; all key-value pairs of the second sub-call parsing result under that sub-call category are extracted to form a second key-value set.
[0083] Determine whether the first key-value set and the second key-value set are the same. If they are the same, it means that the benchmark environment and the test environment called the same object under this sub-call category. If they are different, it means that the benchmark environment and the test environment called different objects under this sub-call category.
[0084] S1042: The comparison result of the sub-call classification is determined to be inconsistent with expectations.
[0085] S1043: For each key value in each key value set, determine whether the first call count of the key value in the first sub-call parsing result is consistent with the second call count in the second sub-call parsing result; if there is a key value whose first call count and second call count are inconsistent, execute S1044; if all key values whose first call count and second call count are consistent, execute S1045.
[0086] In some implementations, if the first key-value set is the same as the second key-value set, the number of calls corresponding to the same key-value is further compared. For each key-value in the first and second key-value sets, the first call count of the key-value in the first sub-call parsing result and the second call count of the key-value in the second sub-call parsing result are obtained respectively. If the first call count and the second call count corresponding to all key-values are consistent, the comparison result of the sub-call classification is determined to be in line with expectations; if the first call count and the second call count corresponding to at least one key-value are inconsistent, the comparison result of the sub-call classification is determined to be unsatisfactory.
[0087] S1044: The comparison result of the sub-call classification is determined to be inconsistent with expectations.
[0088] S1045: The comparison results of the sub-call classification are in line with expectations.
[0089] In this application embodiment, the two-layer comparison logic of first comparing the key-value sets and then comparing the number of calls when the key-value sets are the same is beneficial to discover version differences from multiple dimensions such as sub-call classification, key-value, and number of calls, thus enriching the comparison dimensions of the comparison test.
[0090] S105: Generate a sub-call classification analysis report and automated test results based on the comparison results.
[0091] In S105, the subcall classification analysis report may include at least one of the following: subcall parsing results of the benchmark environment and the test environment under the same dataset; whether the subcall classification comparison results are consistent; and whether the results meet expectations.
[0092] The automated test results indicate whether the batch of production-ready programs has passed the automated comparison test, and can be classified as either "passed" or "failed". If the comparison results for all sub-call categories are as expected, the automated test result is "passed"; if the comparison result for at least one sub-call category is as expected, the automated test result is "failed".
[0093] Based on the embodiments disclosed in this application, by separately statistically analyzing and comparing the preprocessed data volume of the benchmark environment and the test environment, and when the data volume is consistent, batch nodes of the current production program and the program to be put into production are run separately. Based on bytecode enhancement parsing, sub-calls generated during the execution of batch nodes are parsed, and key values and call counts are compared according to sub-call classification to generate sub-call classification analysis reports and automated test results. Based on this, the purpose of improving batch testing efficiency, increasing automated comparison dimensions, and data difference tracing analysis is achieved.
[0094] Based on the bytecode enhancement-based batch comparison method disclosed in the above embodiments of this application, the bytecode enhancement-based batch comparison method further includes a calibration process when the first data volume and the second data volume are inconsistent, specifically including the following steps:
[0095] S201: Calculate the first data volume of the first preprocessed data in the benchmark environment and the second data volume of the second preprocessed data in the test environment, respectively.
[0096] The specific execution process and principle of S201 are the same as those of S101, which can be found here and will not be repeated here.
[0097] S202: In response to the inconsistency between the first data volume and the second data volume, the first preprocessed data and / or the second preprocessed data are calibrated, and the process returns to execute S201.
[0098] During process S202, after calibrating the first preprocessed data and / or the second preprocessed data, the process returns to S201 to recalculate the first and second data volumes and determine their consistency again. If they are still inconsistent, calibration continues until the first and second data volumes are consistent, at which point the aforementioned S102 is executed.
[0099] In some implementations, if the first data volume is inconsistent with the second data volume, it indicates a difference in the preprocessed data volume between the baseline environment and the test environment. In this case, the cause of the inconsistency can be analyzed, and the first and / or second preprocessed data can be calibrated. Calibration methods may include at least one of the following: supplementing data, deleting data, correcting data, or re-importing data.
[0100] For example, if the first data volume is greater than the second data volume, the missing preprocessed data can be added to the test environment; if the first data volume is less than the second data volume, redundant preprocessed data can be deleted from the benchmark environment, or missing preprocessed data can be added to the benchmark environment. It should be noted that the specific calibration method can be determined based on the actual data differences, and this application is not limited to this.
[0101] In this embodiment of the application, by introducing a calibration and re-statistical data volume calibration process, it is beneficial to eliminate interference factors that cause the comparison results to be distorted due to the inconsistency of the data volume of the two sets of environments, and to ensure the effectiveness of subsequent sub-call comparisons.
[0102] Based on the batch comparison method based on bytecode enhancement disclosed in the above embodiments of this application, the specific implementation process of obtaining the first sub-call parsing result generated by the benchmark environment and the second sub-call parsing result generated by the test environment based on bytecode enhancement during the running of batch nodes in the aforementioned S103 includes:
[0103] S1031: Based on the pre-configured bytecode enhancement agent in the benchmark and test environments, insert call information collection logic at the call point of the sub-call.
[0104] In one implementation, bytecode enhancement proxies are pre-configured in both the benchmark and test environments. These proxies enhance the call points between methods within the batch nodes and other methods during the class loading or runtime phases of the batch nodes, without modifying the batch node source code. A call point can be understood as the location where a sub-call occurs. Call information collection logic is used to collect relevant information about the sub-calls, such as sub-call category, key-value pairs, and call count.
[0105] Optionally, the call information collection logic can also collect at least one of the following: call point time consumption information, exception information, call chain information, etc.
[0106] S1032: In response to the triggering of the call point, the call information collection logic parses and collects the sub-call category, key value and call count of the corresponding sub-call.
[0107] In some implementations, the enhanced call point is triggered when the batch nodes reach it during execution. At this time, the call information collection logic parses and collects the sub-call category, key value, and call count of the corresponding sub-call.
[0108] S1033: Use the sub-call classification, key value, and call count collected in the benchmark environment as the first sub-call parsing result.
[0109] S1034: Use the sub-call classification, key value, and call count collected in the test environment as the second sub-call parsing result.
[0110] In some implementations, the sub-call classification, key value, and call count collected in the benchmark environment constitute the first sub-call parsing result, while the sub-call classification, key value, and call count collected in the test environment constitute the second sub-call parsing result.
[0111] Optionally, the parsing result of the first sub-call can be stored in the base table corresponding to the baseline environment, and the parsing result of the second sub-call can be stored in the test table corresponding to the test environment for subsequent comparison and analysis.
[0112] Based on the execution of S1031 to S1034, if the sub-call category includes RPC calls, in response to the triggering of the corresponding RPC call point, the transaction code identifier and call count of the called microservice are parsed out through the call information collection logic; the combination of the microservice identifier and the transaction code indicated by the transaction code identifier is used as the key value, and the call count is used as the call count corresponding to the key value.
[0113] For example, if the batch program calls microservice FW1's transaction code TR1 a total of 20 times, the key value is recorded as FW1-TR1, and the corresponding call count is 20; if microservice FW1's transaction code TR2 is called a total of 10 times, the key value is recorded as FW1-TR2, and the corresponding call count is 10; if microservice FW1's transaction code TR3 is called a total of 5 times, the key value is recorded as FW1-TR3, and the corresponding call count is 5; in the base table and the test table, the key value is recorded as microservice-transaction code, and the count is the corresponding number of times.
[0114] Based on the execution of S1031 to S1034, if the sub-call category includes database DAO operations, in response to the triggering of the corresponding database DAO operation call point, the DDL operation is parsed out through the call information collection logic, such as database operation type, table identifier and query conditions, and the number of calls to the database DAO operation is counted; the combination of database operation type, table identifier and query conditions is used as the key value, and the number of calls is used as the number of calls corresponding to the key value.
[0115] For example, if the query involves selecting table A and the query condition c1 is executed 5 times, the key value is recorded as select-A-c1, and the corresponding call count is 5. If the query involves selecting table A and the query condition c2 is executed 10 times, the key value is recorded as select-A-c2, and the corresponding call count is 10. If the query involves selecting table B and the query condition c3 is executed 10 times, the key value is recorded as select-B-c3, and the corresponding call count is 10. If the query involves updating table A and the query condition c1 is executed 5 times, the key value is recorded as update-A-c1, and the corresponding call count is 5. If the query involves deleting table B and the query condition c3 is executed 5 times, the key value is recorded as delete-B-c3, and the corresponding call count is 5. If the query involves inserting table C and the query condition c3 is executed 15 times, the key value is recorded as insert-C, and the corresponding call count is 15. In the base and test tables, the key value is recorded as data operation type-table-query condition, and the count is the corresponding number of times.
[0116] Based on the execution of S1031 to S1034, if the sub-call category includes error information, in response to the triggering of the call point corresponding to the error information, the error code is parsed out and the number of errors is counted through the call information collection logic; the error code is used as the key value, and the number of errors is used as the call count corresponding to the key value.
[0117] For example, if error code ERR1 occurs once, the key value is recorded as ERR1, and the corresponding call count is 1; if error code ERR2 occurs 10 times, the key value is recorded as ERR2, and the corresponding call count is 10; in the base table and the test table, the key value is recorded as the error code, and the count is the corresponding number of times.
[0118] For example, the parsing results of the first sub-call in the baseline environment and the parsing results of the second sub-call in the test environment are stored in the base1 table and the test1 table, respectively.
[0119] Table 1: Example of the first sub-call resolution result base1 in the baseline environment.
[0120]
[0121] Table 2: Example of the second sub-call parsing result test1 in the test environment.
[0122]
[0123] In this embodiment of the application, the first sub-call parsing result generated by the benchmark environment and the second sub-call parsing result generated by the test environment are obtained by bytecode enhancement. For example, the key value and call count of various types of sub-calls such as RPC calls, database DAO operations and error information are automatically collected and parsed, eliminating the need for manual data embedding. This helps to reduce the difficulty of test data preparation and improve the automation of sub-call parsing.
[0124] Based on Tables 1 and 2 above as examples, execution S104 compares the parsing results of the first and second sub-calls according to the sub-call category to obtain the comparison results. If the sub-call category includes RPC calls, the key values of base1 and test1 are the same, the first key-value set and the second key-value set are both FW1-TR1, FW1-TR2, and FW1-TR3, and the number of calls for FW1-TR1 is 20, the number of calls for FW1-TR2 is 10, and the number of calls for FW1-TR3 is 5, then the comparison result of this RPC call is as expected.
[0125] If the sub-call category includes database DAO operations, and the key values of base1 and test1 are different, with insert-C in the first key-value set of base1 and insert-D in the second key-value set of test1, then the first key-value set is not the same as the second key-value set, and the comparison result of this database access operation does not meet expectations.
[0126] If the sub-call category includes error information, and the key values of base1 and test1 are the same, and the first key-value set and the second key-value set are both ERR1 and ERR2, but as shown in base1, ERR1 has a call count of 1 in the first sub-call parsing result, and as shown in test1, ERR has a call count of 6 in the second sub-call parsing result, then the comparison result of this error code does not meet expectations.
[0127] Based on the bytecode enhancement-based batch comparison method disclosed in the above embodiments of this application, the specific implementation process of S105, which generates a sub-call classification analysis report and automated test results based on the comparison results, includes:
[0128] S1051: If the comparison results meet expectations, generate test results indicating that the automated test has passed, as well as the first sub-call classification analysis report.
[0129] In some implementations, if the comparison results for all sub-call categories meet expectations, a test result indicating that the automated test has passed is generated, along with a first sub-call category analysis report. This report includes the key-value pairs corresponding to the sub-call categories in the benchmark and test environments under the same production dataset, as well as results showing that the number of calls corresponding to these key-value pairs is consistent. Optionally, the first sub-call category analysis report may also include the parsing results, comparison process, and comparison conclusions for each sub-call category.
[0130] S1052: Use the backup dataset to restore the first preprocessed data of the baseline environment and the second preprocessed data of the test environment to their state before running the batch node.
[0131] In some implementations, after automated testing passes, the data in the baseline and test environments is restored using backup datasets. The backup datasets are the datasets imported into the baseline and test environments before running the batch nodes. The restoration operation cleans up the test environment, returning both the baseline and test environments to their initial states before the batch nodes were run, facilitating the next round of testing or regression testing for the next production version.
[0132] S1053: If the comparison result is not as expected, generate a test result indicating that the automated test failed, and a second sub-call classification analysis report.
[0133] In some implementations, if the comparison result of at least one sub-call category is inconsistent with expectations, a test result indicating that the automated test has failed is generated, along with a second sub-call category analysis report. The second sub-call category analysis report includes results showing inconsistencies in the key values or call counts corresponding to at least one sub-call category between the benchmark and test environments using the same production dataset. Optionally, the second sub-call category analysis report may also include information such as inconsistent sub-call categories, inconsistent key values, inconsistent call counts, and the comparison process.
[0134] S1054: Based on the inconsistent subcall categories and the corresponding key values of the subcall categories, locate the call point information that generated the inconsistent subcall.
[0135] In some implementations, the call point information that generated the inconsistent sub-call is located based on the inconsistent sub-call category and the key value corresponding to that category. The call point information indicates the location of the sub-call in the program. The call point information includes at least the class and method. Optionally, the call point information may also include at least one of the following: line number, call stack, method signature, class loader information, thread information, call chain identifier, etc.
[0136] S1055: Based on the call point information, analyze the reasons for the inconsistency between the program to be put into production and the current production program, and the program location.
[0137] In some implementations, if the current production program executes `insert-C` while the production-ready program executes `insert-D`, the call point information can be used to locate the class and method in the production-ready program that executes `insert-D`. This allows analysis to determine if the database access operation in the production-ready program has changed due to code modifications, component upgrades, configuration changes, or other reasons. Optionally, it can also be used to determine if the production-ready program has defects. If defects are found, the analysis results can be fed back to the development and testing personnel for fixing the production-ready program.
[0138] S1056: Use the backup dataset to restore the second preprocessed data of the test environment to the state before running the batch node, and return to the step of running the batch node to be put into production in the test environment in S102.
[0139] In some implementations, after analyzing the cause of the inconsistency, the second preprocessed data in the test environment is restored to its state before running the batch nodes using a backup dataset. The backup dataset consists of datasets imported into both the baseline and test environments before running the batch nodes. After restoring the test environment data, the process returns to the step of running the batch nodes of the production-ready program in the test environment, and steps such as parsing sub-calls and comparison sub-calls are re-executed. Through this cyclical process, automated comparison testing can be re-performed after the production-ready program is fixed, until the automated tests pass.
[0140] In this embodiment, when there is a difference between the first sub-call parsing result and the second sub-call parsing result, the class and method that caused the difference are located by the inconsistent sub-call classification and the key value corresponding to the sub-call classification, so as to realize the source analysis of the difference and solve the problem that the data difference cannot be traced. At the same time, the environmental data is reset by backing up the dataset, which ensures the consistency of the input data of multiple rounds of regression testing.
[0141] Based on the bytecode enhancement-based batch comparison method disclosed in the above embodiments of this application, this application also discloses another bytecode enhancement-based batch comparison method, such as... Figure 2 As shown, the main steps include the following:
[0142] S1: Import the dataset obtained by de-identifying the production dataset or the production dataset from the last backup into the benchmark environment and the test environment.
[0143] S2: The first data volume of the first preprocessed data in the statistical benchmark environment.
[0144] S3: The second data volume of the second preprocessed data in the statistical test environment.
[0145] S4: Compare whether the first data volume and the second data volume are the same. If they are the same, execute S5 and S6; if they are not the same, execute S16.
[0146] S5: Run the batch node of the current production program in the baseline environment and execute S7.
[0147] S6: Run a batch of nodes of the program to be put into production in the test environment and execute S8.
[0148] S7: During the execution of the batch nodes, the first sub-call parsing result generated by the baseline environment is obtained based on bytecode enhancement parsing.
[0149] S8: During the process of running batch nodes, the second sub-call parsing result generated by the test environment is obtained based on bytecode enhancement parsing.
[0150] S9: According to the sub-call classification, compare the parsing results of the first sub-call and the second sub-call. If the comparison results are consistent, execute S10; if the comparison results are inconsistent, execute S12.
[0151] S10: Generate test results indicating that the automated test has passed, as well as a first sub-call classification analysis report.
[0152] S11: Use the backup dataset to restore the first preprocessed data of the baseline environment and the second preprocessed data of the test environment to their state before running the batch nodes.
[0153] S12: Generate test results indicating that the automated test failed, as well as a second sub-call classification analysis report.
[0154] S13: Based on the inconsistent sub-call categories and the corresponding key values of the sub-call categories, locate the call point information that generated the inconsistent sub-calls.
[0155] S14: Based on the call point information, analyze the reasons for the inconsistency between the program to be put into production and the current production program, and the program location.
[0156] S15: Use the backup dataset to restore the second preprocessed data of the test environment to the state before running the batch nodes, and return to execute S6.
[0157] S16: Calibrate the first preprocessed data and / or the second preprocessed data, and return to execute S2 and S3.
[0158] Based on the bytecode-enhanced batch comparison method disclosed in this application, the preprocessed data volume of the benchmark environment and the test environment is statistically analyzed and compared. When the data volume is consistent, batch nodes of the current production program and the program to be deployed are run separately. Automated comparison testing between the production version and the version to be deployed is achieved by parsing sub-calls through bytecode enhancement and setting sub-call comparison rules. This eliminates the need for manual data entry and manual initiation of batch nodes, which helps to improve the automation level and efficiency of batch testing. At the same time, by comparing the key values and call counts of sub-calls, the comparison dimensions of automated testing are enriched. Data difference tracing analysis is achieved based on the generated sub-call classification analysis report and automated test results. Based on this, the goals of improving batch testing efficiency, increasing automated comparison dimensions, and tracing data difference tracing analysis are achieved.
[0159] Based on the batch comparison method based on bytecode enhancement disclosed in the above embodiments of this application, this application also discloses a batch comparison device based on bytecode enhancement, which includes: a statistics module, a running module, a parsing module, a comparison module, and a generation module.
[0160] The statistics module is used to separately count the first data volume of the first preprocessed data in the benchmark environment and the second data volume of the second preprocessed data in the test environment; the first preprocessed data and the second preprocessed data are datasets obtained after de-identifying the production dataset or the production dataset from the last backup.
[0161] The running module is used to run batch nodes of the current production program in the benchmark environment and batch nodes of the program to be put into production in the test environment when the first data volume and the second data volume are consistent.
[0162] The parsing module is used to parse the first sub-call parsing result generated by the benchmark environment and the second sub-call parsing result generated by the test environment based on bytecode enhancement during the running of batch nodes. Both the first and second sub-call parsing results include the sub-call category, the key value corresponding to the sub-call category, and the call count corresponding to the key value. The sub-call is the call of a method inside the batch node to other methods.
[0163] The comparison module is used to compare the parsing results of the first sub-call and the second sub-call according to the sub-call category, and obtain the comparison results. The comparison includes comparing whether the key values under the same sub-call category are the same, and whether the number of calls corresponding to the same key value is consistent.
[0164] The generation module is used to generate sub-call classification analysis reports and automated test results based on the comparison results.
[0165] For details on the specific implementation process of the above module in implementing batch comparison processing based on bytecode enhancement, please refer to the corresponding section of the aforementioned method; it will not be repeated here.
[0166] Based on the bytecode enhancement-based batch comparison method and corresponding apparatus disclosed in the above embodiments of this application, such as Figure 3 As shown in the embodiments of this application, an electronic device is also disclosed. The electronic device includes at least one processor 301, and at least one memory 302 connected to the processor 301, and a bus 303. The processor 301 and the memory 302 communicate with each other through the bus 303. The processor 301 is used to call program instructions in the memory 302 to execute the batch comparison method based on bytecode enhancement disclosed in the aforementioned embodiments of this application.
[0167] This application also discloses a storage medium storing a program that, when executed by a controller, implements the bytecode-enhanced batch comparison method as described above.
[0168] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the descriptions in the method embodiments. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0169] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0170] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A batch comparison method based on bytecode enhancement, characterized in that, The method includes: The first data volume of the first preprocessed data in the benchmark environment and the second data volume of the second preprocessed data in the test environment are respectively counted; the first preprocessed data and the second preprocessed data are datasets obtained after de-identifying the production dataset or the production dataset from the last backup. In response to the first data volume being consistent with the second data volume, a batch node of the current production program is run in the benchmark environment, and a batch node of the program to be put into production is run in the test environment. During the execution of the batch nodes, the first sub-call parsing result generated by the benchmark environment and the second sub-call parsing result generated by the test environment are obtained based on bytecode enhancement. The first sub-call parsing result and the second sub-call parsing result both include the sub-call category, the key value corresponding to the sub-call category, and the number of calls corresponding to the key value. The sub-call is the call of a method inside the batch node to other methods. According to the sub-call classification, the parsing results of the first sub-call and the parsing results of the second sub-call are compared to obtain a comparison result; the comparison includes comparing whether the key values under the same sub-call classification are the same, and whether the number of calls corresponding to the same key values are consistent; Based on the comparison results, a sub-call classification analysis report and automated test results are generated.
2. The method according to claim 1, characterized in that, The method further includes: In response to the inconsistency between the first data volume and the second data volume, the first preprocessed data and / or the second preprocessed data are calibrated, and the step of performing the first data volume of the first preprocessed data in the reference environment and the second data volume of the second preprocessed data in the test environment is returned until the first data volume and the second data volume are consistent.
3. The method according to claim 1, characterized in that, During the execution of the batch nodes, the first sub-call parsing result generated by the baseline environment and the second sub-call parsing result generated by the test environment are obtained based on bytecode enhancement, including: Based on the bytecode enhancement agent pre-configured in the benchmark environment and the test environment, call information collection logic is inserted at the call point of the sub-call; In response to the triggering of the call point, the call information collection logic parses and collects the sub-call category, key value and call count corresponding to the sub-call; The sub-call classification, key value, and call count collected in the benchmark environment are used as the first sub-call parsing result; The sub-call classification, key value, and call count collected in the test environment are used as the second sub-call parsing result.
4. The method according to claim 3, characterized in that, In response to the triggering of the invocation point, the invocation information collection logic parses and collects the sub-invocation category, key value, and invocation count corresponding to the sub-invocation, including: If the sub-call category includes remote procedure calls, in response to the triggering of the call point corresponding to the remote procedure call, the transaction code identifier and call count of the called microservice are parsed out through the call information collection logic; The combination of the microservice identifier and the transaction code indicated by the transaction code identifier is used as the key value, and the number of calls is used as the number of calls corresponding to the key value; If the sub-call category includes database access operations, in response to the triggering of the call point corresponding to the database access operation, the database access operation type, table identifier, and query conditions are parsed through the call information collection logic, and the number of calls to the database access operation is also used. The combination of the database access operation type, table identifier, and query conditions is used as the key value, and the number of calls is used as the number of calls corresponding to the key value; If the sub-call category includes error information, in response to the call point corresponding to the error information being triggered, the error code is parsed and the number of errors is counted through the call information collection logic; The error code is used as the key, and the number of errors is used as the number of calls corresponding to the key.
5. The method according to any one of claims 1 to 4, characterized in that, According to the aforementioned sub-call classification, the parsing results of the first sub-call and the second sub-call are compared to obtain the comparison results, including: For each sub-call category, determine whether the first key-value set of the first sub-call parsing result under the sub-call category is the same as the second key-value set of the second sub-call parsing result under the sub-call category; If they are not the same, the comparison result of the sub-call classification is determined to be inconsistent with expectations; If they are the same, for each key value in each key value set, determine whether the first call count of the key value in the first sub-call parsing result is consistent with the second call count in the second sub-call parsing result; If the first and second call counts corresponding to a key value are inconsistent, the comparison result of the sub-call classification is determined to be unsatisfactory. If the number of first and second calls corresponding to all key values are the same, the comparison result of the sub-call classification is determined to be in line with expectations.
6. The method according to any one of claims 1 to 4, characterized in that, Based on the comparison results, a sub-call classification analysis report and automated test results are generated, including: If the comparison result is as expected, a test result indicating that the automated test has passed is generated, as well as a first sub-call classification analysis report. The first sub-call classification analysis report includes the key values corresponding to the sub-call classifications of the benchmark environment and the test environment under the same production dataset, and the result that the number of calls corresponding to the key values are consistent. The first preprocessed data of the benchmark environment and the second preprocessed data of the test environment are restored to their state before the batch nodes are run using the backup dataset. The backup dataset consists of the datasets imported into the benchmark environment and the test environment respectively before the batch nodes are run.
7. The method according to any one of claims 1 to 4, characterized in that, Based on the comparison results, a sub-call classification analysis report and automated test results are generated, including: If the comparison result is not as expected, a test result indicating that the automated test failed is generated, as well as a second sub-call classification analysis report. The second sub-call classification analysis report includes the results that at least one sub-call classification corresponding to the key value or the number of calls corresponding to the key value is inconsistent in the benchmark environment and the test environment under the same production dataset. Based on the inconsistent sub-call categories and the key values corresponding to the sub-call categories, locate the call point information that generated the inconsistent sub-calls, wherein the call point information includes at least the class and the method; Based on the call point information, analyze the reasons and program location for the inconsistency between the program to be put into production and the current production program; The second preprocessed data of the test environment is restored to its state before the batch node is run using the backup dataset, and the batch node that is to be put into production is run in the test environment is returned to the step of running the batch node. The backup dataset is the dataset that was imported into the benchmark environment and the test environment respectively before running the batch node.
8. A batch comparison device based on bytecode enhancement, characterized in that, The device includes: The statistics module is used to separately count the first data volume of the first preprocessed data in the benchmark environment and the second data volume of the second preprocessed data in the test environment; the first preprocessed data and the second preprocessed data are datasets obtained after de-identifying the production dataset or the production dataset from the last backup. The running module is used to respond to the first data volume being consistent with the second data volume by running the batch nodes of the current production program in the benchmark environment and running the batch nodes of the program to be put into production in the test environment. The parsing module is used to parse the first sub-call parsing result generated by the benchmark environment and the second sub-call parsing result generated by the test environment based on bytecode enhancement during the running of the batch nodes. The first sub-call parsing result and the second sub-call parsing result both include a sub-call category, a key value corresponding to the sub-call category, and the number of calls corresponding to the key value. The sub-call is a call from a method inside the batch node to another method. The comparison module is used to compare the parsing results of the first sub-call and the parsing results of the second sub-call according to the sub-call category, and obtain a comparison result; the comparison includes comparing whether the key values under the same sub-call category are the same, and whether the number of calls corresponding to the same key values are consistent; The generation module is used to generate a sub-call classification analysis report and automated test results based on the comparison results.
9. An electronic device, characterized in that, The electronic device includes at least one processor and at least one memory connected to the processor, and a bus; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the batch comparison method based on bytecode enhancement as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, It stores a program that, when executed by the controller, implements the batch comparison method based on bytecode enhancement as described in any one of claims 1 to 7.
