A test data generation method and system based on big data

By atomically decomposing business scenarios and constructing dependency graphs, and combining various machine learning techniques to generate test data, the problems of low efficiency and incomplete scenario coverage in traditional software testing are solved. In particular, it significantly improves the defect detection rate by verifying data consistency in distributed systems.

CN123048419APending Publication Date: 2026-11-06GHOSTCLOUD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611545250.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-08
Publication Date
2026-11-06

AI Technical Summary

Technical Problem

Traditional software testing methods suffer from inefficient test data construction, incomplete scenario coverage, and insufficient defect discovery capabilities, especially in the context of big data and distributed architectures where constructing end-to-end test data is difficult.

Method used

By atomizing business scenarios, a dependency graph of atomic test scenario units is constructed. Graph neural networks are used to learn dependency patterns, generate the shortest test scenario path that covers the test target, and combine machine learning models to generate test data, including techniques such as reinforcement learning, tensor decomposition, and semantic constraint graphs, to ensure data consistency and coverage.

Benefits of technology

It enables efficient generation of test data covering a massive number of scenario combinations, improving generation efficiency and coverage, and enhancing the ability to discover hidden defects. In particular, it significantly improves the defect detection rate by verifying data consistency in distributed systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123048419A_ABST
    Figure CN123048419A_ABST
Patent Text Reader

Abstract

The application discloses a kind of test data generation method and system based on big data, it is related to computer software testing technical field, the method includes: atomic decomposition is carried out to business scene, the dependency atlas between atomic scene is constructed, and test scene path set is generated according to test target;Corresponding test data is generated for the test scene path based on machine learning model;Wherein, the training and optimization process of machine learning model at least fuses one of following mechanisms: generation strategy optimization mechanism based on reinforcement learning, data association rule mining mechanism based on tensor decomposition, data consistency guarantee mechanism based on semantic constraint graph, through scene atomization and intelligent path planning, can automatically generate the test data of covering mass scene combination, generation efficiency and coverage rate are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer software testing technology, and specifically to a method and system for generating test data based on big data. Background Technology

[0002] With the rapid development of big data, machine learning, and artificial intelligence technologies, and the increasing prevalence of data collection methods such as 5G, the scale of data is exploding, and software systems and their testing environments are becoming increasingly complex. Against this backdrop, testing work should adapt to the trend of intelligent development, making full use of massive amounts of historical test data. Through intelligent classification and learning, it should simulate as many and as comprehensive a combination of scenarios as possible, and utilize off-peak hours such as nighttime and holidays to conduct large-scale automated verification of the program's scalability, robustness, and functionality.

[0003] Especially in the context of big data and distributed architecture, traditional software testing methods face severe challenges. Test data preparation has become a key bottleneck in the testing process, mainly in the following aspects:

[0004] 1) Inefficient test data construction: Test engineers need to rely on domain knowledge and experience to manually construct test data, which is not only time-consuming and laborious, but also difficult to cover a large number of scenario combinations, especially various boundary conditions and abnormal scenarios.

[0005] 2) Existing automation tools lack intelligence: Traditional rule-based or template-based test data generation tools lack learning and adaptive capabilities, resulting in inconsistent quality of generated test data and an inability to perform targeted optimization based on system characteristics, leading to insufficient test effectiveness;

[0006] 3) Lack of systematic test adequacy assessment: Currently, there is a lack of scientific methods to assess whether the test dataset has fully covered all key business rules and states, resulting in a certain degree of blindness in the testing process;

[0007] 4) Difficulty in constructing test data for distributed systems: Under microservice and distributed architecture, it is particularly complex to construct end-to-end test data that can verify cross-service data consistency and transaction integrity. Summary of the Invention

[0008] The purpose of this invention is to overcome the shortcomings of the prior art and provide a test data generation method and system based on big data, which solves the problems of low efficiency, incomplete scenario coverage and insufficient defect discovery capabilities caused by the difficulty in constructing test data in traditional software testing.

[0009] The objective of this invention is achieved through the following technical solution:

[0010] In a first aspect, the present invention discloses a method for generating test data based on big data, comprising the following steps:

[0011] The business scenario is atomically decomposed into atomic test scenario units represented by entity-relationship-behavior triples;

[0012] Construct a dependency graph among atomic test scenario units to identify time dependencies, state dependencies, and data dependencies, and use graph neural networks to learn dependency patterns;

[0013] Construct a scenario reachability matrix based on the dependency graph between atomic test scenario units;

[0014] Based on the scenario reachability matrix, and according to the coverage requirements of the test target, the Monte Carlo tree search algorithm is used to generate the set of shortest test scenario paths that cover the test target.

[0015] For each test scenario path, the corresponding test data input sequence and expected output verification conditions are generated based on the pre-trained machine learning model; wherein, the training and optimization process of the machine learning model incorporates at least one of the following mechanisms: a generation strategy optimization mechanism based on reinforcement learning, a data association rule mining mechanism based on tensor decomposition, and a data consistency guarantee mechanism based on semantic constraint graph.

[0016] Based on the first aspect, NLP tools are used to extract key entities in the business scenario, and relationships and behaviors are identified based on the key entities to construct atomic test scenario units. Each atomic scenario is represented by an entity-relationship-behavior triple. The key entity refers to the core object or conceptual element in the business scenario description of the software system under test that can independently carry data, state or business functions.

[0017] When constructing a dependency graph between atomic scenes, in response to the discovery of new scene combinations or defect patterns, the dependencies and their weights are dynamically adjusted based on graph convolutional networks and attention mechanisms to update the dependency graph.

[0018] Based on the first aspect, the machine learning model adopts an encoder-decoder architecture of path encoder-data decoder, wherein the path encoder uses a graph neural network to encode the test scenario path into a path semantic vector; the data decoder uses a sequence generation model based on Transformer or recurrent neural network, and uses the path semantic vector as input conditions to generate the input sequence of test data and expected output data corresponding to the test scenario path one by one.

[0019] Based on the first aspect, the reinforcement learning-based generation policy optimization mechanism includes:

[0020] Define the state space and action space, and design a multi-objective reward function that integrates coverage reward, defect discovery reward and cost penalty;

[0021] A near-end strategy optimization algorithm is adopted to continuously optimize the data generation strategy with the goal of maximizing long-term cumulative rewards.

[0022] Based on the first aspect, the data association rule mining mechanism based on tensor decomposition includes:

[0023] Construct test data tensor representations with five dimensions: business entities, data fields, time, operation type, and test results;

[0024] The CP tensor decomposition algorithm is used to obtain factor vectors of each dimension, and hidden cross-dimensional correlation patterns are analyzed and identified.

[0025] Data association rules with confidence levels are generated based on the association pattern.

[0026] Based on the first aspect, the data consistency guarantee mechanism based on semantic constraint graphs includes:

[0027] Semantic constraints such as time sequence, numerical calculation, logical dependency, and format matching are extracted from business scenarios to construct a semantic constraint graph;

[0028] Constraint propagation is performed using an extended arc consensus algorithm to ensure that the generated test data satisfies all semantic constraints;

[0029] The generated test data undergoes three-tiered verification: time logic, numerical relationships, and business logic.

[0030] Based on the first aspect, it also includes steps to generate test scenarios for verifying data consistency in a distributed system, specifically including:

[0031] Model a distributed transaction scenario, construct network partitioning, concurrent update conflict and partial failure exception scenarios, and generate corresponding expected states. Use the distributed transaction scenario and the corresponding expected states as test scenarios.

[0032] Based on the first aspect, the process also includes steps such as generating anomaly test datasets from the test data through adaptive anomaly injection, specifically including:

[0033] Weaknesses in the system are identified through static code analysis and dynamic monitoring, and a weakness vector is constructed. The probability of anomaly injection is calculated based on the matching degree of the weakness vector and the historical trigger rate, which serves as the probability distribution of a single anomaly type.

[0034] Based on the probability distribution of multiple anomaly types, the optimal combination strategy for collaborative injection in the same test scenario is obtained through a genetic algorithm, and the optimal combination strategy is used as the anomaly test dataset.

[0035] Based on the first aspect, the following steps are also included:

[0036] The machine learning model and test data generation strategy are iteratively optimized using an optimization iteration mechanism. The optimization iteration mechanism includes a test data sufficiency proof method based on formal verification, specifically including: formally modeling business rules using temporal logic and computation tree logic, verifying test coverage, and supplementing test data based on counterexample paths.

[0037] Secondly, the present invention discloses a test data generation system based on big data, used to execute the test data generation method based on big data described in the first aspect, comprising:

[0038] The scenario decoupling and path generation module is used to atomically decompose business scenarios, construct a dependency graph between atomic scenarios, and generate a set of test scenario paths based on the test objectives.

[0039] The intelligent data generation module, based on a machine learning model, generates the input sequence of test data and the expected output verification conditions for the test scenario path; wherein, the training and optimization process of the machine learning model incorporates at least one of the following mechanisms: a generation strategy optimization mechanism based on reinforcement learning, a data association rule mining mechanism based on tensor decomposition, and a data consistency guarantee mechanism based on semantic constraint graph.

[0040] The data validation and feedback module is used to execute tests and iteratively optimize the machine learning model and test data generation strategy based on the test results.

[0041] The beneficial effects of this invention are:

[0042] 1) This invention can automatically generate test data covering a massive number of scene combinations through scene atomization and path planning, which greatly improves the generation efficiency and coverage.

[0043] 2) This invention integrates multiple machine learning technologies, enabling the generation strategy to self-optimize and focus on error-prone scenarios; it can discover hidden defect correlation patterns; and it ensures the rationality of the data's business logic, significantly improving the defect detection rate.

[0044] 3) This invention is specifically designed for distributed systems and can generate test scenarios to verify data consistency, effectively discovering hidden defects in distributed environments. Attached Figure Description

[0045] Figure 1 This is a flowchart illustrating a test data generation method based on big data according to an embodiment of the present invention.

[0046] Figure 2This is a schematic diagram illustrating the process of generating a test scenario path set using a big data-based test data generation method according to an embodiment of the present invention.

[0047] Figure 3 This is a schematic diagram of the reinforcement learning generation strategy optimization mechanism of a test data generation method based on big data according to an embodiment of the present invention. Detailed Implementation

[0048] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0049] Example 1:

[0050] like Figure 1 As shown, this embodiment provides a method for generating test data based on big data, including the following steps:

[0051] The business scenarios are atomically decomposed, a dependency graph between atomic scenarios is constructed, and a set of test scenario paths is generated based on the test objectives.

[0052] For each test scenario path, the corresponding test data input sequence and expected output verification conditions are generated based on the pre-trained machine learning model; wherein, the training and optimization process of the machine learning model incorporates at least one of the following mechanisms: a generation strategy optimization mechanism based on reinforcement learning, a data association rule mining mechanism based on tensor decomposition, and a data consistency guarantee mechanism based on semantic constraint graph.

[0053] like Figure 2 As shown, as one possible implementation, generating a test scenario path set includes the following steps:

[0054] Business scenarios are broken down into atomic test scenario units represented by "entity-relationship-behavior" triples;

[0055] Construct a dependency graph among atomic test scenario units to identify time dependencies, state dependencies, and data dependencies, and use graph neural networks to learn dependency patterns;

[0056] Construct a scenario reachability matrix based on the dependency graph between atomic test scenario units;

[0057] Based on the scenario reachability matrix, and according to the coverage requirements of the test target, the Monte Carlo tree search algorithm is used to generate the set of shortest test scenario paths that cover the test target.

[0058] For each test scenario path, generate the corresponding test data input sequence and expected output verification conditions.

[0059] In the description of the embodiments of the present invention, the "scenario reachability matrix" is a mathematical structure or data model used to quantify the probability of continuous execution of business logic between different atomic test scenario units. The scenario reachability matrix can be a two-dimensional square matrix, whose rows and columns correspond to all identified atomic scenario units.

[0060] Preferably, the process of atomizing the business scenario and constructing atomic test scenario units includes: using NLP tools to extract key entities in the business scenario; identifying relationships and behaviors based on the key entities, and constructing atomic test scenario units, where each atomic scenario is represented by an "entity-relationship-behavior" triple.

[0061] In the description of the embodiments of the present invention, "key entity" refers to a core object or conceptual element that can independently carry data, status or business functions in a specific business scenario description of the software system under test. For example, such key entity may include, but is not limited to, active or passive participants in the business process, core business objects being processed, items or resources with clear attributes, and abstract concepts that define business rules or status.

[0062] Preferably, when constructing the dependency graph between atomic scenarios, in response to the discovery of new scenario combinations or defect patterns, the dependency relationships and their weights are dynamically adjusted based on graph convolutional networks and attention mechanisms to update the dependency graph; the scenario combination refers to a sequence or set of test scenarios formed by connecting or paralleling two or more atomic test scenario units according to a specific time order, logical relationship or business rules, for verifying more complex business processes or interactions; the defect pattern refers to the inherent rules or templates of defect types, triggering conditions and manifestations that repeatedly appear in the software system and have common or similar characteristics.

[0063] Specifically, the process of constructing a dependency graph between atomic scenes includes:

[0064] In response to the discovery of new scenario combinations or defect patterns, the dependency relationships between atomic test scenario units are identified. For example, if unit 1 is a prerequisite state, unit 2 is a condition judgment, unit 3 is a condition judgment, and unit 4 is a result action, then the possible dependency relationships are that unit 2 depends on unit 1, unit 3 depends on unit 1, and unit 4 depends on both unit 2 and unit 3, and both must be true at the same time.

[0065] The order and frequency of occurrence of units in historical test cases are used as training data to learn more complex and implicit dependency patterns through graph neural networks, and a dependency graph is built. In the dependency graph, nodes are atomic units, edges are dependencies, and the weights of the edges are obtained through the attention mechanism of graph neural networks.

[0066] For example, taking the "e-commerce order placement" business scenario as an example: Use NLP tools to extract key entities from the business scenario description text, including "user," "product," "order," "inventory," and "payment." Based on the key entities, identify relationships and behaviors to construct atomic test scenario units, such as: Unit 1 "User submits order" (entities: user, order; behavior: submit order), Unit 2 "System deducts inventory" (entities: inventory; behavior: deduct), Unit 3 "System creates payment record" (entities: payment record; behavior: create), and Unit 4 "Payment result notifies user" (entities: payment, user; behavior: notification). Each atomic test scenario unit is represented by an "entity-relationship-behavior" triple. Subsequently, the dependencies between units are identified. For example, unit 1 executes before unit 2 (time dependency), unit 3 depends on the execution result of unit 2 (state dependency), and the inventory change data generated by unit 2 is used by unit 3 (data dependency). Based on this, a dependency graph is constructed. For the test objective of "payment failure after successful order placement", the Monte Carlo tree search algorithm is used to generate the shortest test scenario path of "unit 1 → unit 2 → unit 3 (payment failure branch)" based on the scenario reachability matrix. The corresponding test data input sequence (such as user information, product information, payment amount) and expected output verification conditions (such as order status is "pending payment", inventory quantity has not been deducted or has been rolled back) are generated for this path.

[0067] As one possible implementation, the method for generating corresponding test data for the test scenario path based on a machine learning model is as follows:

[0068] Model Structure: The machine learning model adopts an encoder-decoder architecture of "path encoder-data decoder". The path encoder uses a graph neural network to encode the test scenario path (composed of atomic test scenario unit sequences and their dependencies) into a path semantic vector. The data decoder uses a sequence generation model based on Transformer or recurrent neural networks, using the path semantic vector as input to generate the corresponding test data input sequence and expected output data for each path.

[0069] Training process: Historical test cases and their corresponding test data are collected to form a training sample set. The input of each training sample is a test scenario path (including atomic test scenario unit sequence, dependencies between units, and expected output verification conditions), and the output is the test data input sequence and expected output data corresponding to that path. During training, the sum of the cross-entropy loss function of the sequence generation and the constraint violation penalty term is used as the total loss function. The constraint violation penalty term is used to penalize cases where the generated results violate business semantic constraints during the training phase. The Adam optimizer is used for training, and the model is selected through data validity indicators on the validation set to obtain the trained machine learning model.

[0070] Working principle: The machine learning model learns the mapping relationship and distribution pattern between "test scenario path - test data" in historical test cases through training. Therefore, for a newly input test scenario path, the model can generate test data that matches the path based on the learned distribution pattern. At the same time, the generated test data is output after constraint propagation and three-layer verification through a data consistency guarantee mechanism based on semantic constraint graph, ensuring that the data meets the business logic rationality.

[0071] As one possible implementation, the various mechanisms integrated in the training and optimization process of the machine learning model have the following division of labor: The reinforcement learning-based generation strategy optimization mechanism acts as a strategy selection layer, learning to select the optimal data generation strategy (e.g., from tensor rule-driven, semantic constraint sampling, random mutation selection, etc.) to optimize the generation behavior of the main generation model; the tensor decomposition-based data association rule mining mechanism acts as a pattern discovery layer, mining hidden cross-dimensional association patterns from historical test data and generating data association rules to guide the main generation model to generate data that can verify such association patterns; the semantic constraint graph-based data consistency guarantee mechanism acts as a constraint verification layer, performing constraint propagation and three-layer verification on the generated test data to eliminate data that does not meet business semantic constraints. These mechanisms work in conjunction with the main generation model to form a closed loop of "generation-optimization-verification".

[0072] Example 2:

[0073] This embodiment further optimizes upon embodiment 1, providing a specific implementation scheme for a generation strategy optimization mechanism based on reinforcement learning, which transforms the test data generation process from a static process into a dynamic and adaptive decision-making process.

[0074] like Figure 3 As shown, specifically, the reinforcement learning-based generation policy optimization mechanism includes:

[0075] Define the state space and action space, and design a multi-objective reward function that integrates coverage reward, defect discovery reward and cost penalty;

[0076] A near-end strategy optimization algorithm is adopted to continuously optimize the data generation strategy with the goal of maximizing long-term cumulative rewards.

[0077] For example, the state space s t Defined as including the proportion of business rules covered in the current testing cycle, the diversity entropy of generated data, the defect discovery rate of recently generated datasets, and the current resource utilization rate of the system; Action space a t Defined as a policy pool containing a combination of tensor rule-driven, semantic constraint sampling, and random mutation selection; reward r t Define a multi-objective function, preferably, in this embodiment, defined as:

[0078]

[0079] Where A is the number of new coverage rules, B is the total number of rules, C is the number of newly discovered defects, and E is the CPU time consumed for data generation and execution.

[0080] The specific steps for optimization using the near-end strategy optimization algorithm include:

[0081] Algorithm initialization: Create policy network π θ (s t Output action probabilities and value network V φ (s t Assess the value of the condition;

[0082] Interactive data collection: Over multiple test cycles, the current strategy interacts with the environment to collect trajectory data (s). t ,a t , r t , s t+1 );

[0083] Calculate the advantage estimate: Use the GAE method to calculate the advantage function at each time step. t ;

[0084] Update the policy network: Update the policy network by maximizing the pruning objective function of the proximal policy optimization algorithm;

[0085] Updating the value network: The value network is updated by minimizing the mean squared error;

[0086] By iteratively executing the above steps, the policy network learns which data generation action will yield the maximum long-term cumulative reward under which system state.

[0087] Example 3:

[0088] This embodiment further optimizes upon embodiment 1 or 2, providing a specific implementation scheme for a data association rule mining mechanism based on tensor decomposition, used to discover hidden, multi-dimensional association defect patterns in test data.

[0089] Specifically, it includes:

[0090] Construct test data tensor representations with five dimensions: business entities, data fields, time, operation type, and test results;

[0091] The CP tensor decomposition algorithm is used to obtain factor vectors of each dimension, and hidden cross-dimensional correlation patterns are analyzed and identified.

[0092] Data association rules with confidence levels are generated based on the association pattern.

[0093] For example, in this embodiment, the analysis of user registration operations in historical test data includes the following five dimensions:

[0094] Business entities: user, registry, verification code;

[0095] Data fields: Username, password strength, email format, mobile phone number location, etc., and their values;

[0096] Time: The time period during which the operation occurred;

[0097] Operation types: registration, verification, activation;

[0098] Test results: Registration successful, format error, verification failed, system error.

[0099] For a historical test record: In the early morning, a user registered using a weak password and an incorrectly formatted email address, resulting in a system anomaly. Then, increment the value at the corresponding coordinate position of tensor T by 1.

[0100] At this point, tensor T is decomposed into CP tensors, resulting in R components. Each component includes five factor vectors corresponding to the given dimension and a weight. Assume the weight of the r-th component is large, and its factor vectors display the following information:

[0101] 1. The second factor vector has large values ​​for "password strength = weak" and "email format = incorrect";

[0102] 2. The third factor vector has a larger value for "time = early morning";

[0103] 3. The value of the fifth factor vector, "System Anomaly," is very large.

[0104] Based on the above information, a strong correlation pattern can be derived: registration using weak passwords and incorrectly formatted email addresses during the early morning hours is highly correlated with system anomalies.

[0105] Based on the above strong association pattern, it can be transformed into a verifiable rule: IF Time period = early morning AND Password strength = weak AND Email format = incorrect THEN Expected anomaly type = system anomaly WITH Confidence level = 80%.

[0106] This feedback can be sent to the intelligent data generation module, which can then be guided to generate more data that meets this condition to verify the anomaly.

[0107] Example 4:

[0108] This embodiment further optimizes upon embodiments 1-3, providing a specific implementation scheme for a data consistency guarantee mechanism based on semantic constraint graphs, which ensures that the generated data is self-consistent in terms of business logic.

[0109] Specifically, it includes:

[0110] Semantic constraints such as time sequence, numerical calculation, logical dependency, and format matching are extracted from business scenarios to construct a semantic constraint graph; the nodes of the semantic constraint graph are fields or time points, and the edges are semantic constraints.

[0111] Constraint propagation is performed using an extended arc consensus algorithm to ensure that the generated test data satisfies all semantic constraints;

[0112] The generated test data undergoes three-tiered verification: time logic, numerical relationships, and business logic.

[0113] Preferably, the constraint propagation can be implemented in the following ways:

[0114] Handle logical dependencies, check the compatibility of each field in the logical dependency, and reduce the value range of each field. For example, if there are fields "minor" and "adult", when "minor" is selected, the value range is reduced to [0,18), and when "adult" is selected, the value range is reduced to [18,120].

[0115] The time order can be processed, and due to the existence of the time order, the value ranges of time fields can be mutually constrained. For example, the appointment time is before the delivery time.

[0116] It handles numerical calculations and format matching, and performs relevant numerical calculations based on the processed logical dependencies and time order from fields that meet the format matching criteria.

[0117] Multiple iterations of constraint processing significantly reduced the value range of each field, ensuring that all remaining values ​​have semantically consistent combinations.

[0118] Select specific values ​​from the value range after constraint propagation as the generated test data to generate data that is both random and ensures the correctness of business logic and satisfies all semantic constraints.

[0119] When performing three-layer verification, the logic of time logic verification is to verify whether the values ​​of time-related fields in the data conform to objective time sequence logic and specific business time sequence constraints; the logic of numerical relationship verification is to verify whether the calculation logic, dependency relationship and boundary conditions between numerical fields in the data are valid; and the logic of business logic verification is to verify whether the combination of data conforms to business rules, state machine constraints and domain common sense.

[0120] Preferably, verification is typically performed in the order of temporal logic → numerical relationship → business logic. When lower-level verification fails, a failure is returned directly, and the detailed information of the verification failure is added to the defect pattern sample library as a high-quality sample, eliminating the need for more time-consuming deep verification and thus further improving efficiency.

[0121] Example 5:

[0122] This embodiment provides a test scenario generation scheme. The test scenario is the test scenario in the test data generated in embodiments 1-4, which is used to verify the data consistency of the distributed system. The test scenario generation method includes: modeling a distributed transaction scenario, constructing network partition, concurrent update conflict and partial failure exception scenarios, and generating corresponding expected states, and using the distributed transaction scenario and the corresponding expected state as the test scenario.

[0123] Specifically, one possible implementation scheme for modeling distributed interaction scenarios is as follows:

[0124] Identify two or more independent service components or data storage nodes involved in a complete cross-system business interaction;

[0125] Analyze and define the key operation sequence of the interaction, clarifying the expected behavior and state changes of each participant under various scenarios such as normal execution, partial success, and failure. The key operation sequence refers to the predetermined order and logical relationship of a set of core operation steps that must be executed sequentially across the boundaries of different services or components when completing a cross-service transaction or business process with clear business semantics in a distributed system.

[0126] Network partitioning, concurrent update conflicts, and partial failure exceptions are all typical failure scenarios in distributed systems.

[0127] For network partitioning scenarios, network partitions are artificially created by using a testing framework or by injecting network latency and packet loss rules between services. The expected state is divided into the partitioning period and the partition recovery period. During the partitioning period, the independent state within each partition is derived according to the system design. After the partition recovery, the final consistent state of the data items is derived according to the system's conflict resolution strategy. The actual state is obtained by querying the value of the target data from all previously isolated nodes at specific time points during the partitioning period and after recovery.

[0128] For concurrent update conflict scenarios, a concurrency testing tool can be used to simultaneously send multiple requests to the system to modify the same data entity to construct the scenario. The expected state is deduced based on the system's concurrency control protocol and business semantics. The actual state is obtained by querying the final state of the data entity after all concurrent requests have been executed.

[0129] For certain failure scenarios, a service call failure can be simulated in the middle of the distributed transaction execution chain to construct the scenario. The expected state is derived based on the system's fault recovery mode.

[0130] If the system's fault recovery mode uses Saga compensated transactions, the expected state is that successful operations must be correctly restored by the corresponding compensated operations.

[0131] If the system's fault recovery mode uses retry until success, the expected state is that after a certain period of time or after retries, all steps should eventually succeed.

[0132] In some failure scenarios, the actual status is obtained as follows: after the simulated failure is triggered, wait for the system to complete the compensation or retry logic, and then query all services involved in the transaction chain to obtain the status of their relevant business entities.

[0133] Specifically, data pairs are generated based on the expected and actual states in the scenario, which are used to automatically synthesize verification scripts. The execution logic of the script is as follows: after triggering the constructed abnormal scenario, the actual state is obtained, and the actual result is compared with the expected state. Based on the preset assertion rules, it is determined whether the system behavior meets the expectations, thereby completing the automated and deep verification of the consistency of the distributed system.

[0134] Example 6:

[0135] This embodiment provides a scheme for generating an abnormal test dataset. The abnormal test dataset is the abnormal test dataset generated from the test data generated in embodiments 1-4, and is generated through adaptive exception injection. The method for generating this abnormal test dataset includes:

[0136] Weaknesses in the system are identified through static code analysis and dynamic monitoring, and a weakness vector is constructed. The probability of anomaly injection is calculated based on the matching degree of the weakness vector and the historical trigger rate, which serves as the probability distribution of a single anomaly type.

[0137] Based on the probability distribution of multiple anomaly types, the optimal combination strategy for collaborative injection in the same test scenario is obtained through a genetic algorithm, and the optimal combination strategy is used as the anomaly test dataset.

[0138] Specifically, a vulnerability vector is a data model that provides a structured and quantitative description of the potential defects and vulnerabilities of a system under test, represented as W=[w1, w2, ..., wn], where wn corresponds to an identified type of system vulnerability. The formula for calculating the anomaly injection probability Pinject is: Pinject=α·M+β·R; where M is the matching degree of the vulnerability vector, representing the correlation between a specific anomaly type to be injected and each vulnerability dimension in the vulnerability vector, R is the historical trigger rate, representing the frequency with which a specific anomaly type actually successfully triggers a reproducible defect in the historical testing period, and α and β are the corresponding weighting coefficients.

[0139] Example 7:

[0140] This embodiment further optimizes upon embodiments 1-6, describing a closed-loop method for iteratively optimizing the machine learning model and test data generation strategy using an optimization iteration mechanism during the test data generation process.

[0141] The optimization iteration mechanism includes a test data sufficiency proof method based on formal verification, which includes: formally modeling business rules using temporal logic and computation tree logic, verifying test coverage, and supplementing test data based on counterexample paths.

[0142] Specifically, the output of formal modeling is a set of formal specifications, which serve as precise mathematical standards for determining whether a test is sufficient.

[0143] As one possible implementation, the test coverage is verified by inputting the generated test data and the system behaviors it triggers into a formal verification tool; and inputting the generated formal specification into the formal verification tool to automatically verify the system behavior model covered by the test data.

[0144] If the verification result passes, it indicates that the system behavior induced by the current test data fully conforms to the formal specification;

[0145] If the verification result fails, it indicates that there is at least one potential system behavior path that violates the specification and is not covered by the existing test data. In this case, the formal verification tool will generate a counterexample path, which shows a series of state transition sequences from the initial state to the state that violates the specification.

[0146] By analyzing the counterexample paths, a series of executable and observable specific test action sequences, preconditions, and system states can be obtained, thereby enabling targeted test data generation.

[0147] In particular, counterexample paths and their corresponding business rules can be extracted and added to semantic constraint graphs or rule bases, so that future data generation can avoid missing similar coverage in advance.

[0148] Example 8:

[0149] This embodiment provides a test data generation system based on big data, used to execute a test data generation method based on big data as described in any one of embodiments 1-7, including:

[0150] The scenario decoupling and path generation module is used to atomically decompose business scenarios, construct a dependency graph between atomic scenarios, and generate a set of test scenario paths based on the test objectives.

[0151] The intelligent data generation module generates corresponding test data for the test scenario path based on a machine learning model; wherein the training and optimization process of the machine learning model incorporates at least one of the following mechanisms: a generation strategy optimization mechanism based on reinforcement learning, a data association rule mining mechanism based on tensor decomposition, and a data consistency guarantee mechanism based on semantic constraint graph.

[0152] The data validation and feedback module is used to execute tests and iteratively optimize the machine learning model and test data generation strategy based on the test results.

[0153] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.

Claims

1. A method for generating test data based on big data, characterized in that, Includes the following steps: The business scenario is atomically decomposed into atomic test scenario units represented by entity-relationship-behavior triples; Construct a dependency graph among atomic test scenario units to identify time dependencies, state dependencies, and data dependencies, and use graph neural networks to learn dependency patterns; Construct a scenario reachability matrix based on the dependency graph between atomic test scenario units; Based on the scenario reachability matrix, and according to the coverage requirements of the test target, the Monte Carlo tree search algorithm is used to generate the set of shortest test scenario paths that cover the test target. For each test scenario path, the corresponding test data input sequence and expected output verification conditions are generated based on the pre-trained machine learning model; wherein, the training and optimization process of the machine learning model incorporates at least one of the following mechanisms: a generation strategy optimization mechanism based on reinforcement learning, a data association rule mining mechanism based on tensor decomposition, and a data consistency guarantee mechanism based on semantic constraint graph.

2. The test data generation method based on big data according to claim 1, characterized in that: NLP tools are used to extract key entities in the business scenario. Relationships and behaviors are identified based on the key entities, and atomic test scenario units are constructed. Each atomic scenario is represented by an entity-relationship-behavior triple. The key entity refers to the core object or conceptual element in the business scenario description of the software system under test that can independently carry data, state or business functions. When constructing a dependency graph between atomic scenes, in response to the discovery of new scene combinations or defect patterns, the dependencies and their weights are dynamically adjusted based on graph convolutional networks and attention mechanisms to update the dependency graph.

3. The test data generation method based on big data according to claim 2, characterized in that, The machine learning model adopts an encoder-decoder architecture of path encoder-data decoder. The path encoder uses a graph neural network to encode the test scenario path into a path semantic vector. The data decoder uses a sequence generation model based on Transformer or recurrent neural network to generate the input sequence of test data and the expected output data corresponding to the test scenario path one by one, using the path semantic vector as input conditions.

4. The test data generation method based on big data according to claim 3, characterized in that, The reinforcement learning-based generation policy optimization mechanism includes: Define the state space and action space, and design a multi-objective reward function that integrates coverage reward, defect discovery reward and cost penalty; A near-end strategy optimization algorithm is adopted to continuously optimize the data generation strategy with the goal of maximizing long-term cumulative rewards.

5. The test data generation method based on big data according to claim 4, characterized in that, The data association rule mining mechanism based on tensor decomposition includes: Construct test data tensor representations with five dimensions: business entities, data fields, time, operation type, and test results; The CP tensor decomposition algorithm is used to obtain factor vectors of each dimension, and hidden cross-dimensional correlation patterns are analyzed and identified. Data association rules with confidence levels are generated based on the association pattern.

6. The test data generation method based on big data according to claim 5, characterized in that, The data consistency guarantee mechanism based on semantic constraint graphs includes: Semantic constraints such as time sequence, numerical calculation, logical dependency, and format matching are extracted from business scenarios to construct a semantic constraint graph; Constraint propagation is performed using an extended arc consensus algorithm to ensure that the generated test data satisfies all semantic constraints; The generated test data undergoes three-tiered verification: time logic, numerical relationships, and business logic.

7. The test data generation method based on big data according to claim 6, characterized in that, It also includes steps to generate test scenarios for verifying data consistency in a distributed system, specifically including: Model a distributed transaction scenario, construct network partitioning, concurrent update conflict and partial failure exception scenarios, and generate corresponding expected states. Use the distributed transaction scenario and the corresponding expected states as test scenarios.

8. The test data generation method based on big data according to claim 7, characterized in that: It also includes the step of generating an anomaly test dataset from the test data through adaptive anomaly injection, specifically including: Weaknesses in the system are identified through static code analysis and dynamic monitoring, and a weakness vector is constructed. The probability of anomaly injection is calculated based on the matching degree of the weakness vector and the historical trigger rate, which serves as the probability distribution of a single anomaly type. Based on the probability distribution of multiple anomaly types, the optimal combination strategy for collaborative injection in the same test scenario is obtained through a genetic algorithm, and the optimal combination strategy is used as the anomaly test dataset.

9. The test data generation method based on big data according to claim 8, characterized in that, It also includes the following steps: The machine learning model and test data generation strategy are iteratively optimized using an optimization iteration mechanism. The optimization iteration mechanism includes a test data sufficiency proof method based on formal verification, specifically including: formally modeling business rules using temporal logic and computation tree logic, verifying test coverage, and supplementing test data based on counterexample paths.

10. A test data generation system based on big data, characterized in that, A method for generating test data based on big data as described in any one of claims 1-9, comprising: The scenario decoupling and path generation module is used to atomically decompose business scenarios, construct a dependency graph between atomic scenarios, and generate a set of test scenario paths based on the test objectives. The intelligent data generation module, based on a machine learning model, generates the input sequence of test data and the expected output verification conditions for the test scenario path; wherein, the training and optimization process of the machine learning model incorporates at least one of the following mechanisms: a generation strategy optimization mechanism based on reinforcement learning, a data association rule mining mechanism based on tensor decomposition, and a data consistency guarantee mechanism based on semantic constraint graph. The data validation and feedback module is used to execute tests and iteratively optimize the machine learning model and test data generation strategy based on the test results.