A test data generation method and apparatus
By generating a small number of data samples and simulating transactions to generate batch test data, the problems of high resource consumption and data leakage risk in existing technologies are solved, and efficient and secure test data generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2023-02-03
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies require extensive desensitization of production environment data when generating test data, resulting in high resource consumption and the risk of data leakage. Furthermore, incomplete desensitization may increase the risk of data leakage.
Data samples are generated by acquiring a small amount of production environment data. Batch account information is generated using product number segment information and data sequence. The data samples and account information are then combined to form test data, avoiding the direct anonymization of large amounts of production data.
It reduced the amount and time of data processing, improved data processing efficiency, ensured the security of test data, and reduced the risk of data leakage.
Smart Images

Figure CN116302955B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of program testing technology, and in particular to a method and apparatus for generating test data. Background Technology
[0002] Before a business system goes live, it typically needs to undergo business testing to ensure it functions correctly. Currently, test data used for testing business systems is generally obtained by anonymizing data generated in the production environment. However, this process has several drawbacks. First, the large volume of test data required means that anonymizing a large amount of production data consumes significant resources and time. Second, there is a risk of data leakage during the anonymization process, and incomplete anonymization of large datasets also increases the risk of data leakage. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a test data generation method and apparatus that enable test data to have high security, thereby effectively reducing the risk of data leakage caused by test data.
[0004] Firstly, to achieve the above objectives, an embodiment of the present invention provides a test data generation method, comprising:
[0005] Using at least two data points from the production environment, generate at least two data samples;
[0006] Determine the product number segment information corresponding to the production environment, and use the product number segment information and the constructed data sequence to generate batches of account information;
[0007] For each account in the batch of account information, perform the action of combining any of the data samples with the account information to form a test data.
[0008] Optionally, generating at least two data samples includes:
[0009] From each of the multiple original databases stored in the original databases, obtain at least two data entries generated in the production environment;
[0010] At least two data samples generated in the aforementioned production environment are anonymized to form at least two data samples.
[0011] Optionally, the above test data generation method further includes:
[0012] In the batch library, a test data table corresponding to each of the original data tables is generated, wherein the corresponding original data table and the test data table correspond to the same data type in the same business processing stage under the same production environment;
[0013] Store at least two data samples of the same data type belonging to the same business processing stage into a test data table corresponding to the data type.
[0014] Optionally, before combining any of the data samples with the account information to form a test data set, the method further includes:
[0015] Obtain any data sample from the test data table corresponding to any data type in the production environment corresponding to the account information.
[0016] Optionally, determining the product number segment information corresponding to the production environment includes:
[0017] Obtain the product number corresponding to the production environment;
[0018] Search the preset product information table corresponding to the product number;
[0019] Select the product number segment information corresponding to the production environment from the multiple preset product number segments stored in the preset product information table.
[0020] Optionally, the step of generating batch account information can be executed in multiple threads on multiple nodes using the Spring Batch framework.
[0021] Optionally, the test data generation method further includes: storing the account information in a corresponding preset product information table;
[0022] The step of selecting the product number segment information corresponding to the production environment includes:
[0023] Randomly select one of the pre-set product number segments from multiple preset product number segments;
[0024] Based on the account information stored in the preset product information table, the initial screening product number segment information is verified. If the verification passes, the initial screening product number segment information is determined to be the product number segment information corresponding to the production environment.
[0025] Optionally, selecting the product number segment information corresponding to the production environment further includes:
[0026] If the initial screening of product number segment information fails verification, then product number segment information corresponding to the production environment is reselected based on the account information stored in the preset product information table.
[0027] Optionally, the above test data generation method further includes: pre-constructing a data sequence and storing the data sequence in memory;
[0028] The generation of batch account information includes:
[0029] Determine the number segment code corresponding to the product number segment information;
[0030] Retrieve from the memory a target data sequence including the number segment code and the product number corresponding to the production environment;
[0031] If found, a check digit is randomly generated, and the check digit is combined with the target data sequence to form a batch of account information.
[0032] Optionally, generating batches of account information further includes:
[0033] If the target data sequence is not found, a target data sequence including the number segment code and the product number is generated, and a check digit is randomly generated;
[0034] The check digit is combined with the target data sequence to form a batch of account information.
[0035] Optionally, combining the check digit with the target data sequence to form a batch of account information includes:
[0036] The check digit is concatenated with each sequence number in the target data sequence to form account information.
[0037] Optionally, the above-mentioned test data generation method further includes:
[0038] Insert the test data into the test data table where the data sample is located.
[0039] Optionally, the above-mentioned test data generation method further includes:
[0040] The batch of test data is unloaded to convert it into a file of a specific format.
[0041] By performing batch conversion and linking operations on the files of the specific format using multiple threads, the test data is inserted into a preset online table.
[0042] Optionally, in a multi-threaded execution environment created by the ExecutorService thread pool in Java's asynchronous execution framework, the process of inserting the test data into the test data table containing the data sample is executed through multi-threaded execution.
[0043] Secondly, embodiments of the present invention provide a test data generation apparatus, comprising:
[0044] The module includes a data sample generation module, an account generation module, and a test data generation module.
[0045] The data sample generation module is used to generate at least two data samples using at least two data samples generated in the production environment.
[0046] The account generation module is used to determine the product number segment information corresponding to the production environment, and to generate batches of account information using the product number segment information and the constructed data sequence;
[0047] The test data generation module is used to combine any data sample with the account information to form a test data for each account information in the batch of account information.
[0048] Thirdly, embodiments of the present invention also provide an electronic device, comprising:
[0049] One or more processors;
[0050] Storage device for storing one or more programs.
[0051] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0052] Fourthly, embodiments of the present invention also provide a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the methods described in any of the above embodiments.
[0053] Fifthly, embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the method described in any of the above embodiments.
[0054] One embodiment of the above invention has the following advantages or beneficial effects: by determining the product number segment information corresponding to the production environment, using the product number segment information and the constructed data sequence, a batch of account information is generated, and any data sample is combined with the account information to obtain a batch of test data. The entire process only requires a small amount of data generated by the production environment to generate a small amount of data samples, which are then combined with the generated batch of account information. Since the account information does not actually exist, and compared with the existing desensitization of a batch of data generated by the production environment, this application only requires a small amount of data generated by the production environment to generate a small amount of data samples. That is, the amount of data to be processed to generate a small amount of data samples is small, making data processing faster and cleaner. The data samples do not contain sensitive information. Therefore, the test data obtained by combining virtual account information with cleanly processed data samples also does not involve sensitive information, making the test data highly secure and effectively reducing the risk of data leakage caused by the test data.
[0055] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description
[0056] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:
[0057] Figure 1 This is a schematic diagram of the main flow of the test data generation method according to an embodiment of the present invention;
[0058] Figure 2 This is a schematic diagram illustrating the main process of determining product number segment information corresponding to the production environment according to an embodiment of the present invention;
[0059] Figure 3 This is a schematic diagram illustrating the main process of selecting product number segment information corresponding to the production environment according to an embodiment of the present invention;
[0060] Figure 4 This is a schematic diagram of the main process for generating batches of account information according to an embodiment of the present invention;
[0061] Figure 5 This is a schematic diagram of the main process for generating online data according to an embodiment of the present invention;
[0062] Figure 6A This is a schematic diagram of the main flow of a test data generation method according to another embodiment of the present invention;
[0063] Figure 6B This is a schematic diagram of the architecture upon which the test data generation process according to an embodiment of the present invention depends;
[0064] Figure 7This is a schematic diagram of the main modules of a test data generation device according to an embodiment of the present invention;
[0065] Figure 8 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;
[0066] Figure 9 This is a schematic diagram of the structure of a computer system suitable for implementing the server of the present invention. Detailed Implementation
[0067] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0068] As described in the background section, current test data in the testing environment is primarily generated by anonymizing production environment data. This data file is then inserted into the corresponding database. Specifically, data files are exported from the production environment, loaded into the database, anonymized, and then sent to the test database to form the test data. When the testing environment requires a large amount of data, a significant amount of production data needs to be anonymized, generated, and then imported into the test database. Due to the large number of tables and the substantial amount of data in each table, the anonymization process is time-consuming, resulting in a high-risk and time-consuming test data generation process.
[0069] Specifically, in existing technologies, the process of preparing test data involves exporting a .dump file from the existing production environment, importing the file into a database for data anonymization, then exporting the anonymized data back into a .dump file, and finally importing the test data from the .dump file into the test database in the test environment. Because of these multiple data export and anonymization processes, data security cannot be guaranteed. Furthermore, the data preparation process is complex, requiring the continuous export of various types and quantities of product data from the production environment as the test scenario changes.
[0070] To address the problems existing in the prior art, embodiments of the present invention provide a test data generation method and apparatus. Figure 1 The main flow of a test data generation method provided by an embodiment of the present invention is illustrated. For example... Figure 1 As shown, the test data generation method may include the following steps:
[0071] Step S101: Using at least two data points generated in the production environment, generate at least two data samples;
[0072] In this context, the production environment generally refers to the business processing environment constructed within any business data processing link, node, or stage of a banking business system. For example, a production environment could be a credit card posting processing environment, a loan processing environment, a debit card opening processing environment, or a debit card savings processing environment. Correspondingly, the data generated in the production environment generally refers to the data required by any processing link or stage in the banking business system's business data processing, or the data included in the processing results. For example, the data required by the credit card posting processing environment, or the data required for credit card account posting processing or the data generated after the execution of the business; or the data required by the loan processing environment or the data generated after the execution of the business.
[0073] The data generated by the at least two production environments can be virtually constructed by the user or directly obtained from an existing database. In a preferred embodiment, the data generated by the at least two production environments is directly obtained from an existing database.
[0074] This data sample is generally obtained by desensitizing and denoising data generated in the production environment.
[0075] Each piece of data generated by the production environment generally corresponds to one data sample.
[0076] The number of data samples obtained in this step is usually relatively small. For example, the number of data samples generated can be two, ten, or one hundred.
[0077] Step S102: Determine the product number segment information corresponding to the production environment, and use the product number segment information and the constructed data sequence to generate batch account information;
[0078] The product number segment information is generally a specific number of digits configured for a product (i.e., the product corresponding to the banking business). For example, the product corresponding to credit card business (which may include production environments such as credit card billing, credit card disbursement, and credit card repayment) is a credit card, and its corresponding product number segment information may be 1089~1499, 2089~2499, 3089~3499, 4089~4399, etc.; the product corresponding to savings business (which may include production environments such as depositor deposit, depositor withdrawal, and transfer deposit) is a debit product, and its corresponding product number segment information may be 0011~1031, 2011~3031, 4011~5031, 6011~7031, 80110~81110, 90110~90111, 100110~100111, etc.
[0079] The constructed data sequence can be built according to a set strategy.
[0080] Step S103: For each account in the batch of account information, perform the action of combining any data sample with the account information to form a test data.
[0081] One specific implementation of combining any data sample with account information to form a test data can be: randomly select a data sample, and concatenate the account information with the selected data sample to form a test data.
[0082] That is, by using the above-mentioned technical solution provided by the present invention, after obtaining a few pieces of actual data, a large amount of test data is generated by simulating transactions, so that most of the test data is not prepared from the generation environment.
[0083] In addition, the test data generated by this solution is batch test data, which can be used for both non-functional and functional testing.
[0084] exist Figure 1In the illustrated embodiment, by determining the product number segment information corresponding to the production environment, a batch of account information is generated using the product number segment information and the constructed data sequence. Any data sample is then combined with the account information to obtain a batch of test data. The entire process requires only a small amount of data generated in the production environment to generate a small number of data samples, which are then combined with the generated batch of account information. Since the account information does not actually exist, and compared with existing methods of desensitizing batches of data generated in the production environment, this application only requires a small amount of data generated in the production environment to generate a small number of data samples. That is, the amount of data to be processed to generate a small number of data samples is small, making data processing faster and cleaner. The data samples do not contain sensitive information. Therefore, the test data obtained by combining virtual account information with cleanly processed data samples also does not involve sensitive information, making the test data highly secure and effectively reducing the risk of data leakage caused by the test data.
[0085] In step S101 above, the specific implementation of generating at least two data samples may include: obtaining at least two data samples generated in the production environment from multiple original data tables stored in each of the multiple original databases; and performing anonymization processing on the at least two data samples generated in the production environment to form at least two data samples. For example, if the scenario to be tested corresponds to 1024 original data tables in 6 original databases, then at least two data samples generated in the production environment need to be obtained from each of these 6 original databases. In a preferred embodiment, at least two data samples generated in the production environment are obtained from each original data table to ensure that the test data is evenly distributed. This ensures that the test data is effectively balanced in subsequent testing, and that all functional or non-functional test points are tested.
[0086] Specifically, in this embodiment of the invention, the Spring Batch framework is used to execute the above-mentioned steps of generating batch account information in multiple threads on multiple nodes, so as to effectively improve the efficiency of account information generation, thereby effectively improving the efficiency of obtaining batch test data.
[0087] In this embodiment of the invention, the above-mentioned test data generation method may further include: generating a test data table corresponding to each original data table in a batch library, wherein the corresponding original data table and test data table correspond to the same data type in the same business processing stage under the same production environment; storing at least two data samples of the same data type belonging to the same business processing stage into the test data table corresponding to the data type. By generating a test data table corresponding to each original data table, it is convenient to manage the test data according to the data management method of the original data table, which can better simulate the actual production environment of the banking business system.
[0088] A production environment can include multiple business processing stages. For example, a credit card billing business environment can include an account verification business processing stage, a billing amount verification business processing stage, and a billing operation business processing stage. Each business processing stage can correspond to a test data table.
[0089] The aforementioned same data type in the same production environment and the same business processing stage generally refers to the same column in the original data table and its corresponding test data table having the same data type. For example, the username column in the original data table and its corresponding test data table is a text data type, while the account column in the original data table and its corresponding test data table is a numeric data type.
[0090] Furthermore, by storing the data samples in the corresponding test data table, the data samples serve as test data, and the test data table facilitates the management of the data samples.
[0091] In this embodiment of the invention, before combining any data sample with account information to form a test data set, the method may further include: obtaining any data sample from a test data table corresponding to any data type in the production environment corresponding to the account information. This process ensures that the data sample and its corresponding generated test data belong to the same test data table, facilitating unified management of the data samples and test data. Simultaneously, it guarantees that the data samples and test data stored in the same test data table are for the same business processing stage in the same production environment, thus ensuring the accuracy of the test results.
[0092] In embodiments of the present invention, such as Figure 2 As shown, the specific implementation method for determining the product number segment information corresponding to the production environment may include the following steps:
[0093] Step S201: Obtain the product number corresponding to the production environment;
[0094] This product number is a code set for different products. For example, the credit card number is 001 and the debit product number is 002. If the credit card posting business processing environment belongs to the credit card product, then its product number is 001.
[0095] Step S202: Locate the preset product information table corresponding to the product number;
[0096] Each product number corresponds to a product information table, which stores information such as the product number segment, account information, and the number segment code corresponding to the product number segment.
[0097] Step S203: Select the product number segment information corresponding to the production environment from the multiple preset product number segment information stored in the preset product information table.
[0098] For example, if the product number range information corresponding to the credit card is 1089~1499, 2089~2499, 3089~3499, 4089~4399, etc., then through this step, a product number range information can be selected for the credit card billing business environment through random selection or sequential selection.
[0099] The above process allows for the standardized management and acquisition of product number ranges required to generate account information.
[0100] Furthermore, the above-mentioned test data generation method may further include: storing account information in a corresponding preset product information table; accordingly, such as Figure 3 As shown, a specific implementation method for selecting product number segment information corresponding to the production environment may include the following steps:
[0101] Step S301: Randomly select one of the pre-screened product number segments from multiple preset product number segments;
[0102] For example, if the product number ranges corresponding to credit cards are 1089~1499, 2089~2499, 3089~3499, 4089~4399, etc., through this step, a preliminary product number range of 4089~4399 will be randomly selected.
[0103] Step S302: Verify the initial screening of product number range information based on the account information stored in the preset product information table. If the verification passes, proceed to step S303; if the verification fails, proceed to step S304.
[0104] This verification process primarily aims to determine whether the initially screened product number segment information has already been used to generate account information stored in the preset product information table. If the initially screened product number segment information has been used to generate account information stored in the preset product information table, the verification fails; if the initially screened product number segment information has not been used to generate account information stored in the preset product information table, the verification passes. This ensures the uniqueness of account information in the test data, thereby guaranteeing the correctness of the test data.
[0105] The verification process mainly involves: determining the number segment code corresponding to the initial screening product number segment information, and then determining whether a specific location in the account information contains the number segment code. If the specific location in the account information does not contain the number segment code, the verification is considered successful; if the specific location in the account information contains the number segment code, the verification is considered unsuccessful.
[0106] For example, the product number segment code AZ1 is for 1089-1499, AZ2 is for 2089-2499, AZ3 is for 3089-3499, and AZ4 is for 4089-4399. This segment code can be located in the first three, fifth to seventh, or last three digits of the account information. For instance, for the initial screening of product number segments 4089-4399, the corresponding segment code is AZ4. The system checks if any account information containing AZ4 in the first three digits of the product information stored in the preset product information table exists. If it does, the verification fails; otherwise, the verification passes.
[0107] Step S303: Determine that the initial screening product number segment information corresponds to the product number segment information of the production environment, and end the current process;
[0108] Step S304: Based on the account information stored in the preset product information table, reselect the product number segment information corresponding to the production environment.
[0109] This reselection process can involve choosing a product number range that has not been selected before. For example, by comparing AZ1, AZ2, AZ3, and AZ4 with the account information, if the account information contains both AZ2 and AZ3, then this step can select one from AZ1 and AZ4.
[0110] Furthermore, such as Figure 4 As shown, the specific implementation method for generating batch account information described above may include the following steps:
[0111] Step S401: Pre-construct the data sequence and store the data sequence in memory;
[0112] This pre-built data sequence can be achieved using Oracle sequences and triggers to generate a set of equally spaced values (i.e., a data sequence). This set of equally spaced values (i.e., a data sequence) can be referenced in insert statements or used to check the current value through queries.
[0113] By storing data sequences in memory, the efficiency of account information generation can be effectively improved, avoiding performance bottlenecks caused by resource consumption from batch account information generation.
[0114] The number of data sequences stored in memory can be up to 200 to avoid the problem of data sequence loss caused by the resource restart clearing memory information due to the large number of data sequences.
[0115] Step S402: Determine the number segment code corresponding to the product number segment information;
[0116] For example, the number segment code determined in this step is AZ4, which corresponds to the product number 001 in the production environment.
[0117] Step S403: Search the memory for the target data sequence, which includes the number segment code and the product number corresponding to the production environment; if found, proceed to step S404; if not found, proceed to step S405.
[0118] For example, a data sequence typically has 15 digits, where the number segment code is located in digits 2-4, the product number corresponding to the production environment is located in digits 5-7, and digits 8-15 are arbitrary values. Therefore, the target data sequence is searched from memory where digits 2-4 are AZ4 and digits 5-7 are 001.
[0119] Step S404: Randomly generate a check digit, combine the check digit with the target data sequence to form a batch of account information, and end the current process;
[0120] This check bit can be the first bit in the data sequence. This check bit further ensures the uniqueness of the account information.
[0121] Step S405: Generate a target data sequence including number segment code and product number, and randomly generate a check digit;
[0122] Step S406: Combine the check digit with the target data sequence to form a batch of account information.
[0123] One specific implementation method for combining the check digit with the target data sequence to form a batch of account information may include: concatenating the check digit with each sequence number in the target data sequence to form account information.
[0124] The above-mentioned test data generation method may further include: inserting the test data into the test data table containing the data samples, to facilitate unified management and retrieval of the test data.
[0125] Specifically, within the multi-threaded execution environment created by the ExecutorService thread pool in Java's asynchronous execution framework, test data is inserted into the test data table containing the data samples through multi-threaded execution. This ensures the efficiency of test data generation, resolves the bottleneck of batch test data insertion into the test data table, and solves the problem of synchronizing large amounts of data between databases.
[0126] Furthermore, such as Figure 5 As shown, the above test data generation method may further include the following steps:
[0127] Step S501: Perform a data unloading operation on the generated batch of test data to convert the batch of test data into a file of a specific format;
[0128] Step S502: Perform batch conversion and linking operations on files of a specific format using multi-threading, and insert the test data into a preset online table.
[0129] Through this Figure 5 The provided solution converts batch test data into online test data required for online testing.
[0130] In addition, through this Figure 5 The provided solution can simulate online transactions to quickly generate large amounts of test data, and can synchronize the test data required for the generated online transactions to the online database, thereby eliminating the need to prepare test data from the production environment, achieving the goal of reducing risk and simplifying the process.
[0131] Furthermore, after conducting tests using test data from any test data table, the test results are further stored as test data in the test data table corresponding to the next business phase. This increases the volume and diversity of the test data.
[0132] The following section details the test data generation process, using the example of generating batch test data and online transaction test data for various production environments of a banking product—credit cards. Figure 6A As shown, the process of generating test data for each production environment of this credit card may include the following steps:
[0133] Step S601: In the batch library, generate a test data table corresponding to each original data table, wherein the corresponding original data table and test data table correspond to the same data type in the same business processing stage under the same production environment.
[0134] like Figure 6B As shown, this step generates batch data tables 1, 2, 3, ..., N for the credit card test scenario.
[0135] Step S602: Pre-construct the data sequence and store the data sequence in memory;
[0136] Step S603: Obtain at least two data entries generated in the production environment from each of the multiple original databases that correspond to the credit card product;
[0137] Step S604: De-identify at least two data points generated in the production environment to form at least two data samples;
[0138] Step S605: Store at least two data samples of the same data type belonging to the same business processing stage into the corresponding batch data table;
[0139] Store at least two data samples in a location such as Figure 6B The batch data tables 1 to N are shown, corresponding to the business processing stage and data type of the data sample.
[0140] Step S606: Obtain any data sample from the test data table corresponding to any data type in the production environment corresponding to the account information;
[0141] For example, from Figure 6B Data samples were obtained from the batch data table 1 shown.
[0142] Step S607: Obtain the product number of the production environment corresponding to the credit card product's billing transaction;
[0143] For example, the product number is 001.
[0144] Step S608: Locate the preset product information table corresponding to the product number;
[0145] This preset product information table is stored in, for example... Figure 6B The step can be performed from the credit card BIN component shown. Figure 6B Locate the default product information table in the credit card BIN component shown, and in the following steps, from... Figure 6B The credit card segment information (i.e., the product number segment information described below) is retrieved from the preset product information table in the credit card BIN component shown. Additionally, as... Figure 6B As shown, the credit card BIN component can return credit card segment information to obtain account information.
[0146] Step S609: Randomly select one of the pre-screened product number segments from multiple preset product number segments;
[0147] Step S610: Verify the initial screening product number segment information based on the account information stored in the preset product information table. If the verification passes, proceed to step S611; if the initial screening product number segment information verification fails, proceed to step S612.
[0148] Step S611: Determine that the initial screening product number segment information is the product number segment information corresponding to the production environment, and proceed to step S613;
[0149] Step S612: Based on the account information stored in the preset product information table, reselect the product number segment information corresponding to the production environment;
[0150] Step S613: Determine the number segment code corresponding to the product number segment information;
[0151] Step S614: Search the memory for a target data sequence including the number segment code and the product number corresponding to the production environment; if found, proceed to step S615; if the target data sequence is not found, proceed to step S616.
[0152] Step S615: Randomly generate a check digit, combine the check digit with the target data sequence to form a batch of account information, and then execute step S617;
[0153] Specifically, this step involves concatenating the check digit with each sequence number in the target data sequence to form account information.
[0154] Step S616: Generate a target data sequence including number segment code and product number, and execute step S615;
[0155] It is worth noting that in this embodiment of the invention, the Spring Batch framework is generally used to execute steps S606 to S616 on multiple threads across multiple nodes. That is, by using the Spring Batch framework on multiple threads across multiple nodes, the number of account information items generated by the program at one time can be specified, which controls the processing speed of a single account information generation job, enabling dynamic configuration of the amount of test data that needs to be split or increased, and achieving configurability of the test data.
[0156] Step S617: Store the account information in the corresponding preset product information table;
[0157] For example, account information can be stored in such Figure 6B The default product information table in the credit card BIN component shown.
[0158] Step S618: In the multi-threaded execution environment created by the ExecutorService thread pool of Java's asynchronous execution framework, insert the test data into the test data table where the data sample is located through multiple threads;
[0159] This step mainly involves storing the batch test data generated from data samples and account information to a storage device such as... Figure 6B The diagram shows batch data tables 1, 2, 3, ..., N. This stored procedure typically stores test data of the same data type belonging to the same production environment into the same batch data table. This reduces the number of data entry operations, optimizes the process, and improves efficiency.
[0160] Step S619: Perform a data unloading operation on the generated batch of test data to convert the batch of test data into a file of a specific format;
[0161] This data unloading operation refers to taking a portion of data (such as one or more rows of data) from a batch data table to generate a file in a specific format.
[0162] Step S620: Perform batch conversion and linking operations on files of a specific format using multi-threading, and insert the test data into a preset online table.
[0163] Batch-to-link operations convert batch test data into online test data for testing online transactions.
[0164] In summary, the above process mainly includes: account information generation, test data generation, data file generation, multi-threaded output, batch transfer and linking, etc. That is, this embodiment of the invention can obtain data samples from several existing data entries, automatically generate batches of account information based on the amount of data to be generated, then obtain batches of test data using the account information and data samples, and insert the data into the test data table of the batch database. Then, through a data unloading program, the data in the batch database is generated into a file, and through multi-threaded batch transfer and linking operations, the data in the data file is quickly inserted into the online table to complete the preparation of a large amount of diverse test data. Since the test data does not need to be obtained from the production environment and then anonymized, access to the production database is reduced, ensuring high data security. Furthermore, the entire process only requires preparing a few data entries generated in the production environment to achieve data fission or addition, and the fissioned or added data can be synchronized to the test database. The entire process is simple and efficient.
[0165] Figure 7 This invention provides a test data generation device 700, which may include: a data sample generation module 701, an account generation module 702, and a test data generation module 703.
[0166] The data sample generation module 701 is used to generate at least two data samples using at least two data samples generated in the production environment.
[0167] The account generation module 702 is used to determine the product number segment information corresponding to the production environment, and to generate batches of account information using the product number segment information and the constructed data sequence;
[0168] The test data generation module 703 is used to combine any data sample with the account information to form a test data for each account in the batch of account information.
[0169] In this embodiment of the invention, the data sample generation module 701 is further configured to obtain at least two data points generated in the production environment from multiple original data tables stored in each of the multiple original databases; and to perform desensitization processing on the at least two data points generated in the production environment to form at least two data samples.
[0170] In this embodiment of the invention, the data sample generation module 701 is further configured to generate a test data table corresponding to each original data table in the batch library, wherein the corresponding original data table and test data table correspond to the same data type in the same business processing stage under the same production environment; and store at least two data samples of the same data type belonging to the same business processing stage into the test data table corresponding to the data type.
[0171] In this embodiment of the invention, the data sample generation module 701 is further configured to obtain any data sample from a test data table corresponding to any data type in the production environment corresponding to the account information.
[0172] In this embodiment of the invention, the account generation module 702 is further configured to obtain the product number corresponding to the production environment; search the preset product information table corresponding to the product number; and select the product number segment information corresponding to the production environment from the multiple preset product number segment information stored in the preset product information table.
[0173] In this embodiment of the invention, the account generation module 702 uses the Spring Batch framework to execute the step of generating batch account information in multiple threads on multiple nodes.
[0174] In this embodiment of the invention, the account generation module 702 is further configured to store account information in a corresponding preset product information table; randomly select a preliminary screening product number segment from multiple preset product number segment information; verify the preliminary screening product number segment information according to the account information stored in the preset product information table; if the verification passes, determine that the preliminary screening product number segment information is the product number segment information corresponding to the production environment.
[0175] In this embodiment of the invention, the account generation module 702 is further configured to, if the initial screening of product number segment information fails the verification, reselect product number segment information corresponding to the production environment based on the account information stored in the preset product information table.
[0176] In this embodiment of the invention, the account generation module 702 is further configured to pre-construct a data sequence and store the data sequence in memory; determine the number segment code corresponding to the product number segment information; search for a target data sequence including the number segment code and the product number corresponding to the production environment from memory; if found, randomly generate a check digit and combine the check digit with the target data sequence to form a batch of account information.
[0177] In this embodiment of the invention, the account generation module 702 is further configured to generate a target data sequence including a number segment code and a product number if no target data sequence is found, and randomly generate a check digit; and combine the check digit with the target data sequence to form a batch of account information.
[0178] In this embodiment of the invention, the account generation module 702 is further used to concatenate the check bit with each sequence number in the target data sequence to form account information.
[0179] In this embodiment of the invention, the test data generation module 703 is further used to insert the test data into the test data table where the data sample is located.
[0180] In this embodiment of the invention, the test data generation module 703 is further used to perform a data unloading operation on the generated batch of test data to convert the batch of test data into a file of a specific format; and to perform batch conversion and linking operations on the file of the specific format through multi-threading to insert the test data into a preset online table.
[0181] In this embodiment of the invention, the test data generation module 703 inserts test data into the test data table where the data sample is located through multi-threaded execution in a multi-threaded execution environment created by the Java asynchronous execution framework ExecutorService thread pool.
[0182] Figure 8 An exemplary system architecture 800 is shown that can be applied to the test data generation method and apparatus of embodiments of the present invention.
[0183] like Figure 8 As shown, the system architecture 800 may include banking business terminals 801, 802, and 803 under test, a test database 804 for managing test data, a business database 805 for managing banking business data, a network 806, and a server 807. The network 806 serves as a medium for providing communication links between the banking business terminals 801, 802, and 803 under test and the test database 804 for managing test data; between the test database 804 and the server 807; and between the business database 805 and the server 807. The network 806 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0184] The banking terminals 801, 802, and 803 under test interact with the test database 804 via network 806 to retrieve test data from the test database 804 and store the generated data as test data in the test database 804, etc. The banking terminals 801, 802, and 803 under test can be terminals used by users conducting business, terminals operated and used by bank staff, or server terminals for handling banking services such as credit card services and savings services. Various applications or systems required for handling banking services can be installed on these banking terminals 801, 802, and 803, such as personal online banking, corporate online banking, mobile banking, credit card service applications or systems, etc. (this is just an example).
[0185] The banking business terminals 801, 802, and 803 to be tested can be various electronic devices used for handling banking business, including but not limited to servers, desktop computers, laptops, mobile phones, ATMs, POS machines, etc.
[0186] The business database 805, which manages banking business data, interacts with the server 807 via network 106 to provide the server 807 with data generated in the production environment, etc.
[0187] Server 807 can provide various background services, such as maintaining and managing test data, and generating account information, etc. (for example only).
[0188] It should be noted that the test data generation method provided in this embodiment of the invention is generally executed by server 807, and correspondingly, the test data generation device is generally installed on server 807.
[0189] It should be understood that Figure 8 The number of banking business terminals to be tested, test databases for managing test data, business databases for managing banking business data, networks, and servers shown in the diagram are merely illustrative. Depending on implementation needs, there can be any number of banking business terminals to be tested, test databases for managing test data, business databases for managing banking business data, networks, and servers.
[0190] The following is for reference. Figure 9 It shows a schematic diagram of the structure of a computer system 900 suitable for implementing an embodiment of the present invention. Figure 9 The server shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0191] like Figure 9As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 902 or programs loaded from storage section 908 into random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the system 900. The CPU 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0192] The following components are connected to I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to I / O interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 910 as needed so that computer programs read from it can be installed into storage section 908 as needed.
[0193] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 909, and / or installed from removable medium 911. When the computer program is executed by central processing unit (CPU) 901, it performs the functions defined above in the system of this invention.
[0194] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0195] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0196] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor may be described as including a data sample generation module, an account generation module, and a test data generation module. The names of these modules do not necessarily limit the module itself; for example, the account generation module may also be described as a "module for generating batches of account information."
[0197] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs that, when executed by the device, cause the device to: generate at least two data samples using at least two pieces of data generated in a production environment; determine product number segment information corresponding to the production environment, and generate a batch of account information using the product number segment information and the constructed data sequence; and for each account information in the batch of account information, perform the action of combining any data sample with the account information to form a test data set.
[0198] In another aspect, embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the methods described in any of the above embodiments.
[0199] According to the technical solution of the present invention, by determining the product number segment information corresponding to the production environment, using the product number segment information and the constructed data sequence, a batch of account information is generated, and any data sample is combined with the account information to obtain a batch of test data. The entire process only requires a small amount of data generated by the production environment to generate a small amount of data samples, which are then combined with the generated batch of account information. Since the account information does not actually exist, and compared with the existing desensitization of a batch of data generated by the production environment, this application only requires a small amount of data generated by the production environment to generate a small amount of data samples. That is, the amount of data to be processed to generate a small amount of data samples is small, making data processing faster and cleaner. The data samples do not contain sensitive information. Therefore, the test data obtained by combining virtual account information with clean data samples does not involve sensitive information, making the test data highly secure and effectively reducing the risk of data leakage caused by the test data.
[0200] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for generating test data, characterized in that, include: Using at least two data points generated from the production environment, generate at least two data samples; The product number segment information corresponding to the production environment is determined, and a batch of account information is generated using the product number segment information and the constructed data sequence, wherein the product number segment information is a specific number segment configured for the products corresponding to banking business; For each account in the batch of account information, perform the action of combining any of the data samples with the account information to form a test data; The test data generation method also includes: storing the account information in a corresponding preset product information table; The step of determining the product number segment information corresponding to the production environment includes: obtaining the product number corresponding to the production environment; searching a preset product information table corresponding to the product number; the preset product information table stores product number segment information, account information, and number segment codes corresponding to the product number segment information; randomly selecting a preliminary screening product number segment information from multiple preset product number segment information stored in the preset product information table; verifying the preliminary screening product number segment information according to the account information stored in the preset product information table; if the verification passes, determining that the preliminary screening product number segment information is the product number segment information corresponding to the production environment. The verification of the initial screening product number segment information specifically includes: determining the number segment code corresponding to the initial screening product number segment information, and determining whether a specific location of the account information stored in the preset product information table contains the number segment code. If the specific location of the account information does not contain the number segment code, the verification is deemed successful; if the specific location of the account information contains the number segment code, the verification is deemed unsuccessful.
2. The test data generation method according to claim 1, characterized in that, The generation of at least two data samples includes: From each of the multiple original databases stored in the original databases, obtain at least two data entries generated in the production environment; At least two data samples generated in the aforementioned production environment are anonymized to form at least two data samples.
3. The test data generation method according to claim 1 or 2, characterized in that, Also includes: In the batch library, a test data table corresponding to each of the original data tables is generated, wherein the corresponding original data table and the test data table correspond to the same data type in the same business processing stage under the same production environment; Store at least two data samples of the same data type belonging to the same business processing stage into a test data table corresponding to the data type.
4. The test data generation method according to claim 3, characterized in that, Before combining any of the data samples with the account information to form a test dataset, the method further includes: Obtain any data sample from the test data table corresponding to any data type in the production environment corresponding to the account information.
5. The test data generation method according to claim 1, characterized in that, The Spring Batch framework is used to execute the step of generating batch account information in multiple threads on multiple nodes.
6. The test data generation method according to claim 1, characterized in that, The step of selecting the product number segment information corresponding to the production environment further includes: If the initial screening of product number segment information fails verification, then product number segment information corresponding to the production environment is reselected based on the account information stored in the preset product information table.
7. The test data generation method according to any one of claims 1, 5, and 6, characterized in that, It also includes: pre-constructing a data sequence and storing the data sequence in memory; The generation of batch account information includes: Determine the number segment code corresponding to the product number segment information; Retrieve from the memory a target data sequence including the number segment code and the product number corresponding to the production environment; If found, a check digit is randomly generated, and the check digit is combined with the target data sequence to form a batch of account information.
8. The test data generation method according to claim 7, characterized in that, The generation of batch account information also includes: If the target data sequence is not found, a target data sequence including the number segment code and the product number is generated, and a check digit is randomly generated; The check digit is combined with the target data sequence to form a batch of account information.
9. The test data generation method according to claim 6, characterized in that, The check digit is combined with the target data sequence to form batch account information, including: The check digit is concatenated with each sequence number in the target data sequence to form account information.
10. The test data generation method according to claim 4, characterized in that, Further includes: Insert the test data into the test data table where the data sample is located.
11. The test data generation method according to claim 1, characterized in that, Further includes: The batch of test data is unloaded to convert it into a file of a specific format. By performing batch conversion and linking operations on the files of the specific format using multiple threads, the test data is inserted into a preset online table.
12. The test data generation method according to claim 10, characterized in that, In a multi-threaded execution environment created by the ExecutorService thread pool in Java's asynchronous execution framework, the test data is inserted into the test data table containing the data sample through multi-threaded execution.
13. A test data generation device, characterized in that, include: The module includes a data sample generation module, an account generation module, and a test data generation module. The data sample generation module is used to generate at least two data samples using at least two data samples generated in the production environment. The account generation module is used to determine the product number segment information corresponding to the production environment, and to generate a batch of account information using the product number segment information and the constructed data sequence, wherein the product number segment information is a specific number segment configured for the products corresponding to banking business; The test data generation module is used to combine any data sample with the account information to form a test data for each account information in the batch of account information; The account generation module is further configured to store the account information in a corresponding preset product information table; obtain the product number corresponding to the production environment; search the preset product information table corresponding to the product number; the preset product information table stores product number segment information, account information, and number segment code corresponding to the product number segment information; randomly select a preliminary screening product number segment information from multiple preset product number segment information stored in the preset product information table; determine the number segment code corresponding to the preliminary screening product number segment information based on the account information stored in the preset product information table; determine whether a specific position of the account information contains the number segment code; if the specific position of the account information does not contain the number segment code, the verification is deemed successful, and the preliminary screening product number segment information is determined to be the product number segment information corresponding to the production environment; if the specific position of the account information contains the number segment code, the verification is deemed unsuccessful.
14. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-12.
15. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-12.
16. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-12.