Automatic database testing method and system
By building a front-end service module, use case management and real-time data generation are realized, which solves the problem of insufficient use case management and data generation capabilities of the existing database automated testing system, and improves the comprehensiveness and efficiency of database testing.
Patent Information
- Application Number
- CN202410650628.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-08-30
AI Technical Summary
The existing database automated testing system lacks use case management and real-time data generation capabilities, resulting in isolated and one-sided test cases that cannot fully simulate actual business scenarios and cannot effectively test the functions, performance, and availability of the database.
A database automated testing method and system is designed. By building a front-end service module, including a test management module, a test execution module, a monitoring alarm module and a result viewing module, the use case management, data generation and real-time data generation functions are realized, and the tests are organized by unified rules. Statements, organize multiple test statements into use cases, generate test data sets, and support scenario management, use case management, object model management and test data management.
It realizes use case management and real-time data generation, maximizes the reuse of test cases, saves testing time, can more fully test the performance of the database in different business scenarios, and improves the comprehensiveness of function, performance and usability testing.
Smart Images

Figure CN118567978A
Abstract
Description
Technical Field
[0001] The invention discloses a method and a system, and relates to the technical field of computer automatic testing, in particular to a database automatic testing method and a system. Background Art
[0002] During the development of database systems, it is necessary to frequently conduct functional, performance, and stress tests on the database system to ensure that the developed database system software has the functions, performance, availability, and robustness required by users. Because testing activities are very frequent, major database companies develop automated testing systems internally, or use some open source testing frameworks to build their own database automated testing systems, but most of them are limited to using automated testing scripts. The use cases written each time are arbitrary, and each test uses roughly the same test data. There is a lack of systematic management of test cases, resulting in a lack of linkage between different use case sets. Testing can only be performed in an isolated, one-sided, and static manner on specific use cases, and it is impossible to connect with the actual situation to form a more practical simulation scenario. Summary of the invention
[0003] In view of the problems of the prior art, the present invention provides a database automation testing method and system, which can manage use cases and generate test data in real time, and perform automated function, performance and stress testing on the database.
[0004] The specific scheme proposed by the present invention is:
[0005] The present invention provides a database automation testing method, comprising:
[0006] Step 1: Build the front-end service module, including the test management module, test execution module, monitoring and alarm module, and result viewing module.
[0007] Step 2: Provide scenario management, use case management, object model management, test data management, and query and assertion management services through the test management module. The test management module uses unified rules to organize test statements, organize multiple test statements into use cases, organize multiple use cases into test scenarios, and centrally manage test cases and reuse test cases.
[0008] Step 3: Provide data generation, test execution, deployment scheduling and execution scheduling services through the test execution module, where the test data generation template is used by the test execution module to generate the test data set required for the test.
[0009] Step 4: Provide monitoring indicator collection, monitoring configuration, alarm rule configuration and alarm push services through the monitoring alarm module.
[0010] Step 5: Provide test result collection, test result processing, and test result display services through the result viewing module.
[0011] Furthermore, in the step 2 of the database automated testing method, scenario management is performed by a test management module, including:
[0012] Display scene lists and scene queries, create scenes, edit scenes, enable and disable scenes, and delete scenes.
[0013] When displaying and querying the scene list, display and query the currently created scenes.
[0014] When creating a scenario, create a new scenario using the test case.
[0015] When editing a scenario, you can add test cases to the scenario or modify the arrangement of test cases in the scenario.
[0016] When enabling or disabling a scene, enable or disable the scene.
[0017] When deleting a scene, delete an obsolete scene.
[0018] Furthermore, in the step 2 of the database automated testing method, use case management is performed by a test management module, including:
[0019] Display and query the use case list, create use cases, edit use cases, enable and disable use cases, and delete use cases.
[0020] When displaying and querying the use case list, display and query the currently created use cases.
[0021] When creating a use case, create a new use case using the model.
[0022] When editing a use case, you can add test models and query statements to the use case, or modify the models or query statements used in the use case and their arrangement.
[0023] When enabling or disabling a use case, enable or disable the use case.
[0024] When deleting a use case, delete an obsolete use case.
[0025] Furthermore, in the step 2 of the database automated testing method, object model management is performed by a test management module, including:
[0026] For the database objects used, display and query the object list, create objects, edit objects, enable and disable objects, and delete objects.
[0027] Display and query the object list, display and query the currently created database objects, create objects, and create a database object.
[0028] Edit the object, add object template files and seed data files to the object to generate templates and define object types.
[0029] Enable or disable an object.
[0030] Delete an object and delete an obsolete object.
[0031] Further, in step 2 of the database automation testing method, test data management is performed by a test management module, including managing the test data generation templates used in the test and the data sets generated by the templates, specifically including: displaying and querying the test data generation template list, creating the test data generation template, editing the test data generation template, enabling and disabling the test data generation template, and deleting the test data generation template.
[0032] Display and query the test data generation template list, which is used to display and query the test data generation templates that have been created.
[0033] Creation of test data generation template, used to create a test data generation template,
[0034] Editing of test data generation templates is used to modify data generation templates and manage the test data sets corresponding to the data generation templates.
[0035] Enable or disable the test data generation template, which is used to enable or disable the test data generation template.
[0036] The test data generation template deletion operation is used to delete an obsolete test data generation template.
[0037] The present invention also provides a database automated testing system, comprising a front-end service module, wherein the front-end service module comprises a test management module, a test execution module, a monitoring and alarm module and a result viewing module.
[0038] The test management module provides scenario management, use case management, object model management, test data management, and query and assertion management services. The test management module uses unified rules to organize test statements, organize multiple test statements into use cases, organize multiple use cases into test scenarios, and centrally manage test cases and reuse test cases.
[0039] The test execution module provides data generation, test execution, deployment scheduling, and execution scheduling services. The test execution module uses the test data generation template to generate the test data set required for the test.
[0040] The monitoring and alarm module provides monitoring indicator collection, monitoring configuration, alarm rule configuration and alarm push services.
[0041] The result viewing module provides test result collection, test result processing, and test result display services.
[0042] Furthermore, the test management module in the database automated test system performs scenario management, including:
[0043] Display scene lists and scene queries, create scenes, edit scenes, enable and disable scenes, and delete scenes.
[0044] When displaying and querying the scene list, display and query the currently created scenes.
[0045] When creating a scenario, create a new scenario using the test case.
[0046] When editing a scenario, you can add test cases to the scenario or modify the arrangement of test cases in the scenario.
[0047] When enabling or disabling a scene, enable or disable the scene.
[0048] When deleting a scene, delete an obsolete scene.
[0049] Furthermore, the test management module in the database automated test system performs use case management, including:
[0050] Display and query the use case list, create use cases, edit use cases, enable and disable use cases, and delete use cases.
[0051] When displaying and querying the use case list, display and query the currently created use cases.
[0052] When creating a use case, create a new use case using the model.
[0053] When editing a use case, you can add test models and query statements to the use case, or modify the models or query statements used in the use case and their arrangement.
[0054] When enabling or disabling a use case, enable or disable the use case.
[0055] When deleting a use case, delete an obsolete use case.
[0056] Furthermore, the test management module in the database automated test system performs object model management, including:
[0057] For the database objects used, display and query the object list, create objects, edit objects, enable and disable objects, and delete objects.
[0058] Display and query the object list, display and query the currently created database objects, create objects, and create a database object.
[0059] Edit the object, add object template files and seed data files to the object to generate templates and define object types.
[0060] Enable or disable an object.
[0061] Delete an object and delete an obsolete object.
[0062] Furthermore, the test management module in the database automated testing system performs test data management, including managing the test data generation templates used in the test and the data sets generated by the templates, specifically including: displaying and querying the test data generation template list, creating the test data generation template, editing the test data generation template, enabling and disabling the test data generation template, and deleting the test data generation template.
[0063] Display and query the test data generation template list, which is used to display and query the test data generation templates that have been created.
[0064] Creation of test data generation template, used to create a test data generation template,
[0065] Editing of test data generation templates is used to modify data generation templates and manage the test data sets corresponding to the data generation templates.
[0066] Enable or disable the test data generation template, which is used to enable or disable the test data generation template.
[0067] The test data generation template deletion operation is used to delete an obsolete test data generation template.
[0068] The benefits of the present invention are:
[0069] The present invention realizes a database automation test process with use case management and real-time data generation functions, can organize test statements using unified rules, and use a special database to save the use case DDL, DML statements and the index of data written into the seed file, provide a layout template and engine for testers, organize multiple test statements into use cases, organize multiple use cases into test scenarios, and centrally manage test cases, maximize the reuse of test cases, and save test time. At the same time, the present invention generates a business data seed file according to certain rules through a template file, and uses the seed file to generate the ability of test data written into the database in real time, and examines the performance of the database in different business scenarios through testing of different business scenarios, so as to more fully test the function, performance, availability and robustness of the database. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 It is a schematic flow chart of the method of the present invention.
[0071] Figure 2 It is a schematic diagram of the application framework of the system of the present invention. Figure 3 This is a schematic diagram of the physical framework of the system of the present invention. Figure 4 It is a service deployment diagram of the system of the present invention. Figure 5 This is the entity-relationship ER diagram involved in the present invention. DETAILED DESCRIPTION
[0072] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0073] Example 1
[0074] The present invention provides a database automation testing method, comprising:
[0075] Step 1: Build the front-end service module, including the test management module, test execution module, monitoring and alarm module, and result viewing module.
[0076] Step 2: Provide scenario management, use case management, object model management, test data management, and query and assertion management services through the test management module. The test management module uses unified rules to organize test statements, organize multiple test statements into use cases, organize multiple use cases into test scenarios, and centrally manage test cases and reuse test cases.
[0077] Step 3: Provide data generation, test execution, deployment scheduling and execution scheduling services through the test execution module, where the test data generation template is used by the test execution module to generate the test data set required for the test.
[0078] Step 4: Provide monitoring indicator collection, monitoring configuration, alarm rule configuration and alarm push services through the monitoring alarm module.
[0079] Step 5: Provide test result collection, test result processing, and test result display services through the result viewing module.
[0080] The method of the present invention can use unified rules to organize test scenarios, test cases and statements, and can provide testers with an arrangement template and engine to facilitate centralized management of test cases, maximize the reuse of test cases, and save testing time.
[0081] Example 2
[0082] Based on Example 1, the present invention performs scenario management through a test management module in step 2, which may further include:
[0083] Display scene lists and scene queries, create scenes, edit scenes, enable and disable scenes, and delete scenes.
[0084] When displaying and querying the scene list, display and query the currently created scenes.
[0085] When creating a scenario, create a new scenario using the test case.
[0086] When editing a scenario, you can add test cases to the scenario or modify the arrangement of test cases in the scenario.
[0087] When enabling or disabling a scene, enable or disable the scene.
[0088] When deleting a scene, an obsolete scene is deleted. The scene list display and query use a list to display the created scenes, provide query conditions such as scene name and whether it is enabled for querying scenes, and provide paging display function. A create button is provided above the scene list to create a new scene. The newly created scene is disabled by default and needs to be manually enabled by the scene maintenance personnel after confirmation through the enable disable button.
[0089] A button is provided on the far right of each scenario record in the scenario list for editing the scenario. After clicking the edit button, the system provides a user interaction view for scenario maintainers to use. Scenario maintainers can search, add, and arrange the locations where test cases appear in the scenario in the view, such as by adding / modifying scene_case_relation entities. Scenario maintainers can also perform operations such as adding / modifying relation_case entities, and dragging and connecting cases to organize each independent case into one or more directed acyclic graphs to construct a test scenario. Test cases in multiple graphs will be executed concurrently.
[0090] A button is provided on the right side of the Edit button in each scenario record to enable or disable the scenario, and a Delete button is provided on the right side of the Enable or Disable button to delete unnecessary scenarios. When a scenario is disabled or deleted, its associated use cases are automatically disabled or deleted in cascade, and the associated test plans are automatically disabled or deleted.
[0091] In step 2, use case management is performed through the test management module, which may further include:
[0092] Display and query the use case list, create use cases, edit use cases, enable and disable use cases, and delete use cases.
[0093] When displaying and querying the use case list, display and query the currently created use cases.
[0094] When creating a use case, create a new use case using the model.
[0095] When editing a use case, you can add test models and query statements to the use case, or modify the models or query statements used in the use case and their arrangement.
[0096] When enabling or disabling a use case, enable or disable the use case.
[0097] When deleting a use case, delete an obsolete use case. The use case list display and query use a list to display the created use cases, provide query conditions such as use case name and whether it is enabled for querying use cases, and provide paging display function.
[0098] A Create button is provided above the use case list to create a new use case. The newly created use case is disabled by default and needs to be manually enabled by the use case maintainer after confirmation through the Enable Disable button.
[0099] A button is provided on the far right of each use case record in the use case list for editing the use case. After clicking the edit button, the system provides a user interaction view for use case maintainers. Use case maintainers can search and add models added and enabled in the object model management function in the view, search and add queries added and enabled in query and assertion management, arrange the location of queries in the scenario (by adding / modifying case_query entities) and execution methods (by adding / modifying the is_prepare attribute of case_query entities), and specify the location of each statement of the model under the use case (by adding / modifying case_model_query entities). Statements are presented in a vertical list in the use case, and models are presented in a sublist after each statement. The order matches the model placeholder in the statement. Use case maintainers edit the use case by dragging and dropping to arrange the positions of statements and models.
[0100] A button is provided on the right side of the edit button in each scenario record to enable or disable the scenario, and a delete button is provided on the right side of the enable or disable button to delete unnecessary scenarios. When a use case is disabled or deleted, its associated queries and database object models are automatically disabled or deleted in cascade, and the associated scenarios automatically become disabled.
[0101] In step 2, object model management is performed by the test management module, which may further include:
[0102] For the database objects used, display and query the object list, create objects, edit objects, enable and disable objects, and delete objects.
[0103] Display and query the object list, display and query the currently created database objects, create objects, and create a database object.
[0104] Edit the object, add object template files and seed data files to the object to generate templates and define object types.
[0105] Enable or disable an object.
[0106] Delete an object and delete an obsolete object. The object list display and query uses a list to display the created objects, provides query conditions such as object name, object type, whether it is enabled, etc. for querying objects, and provides paging display function.
[0107] A Create button is provided above the object list to create a new object. The newly created object is disabled by default and needs to be manually enabled by the object maintenance personnel after confirmation through the Enable Disable button.
[0108] A button is provided on the far right of each use case record in the object list for editing the use case. After clicking the Edit button, the system provides a user interaction view for object maintainers to use. The maintainer can edit the object name in the view, select the object type (schema / database / table / view / job, etc.), create and upload the object template file, and create and specify the seed data file generation template (test_data_tmpl).
[0109] A button is provided on the right side of the Edit button in each object record to enable the disabled object, and a Delete button is provided on the right side of the Enable Disable button to delete the unwanted object. When a database object is disabled or deleted, its associated queries, use cases, and scenarios automatically become disabled.
[0110] In step 2, test data management is performed through the test management module, which further includes managing the test data generation templates used in the test and the data sets generated by the templates, specifically including: displaying and querying the test data generation template list, creating the test data generation template, editing the test data generation template, enabling and disabling the test data generation template, and deleting the test data generation template.
[0111] Display and query the test data generation template list, which is used to display and query the test data generation templates that have been created.
[0112] Creation of test data generation template, used to create a test data generation template,
[0113] Editing of test data generation templates is used to modify data generation templates and manage the test data sets corresponding to the data generation templates.
[0114] Enable or disable the test data generation template, which is used to enable or disable the test data generation template.
[0115] The delete operation of the test data generation template is used to delete an obsolete test data generation template. The test data generation template list display and query uses a list to display the created test data generation templates, provides query conditions such as template name and whether it is enabled for querying templates, and provides paging display function.
[0116] A Create button is provided above the test data generation template list to create a new test data generation template. The newly created test data generation template is disabled by default and needs to be manually enabled by the maintenance personnel after confirmation through the Enable Disable button.
[0117] A button is provided on the far right of each record in the test data generation template list for editing the test data generation template. After clicking the edit button, the system provides a user interaction view for maintenance personnel to use. Maintenance personnel can edit the template name, create and upload test data generation template files, and view and specify test data sets in the view. The test data sets are displayed in a paged list. Each record includes the name, data set file path, and enable, disable, and delete operation buttons. When a test data set is deleted or disabled, the corresponding test plan is automatically disabled.
[0118] A button is provided on the right side of the edit button in each test data generation template record to enable or disable the test data generation template, and a delete button is provided on the right side of the enable or disable button to delete the unnecessary test data generation template. When a test data generation template is disabled or deleted, its associated database object model, use case, and scenario automatically become disabled.
[0119] The test data generation template is a csv file. Each line in the file corresponds to a table field of the table object. The columns of the template represent the table field name, field type, value range / regular expression, and data generation method from left to right. The data generation method is an enumerated string, which corresponds to a data generation function of the data generator (random type value, random fixed-length string, random variable-length string, random normal distribution type value, random binomial distribution type value, random Poisson distribution type value, random Bernoulli distribution, random geometric distribution, random hypergeometric distribution, etc.). The function generates random data and generates a test data set by loading the field type and value range / regular expression.
[0120] The value range / rule expression is a set of expressions specified by the data generation function, which consists of multiple numeric parameters separated by the "-" symbol in "[] / () / (] / [)" brackets. [] represents a fully closed interval, () represents a fully open interval, (] represents a left-open and right-closed interval, and [) represents a left-closed and right-open interval. For example, when the generation function is a random type value, the expression [1-100) means that when each record is generated for this field, a value of this type greater than or equal to 1 and less than 100 is generated. If the field type is an integer, the generated valid values are 1, 15, 49, 67, 99, etc. If the field type is a floating point number, the generated valid values are 1.0, 15.47, 36.42, 88.67, 99.99. When the generation function is a random variable-length string, [1-100) means that the generated string contains at least one character and no more than 100 characters. When the generating function is a random normal distribution type value (0-1-101), it means using 101 points to fit and generate a standard normal distribution with an expected value of 0 and a standard deviation of 1. Other functions can be provided with parameters by similar regular expressions, which are not listed here.
[0121] In step 2, query and assertion management is performed through the test management module, which may include: query and assertion management functions are used to manage query statements and assertions used in the test, including sub-functions such as query and assertion list display and query, create query and assertion, edit query and assertion, enable and disable query and assertion, and delete query and assertion. Query and assertion list display and query are used to display and query the currently created queries and assertions, create query and assertion is used to create a query and its assertion, edit query and assertion is used to modify query and assertion, enable and disable query and assertion is used to enable or disable query and assertion, and delete query and assertion is used to delete an invalid query and assertion.
[0122] The query and assertion list display and query uses a list to display the created queries and assertions, provides query conditions such as query name, database dialect, whether to enable, etc. for querying database queries and assertions, and provides paging display function.
[0123] A Create button is provided above the query and assertion list to create a new query and assertion. Newly created queries and assertions are disabled by default and need to be manually enabled by the maintenance personnel after confirmation through the Enable Disable button.
[0124] A button is provided on the far right of each record in the query and assertion list for editing queries and assertions. After clicking the edit button, the system provides a user interactive view for maintenance personnel to use. Maintenance personnel can edit the query name in the view, create and upload query parameter files and the assertion files corresponding to the parameter files, and specify the database dialect for the query.
[0125] A button is provided on the right side of the Edit button in each query and assertion record to enable or disable the query and assertion. A Delete button is provided on the right side of the Enable or Disable button to delete unnecessary queries and assertions. When a query or assertion is disabled or deleted, the status of the associated use case automatically changes to disabled if there are no other queries or assertions.
[0126] In step 3, the test execution module provides data generation, test execution, deployment scheduling, and execution scheduling services.
[0127] When generating data, use the test data generation template to generate the test data set required for the test. In addition to the editing view of the test data generation template integrated in the test data management, an independent interactive interface is provided for the separate management of test data sets: a paginated list is used to display the test data set, and the list is displayed by scenario name, use case name, data generation template name, data set name, data set file storage path (relative path to the system file storage root path), data set status and operation. A search box is provided above the list for querying by scenario name, use case name, data generation template name, and data set name. A Generate button is provided for generating data sets. Enable, Disable and Delete buttons are provided in the Operation column for enabling, disabling or deleting data sets.
[0128] After the maintenance personnel clicks the Generate button, a window pops up, where they can select scenarios, use cases, and templates, and fill in the relative path of the file under the root path of the system file storage, the number of files, and the amount of data in each file. Then, they click the Generate button at the bottom of the window to generate the test data set file. The status of a newly created data set that has not been generated is Not Generated, the status of a test data set that has been generated and is being generated is Generating, and the status of a data set that has been generated is Generated.
[0129] The generated data set, if enabled, can be used to generate a test plan under the test execution function. If the data set is deleted or disabled, the corresponding test plan automatically becomes disabled.
[0130] When executing a test, a test plan file is generated through the test orchestration service based on the scenario and test data set. The test plan is referenced by the deployment model and deployed to the test execution service on the test execution node with the client role during the test deployment phase. The test execution service starts a test instance and performs automated testing on the database service on the test execution node with the server role according to the test plan.
[0131] The test execution function consists of sub-functions such as test plan list display and query, create test plan, edit test plan, enable and disable test plan, and delete test plan. Test plan list display and query are used to display and query the currently created test plans and the execution status of the test plans. Create test plan is used to create a test plan, edit test plan is used to modify the test plan, enable and disable test plan is used to enable or disable the test plan, and delete test plan is used to delete an obsolete test plan.
[0132] Test plan list display and query uses a list to display the created test plans, provides query conditions such as test plan name, scenario name, data set name, whether enabled, etc. for querying test plans, and provides paging display function. The test plan list displays the test plan name, scenario name, data set name, whether enabled, test plan status and test instance fields respectively. The test instance is a hyperlink. Click the test instance hyperlink to enter a new interactive interface. The execution status of the current test plan in different test instances is displayed in the form of a paging list in the interface. The list is sorted in reverse order by the test instance number. Each column displays the test instance number, test result set, test instance status and operation button area respectively. The test instance status includes scheduling, running, done and error. The operation button area provides a cancel execution button, which is used to call the test executor to force the end of the test.
[0133] A Create button is provided above the test plan list to create a new test plan. The newly created test plan is disabled by default and needs to be manually enabled by the maintenance personnel after confirmation through the Enable Disable button.
[0134] A button is provided on the far right of each record in the test plan list for editing the test plan. After clicking the Edit button, the system provides a user interaction view for maintenance personnel to use. Maintenance personnel can edit the test plan name in the view, manage the scenarios and test data sets of the test plan, and use the Orchestrate Test Plan button at the bottom of the view to call the test orchestration service to generate a test plan. The status of a test plan that has not been orchestrated is Not Generated, and the status of a test plan that has completed the orchestration is Generated. Test plans in the Ungenerated state cannot be enabled.
[0135] A button is provided on the right side of the Edit button in each test plan record to enable or disable the test plan, and a Delete button is provided on the right side of the Enable or Disable button to delete the unnecessary test plan. When a test plan is disabled or deleted, the corresponding deployment scheduling configuration is automatically disabled.
[0136] When performing deployment scheduling, declare the resources and deployment methods (deployment scripts) required to execute the test plan. When the scheduled task set in the execution schedule is triggered, the test deployment service creates a test instance, deploys the database service nodes and client nodes required for the test according to the resource specifications and deployment scripts described in the deployment schedule, and sends the test plan to the test execution service of the client node.
[0137] The deployment scheduling function consists of sub-functions such as deployment scheduling list display and query, create deployment scheduling, edit deployment scheduling, and delete deployment scheduling. Deployment scheduling list display and query are used to display and query the currently created deployment scheduling, create deployment scheduling is used to create a deployment scheduling, edit deployment scheduling is used to modify deployment scheduling, and delete deployment scheduling is used to delete an obsolete deployment scheduling.
[0138] Deployment schedule list display and query uses a list to display the created deployment schedule, provides query conditions such as deployment model name, test plan name, number of server nodes, number of client nodes, server maximum CPU limit, server maximum memory limit, client maximum CPU limit, client maximum memory limit, server affinity, client affinity, etc. for querying test plans, and provides paging display function.
[0139] A Create button is provided above the deployment schedule list to create a new deployment schedule.
[0140] A button is provided on the far right of each record in the deployment schedule list for editing the deployment schedule. After clicking the Edit button, the system provides a user interaction view for maintenance personnel to use. Maintenance personnel can modify the deployment model name in the view, set the test plan for the deployment schedule, the number of server nodes, the number of client nodes, the maximum CPU limit of the server, the maximum memory limit of the server, the maximum CPU limit of the client, the maximum memory limit of the client, the server affinity, the client affinity, and write and upload the deployment script.
[0141] A delete button is provided on the right side of the edit button in each deployment schedule record to delete unnecessary deployment schedules. When a deployment schedule is deleted, the corresponding execution schedule is automatically deleted.
[0142] When executing a test, the deployment scheduling service uses a scheduling algorithm based on the deployment scheduling information to find the test execution node with the least tasks that meets the deployment scheduling rules and deploys test resources according to the specifications in the deployment scheduling information.
[0143] Deployment scripts are divided into server-side and client-side scripts, which use deploy_server.sh and deploy_client.sh respectively. Maintenance personnel can write different scripts according to test requirements and upload them to the deployment scheduler. When storing, create a directory with the UUID of the deployment scheduler to store different deployment scripts.
[0144] When performing execution scheduling, use the execution scheduling function to set the rules for execution deployment scheduling. The test scheduling service should be a distributed timed task scheduling service, such as xxl-job, which triggers a test according to the crontab expression recorded in the execution scheduling record. The execution scheduling provides a one-time trigger for manual execution of tests or debugging.
[0145] The execution scheduling function consists of sub-functions such as execution schedule list display and query, create execution schedule, edit execution schedule, delete execution schedule, etc. Execution schedule list display and query are used to display and query the currently created execution schedule, create execution schedule is used to create an execution schedule, edit execution schedule is used to modify the execution schedule, and delete execution schedule is used to delete an obsolete execution schedule.
[0146] Execution schedule list display and query uses a list to display the created execution schedules, provides query conditions such as deployment model name and test plan name for querying execution schedules, and provides paging display function.
[0147] A Create button is provided above the execution schedule list to create a new execution schedule.
[0148] A button is provided on the far right of each record in the execution schedule list for editing the execution schedule. After clicking the edit button, the system provides a user interaction view for maintenance personnel to use, in which the maintenance personnel can set the crontab expression for deployment scheduling and execution test.
[0149] A delete button is provided on the right side of the edit button in each execution schedule record to delete unnecessary execution schedules. When an execution schedule is deleted, the corresponding deployment schedule will no longer be executed according to the deleted execution plan.
[0150] In step 5, the result viewing module provides test result collection, test result processing, and test result display services.
[0151] When collecting test results, the test execution service on the test execution node records the results when executing the test plan and writes them into a csv file. The response delay of the use case is obtained by recording the system time before and after executing the use case and calculating the time difference. The result of the test execution is judged by comparing the query result with the query assertion. If the query result is consistent with the query assertion, the test result is successful, otherwise the test fails. If an exception occurs during the test or the database server returns an error, these exception information and error information are also recorded in the response message field.
[0152] The format of the csv file used to collect test results is:
[0153] Timestamp: used to record the time when the test result was generated.
[0154] Test duration: used to record the total time taken to execute a test case.
[0155] Use case name: used to distinguish use cases.
[0156] Return code: record the status code returned by the test.
[0157] Response information: record the results returned by the test (you can truncate them through the configuration file to avoid insufficient test pressure performance caused by disk IO writing to csv during actual execution).
[0158] Thread name: used to record the thread that executes the use case.
[0159] Whether the test is successful: True if the test is successful, otherwise False.
[0160] Failure information: used to record the exception information that occurs during the test or the error information returned by the database server (it can be truncated through the configuration file to avoid insufficient test pressure performance caused by disk IO written to csv during actual execution).
[0161] Waiting time: used to record the waiting time for this use case execution. Waiting time = test duration - response delay.
[0162] Response delay: used to record the total time from when the tested SQL is sent to the database to when the database returns the query results in the test case.
[0163] When processing test results, the test report generation operation can be triggered by calling the specific interface of the test execution service. After the test execution service receives the request to generate a test report, it executes the test result processing function according to the test instance test plan ID and test number in the request, and generates a test report for this test by merging the csv file generated by the test result collection and writes it into an html file.
[0164] When displaying the test results, the test results are displayed in the HTML page generated by the test result processing, and viewing and downloading services are provided through an http server:
[0165] The page consists of three tabs: result summary list, error summary list, and performance chart.
[0166] The result summary list summarizes the execution results by use case, including the total number of executions of the use case, the number of successes, the number of failures, the minimum response time, the maximum response time, the average response time, the 90% response time, the 95% response time, the 99% response time, etc.
[0167] The error summary list categorizes and summarizes the error information that occurs during the test execution, and displays the number of error occurrences and error contents in descending order of error frequency.
[0168] The performance chart draws various response delay curves based on the timestamp and response delay of each use case to analyze the performance of the database in executing each use case.
[0169] Example 3
[0170] The present invention also provides a database automated testing system, comprising a front-end service module, wherein the front-end service module comprises a test management module, a test execution module, a monitoring and alarm module and a result viewing module.
[0171] The test management module provides scenario management, use case management, object model management, test data management, and query and assertion management services. The test management module uses unified rules to organize test statements, organize multiple test statements into use cases, organize multiple use cases into test scenarios, and centrally manage test cases and reuse test cases.
[0172] The test execution module provides data generation, test execution, deployment scheduling, and execution scheduling services. The test execution module uses the test data generation template to generate the test data set required for the test.
[0173] The monitoring and alarm module provides monitoring indicator collection, monitoring configuration, alarm rule configuration and alarm push services.
[0174] The result viewing module provides test result collection, test result processing, and test result display services.
[0175] The information interaction, execution process and other contents between the modules in the above-mentioned system are based on the same concept as the embodiment of the method of the present invention. For the specific contents, please refer to the description in the embodiment of the method of the present invention, and no further description is given here.
[0176] Similarly, the device of the present invention realizes the database automation test process with use case management and real-time data generation functions, can organize test statements using unified rules, and use a special database to save the use case DDL, DML statements and the index of data written into the seed file, provide test personnel with an arrangement template and engine, organize multiple test statements into use cases, organize multiple use cases into test scenarios, and centrally manage test cases, maximize the reuse of test cases, and save test time. At the same time, the present invention generates business data seed files according to certain rules through template files, and uses the seed files to generate the ability of test data written into the database in real time. Through the test of different business scenarios, the performance of the database in different business scenarios is examined, and the function, performance, availability and robustness of the database are more fully tested.
[0177] Example 4
[0178] Based on Example 3, combined Figure 2 The system of the present invention is mainly applied to the access layer and the application layer, and also involves the domain layer and the infrastructure layer. The access layer is a front-end module that provides interactive functions for users, including a test management module, a test execution module, a monitoring and alarm module, and a result viewing module.
[0179] The application layer provides segmented service interfaces for these four modules. The test management module provides scenario management, use case management, object model management, test data management, and query and assertion management services. The test execution module provides data generation, test execution, deployment scheduling, and execution scheduling services. The monitoring and alarm module provides monitoring indicator collection, monitoring configuration, alarm rule configuration, and alarm push services. The result viewing module provides test result collection, test result processing, and test result display services.
[0180] The domain layer is mainly the business domain model of the system itself, corresponding to ER entities and database tables. The test metadata domain mainly includes scenarios, use cases, table structures (specifically the table structure of the business model of the tested scenario), test data templates, queries and other domain models; the execution information domain mainly includes test data entities, test plans, test deployment models, execution scheduling information and other domain models; the monitoring and alarm indicator domain mainly includes monitoring indicators, monitoring configuration, alarm rules, alarm push and other domain models; the result viewing domain only has the test result domain model.
[0181] The infrastructure layer mainly includes other necessary services and components that must be deployed to realize the functions covered by this system, mainly including: test orchestration service, test deployment service, test execution service, test scheduling service, monitoring service and alarm push service, as well as relational database and file storage services.
[0182] Combination Figure 3The deployment architecture of the system of the present invention can mainly include a test management server group and a test load server group, wherein the test management server group is composed of a high-availability cluster composed of several services deployed in this system, and provides various test services described in the logical architecture to testers through a load balancer, and uses a high-availability shared storage as a file server to store test object creation files, test data generation template files, test query parameters and assertion files, test data set files, test plans and deployment plans. The test case maintainer uses the object model management function to enter the test object creation file, uses the query and assertion management function to enter the test query parameters and assertion files, uses the test data management function to enter the data generation template, uses the data generation function to generate the test data set file, uses the test execution function and the deployment scheduling function to activate the test orchestration and test deployment service through the test scheduling service deployed on the same server to generate the test plan and deployment plan, and uses the execution scheduling function to plan the scheduling time of the test plan, schedules the test task to the test load server under the test load server group by the timer, executes the test through the test execution service deployed on the test load server, and transmits the monitoring information back to the test management service deployed on the test management server through the monitoring service deployed on the test load server, and calls the web hook or web service interface of the external service to send alarm information to the tester.
[0183] The entity relationship model of this system mainly includes scheduling plan (schedule_plan), deployment model (deploy_model), test plan (test_plan), test instance (test_impl), scene (scene), scene use case relationship (scene_case_relation), relationship use case information (relation_case), use case (case), use case model relationship (case_model), model (model), test data template (test_data_tmpl), test data set (test_data_set), model query relationship (case_model_query), query (query), and use case query relationship (case_query) entities.
[0184] Unless otherwise specified, properties cannot have null values.
[0185] Combination Figure 5 , describing the entity-relationship model. The schedule plan (schedule_plan) is used to record the deployment model ID (deploy_id) of a test and the test timing schedule expression (schedule_expr, crontab expression, which can be empty). When the timing schedule expression is empty, it means that the schedule is a one-time real-time trigger, otherwise it will be triggered according to the expression.
[0186] The deployment model (deploy_model) is used to record the deployment information of a test, including the deployment model name (name), the test plan (plan_id) used, the number of database nodes (server_node_count), the deployment script path (deploy_script, the path of the automation script used to deploy different databases), the database maximum CPU limit (server_cpu_limit), the database maximum memory limit (server_mem_limit) and affinity (server_affinity: true for affinity, false for anti-affinity), the number of client nodes (client_count), the client maximum CPU limit (client_cpu_limit), the client maximum memory limit (client_mem_limit) and affinity (client_affinity: true for affinity, false for anti-affinity). Affinity here mainly refers to the way that services of the same type are deployed to physical nodes, which can be divided into affinity and anti-affinity: affinity means that services of the same type should be deployed to the same physical node, which is usually used for services that do not require disaster recovery and high availability, and is only used to improve concurrency and performance; anti-affinity means that services of the same type should be deployed to different physical nodes, which is usually used for disaster recovery and to provide high availability for services (usually not used independently, and a high-availability proxy or load balancer needs to be configured before the service). One deployment model corresponds to one test plan.
[0187] The test plan (test_plan) is used to record the simulation data set id (data_set_id) and deployment model id (deploy_id) used under a test scenario id (scene_id). The test plan has a status (status, not generated / generated) and can be enabled or disabled (active). A test plan can be used for multiple deployment models, multiple test instances (test_impl) and a scene (scene).
[0188] A test instance (test_impl) is used to record the status (status, scheduling / running / done) of a test execution (num) using a test data set (data_set_id) with a test plan id (plan_id). A test instance corresponds to a test data set (test_data_set) and a test plan (test_plan).
[0189] A scenario is used to describe a business scenario that uses a database, including the scenario name (name), the size of the database connection pool used (conn_pool_size), the method of connecting to the database (db_url, usually the URL of JDBC / ODBC), the user (db_user) and password (db_passwd, which can be empty. If empty, it is an SSL connection. The deployment script used when deploying database services needs to provide the SSL certificate generation steps), and an identification bit is used to enable or disable control (active). A scenario corresponds to a test plan, and can correspond to multiple scenario use case relationships.
[0190] The scene-case relationship (scene_case_relation) is used to describe the relationship between each use case in a test scenario, including the scene id (scene_id), the previous use case id (pre_case_id, which can be empty. When it is empty, it means that the current use case of this record is the starting use case in this scene. Under a scene_id, there can be multiple records with different case_id and this field is empty, indicating that multiple starting use cases are executed simultaneously at the beginning of the test), the current use case id (case_id), and the next use case id (next_case_id, which can be empty. When it is empty, it means that the current use case of this record is the final use case in this scene, that is, the last use case to be executed; under a scene_id, there can be multiple records with different case_id and this field is empty. Multiple records indicate that these case_id records will be executed simultaneously in the end in this scene). All scene-case relationship records in the same scene can form multiple directed acyclic graphs, and each graph is executed in parallel. A scene-case relationship corresponds to one scene and multiple relationship use case information.
[0191] The relationship use case information (relation_case) mainly describes the way in which the use case is executed under a certain scenario use case relationship, mainly including the scenario use case relationship id (relation_id), the use case id (case_id), the number of use case threads (case_thread, indicating the number of concurrent threads that need to execute the use case corresponding to the condition case_id at the same time), the use case execution time (case_duration, integer, in seconds), the order of use case appearance (case_order, integer, starting from 1 and increasing by step 1, indicating that under a scenario use case relationship, this information describes the behavior of the use case at which time it appears. For example, the same use case appears for the first time with 2 case_threads, 180 seconds of case_duration, 0 seconds of pre_case_wait and 10 loops, and the second time it appears can be executed with 5 case_threads, 3600 seconds of case_duration, 30 seconds of pre_case_wait and 5 loops), how long it takes to wait after the previous use case is executed before starting to execute this use case (pre_case_wait, integer, in seconds), and the number of loops (loops) that the current use case needs to execute. One relationship use case information corresponds to multiple scenario use case relationships and one use case.
[0192] A use case is used to mark the database objects (schema, database, table, view, user, or job, etc.) used by a use case and a series of statements that execute database DDL or DML queries. The use case itself does not contain this information, and these database objects and statements need to be found through the use case model (case_model) and use case query (case_query) entity relationships. A use case includes the following attributes: name (name), description (description), and enable flag (active). A use case can be used for multiple relational use case information, corresponding to multiple use case models and multiple use case query information.
[0193] The use case model relationship (case_model) is used to describe the relationship between the use case and the model, including the use case id (case_id) and the model id (model_id). A use case model relationship corresponds to a unique use case and a unique model.
[0194] Models are used to describe database objects, including schema, database, table, view, user, or job. Model attributes include object name (obj_name), model creation file path (model_file_path, mainly used to save DDL[5] statements for creating database objects), data generation template id (tmpl_id), model object type (model_type), and enable flag (active). A model corresponds to a test data template, multiple use case model relationships, and multiple model query relationships.
[0195] The test data template (test_data_tmpl) is used to save the test data generation template information, including the template path (tmpl_path) and the enable flag (active). A test data template corresponds to a model and multiple test data set files.
[0196] The test data set (test_data_set) is used to save the path (file_path) of the test data seed file generated by the data generator using the test data template. A test data set corresponds to a test data template information and a test plan.
[0197] The model query relation (case_model_query) is used to describe the position where a database object appears in a query, including the model id (model_id), the query id (query_id), and the position of the model in the query (order_in_query).
[0198] Query is used to describe the DML query statements used in the test plan, including the query name, query statement, whether to preprocess the execution (is_prepare), query parameter file path (param_csv_path), assertion file path (assertion_path, used to save the query assertion results to determine whether the query results returned by the test are correct), the database dialect used (the syntax used by database products from various manufacturers to implement the SQL standard has slight differences, and this difference is called database dialect in computer terminology) and the enable flag (active). A query corresponds to multiple use case query relationships and multiple model query relationships.
[0199] The case query relationship (case_query) is used to describe the relationship between the test case (case) and the query (query), including the case id (case_id), the query id (query_id), and the position of the query statement in the case (query_order, indicating the order of the query statement in the case). A case query relationship corresponds to one case and multiple query statements.
[0200] It should be noted that not all steps and modules in the above-mentioned processes and system structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0201] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.
Claims
1. A database automation testing method, characterized in that include: Step 1: Build the front-end service module, including the test management module, test execution module, monitoring and alarm module, and result viewing module. Step 2: Provide scenario management, use case management, object model management, test data management, and query and assertion management services through the test management module. The test management module uses unified rules to organize test statements, organize multiple test statements into use cases, organize multiple use cases into test scenarios, and centrally manage test cases and reuse test cases. Step 3: Provide data generation, test execution, deployment scheduling and execution scheduling services through the test execution module, where the test data generation template is used by the test execution module to generate the test data set required for the test. Step 4: Provide monitoring indicator collection, monitoring configuration, alarm rule configuration and alarm push services through the monitoring alarm module. Step 5: Provide test result collection, test result processing, and test result display services through the result viewing module.
2. A database automation testing method according to claim 1, characterized in that In step 2, scenario management is performed through the test management module, including: Display scene lists and scene queries, create scenes, edit scenes, enable and disable scenes, and delete scenes. When displaying and querying the scene list, display and query the currently created scenes. When creating a scenario, create a new scenario using the test case. When editing a scenario, you can add test cases to the scenario or modify the arrangement of test cases in the scenario. When enabling or disabling a scene, enable or disable the scene. When deleting a scene, delete an obsolete scene.
3. A database automation testing method according to claim 1, characterized in that In step 2, use case management is performed through the test management module, including: Display and query the use case list, create use cases, edit use cases, enable and disable use cases, and delete use cases. When displaying and querying the use case list, display and query the currently created use cases. When creating a use case, create a new use case using the model. When editing a use case, you can add test models and query statements to the use case, or modify the models or query statements used in the use case and their arrangement. When enabling or disabling a use case, enable or disable the use case. When deleting a use case, delete an obsolete use case.
4. A database automation testing method according to claim 1, characterized in that In step 2, the object model is managed through the test management module, including: For the database objects used, display and query the object list, create objects, edit objects, enable and disable objects, and delete objects. Display and query the object list, display and query the currently created database objects, create objects, and create a database object. Edit the object, add object template files and seed data files to the object to generate templates and define object types. Enable or disable an object. Delete an object and delete an obsolete object.
5. A database automation testing method according to claim 1, characterized in that In step 2, test data management is performed through the test management module, including management of the test data generation templates used in the test and the data sets generated by the templates, including: display and query of the test data generation template list, creation of test data generation templates, editing of test data generation templates, enabling and disabling of test data generation templates, and deletion of test data generation templates. Display and query the test data generation template list, which is used to display and query the test data generation templates that have been created. Creation of test data generation template, used to create a test data generation template, Editing of test data generation templates is used to modify data generation templates and manage the test data sets corresponding to the data generation templates. Enable or disable the test data generation template, which is used to enable or disable the test data generation template. The test data generation template deletion operation is used to delete an obsolete test data generation template.
6. A database automated testing system, characterized in that It includes a front-end service module, which includes a test management module, a test execution module, a monitoring and alarm module, and a result viewing module. The test management module provides scenario management, use case management, object model management, test data management, and query and assertion management services. The test management module uses unified rules to organize test statements, organize multiple test statements into use cases, organize multiple use cases into test scenarios, and centrally manage test cases and reuse test cases. The test execution module provides data generation, test execution, deployment scheduling, and execution scheduling services. The test execution module uses the test data generation template to generate the test data set required for the test. The monitoring and alarm module provides monitoring indicator collection, monitoring configuration, alarm rule configuration and alarm push services. The result viewing module provides test result collection, test result processing, and test result display services.
7. A database automated testing system according to claim 5, characterized in that The test management module manages scenarios, including: Display scene lists and scene queries, create scenes, edit scenes, enable and disable scenes, and delete scenes. When displaying and querying the scene list, display and query the currently created scenes. When creating a scenario, create a new scenario using the test case. When editing a scenario, you can add test cases to the scenario or modify the arrangement of test cases in the scenario. When enabling or disabling a scene, enable or disable the scene. When deleting a scene, delete an obsolete scene.
8. A database automated testing system according to claim 1, characterized in that The test management module manages use cases, including: Display and query the use case list, create use cases, edit use cases, enable and disable use cases, and delete use cases. When displaying and querying the use case list, display and query the currently created use cases. When creating a use case, create a new use case using the model. When editing a use case, you can add test models and query statements to the use case, or modify the models or query statements used in the use case and their arrangement. When enabling or disabling a use case, enable or disable the use case. When deleting a use case, delete an obsolete use case.
9. A database automated testing system according to claim 6, characterized in that The test management module manages the object model, including: For the database objects used, display and query the object list, create objects, edit objects, enable and disable objects, and delete objects. Display and query the object list, display and query the currently created database objects, create objects, and create a database object. Edit the object, add object template files and seed data files to the object to generate templates and define object types. Enable or disable an object. Delete an object and delete an obsolete object.
10. A database automated testing system according to claim 6, characterized in that The test management module manages test data, including managing the test data generation templates used in the test and the data sets generated by the templates, including: displaying and querying the list of test data generation templates, creating test data generation templates, editing test data generation templates, enabling and disabling test data generation templates, and deleting test data generation templates. Display and query the test data generation template list, which is used to display and query the test data generation templates that have been created. Creation of test data generation template, used to create a test data generation template, Editing of test data generation templates is used to modify data generation templates and manage the test data sets corresponding to the data generation templates. Enable or disable the test data generation template, which is used to enable or disable the test data generation template. The test data generation template deletion operation is used to delete an obsolete test data generation template.
