Database automated function testing method and device, electronic device and storage medium
By generating public test parameters and automated test methods, database functional tests are executed under the same configuration environment, the problem of inefficiency of repetitive comparison verification in existing test methods is solved, and efficient and automated database functional tests are achieved.
Patent Information
- Application Number
- CN202411641276.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-18
AI Technical Summary
The existing database functional testing methods have a large number of repetitive comparison verification work, which occupies a lot of manpower and is inefficient, resulting in problem location and testing delays.
By generating public test parameters, each test project is executed under the same configuration environment, and the automated test method is used to automatically repeat and compare the work throughout the process, achieving one-to-one test to the end and quickly expose the problem.
It reduces the occupation of human resources, improves testing efficiency, can quickly expose problems, saves manpower and material resources, and ensures the accuracy and completeness of test results.
Smart Images

Figure CN119149437B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of database technology and automated testing technology, and in particular to a database automated functional testing method and device, electronic equipment and storage medium. Background Art
[0002] The functional testing of the database involves basic functional verification such as Structured Query Language (SQL) execution result verification, database command verification, etc., disk information verification such as data disk and log disk verification, system environment verification such as disk memory usage verification, etc. The test of a function not only requires the execution of operations on the database itself, but also requires cross-machine system operations for corresponding verification. Therefore, in related technologies, the testing method is basically to use scripts to execute batch SQL statement functional operations, plus manual system operations and manual verification for pure manual or semi-automatic methods for testing and verification.
[0003] This type of testing method mainly faces a large amount of repetitive comparison and verification work, which takes up a lot of manpower and wastes resources; the efficiency of manual information comparison is not high and cannot expose existing problems as soon as possible; once a problem is found during the test, locating the problem will take up manpower, so subsequent tests will be postponed and all functional test points cannot be covered in time. Summary of the invention
[0004] In view of the above problems, the present invention provides a method, device, electronic device, storage medium and program product for automated database function testing.
[0005] According to a first aspect of the present invention, there is provided a method for automated functional testing of a database, comprising: obtaining original configuration parameters of a database to be tested; modifying the original configuration parameters according to overall test requirements to generate common test parameters, wherein the common test parameters are used to make the test environment meet the test operation standard; based on the common test parameters, calling n independent test items to perform n functional tests on the database to be tested, and generating test results, wherein n is a positive integer.
[0006] According to an embodiment of the present invention, based on common test parameters, each independent test item is called to perform a functional test on the database to be tested, and n groups of test records corresponding to the n independent test items are generated; and test results are generated according to the n groups of test records.
[0007] According to an embodiment of the present invention, based on common test parameters, each independent test project is called to perform a functional test on the database to be tested, and n groups of test records corresponding to the n independent test projects are generated, including: modifying based on the common test parameters to generate self-use parameters, wherein the self-use parameters are special configuration parameters for executing independent test project tests; based on the self-use parameters, calling the independent test project to perform functional tests, generating a test record of the test project, the test record is passed or failed, wherein, when the test record is failed, the failed project information of the independent test project is recorded; restarting the cluster where the independent test project is located to initialize the cluster environment, so that the database to be tested is restored to the common test parameter configuration.
[0008] According to an embodiment of the present invention, based on self-use parameters, the test project is called to perform functional testing and a test record of the test project is generated, including: based on self-use parameters, calling the corresponding SQL statement or database command of each independent test project to implement function triggering, verifying the implementation of the corresponding function of the test in the database or system to be tested, and generating a test record.
[0009] According to an embodiment of the present invention, the original configuration parameters are called to overwrite the configuration of the database to be tested, so that the database to be tested restores the original configuration parameters.
[0010] According to an embodiment of the present invention, before generating common test parameters or after generating test results, the cluster where n test items are located is upgraded or rolled back, wherein the upgrade or rollback operation is used to keep the cluster where n test items are located in the same state before and after the test.
[0011] The second aspect of the present invention provides a database automated functional testing device, including an acquisition module, a configuration module, a test module and a cleanup work module, the acquisition module is used to acquire the original configuration parameters of the database to be tested; the configuration module is used to modify the original configuration parameters according to the overall test requirements and generate common test parameters, wherein the common test parameters are used to make the test environment meet the test operation standards; the test module is used for n independent test projects to perform n functional tests on the database to be tested and generate test results; the cleanup work module calls the original configuration parameters to overwrite the configuration of the database to be tested so that the database to be tested restores the original configuration parameters.
[0012] The third aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more computer programs, and when the one or more processors execute the one or more computer programs, the steps of the above-mentioned database automated functional testing method are implemented.
[0013] The fourth aspect of the present invention further provides a computer-readable storage medium having a computer program or instruction stored thereon, which implements the steps of the above-mentioned database automated functional testing method when executed by a processor.
[0014] The fifth aspect of the present invention also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the steps of the above-mentioned database automated functional testing method.
[0015] According to an embodiment of the present invention, the present invention generates common test parameters so that each test item is executed in the same configuration environment without interfering with each other, and the common test parameters can be configured according to test requirements and software and hardware conditions; the present invention automatically completes repetitive work and comparison work through full automation, and tests to the end, exposing all problems as soon as possible so that they can be analyzed and solved one by one, and the test record information of all independent test items can be reflected in the test results. At the same time, various test requirements can be met by flexibly adding and deleting independent test items. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The above contents and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0017] Figure 1 An application scenario diagram of a database automated functional testing method, device, electronic device, storage medium, and program product according to an embodiment of the present invention is shown;
[0018] Figure 2 A flowchart of a method for automated database function testing according to an embodiment of the present invention is shown;
[0019] Figure 3 A flow chart showing a method for generating a test record for each independent test item according to an embodiment of the present invention is shown;
[0020] Figure 4 A schematic diagram of database automated functional testing operation according to an embodiment of the present invention is shown;
[0021] Figure 5 It shows a structural block diagram of a database automated function testing device according to an embodiment of the present invention;
[0022] Figure 6 A block diagram of an electronic device for a database automated functional testing method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0023] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.
[0024] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0025] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0026] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0027] In the technical solution of the present invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0028] It should be noted that the database automated functional testing method and device, electronic device and storage medium of the embodiments of the present invention can be applied to the fields of database technology and automated testing technology, and can also be used in any field other than the fields of database technology and automated testing technology. The embodiments of the present invention do not limit the application fields of the above-mentioned database automated functional testing method and device, electronic device and storage medium.
[0029] An embodiment of the present invention provides a method for automated functional testing of a database, comprising: obtaining original configuration parameters of a database to be tested; modifying the original configuration parameters according to overall test requirements to generate common test parameters, wherein the common test parameters are used to make a test environment meet test operation standards; based on the common test parameters, calling n independent test items to perform n functional tests on the database to be tested, and generating test results.
[0030] Figure 1 An application scenario diagram of a database automated functional testing method, device, electronic device, storage medium, and program product according to an embodiment of the present invention is shown.
[0031] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0032] The user may use at least one of the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0033] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0034] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0035] It should be noted that the database automation function testing method provided in the embodiment of the present invention can generally be performed by the server 105. Accordingly, the database automation function testing device provided in the embodiment of the present invention can generally be set in the server 105. The database automation function testing method provided in the embodiment of the present invention can also be performed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the database automation function testing device provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.
[0036] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0037] The following will be based on Figure 1 The scene described by Figure 2~Figure 4 The database automated functional testing method of the disclosed embodiment is described in detail.
[0038] Figure 2 A flow chart of a database automated functional testing method according to an embodiment of the present invention is shown.
[0039] like Figure 2 As shown, the database automated functional testing method according to the embodiment of the present invention includes operations S201 to S203.
[0040] In operation S201, original configuration parameters of the database to be tested are obtained.
[0041] In operation S202, the original configuration parameters are modified according to the overall test requirements to generate common test parameters, wherein the common test parameters are used to make the test environment meet the test running standard.
[0042] In operation S203, based on the common test parameters, n independent test items are called to perform n functional tests on the database to be tested, and a test result is generated, where n is a positive integer.
[0043] According to an embodiment of the present invention, before operation S201, the data files required for the test are pushed to a designated server or other machine for testing through a system command interface. The data files used in the test need to be pushed to an importable location and then imported uniformly.
[0044] According to an embodiment of the present invention, before operation S201, a test script or tool that can simulate the database function testing process can be coded based on the programming interface of the database and combined with the interface of the programming language for system operation. The languages involved include but are not limited to shell scripts, C language and other programming languages.
[0045] According to an embodiment of the present invention, in operation S201, original configuration parameters of the database to be tested are obtained.
[0046] According to an embodiment of the present invention, after the original configuration parameters of the database to be tested are obtained, the original configuration parameters may be backed up, and after the test is completed, the backup is directly overwritten to restore the database to the state before the test.
[0047] According to an embodiment of the present invention, in operation S202, the original configuration parameters are modified according to the overall test requirements to generate common test parameters, wherein the common test parameters are used to make the test environment meet the test running standard.
[0048] According to an embodiment of the present invention, the original configuration parameters are modified according to the overall test requirements to generate common test parameters, and the system is set through the system command interface coding to meet the test requirements such as network environment settings. The network settings and firewall rules can also be configured to limit network access to the system, which can ensure that only authorized devices and users can access the system and reduce potential security risks; user accounts and permissions can also be set. According to test requirements, user accounts can be created or modified, and corresponding permissions and access controls can be set to ensure that testers have the necessary permissions to perform test tasks while limiting access to sensitive data and functions; system resource allocation and hard disk occupancy are set, and according to test requirements, the allocation of system resources such as central processing unit (CPU), memory and disk space are adjusted, which can ensure that the system has sufficient resources to run test tasks during testing and avoid problems caused by resource bottlenecks.
[0049] According to an embodiment of the present invention, in operation S203, based on the common test parameters, n independent test items are called to perform n functional tests on the database to be tested, and a test result is generated, where n is a positive integer.
[0050] According to an embodiment of the present invention, an independent test project is to detect the functions of the database to be tested, for example, it can be a database object test to verify that all database objects such as database tables, views, indexes, stored procedures, triggers, constraints, rules, etc. exist and work as expected, and test the data integrity and consistency of these objects; data integrity testing to verify whether the data is input and stored according to predefined business rules, and check whether foreign key constraints, uniqueness constraints, non-null constraints, etc. are correctly executed; security testing to check whether the access control mechanism of the database is effective, including user authentication, authority management, data encryption, etc.; interface testing to verify whether the interface between the database and other systems or components works normally, including data exchange, synchronization and transmission, etc., and use equivalence classes, boundary values, error guessing and other methods to test the stability and fault tolerance of the interface.
[0051] According to an embodiment of the present invention, independent test items can be set according to the overall test requirements. There is no limit to the number n, and test items can be set infinitely within the load range of the test system; the n independent test items are all run separately one by one under the configuration of common test parameters. After the previous independent test item is completed, the next independent test item is tested, and the process is automatically carried out one by one until all independent test items are tested and the final test results are generated.
[0052] According to an embodiment of the present invention, the test results may be exported in formats such as comma separated values (CSV), Excel, XML, JSON, etc., or a custom export script may be written. The export method may vary depending on the test database type and operating system being tested.
[0053] According to an embodiment of the present invention, after operation S203, after the test is completed, the data files required for the test are deleted from the designated server or other machine through the system command interface.
[0054] According to an embodiment of the present invention, the present invention generates common test parameters so that each test item is executed in the same configuration environment without interfering with each other, and the common test parameters can be configured according to test requirements and software and hardware conditions; the present invention automatically completes repetitive work and comparison work through full automation, and tests to the end, exposing all problems as soon as possible so that they can be analyzed and solved one by one, and the test record information of all independent test items can be reflected in the test results. At the same time, various test requirements can be met by flexibly adding and deleting independent test items.
[0055] According to an embodiment of the present invention, in operation S203, based on common test parameters, each independent test item is called to perform a functional test on the database to be tested, and n groups of test records corresponding to the n independent test items are generated; and test results are generated according to the n groups of test records.
[0056] According to an embodiment of the present invention, each independent test item will generate a test record, and the test record includes whether this independent test item passes. If passed, the test record will only record the "pass" or "pass" result. If failed, the test record will record the "fail" or "fail" result and the failed item information of the test content of this independent test item, including the location information, environmental information and other contents.
[0057] According to an embodiment of the present invention, after all independent test items have been tested, all test records are traversed, and when all test records are "passed" or "pass", a test result of "pass" or "pass" is generated; when one or more test records are not "passed" or "pass", a test result of "failed" or "fail" is generated. When the test result is "failed" or "fail", the test user can call the test record to view the content and location environment information of the failed independent test items, and proceed to the next step of processing.
[0058] Figure 3 A flow chart of a method for generating a test record for each independent test item according to an embodiment of the present invention is shown.
[0059] like Figure 3 As shown, the method for generating a test record for each independent test item in this embodiment includes operations S301 to S303.
[0060] In operation S301, modifications are performed based on common test parameters to generate self-use parameters, wherein the self-use parameters are dedicated configuration parameters for executing independent test items.
[0061] In operation S302, based on the self-use parameters, an independent test item is called to perform a functional test, and a test record of the test item is generated. The test record is passed or failed. When the test record is failed, the failed item information of the independent test item is recorded.
[0062] In operation S303, the cluster where the independent test project is located is restarted to initialize the cluster environment so that the database to be tested is restored to the common test parameter configuration.
[0063] According to an embodiment of the present invention, in operation S301, modification is performed based on the common test parameters to generate self-use parameters, wherein the self-use parameters are dedicated configuration parameters for executing independent test item tests.
[0064] According to an embodiment of the present invention, the setting of the self-use parameters only serves the use of this independent test project. The setting of the self-use parameters is set on the basis of the common parameters of all independent test projects, that is, the common test parameters, and is configured according to the needs of this independent test project. The supporting settings can be made in advance together with the independent test project. When calling this independent test project, the self-use parameter settings are set up together. Exemplarily, the self-use parameters can be modified on the basis of the common test parameters, and the system can be set to meet the test needs such as network environment settings through the system command interface coding. The network settings and firewall rules can also be configured to limit network access to the system, which can ensure that only authorized devices and users can access the system and reduce potential security risks; user accounts and permissions can also be set. According to the test requirements, user accounts can be created or modified, and corresponding permissions and access controls can be set to ensure that the testers have the necessary permissions to perform the test tasks, while limiting access to sensitive data and functions; system resource allocation and hard disk occupancy are set, and the allocation of system resources, such as CPU, memory and disk space, can be adjusted according to the test requirements. This can ensure that the system has sufficient resources to run the test tasks during the test and avoid problems caused by resource bottlenecks.
[0065] According to an embodiment of the present invention, in operation S302, based on self-use parameters, an independent test item is called to perform a functional test, and a test record of the test item is generated. The test record is passed or failed. When the test record is failed, the failed item information of the independent test item is recorded.
[0066] According to an embodiment of the present invention, a test record is generated after each independent test item is executed, and the result of the test record can be set to "pass" or "pass", "fail" or "fail". When the test passes, the failed item information will not be recorded, and the step of restarting the cluster initialization configuration to the public test parameters will be automatically entered; when the test fails, before entering the restart cluster initialization, the failed item information of the test item must be recorded, and it will also be reflected in the final test result. Different project information includes the location information, environmental information, etc. of the independent test item. In some specific embodiments, during the execution of the independent test item, error information such as directory not found, no access permission, inability to execute statement, etc. will occur, and such error information will be recorded and reflected in the failed item information.
[0067] It is convenient for users to quickly find the location and environment of failed projects, and find the problems of the database to be tested more quickly. At the same time, since the cluster is restarted after recording, the subsequent independent test projects will not be affected by its configuration and problems, and automatic testing is achieved without affecting each other.
[0068] According to an embodiment of the present invention, in operation S303, the cluster where the independent test project is located is restarted to initialize the cluster environment so that the database to be tested is restored to the common test parameter configuration.
[0069] According to an embodiment of the present invention, the database cluster state is restored by restarting each node in the cluster, so that coupling between each individual test project can be avoided as much as possible. This can be achieved through the database interface in the shell script without adding label processing. Each individual test project can achieve its own parameter configuration by setting its own parameters through the database. Once the database cluster is restarted, these set parameters will be restored and will not affect subsequent test projects, thereby achieving the purpose of both unified effect of common parameters and separate effect of independent parameter settings for each test project through interface settings.
[0070] According to an embodiment of the present invention, by setting the parameters for each independent test project, the independent test projects are placed in the same large configuration environment for independent testing based on the public parameter configuration. At the same time, since each test function and method of the independent test project is different, fine-tuning of the configuration that is more suitable for itself is performed on the basis of the public test parameters, and no large-scale configuration modification is performed, which is only more suitable for its own test operation. Finally, by restarting the cluster where the test project is located and initializing the cluster configuration to the public test parameter configuration, the large configuration environment of each independent test project is the same.
[0071] According to an embodiment of the present invention, based on self-use parameters, the corresponding SQL statement or database command of each independent test item is called to implement function triggering, and the corresponding function of the test in the database or system to be tested is verified to generate a test record.
[0072] According to an embodiment of the present invention, through preset test items, function triggering can be achieved through corresponding SQL statements or data commands, and function verification can be achieved by comparing the triggered function with the preset result, such as verification of database structure, data integrity, data security, concurrency control, backup and recovery, etc. For example, the data integrity of the database can be verified, and whether the constraints, primary key and foreign key relationships, indexes, etc. of the data work as expected can be verified to verify whether the data in the database remains complete, accurate and consistent. By verifying whether functions such as user authentication, authority management, and data encryption are effective, it can be verified whether the database system provides sufficient security protection to prevent unauthorized access and tampering. It can be verified whether the database system can correctly handle concurrent operations of multiple users or transactions to avoid data conflicts and inconsistencies. It can be verified whether the backup and recovery functions of the database system are reliable and effective by verifying the integrity of the backup file, the correctness of the recovery operation, and the recovery time.
[0073] In some embodiments of the present invention, original configuration parameters, public test parameters and self-use parameters may include the same configuration fields.
[0074] According to an embodiment of the present invention, the original configuration parameters, public test parameters and self-use parameters include the same fields, but the values therein are different, wherein the self-use parameters are fine-tuned under the conditions of the public test parameters to adapt to the operation of the independent test items; the public test parameters are changed on the basis of the original configuration parameters, and will not exceed the range of the original configuration parameters; the self-use parameters are changed on the basis of the public test parameters, and will not be modified beyond the range of the public test parameters. The three parameters use the same field with different values to change according to actual needs, and can also ensure that the system cannot run due to the modification of the configuration parameters during the test process, ensuring that the system works as expected. According to an embodiment of the present invention, taking the network configuration parameters as an example, the configuration contents such as the maximum number of connections, the number of concurrent connections, the delay time, the bandwidth or the packet loss rate can be included; the same fields of the original configuration parameters, the public test parameters and the self-use parameters can be understood in this example as, for example, including the setting of the network delay time, but the setting values are different, such as the original configuration parameters are set to 100ms, the public test parameters are set to 120ms, and the self-use parameters are set to 125ms. The above example is only to illustrate the meaning of different values of the same field of the configuration parameters, and does not make any limitation on the specific implementation content.
[0075] According to an embodiment of the present invention, the original configuration parameters are called to overwrite the configuration of the database to be tested, so that the database to be tested restores the original configuration parameters.
[0076] According to an embodiment of the present invention, the original configuration parameters are backed up when they are obtained. After the test is completely completed or after the test results are generated, the backup of the original configuration parameters is directly overwritten by the configuration, which can ensure that the database is restored to a normal operating state without affecting the operation of the database.
[0077] In some specific embodiments of the present invention, original configuration parameters, public test parameters and self-use parameters may include different fields. The modification of public test parameters may be only for the parameters that need to be modified based on the original configuration parameters according to the test requirements. Other parameters still use the database default values. The modification of self-use parameters may exceed the fields of original configuration parameters and public test parameters to add new configuration parameters to better adapt to independent test projects. After all tests are completed and restarted, the database configuration will be restored to the default configuration parameters, i.e., the original configuration parameters. In this way, there is no need to back up all the parameters of the original configuration parameters, thereby reducing the workload of backing up the original configuration parameters.
[0078] According to an embodiment of the present invention, before generating common test parameters or after generating test results, the cluster where n test items are located is upgraded or rolled back, wherein the upgrade or rollback operation is used to keep the cluster where n test items are located in the same state before and after the test.
[0079] According to an embodiment of the present invention, before generating common test parameters, programming is performed through the database command interface, and the entire cluster upgrade steps are completed in combination with the system command interface coding. Correspondingly, after generating the test results, programming is performed through the database command interface, and the entire cluster rollback steps are completed in combination with the system command interface coding to keep the database to be tested at the same version before and after the test. The upgrade and rollback are only for the test process, and the version of the database to be tested will not be changed.
[0080] According to an embodiment of the present invention, before generating common test parameters, programming is performed through the database command interface, and the entire cluster rollback step is completed in combination with the system command interface coding. Conversely, after generating the test results, programming is performed through the database command interface, and the entire cluster upgrade step is completed in combination with the system command interface coding to keep the database to be tested in the same state before and after the test. Rollback and upgrade are only for the test process, and will not change the version of the database to be tested.
[0081] In some specific embodiments of the present invention, before performing database testing, the version of the database is 2.0. This test needs to test the new functions of version 1.0 of the database, so the database needs to be rolled back to version 1.0 for testing. After the test, it is upgraded back to version 2.0 before the test. Therefore, the database version will not be changed, and the database version can be rolled back as needed.
[0082] In some specific embodiments of the present invention, before performing a database test, the version of the database is 1.0. This test needs to test the functionality of version 2.0 of the database, so the database needs to be upgraded to version 2.0 for testing. After the test, it will be rolled back to version 1.0 before the test. Therefore, the database version will not be changed, and the database version can be upgraded as needed.
[0083] According to an embodiment of the present invention, programming can be performed through the database command interface on the database to be tested, and the entire installation step can be completed in combination with the system command interface coding; conversely, programming can be performed through the database command interface after the test is completed, and the entire uninstallation step can be completed in combination with the system command interface coding.
[0084] Figure 4 A schematic diagram of database automated functional testing operations according to an embodiment of the present invention is shown.
[0085] According to an embodiment of the present invention, the following is combined with Shell programming language Figure 4The process of implementing automated testing of a simple function is explained in detail in the above steps.
[0086] Configuration file settings, the configuration content is as follows:
[0087] [Init_Database_Config_Set]#Public test parameter configuration file setting tag
[0088] Use=true#true means the item is processed
[0089] [Add_Seg] #Secondary tag, add parameter tag, if not, do not add
[0090] Parameter name 1 = value 1
[0091] [Delete_Seg]# Secondary tag, delete parameter tag, if there is no tag, no tag will be added
[0092] Parameter name 2
[0093] [Modify_Seg]#Secondary tag, modify parameter value tag, if not, do not add
[0094] Parameter name 3 = value 3
[0095] [Test]#Functional main test module, required test process, no Use
[0096] Test1=Independent test project 1.sh
[0097] Test2=Independent test project 2.sh
[0098] [Clear_Database_Config_Set]#Restore the original database configuration file setting tag
[0099] Use=true#true means the item is processed
[0100] According to an embodiment of the present invention, Figure 4In S402, when the public test parameter configuration tag [Init_Database_Config_Set] of the configuration file of the database to be tested in the initialization work is read, when the code determines that the Use parameter of [Init_Database_Config_Set] is true, it will automatically call the corresponding script "Init_Database_Config_Set.sh" of the database configuration module under the initialization work module; because it has a secondary tag in the configuration file, the script will first back up the configuration file, and then analyze the secondary tags under it one by one, and in the secondary tags, the corresponding content will be processed differently according to the different processing tags. Since the Use parameter of [Init_Database_Config_Set] is true, after modifying the configuration file, the cluster restart operation will be executed through the cluster interface command to make the parameter configuration effective.
[0101] According to an embodiment of the present invention, Figure 4 In S403~S406, the functional main body test module [Test] is read. This module is a must-test content, so there is no need to judge the parameter Use. Instead, the corresponding shell scripts of each test item are directly corresponded one by one with parameters such as Test1, Test2...Test n, and these Shell scripts are called in sequence to complete the test of each test item in turn.
[0102] According to an embodiment of the present invention, in the [Test] independent test project test, coupling between each individual test project is avoided as much as possible, and the database cluster state can be restored by restarting each node of the cluster. At this time, the [Init_Database_Config_Set] configuration file setting plays a role in successfully setting the public test parameter environment. Each individual test project can be implemented through the database interface in the Shell script through the method of setting the database self-use parameters, without adding label processing, to achieve their own parameter configuration. Once the database cluster is restarted, these set parameters will be restored and will not affect subsequent test projects. Through the [Init_Database_Config_Set] configuration file setting, the purpose of both unifying the public parameters and setting the self-use parameters for each test project separately through the interface settings is achieved.
[0103] According to an embodiment of the present invention, Figure 4In S407, each shell script executes the corresponding SQL statement or SQL script according to the needs of the actual function item, and then verifies the execution result according to expectations, and / or verifies the cluster status through cluster commands, and / or verifies the generated files through system commands, and / or verifies the system status through system commands, etc. Once the verification result meets the expectations, the result of the test item is Pass, and the test records 1, 2...n of this independent test item will be generated.
[0104] All test records will be written into the test results uniformly, such as: result.log. When all independent test items are executed, the test result file result.log can be automatically read to retrieve all test item results, and all results can be printed to the command line. When all test items are Pass, the final test conclusion is Pass, otherwise the final test conclusion is Fail.
[0105] According to an embodiment of the present invention, Figure 4 In S408, when the database configuration file setting tag [Clear_Database_Config_Set] is read, when the code determines that its Use parameter is true, it will automatically call the corresponding script "Clear_Database_Config_Set.sh". This script restores the common test parameters. At this time, the Shell script uses the system command to overwrite the existing configuration file with the configuration file backed up when the original configuration parameters are initialized in step S401, and then executes the cluster restart operation through the cluster interface command to restore the original configuration parameters of the database under test.
[0106] According to the embodiment of the present invention, combined with the above configuration content, it can be seen that by processing the first-level tags one by one, except for the Test tag without the Use parameter, each first-level tag has a Use parameter, and when the parameter is true, it indicates that this item needs to be processed and executed. By setting the first-level and second-level tags, the entire test function can be automatically performed, and all independent test items are tested under unified public test parameters, which will not affect each other, and the problem or error caused by the previous test item will not be carried over to the next test item, making the next test item inaccurate. The entire test process is automated and tested from beginning to end. At the same time, the test results can be quickly judged by generating the test results of each test item. In the case of a test failure, the problem can be quickly found, saving manpower and material resources and being convenient and fast.
[0107] Figure 5 A structural block diagram of a database automated functional testing device according to an embodiment of the present invention is shown.
[0108] like Figure 5As shown, the database automated functional testing device 500 of this embodiment includes an acquisition module 510 , a configuration module 520 and a testing module 530 .
[0109] The acquisition module 510 is used to acquire the original configuration parameters of the database to be tested. In one embodiment, the acquisition module 510 can be used to perform the operation S201 described above, which will not be described in detail here.
[0110] The configuration module 520 is used to modify the original configuration parameters according to the overall test requirements to generate common test parameters, which are used to make the test environment meet the test running standard. In one embodiment, the configuration module 520 can be used to perform the operation S202 described above, which will not be repeated here.
[0111] The test module 530 is used to perform n functional tests on the database to be tested for n independent test items and generate test results. In one embodiment, the test module 530 can be used to perform the operation S203 described above, which will not be described in detail here.
[0112] According to an embodiment of the present invention, the test module 530 includes a first execution unit, a second test unit, and a third execution unit.
[0113] The first execution unit is used to modify the public test parameters to generate self-use parameters, wherein the self-use parameters are dedicated configuration parameters for executing independent test items. In one embodiment, the first execution unit can be used to execute the operation S301 described above, which will not be repeated here.
[0114] The second test unit is used to call the independent test item to perform a functional test based on the self-use parameter, and generate a test record of the test item, wherein the test record is passed or failed, wherein, when the test record is failed, the failed item information of the independent test item is recorded. In one embodiment, the second test unit can be used to perform the operation S302 described above, which will not be repeated here.
[0115] The third execution unit is used to restart the cluster where the independent test project is located, to initialize the cluster environment, and to restore the database to be tested to the common test parameter configuration. In one embodiment, the third execution unit can be used to perform the operation S303 described above, which will not be repeated here.
[0116] According to an embodiment of the present invention, at least one of the acquisition module 510, the configuration module 520 and the test module 530 may be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or may be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in an appropriate combination of any of them. Alternatively, at least one of the acquisition module 510, the configuration module 520 and the test module 530 may be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function may be executed.
[0117] According to an embodiment of the present invention, the present invention generates common test parameters so that each test item is executed in the same configuration environment without interfering with each other, and the common test parameters can be configured according to test requirements and software and hardware conditions; the present invention automatically completes repetitive work and comparison work through full automation, and tests to the end, exposing all problems as soon as possible so that they can be analyzed and solved one by one, and the test record information of all independent test items can be reflected in the test results. At the same time, various test requirements can be met by flexibly adding and deleting independent test items.
[0118] Figure 6 A block diagram of an electronic device for a database automated functional testing method according to an embodiment of the present invention is schematically shown.
[0119] like Figure 6 As shown, the electronic device 600 according to an embodiment of the present invention includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 to a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0120] In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other via bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in the one or more memories.
[0121] According to an embodiment of the present invention, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the input / output (I / O) interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.
[0122] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.
[0123] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present invention, the computer-readable storage medium may include the ROM 602 and / or RAM 603 described above and / or one or more memories other than ROM 602 and RAM 603.
[0124] The embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the above method provided by the embodiment of the present invention.
[0125] The computer program executes the above functions defined in the system / device of the embodiment of the present invention when it is executed by the processor 601. According to the embodiment of the present invention, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0126] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0127] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above functions defined in the system of the embodiment of the present invention are performed. According to the embodiment of the present invention, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0128] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0129] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0130] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present invention may be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments of the present invention may be combined and / or combined in various ways. All of these combinations and / or combinations fall within the scope of the present invention.
[0131] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A database automated functional testing method, characterized in that: The following steps are involved: Get the original configuration parameters of the database to be tested; Modifying the original configuration parameters according to the overall test requirements to generate common test parameters, wherein the common test parameters are used to make the test environment meet the test running standard; Modify the configuration parameters based on the public test parameters to generate self-use parameters, wherein the self-use parameters are dedicated configuration parameters for executing independent test items, and based on the self-use parameters, call n independent test items to execute n functional tests on the database to be tested to generate test results, wherein n is a positive integer; the self-use parameters include network setting parameters, access permission parameters and system resource allocation parameters; Restarting the cluster where the independent test project is located to initialize the cluster environment so that the database to be tested is restored to the configuration of the common test parameters; Among them, the original configuration parameters, the public test parameters and the self-use parameters include the same fields, the public test parameters are changed in value based on the original configuration parameters, and the self-use parameters are changed in value based on the public test parameters to adapt to the operation of the independent test item.
2. The method according to claim 1, characterized in that Calling n independent test items to perform n functional tests on the database to be tested, and generating test results including: Calling each of the independent test items to perform one functional test on the database to be tested, and generating n groups of test records corresponding to the n independent test items; The test result is generated according to the n groups of test records.
3. The method according to claim 2, characterized in that The test record is passed or failed, wherein when the test record is failed, the failed item information of the independent test item is recorded.
4. The method according to claim 3, characterized in that Based on the self-use parameters, calling the independent test item to perform the functional test and generating the test record of the test item includes: Based on the self-use parameters, the corresponding SQL statement or database command of each independent test item is called to implement function triggering, and the verification is implemented with the corresponding test function in the database or system to be tested to generate the test record.
5. The method according to claim 1, characterized in that After generating the test results, the method further includes: The original configuration parameters are called to overwrite the configuration of the database to be tested, so that the database to be tested restores the original configuration parameters.
6. The method according to claim 1, characterized in that Also includes: Before generating the common test parameters or after generating the test results, the cluster where the n independent test items are located is upgraded or rolled back, wherein the upgrade or rollback operation is used to keep the cluster where the n independent test items are located in the same state before and after the test.
7. A database automated functional testing device, comprising an acquisition module, a configuration module and a test module, characterized in that: The acquisition module is used to acquire the original configuration parameters of the database to be tested; The configuration module is used to modify the original configuration parameters according to the overall test requirements to generate common test parameters, wherein the common test parameters are used to make the test environment meet the test operation standard; The test module is used to modify the configuration parameters based on the public test parameters to generate self-use parameters, wherein the self-use parameters are dedicated configuration parameters for executing independent test items, and based on the self-use parameters, n independent test items are called to execute n functional tests on the database to be tested to generate test results, wherein n is a positive integer; the self-use parameters include network setting parameters, access permission parameters and system resource allocation parameters; Restarting the cluster where the independent test project is located to initialize the cluster environment so that the database to be tested is restored to the configuration of the common test parameters; Among them, the original configuration parameters, the public test parameters and the self-use parameters include the same fields, the public test parameters are changed in value based on the original configuration parameters, and the self-use parameters are changed in value based on the public test parameters to adapt to the operation of the independent test item.
8. An electronic device, characterized in that: include: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
RRU automatic test method and device
CN109673017A