Chaotic test method and device, equipment and storage medium
By obtaining data and business description information in the test configuration file, generating and injecting the bottoming data of the database, and building a concurrent transaction queue to submit transactions, the problem that data creation methods in the prior art cannot query and change database data according to business needs is solved, and the testing quality and effectiveness of data synchronization and replication tools are improved.
Patent Information
- Application Number
- CN202411872829.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-11
AI Technical Summary
The data creation method used in the existing chaos testing process can only inject static data into the database at one time, and cannot query and change the database data according to business needs, resulting in poor test quality and effectiveness of data synchronization and migration tools.
By obtaining the data description information and business description information in the test configuration file, the bottoming data is generated and injected into the database, the concurrent transaction queue is constructed based on the business description information, and the transaction is submitted to the database for execution.
It realizes the rapid construction of bottoming data according to business needs, and automatically changes and query operations on database data, improving the testing effect and quality of data synchronization and replication tools.
Smart Images

Figure CN119807055A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing, and in particular to a chaos testing method, device, equipment and storage medium. Background Art
[0002] With the rapid development of distributed database technology, production environments are gradually synchronizing from centralized databases to distributed databases, which puts higher requirements on database data synchronization technology. Due to the variety of synchronization scenarios, data confusion or data loss often occurs during the testing of data synchronization or data migration tools. The existing database number generation method used in the chaos test process can provide data conditions for testing data synchronization and data migration in different scenarios.
[0003] However, the data generation method used in the existing chaos testing process can only inject static data that meets the test requirements into the database at one time, and cannot query or change the data in the database according to business needs, which has poor test quality and test effect on data synchronization and data migration tools. Summary of the invention
[0004] The present application provides a chaos testing method, device, equipment and storage medium to solve the technical problems that the data generation method used in the existing chaos testing process can only inject static data that meets the test requirements into the database once, and cannot query or change the data in the database according to business needs, resulting in poor test quality and test effect of data synchronization and data migration tools.
[0005] In a first aspect, the present application provides a chaos testing method, the method comprising:
[0006] Obtaining a test configuration file, wherein the test configuration file includes data description information and service description information;
[0007] Generate the base data according to the data description information, and inject the base data into the database;
[0008] Generate database statements of different operation types according to the business description information, and construct a first concurrent transaction queue, wherein each transaction in the first concurrent transaction queue includes at least one of the database statements;
[0009] Submit the transactions in the first concurrent transaction queue to the database for execution.
[0010] In a possible implementation manner, generating the base data according to the data description information and injecting the base data into a database includes:
[0011] Parsing the test configuration file to obtain the data description information, wherein the data description information at least includes database connection information and table structure description information;
[0012] Connecting to a corresponding database according to the database connection information, and generating a corresponding table structure according to the table structure description information;
[0013] Create a corresponding table in the database according to the table structure;
[0014] Generate the underlying data, and inject the underlying data into the corresponding table.
[0015] In a possible implementation manner, after generating a corresponding table structure according to the table structure information, the method further includes:
[0016] Displaying the table structure;
[0017] In response to an adjustment operation on the table structure, adjusting the table structure;
[0018] The step of creating a corresponding table in the database according to the table structure is performed according to the adjusted table structure.
[0019] In a possible implementation, generating the base data includes:
[0020] According to the table structure description information, a set random number generation algorithm is called to generate a set number of random numbers, and the random numbers are used as base data.
[0021] In a possible implementation manner, after submitting the transactions in the first concurrent transaction queue to the database for execution, the method further includes:
[0022] When any transaction in the first concurrent transaction queue is successfully executed, recording the transaction and the database statements included in the transaction;
[0023] If any transaction in the first concurrent transaction queue fails to execute successfully, database statements of different operation types are generated according to the business description information, and a second concurrent transaction queue is constructed, each transaction in the second concurrent transaction queue contains at least one of the database statements, and the transactions in the second concurrent transaction queue are submitted to the database for execution.
[0024] In a possible implementation manner, when all transactions in the first concurrent transaction queue are successfully executed, the method further includes:
[0025] Determine whether the set test stop condition is currently met;
[0026] When it is determined that the set test stop condition is not currently met, database statements of different operation types are generated according to the business description information, and a third concurrent transaction queue is constructed, each transaction in the third concurrent transaction queue contains at least one of the database statements, and the transactions in the third concurrent transaction queue are submitted to the database for execution.
[0027] In a possible implementation manner, determining whether a set test stop condition is currently met includes:
[0028] Determine whether the preset test task running time has been reached;
[0029] When it is determined that the running time of the test task has been reached, determining that a set test stop condition is currently met;
[0030] In the case where it is determined that the set test stop condition is not currently met, it is determined that the set test stop condition is not currently met.
[0031] In a second aspect, the present application provides a chaos testing device, the device comprising:
[0032] A configuration acquisition module is used to acquire a test configuration file, wherein the test configuration file includes data description information and service description information;
[0033] A data generation module, used to generate base data according to the data description information, and inject the base data into a database;
[0034] A transaction construction module, configured to generate database statements of different operation types according to the business description information, and to construct a first concurrent transaction queue, wherein each transaction in the first concurrent transaction queue includes at least one of the database statements;
[0035] A transaction submission module is used to submit the transactions in the first concurrent transaction queue to the database for execution.
[0036] In a possible implementation, the data generation module includes:
[0037] A data parsing unit, used for parsing the test configuration file to obtain the data description information, wherein the data description information at least includes database connection information and table structure description information;
[0038] A table structure generating unit, configured to connect to a corresponding database according to the database connection information, and to generate a corresponding table structure according to the table structure description information;
[0039] A table creation unit, used to create a corresponding table in the database according to the table structure;
[0040] The data injection unit is used to generate the base data and inject the base data into the corresponding table.
[0041] In a possible implementation manner, after the table structure generating unit, the method further includes:
[0042] A table structure display unit, used to display the table structure;
[0043] A table structure adjustment unit, configured to adjust the table structure in response to an adjustment operation on the table structure;
[0044] A table creation unit is used to execute the step of creating a corresponding table in the database according to the table structure according to the adjusted table structure.
[0045] In a possible implementation, generating the base data includes:
[0046] According to the table structure description information, a set random number generation algorithm is called to generate a set number of random numbers, and the random numbers are used as base data.
[0047] In a possible implementation manner, after the transaction submission module, the method further includes:
[0048] A transaction recording module, configured to record the transaction and the database statements included in the transaction when any transaction in the first concurrent transaction queue is successfully executed;
[0049] A transaction judgment module is used to generate database statements of different operation types according to the business description information when any transaction in the first concurrent transaction queue fails to execute successfully, and to build a second concurrent transaction queue, each transaction in the second concurrent transaction queue contains at least one of the database statements, and submit the transactions in the second concurrent transaction queue to the database for execution.
[0050] In a possible implementation manner, the transaction recording module further includes:
[0051] A condition determination unit, used to determine whether a set test stop condition is currently met;
[0052] A transaction submission module is used to generate database statements of different operation types according to the business description information when it is determined that the set test stop condition is not currently met, and to build a third concurrent transaction queue, each transaction in the third concurrent transaction queue contains at least one of the database statements, and submit the transactions in the third concurrent transaction queue to the database for execution.
[0053] In a possible implementation manner, the condition determination unit is specifically configured to:
[0054] Determine whether the preset test task running time has been reached;
[0055] When it is determined that the running time of the test task has been reached, determining that a set test stop condition is currently met;
[0056] In the case where it is determined that the set test stop condition is not currently met, it is determined that the set test stop condition is not currently met.
[0057] In a third aspect, the present application provides a device comprising: a processor and a memory, wherein the processor is used to execute a chaos testing program stored in the memory to implement the chaos testing method described in any one of the first aspects.
[0058] In a fourth aspect, the present application provides a storage medium storing one or more programs, which can be executed by one or more processors to implement the chaos testing method described in any one of the first aspects.
[0059] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application generates the underlying data according to the data description information in the test configuration file, injects the underlying data into the database, assembles and generates database statements of different operation types according to the table structure information, and constructs a concurrent transaction queue, and submits the transactions in the concurrent transaction queue to the database for execution. This method can quickly construct underlying data in the database according to business needs, automatically change the data in the database, query operations to automatically generate incremental chaotic business data, and improve the test effect and test quality of tools such as data synchronization and data replication. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0061] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0062] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0063] Figure 1 A flow chart of an embodiment of a chaos testing method provided in an embodiment of the present application.
[0064] Figure 2 A flowchart of another chaos testing method provided in an embodiment of the present application.
[0065] Figure 3 A flow chart of another embodiment of a chaos testing method provided in the embodiment of the present application.
[0066] Figure 4 A diagram of a chaos testing device provided in an embodiment of the present application.
[0067] Figure 5 A schematic diagram of the structure of a device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0069] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0070] In order to solve the technical problems that the data generation method used in the existing chaos testing process can only inject static data that meets the test requirements into the database at one time, and cannot query or change the data in the database according to business needs, and the test quality and test effect of data synchronization and data migration tools are poor, the present application provides a chaos testing device that can automatically change and query the data in the database according to user needs, automatically generate incremental chaotic business data, and improve the test effect and test quality of data synchronization and data replication tools.
[0071] The main purpose of chaos testing is to evaluate the robustness and stability of the system in a complex and unpredictable environment. Existing chaos testing methods mainly involve system and environment simulation, load and stress testing, anomaly and fault injection, data consistency and integrity testing, etc. The chaos testing method provided in the embodiment of the present application mainly involves system and environment simulation, data consistency and integrity testing, etc. The following will be explained through relevant embodiments.
[0072] Figure 1 The flowchart of an embodiment of a chaos testing method provided in the present application is shown in FIG. 1 . In one embodiment, the execution subject of the method is a computer program or device installed with the chaos testing method, such as Figure 1 As shown, the method comprises the following steps:
[0073] Step 101: Obtain a test configuration file, which includes data description information and service description information.
[0074] A configuration file is a computer file used to store configuration information for software or systems, including various parameters, settings, and options that can affect the behavior and functionality of the software.
[0075] The test configuration file in the embodiment of the present application includes but is not limited to data description information, business description information, etc. Among them, the data description information includes but is not limited to: database connection information and table structure information such as the number of fields in the table, field type, primary key, index, etc. The business description information includes but is not limited to: running time, number of concurrent transactions, transaction type, number of database statements in a single transaction, and the ratio of SELECT, UPDATE, DELETE, and INSERT in the database statements.
[0076] Data Manipulation Language (DML) is used to add, modify, delete, and other operations on data in the database. SELECT, UPDATE, DELETE, and INSERT in database statements are the core instructions of Data Manipulation Language (DML), which are used to query, update, delete, and insert data in the database.
[0077] In one embodiment, the specific implementation method of obtaining the test configuration file is to set the configuration information such as relevant parameters, settings and options of the configuration file by the user and upload the test configuration file to the system. The system reads the test configuration file uploaded by the user through a reading method and further parses the relevant configuration information in the test configuration file.
[0078] Step 102: Generate the base data according to the data description information, and inject the base data into the database.
[0079] The base data refers to a large amount of data stored in the database according to business logic before the performance test. The main purpose of the base data is to make the performance test environment consistent with the online environment and ensure that the system under test has a certain scale in order to find performance bottlenecks such as database query and update.
[0080] In one embodiment, the specific implementation method of generating the base data according to the data description information and injecting the base data into the database is: obtaining the database connection information and the table structure information according to the data description information, connecting to the database according to the database connection information, randomly generating the data of each table field according to the table structure information, assembling the database statement according to the table structure information, and executing the database statement to insert the relevant data into the database. For a detailed description of the above implementation method, please refer to the relevant embodiment below.
[0081] Step 103: Generate database statements of different operation types according to the business description information, and build a first concurrent transaction queue, where each transaction in the first concurrent transaction queue includes at least one database statement.
[0082] Step 104: Submit the transactions in the first concurrent transaction queue to the database for execution.
[0083] For the convenience of description, the above steps 103 and 104 are described uniformly below:
[0084] Based on the description of the above steps, the business description information includes but is not limited to: running time, number of concurrent transactions, transaction type, number of database statements in a single transaction, ratio of SELECT, UPDATE, DELETE and INSERT in database statements, etc.
[0085] Transaction is a concept in database management systems that is used to manage database operations consisting of a group of database statements so that they act as an indivisible unit of work that is either all executed successfully or all rolled back (undone).
[0086] A concurrent transaction refers to two or more transactions being executed simultaneously. A concurrent transaction queue in the embodiment of the present application refers to a task queue consisting of multiple transactions that can be executed simultaneously.
[0087] In one embodiment, database statements of different operation types are generated according to the business description information, and a first concurrent transaction queue is constructed, and the transactions in the first concurrent transaction queue are submitted to the database for execution. The specific implementation method is: obtain the business description information, parse the business description information to obtain the proportion of SELECT, UPDATE, DELETE and INSERT in the database statements, and generate different types of database statements according to the above proportions. According to the number of database statements in each transaction in the configuration file and the number of concurrent transactions, a first concurrent transaction queue is constructed, and the first concurrent transaction queue is submitted to the database for execution.
[0088] The method provided by the embodiment of the present application generates the base data according to the data description information in the test configuration file, injects the base data into the database, assembles and generates database statements of different operation types according to the table structure information, and builds a concurrent transaction queue, and submits the transactions in the concurrent transaction queue to the database for execution. This method can quickly construct the base data in the database according to business needs, automatically change the data in the database, query operations to automatically generate incremental chaotic business data, and improve the test effect and test quality of tools such as data synchronization and data replication.
[0089] Figure 2 This is a flow chart of another chaos testing method provided in the present application. Figure 2 The embodiment shown in Figure 1 Based on the embodiment shown in the figure, it mainly describes how to generate the base data according to the database description information and inject the base data into the database, such as Figure 2 As shown, the following steps are included:
[0090] Step 201: Obtain a test configuration file, which includes data description information and service description information.
[0091] For a detailed description of step 201, see Figure 1 Description of the relevant process.
[0092] Step 202: Parse the test configuration file to obtain data description information, where the data description information at least includes database connection information and table structure description information.
[0093] In one embodiment, the specific implementation method of parsing the test configuration file to obtain the data description information is: obtain the test configuration file, and parse the configuration file based on the annotation information of the test configuration file to obtain the data description information. Among them, as a possible implementation method, the test configuration file is parsed based on a regular expression tool to obtain the data description information. In addition, there may be other ways to parse the test configuration file to obtain the data description information, which is not limited in the embodiment of the present application.
[0094] The data description information at least includes data connection information and table structure description information, which includes but is not limited to the range of fields in the table, field type, primary key, index, number of records in the table, etc.
[0095] Step 203: Connect to the corresponding database according to the database connection information, and generate the corresponding table structure according to the table structure description information.
[0096] A database connection is a mechanism that enables an application to interact with a database server. Its main function is to ensure smooth data transmission and operations.
[0097] Database connection information includes but is not limited to server address, port number, database authentication information (user name and password), etc.
[0098] In one embodiment, the specific implementation method of connecting to the corresponding database according to the database connection information is: obtain the server address, port number, database authentication information (user name and password), etc. in the database connection information, find the database connection entrance according to the server address and port number, and enter the correct database authentication information (user name and password) to connect to the database for data transmission and operation.
[0099] The specific implementation method of generating the corresponding table structure according to the table structure description information is: obtaining the table structure description information, assembling the database operation statement based on the information, and executing the database operation statement to generate a complete table structure in the database. Among them, the table structure mainly describes the framework of the table, including field names, data types, constraints, and relationships between tables, etc., and does not contain specific data.
[0100] For example, the structure of an "employee information table" may specify columns such as "employee number" (data type is integer, primary key), "employee name" (data type is character type, non-null), and "date of employment" (data type is date type), but at this time the table structure is just an empty template and does not contain specific data.
[0101] Step 204: display the table structure, adjust the table structure in response to the adjustment operation on the table structure, and create a corresponding table in the database according to the adjusted table structure.
[0102] In one embodiment, the specific implementation method of displaying the table structure, adjusting the table structure in response to the adjustment operation of the table structure, and creating the corresponding table in the database according to the adjusted table structure is: querying and displaying the table structure based on the database query statement, and adjusting the table structure in response to the adjustment operation of the table structure when the current table structure information is incorrect. Among them, the user can directly adjust the table structure by manually adjusting the mouse to form an adjusted table structure, or modify the table structure information through a database operation statement, and execute the modification statement to form an adjusted table structure; there can also be other adjustment methods to adjust the table structure, which is not limited in the embodiment of the present application.
[0103] For example, the structure of an "employee information table" has columns such as "employee number" (data type is integer, primary key), "employee name" (data type is character type, non-null), and "date of employment" (data type is date type). The table structure information of this table is displayed, and it is found that the data type of the employee number column is integer. However, another current test task requires the data in this column to be floating point type. At this time, the user can adjust the table structure information of the table, for example, adjust the data type of the employee number column to floating point type. By adjusting and confirming the generated table structure, the table structure can be flexibly adjusted according to business needs to meet different test business needs, improve user satisfaction, and improve the test efficiency of different test tasks.
[0104] Step 205: according to the table structure description information, call the set random number generation algorithm to generate a set number of random numbers, use the random numbers as the base data, and inject the base data into the corresponding table.
[0105] A random number generation algorithm is a method of generating a series of numbers or words through specific logical rules, and these numbers and words show randomness to a certain extent. The random number generation algorithm set in the embodiment of the present application can generate random characters based on a character encoding system according to certain logical rules. In addition, it can also be other methods, which are not limited by the embodiment of the present application.
[0106] In one embodiment, according to the table structure description information, a set random number generation algorithm is called to generate a set number of random numbers, the random numbers are used as the base data, and the base data is injected into the corresponding table. The specific implementation method is to call the set random number generation algorithm according to the table structure description information, generate a set number of random numbers, use the random numbers as the base data, assemble the database insert statement, execute the database insert statement, and insert the base data into the relevant table of the database.
[0107] Among them, the set data in the set number of random numbers can be calculated by multiplying the number of records in the table obtained according to the table structure description information and the number of column fields in the table. The above set number can be a specific value or a value range, and the embodiment of the present application does not limit this.
[0108] Step 206: Generate database statements of different operation types according to the business description information, and build a first concurrent transaction queue, where each transaction in the first concurrent transaction queue includes at least one database statement.
[0109] Step 207: Submit the transactions in the first concurrent transaction queue to the database for execution.
[0110] For detailed description of steps 206 to 207, see the above Figure 1 A description of the process shown.
[0111] Through the above Figure 2 The description of the illustrated embodiment connects to the database using database connection information, generates base data based on table structure description information, assembles database insert statements, and inserts the base data into the database, thereby automatically generating base data based on business needs, making testing in a non-production environment more efficient and accurate.
[0112] Figure 3 A flowchart of another chaos testing method provided in the present application is provided. Figure 3 The flow chart shown in Figure 1 Based on the process shown in FIG. 1 , the following mainly describes how to stop submitting transactions in the concurrent transaction queue to the database for execution after the transactions in the first concurrent transaction queue are submitted to the database for execution and under what conditions. Figure 3 As shown, the following steps are included:
[0113] Step 301: Submit transactions in the first concurrent transaction queue to the database for execution.
[0114] For a detailed description of step 301, see the above Figure 1 The description of the process shown will not be repeated here.
[0115] Step 302: If any transaction in the first concurrent transaction queue is successfully executed, execute step 303; if any transaction in the first concurrent transaction queue is unsuccessful, execute step 304.
[0116] Step 303: record the transaction and the database statements included in the transaction; and execute step 305.
[0117] Step 304: Generate database statements of different operation types according to the business description information, and build a second concurrent transaction queue. Each transaction in the second concurrent transaction queue contains at least one database statement. Submit the transactions in the second concurrent transaction queue to the database for execution. If any transaction in the second concurrent transaction queue is successfully executed, execute step 305.
[0118] For the convenience of description, steps 302 to 304 are described uniformly below:
[0119] Based on the relevant description of the above embodiment, the number of transactions in the concurrent transaction queue is determined according to the business description information in the test configuration file. Specifically, the number of concurrent transactions is obtained according to the business description information, and the number of concurrent transactions is used as the number of transactions in the concurrent transaction queue.
[0120] In one embodiment, a concurrent transaction queue may include multiple transactions. When all transactions in the first concurrent transaction queue are executed successfully, the successfully executed transactions and the database statements included in the transactions are recorded to facilitate the discovery of problems during the test process, repeated testing, and improved test quality and efficiency.
[0121] In one embodiment, if any transaction in the first concurrent transaction queue fails to execute successfully, database statements of different operation types are generated according to the business description information, and a second concurrent transaction queue is constructed, each transaction in the second concurrent transaction queue contains at least one database statement, and the transactions in the second concurrent transaction queue are submitted to the database for execution. The specific implementation method is: if any transaction in the first concurrent transaction queue fails to execute successfully, the error reason for the unsuccessful transaction execution is recorded. Database statements of different operation types are regenerated according to the business description information, and a second concurrent transaction queue is constructed, and the transactions in the second concurrent transaction queue are submitted to the database for execution. If any transaction in the second concurrent transaction queue is successfully executed, step 305 is continued.
[0122] Step 305 , determining whether the set test stop condition is currently met; if it is determined that the set test stop condition is currently met, ending the process; if it is determined that the set test stop condition is currently not met, executing step 306 .
[0123] Step 306: Generate database statements of different operation types according to the business description information, and build a third concurrent transaction queue. Each transaction in the third concurrent transaction queue contains at least one database statement. Submit the transactions in the third concurrent transaction queue to the database for execution. When any transaction in the third concurrent transaction queue is successfully executed, execute step 305.
[0124] For the convenience of description, steps 305 to 306 are described uniformly below:
[0125] In one embodiment, it is determined whether the set test stop condition is currently met. As a possible implementation method, the service description information in the test configuration file is obtained, and the running time is obtained according to the service description information, and the running time is used as the preset test task running time. When it is determined that the test task running time has been reached, it is determined that the set test stop condition is currently met, and the process ends.
[0126] When it is determined that the current running time of the test task has not been reached, it is determined that the set test stop condition is not met. In this case, database statements of different operation types are generated according to the business description information, and a third concurrent transaction queue is constructed. Each transaction in the third concurrent transaction queue contains at least one database statement, and the transactions in the third concurrent transaction queue are submitted to the database for execution. The specific implementation method is: when the current running time of the test task has not been reached, it is determined that the current test stop condition is not met, database statements of different operation types are regenerated according to the business description information, and a third concurrent transaction queue is constructed, and the transactions in the third concurrent transaction queue are submitted to the database for execution. When any transaction in the third concurrent transaction queue is successfully executed, step 305 is continued.
[0127] pass Figure 3 The relevant description of the illustrated embodiment can automatically run chaotic services for a long time. By constructing concurrent transactions composed of database statements of different operation types, the concurrent transaction queue is submitted to the database for execution, thereby realizing automatic query and change operations on data. The running time can be set, which improves the diversity of data in non-production environments and solves the problem of narrow business testing coverage of data synchronization and replication tools in non-production environments when facing complex and diverse testing businesses.
[0128] Figure 4 A chaos testing device is provided in an embodiment of the present application. Figure 4 As shown, the device comprises:
[0129] The configuration acquisition module 41 is used to acquire a test configuration file, wherein the test configuration file includes data description information and service description information;
[0130] A data generation module 42, used to generate base data according to the data description information, and inject the base data into a database;
[0131] A transaction construction module 43, configured to generate database statements of different operation types according to the business description information, and to construct a first concurrent transaction queue, wherein each transaction in the first concurrent transaction queue includes at least one of the database statements;
[0132] The transaction submission module 44 is used to submit the transactions in the first concurrent transaction queue to the database for execution.
[0133] In a possible implementation, the data generation module 42 includes:
[0134] A data parsing unit, used for parsing the test configuration file to obtain the data description information, wherein the data description information at least includes database connection information and table structure description information;
[0135] A table structure generating unit, configured to connect to a corresponding database according to the database connection information, and to generate a corresponding table structure according to the table structure description information;
[0136] A table creation unit, used to create a corresponding table in the database according to the table structure;
[0137] The data injection unit is used to generate the base data and inject the base data into the corresponding table.
[0138] In a possible implementation manner, after the table structure generating unit, the method further includes:
[0139] A table structure display unit, used to display the table structure;
[0140] A table structure adjustment unit, configured to adjust the table structure in response to an adjustment operation on the table structure;
[0141] A table creation unit is used to execute the step of creating a corresponding table in the database according to the table structure according to the adjusted table structure.
[0142] In a possible implementation, generating the base data includes:
[0143] According to the table structure description information, a set random number generation algorithm is called to generate a set number of random numbers, and the random numbers are used as base data.
[0144] In a possible implementation manner, after the transaction submission module 44, the following is further included:
[0145] A transaction recording module, configured to record the transaction and the database statements included in the transaction when any transaction in the first concurrent transaction queue is successfully executed;
[0146] A transaction judgment module is used to generate database statements of different operation types according to the business description information when any transaction in the first concurrent transaction queue fails to execute successfully, and to build a second concurrent transaction queue, each transaction in the second concurrent transaction queue contains at least one of the database statements, and submit the transactions in the second concurrent transaction queue to the database for execution.
[0147] In a possible implementation manner, the transaction recording module further includes:
[0148] A condition determination unit, used to determine whether a set test stop condition is currently met;
[0149] A transaction submission module is used to generate database statements of different operation types according to the business description information when it is determined that the set test stop condition is not currently met, and to build a third concurrent transaction queue, each transaction in the third concurrent transaction queue contains at least one of the database statements, and submit the transactions in the third concurrent transaction queue to the database for execution.
[0150] In a possible implementation manner, the condition determination unit is specifically configured to:
[0151] Determine whether the preset test task running time has been reached;
[0152] When it is determined that the running time of the test task has been reached, determining that a set test stop condition is currently met;
[0153] In the case where it is determined that the set test stop condition is not currently met, it is determined that the set test stop condition is not currently met.
[0154] like Figure 5 As shown, the embodiment of the present application provides an air conditioner control device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0155] Memory 113, used for storing computer programs;
[0156] In one embodiment of the present application, the processor 111 is used to implement the control method of the chaos test provided by any one of the above method embodiments when executing the program stored in the memory 113, including:
[0157] Obtaining a test configuration file, wherein the test configuration file includes data description information and service description information;
[0158] Generate the base data according to the data description information, and inject the base data into the database;
[0159] Generate database statements of different operation types according to the business description information, and construct a first concurrent transaction queue, wherein each transaction in the first concurrent transaction queue includes at least one of the database statements;
[0160] Submit the transactions in the first concurrent transaction queue to the database for execution.
[0161] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the chaos testing method provided in any of the aforementioned method embodiments are implemented.
[0162] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0163] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0164] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0165] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A chaos testing method, characterized in that: The method comprises: Obtaining a test configuration file, wherein the test configuration file includes data description information and service description information; Generate the base data according to the data description information, and inject the base data into the database; Generate database statements of different operation types according to the business description information, and construct a first concurrent transaction queue, wherein each transaction in the first concurrent transaction queue includes at least one of the database statements; Submit the transactions in the first concurrent transaction queue to the database for execution.
2. The method according to claim 1, characterized in that The step of generating the base data according to the data description information and injecting the base data into the database includes: Parsing the test configuration file to obtain the data description information, wherein the data description information at least includes database connection information and table structure description information; Connecting to a corresponding database according to the database connection information, and generating a corresponding table structure according to the table structure description information; Create a corresponding table in the database according to the table structure; Generate the underlying data, and inject the underlying data into the corresponding table.
3. The method according to claim 2, characterized in that After generating the corresponding table structure according to the table structure information, the method further includes: Displaying the table structure; In response to an adjustment operation on the table structure, adjusting the table structure; The step of creating a corresponding table in the database according to the table structure is performed according to the adjusted table structure.
4. The method according to claim 2, characterized in that: The generating of the base data comprises: According to the table structure description information, a set random number generation algorithm is called to generate a set number of random numbers, and the random numbers are used as base data.
5. The method according to claim 1, characterized in that After submitting the transactions in the first concurrent transaction queue to the database for execution, the method further includes: When any transaction in the first concurrent transaction queue is successfully executed, recording the transaction and the database statements included in the transaction; If any transaction in the first concurrent transaction queue fails to execute successfully, database statements of different operation types are generated according to the business description information, and a second concurrent transaction queue is constructed, each transaction in the second concurrent transaction queue contains at least one of the database statements, and the transactions in the second concurrent transaction queue are submitted to the database for execution.
6. The method according to claim 5, characterized in that In the case where all transactions in the first concurrent transaction queue are successfully executed, the method further includes: Determine whether the set test stop condition is currently met; When it is determined that the set test stop condition is not currently met, database statements of different operation types are generated according to the business description information, and a third concurrent transaction queue is constructed, each transaction in the third concurrent transaction queue contains at least one of the database statements, and the transactions in the third concurrent transaction queue are submitted to the database for execution.
7. The method according to claim 6, characterized in that The step of determining whether a set test stop condition is currently met includes: Determine whether the preset test task running time has been reached; When it is determined that the running time of the test task has been reached, determining that a set test stop condition is currently met; In the case where it is determined that the set test stop condition is not currently met, it is determined that the set test stop condition is not currently met.
8. A chaos testing device, characterized in that: The device comprises: A configuration acquisition module is used to acquire a test configuration file, wherein the test configuration file includes data description information and service description information; A data generation module, used to generate base data according to the data description information, and inject the base data into a database; A transaction construction module, configured to generate database statements of different operation types according to the business description information, and to construct a first concurrent transaction queue, wherein each transaction in the first concurrent transaction queue includes at least one of the database statements; A transaction submission module is used to submit the transactions in the first concurrent transaction queue to the database for execution.
9. A device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a chaos testing program stored in the memory to implement the chaos testing method described in any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the chaos testing method described in any one of claims 1-7.