Automatic method and device for database exception test, equipment and medium
Through automated fault scenario templates and data comparison methods, the problem of low database abnormal test efficiency is solved, and efficient and accurate test results are achieved.
Patent Information
- Application Number
- CN202510607677.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-08-26
AI Technical Summary
Existing database exception testing methods are inefficient and prone to errors, especially when facing complex failure scenarios, the test efficiency is low and the probability of errors is high.
By obtaining predefined fault scenario templates, identify the target fault object, initiate business load based on load configuration information, inject faults with fault type configuration information, and compare standard test data and real-time test data to obtain target test results.
It realizes the automation of database exception testing, improves testing efficiency and accuracy, and can effectively discover potential system weaknesses.
Smart Images

Figure CN120540948A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to an automated method, device, equipment and medium for database anomaly testing. Background Art
[0002] In the daily development and testing of self-developed databases, it is necessary to perform abnormal testing on the product. That is, by simulating various abnormal situations (such as hardware failures, network interruptions, data corruption, etc.), the fault tolerance, recovery ability and stability of the database system in the face of unexpected events are verified, so as to discover potential system weaknesses and improve the robustness and resilience of the system.
[0003] In the existing technology, most of the testing tasks for these abnormal scenarios are completed manually. However, this abnormal testing method is time-consuming, labor-intensive, and prone to errors. At the same time, there are many types of fault scenarios, which makes it difficult to systematically manage the test scenarios. In addition, when more complex abnormal testing scenarios arise, such as when multiple faults need to be injected into the system under test at the same time, low testing efficiency and high error probability are likely to occur.
[0004] Therefore, the existing abnormality testing method has the problem of low testing efficiency. Summary of the Invention
[0005] The embodiments of the present invention provide an automated method, apparatus, device and medium for database anomaly testing, aiming to solve the problem of low testing efficiency in existing anomaly testing methods.
[0006] In a first aspect, an embodiment of the present invention provides an automated method for database anomaly testing, the method comprising:
[0007] Obtain a predefined fault scenario template; wherein the fault scenario template includes target fault object configuration information, load configuration information, and fault type configuration information;
[0008] Determine a target fault object according to the target fault object configuration information;
[0009] Initiate a service load on the target fault object according to the load configuration information to obtain standard test data;
[0010] Injecting a fault into the target fault object according to the fault type configuration information to obtain real-time test data;
[0011] The standard test data and the real-time test data are compared to obtain corresponding target test results.
[0012] In a second aspect, an embodiment of the present invention further provides an automated device for database anomaly testing, the device comprising:
[0013] A template acquisition unit, configured to acquire a predefined fault scenario template; wherein the fault scenario template includes target fault object configuration information, load configuration information, and fault type configuration information;
[0014] a determining unit, configured to determine a target fault object according to the target fault object configuration information;
[0015] A first acquiring unit is configured to initiate a service load on the target fault object according to the load configuration information to obtain standard test data;
[0016] A second acquisition unit is configured to inject a fault into the target fault object according to the fault type configuration information to obtain real-time test data;
[0017] The target test result acquisition unit is used to compare the standard test data and the real-time test data to obtain a corresponding target test result.
[0018] In a third aspect, an embodiment of the present invention further provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the method described in the first aspect when executing the computer program.
[0019] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the method described in the first aspect can be implemented.
[0020] The present invention provides an automated method, apparatus, device, and medium for database anomaly testing. The method comprises: obtaining a predefined fault scenario template; wherein the fault scenario template includes target fault object configuration information, load configuration information, and fault type configuration information; determining a target fault object based on the target fault object configuration information; initiating a service load on the target fault object based on the load configuration information to obtain standard test data; injecting a fault into the target fault object based on the fault type configuration information to obtain real-time test data; and comparing the standard test data and the real-time test data to obtain a corresponding target test result. The embodiments of the present invention can automatically perform anomaly testing on a target fault object through a predefined fault scenario template. This automated approach can effectively improve test efficiency and test accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0022] Figure 1 A schematic diagram of a flow chart of an automated method for database anomaly testing provided by an embodiment of the present invention;
[0023] Figure 2 A schematic block diagram of an automated device for database anomaly testing provided by an embodiment of the present invention;
[0024] Figure 3 A schematic block diagram of an electronic device provided in an embodiment of the present invention;
[0025] Figure 4 A schematic diagram of an application environment for an automated method for database anomaly testing provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0027] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0028] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the present invention. As used in the specification and appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0029] It should be further understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations. The embodiment of the present invention provides an automated method, apparatus, device and medium for database anomaly testing. The automated method for database anomaly testing can be found in Figure 4 , Figure 4 Schematic diagram of the application environment of the automated method for database anomaly testing provided by an embodiment of the present invention. The automated method for database anomaly testing is applied in Figure 4 In an application environment, a computer device communicates with at least one host device via a network; the computer device may be a server or a personal computer, wherein the server may be implemented as an independent server or a server cluster consisting of multiple servers; and the host device may be, but is not limited to, a server, a smartphone, a tablet computer, a desktop computer, or other electronic device. The present invention is described in detail below using specific embodiments.
[0030] Figure 1 The flowchart of the automated method for database anomaly testing provided by the embodiment of the present invention is as follows. Figure 1 As shown, the method includes the following steps S110-S150.
[0031] S110. Obtain a predefined fault scenario template; wherein the fault scenario template includes target fault object configuration information, load configuration information, and fault type configuration information.
[0032] In this embodiment, the staff quickly creates a fault scenario template on the front-end interface of the computer device; wherein, the fault scenario template includes target fault object configuration information, load configuration information and fault type configuration information; the target fault object configuration information includes information such as the host address and the tested database; the load configuration information includes information such as the tested database, the designated port and the number of concurrent users; the fault type configuration information includes the fault type, fault parameters and fault execution parameters; wherein, the fault type includes but is not limited to network failure, disk failure, etc.
[0033] The target host device is determined according to the host address, a connection is established with the tested database (i.e., the target fault object) of the target host device according to the designated port, and the number of users interacting with the tested database at the same time is simulated according to the concurrent number of users; the present invention relates to multiple fields such as medical care and finance, Example 1: in the field of financial applications, the tested database may be a transaction database, and when the concurrent number of users is set to 5, 5 virtual users may be simulated according to the concurrent number of users to simultaneously perform operations such as account balance query, transfer and remittance, and transaction record update on the transaction database; Example 2: in the field of medical applications, the tested database may be an electronic medical record database, and when the concurrent number of users is set to 5, 5 virtual users may be simulated according to the concurrent number of users to simultaneously perform operations such as medical record query, writing, and updating on the electronic medical record database.
[0034] In one embodiment, after step S110, the method further includes: when a template adjustment instruction is detected, generating a new fault scenario template according to the adjustment information in the template adjustment instruction; wherein the new fault scenario template includes new target fault object configuration information, new load configuration information and new fault type configuration information.
[0035] In this embodiment, staff can quickly create or adjust fault scenario templates according to different business needs. The template design makes the definition and management of fault scenarios more flexible, thereby improving testing efficiency and achieving the purpose of improving abnormal test coverage.
[0036] For the convenience of description, taking the financial scenario as an example, the staff adjusts the target fault object configuration information in the fault scenario template, and adjusts the "bank internal business database of host device A" to "financial product database of host device A". After the adjustment is completed, click the "OK" button to generate the corresponding template adjustment instruction. At this time, the adjustment information in the template adjustment instruction is "Adjust "bank internal business database of host device A" to "financial product database of host device A". A new fault scenario template is generated based on the adjustment information. In the new fault scenario template, the new target fault object configuration information is "financial product database of host device A".
[0037] S120: Determine a target fault object according to the target fault object configuration information.
[0038] In this embodiment, the target fault object configuration information includes information such as the host address and the database under test, and the target fault object (i.e., the database under test) is determined based on the target fault object configuration information; for example, the target fault object can be the "electronic medical record database of host device B."
[0039] S130: Initiate a service load to the target fault object according to the load configuration information to obtain standard test data.
[0040] In this embodiment, the load configuration information includes information such as the tested database, the designated port, and the number of concurrent users; a connection is established with the tested database (i.e., the target fault object) according to the designated port, and a business load is initiated to the target fault object according to the concurrent user number and continues for a preset period of time to obtain standard test data; wherein, the standard test data includes standard TPS (Transactions Per Second) and standard QPS (Queries Per Second).
[0041] For the convenience of description, take the medical business scenario as an example: when the target fault object is the electronic medical record database and the number of concurrent users is 5, use a test tool (such as pgbench) to simulate 5 virtual users to simultaneously write and query medical records on the electronic medical record database for a preset period of time, and obtain relatively stable TPS and QPS within the preset period of time. The TPS is used as the standard TPS, and the QPS is used as the standard QPS. The standard TPS and the standard QPS refer to the number of transactions processed per second and the number of queries that can be responded to per second by the electronic medical record database under normal circumstances. The standard TPS and the standard QPS are used as the standard test data.
[0042] S140: Inject a fault into the target fault object according to the fault type configuration information to obtain real-time test data.
[0043] In this embodiment, a business load is initiated to the target fault object according to the load configuration information. After a preset period of time, a fault is injected into the target fault object according to the fault type configuration information. At the same time, real-time test data is recorded; wherein, the injected fault can be a single fault or a superimposed, multi-dimensional fault. The injected fault can be "network delay" or "disk X failure" or "network delay + disk X failure", etc.; the real-time test data includes real-time TPS and real-time QPS. The real-time TPS and the real-time QPS refer to the number of transactions processed per second and the number of queries that can be responded to per second by the target fault object (i.e., the database under test) under abnormal circumstances.
[0044] In one embodiment, step S140 includes: determining the fault type, fault parameters, and fault execution parameters according to the fault type configuration information; and cyclically executing the step of injecting faults into the target fault object according to the fault type and fault parameters according to the fault execution parameters and recording real-time test data.
[0045] In this embodiment, the fault type configuration information includes fault type, fault parameters and fault execution parameters; wherein, the fault type includes but is not limited to network failure, disk failure, etc., and the fault execution parameters include fault interval running time and fault execution times.
[0046] For ease of description, take a network failure as an example: when the fault parameters are "inject a 15-second network delay fault, and automatically recover after the fault lasts for 30 seconds", the fault interval running time is "20 seconds", and the number of fault executions is "3 times", the following steps are performed: inject a 15-second network delay fault into the target fault object every 20 seconds, and automatically recover after the fault lasts for 30 seconds. The task is executed 3 times in succession; after the fault is injected, the real-time TPS and the real-time QPS are monitored as the real-time test data.
[0047] In one embodiment, after step S140 , the method further includes: displaying the standard test data and the real-time test data in a chart format.
[0048] In this embodiment, the transaction number and query rate of the target fault object can be monitored by promethus to obtain the standard test data and the real-time test data; wherein, the standard test data includes standard TPS and standard QPS, and the real-time test data includes real-time TPS and real-time QPS; promethus outputs the monitored data to Grafana, which is a visualization tool that can intuitively display the received data through charts and the like.
[0049] S150: Compare the standard test data and the real-time test data to obtain corresponding target test results.
[0050] In this embodiment, the standard test data is the standard TPS and standard QPS, and the real-time test data is the real-time TPS and real-time QPS. The standard test data and the real-time test data are compared to determine whether the real-time TPS and the real-time QPS have changed. If no significant change occurs, the target test result of test passing is obtained; if the real-time TPS and / or the real-time QPS changes significantly, and the degree of change exceeds a preset threshold, it can be considered that in this fault scenario, the target fault object (i.e., the database under test) has a potential problem, and the target test result of test failure is obtained.
[0051] In one embodiment, step S150 includes: determining a target floating range based on a preset threshold and the standard test data; judging whether the real-time test data is always within the target floating range to obtain a judgment result; if the judgment result is yes, obtaining a target test result of test passing; if the judgment result is no, obtaining a target test result of test failure.
[0052] In this embodiment, the target floating range includes a first target floating range and a second target floating range, wherein the first target floating range is determined according to the preset threshold and the standard TPS, and the second target floating range is determined according to the standard QPS; it is judged whether the real-time TPS is always within the first target floating range and whether the real-time QPS is always within the second target floating range to obtain a judgment result; if the judgment result is yes (that is, the real-time TPS is always within the first target floating range, and the real-time QPS is always within the second target floating range), the target test result of test passing is obtained; if the judgment result is no (that is, the real-time TPS exceeds the first target floating range and / or the real-time QPS exceeds the second target floating range), the target test result of test failure is obtained.
[0053] In one embodiment, if the judgment result is no, after obtaining the target test result of test failure, the method further includes: generating corresponding first abnormality prompt information according to the standard test data and the real-time test data.
[0054] In this embodiment, corresponding first abnormal prompt information is generated according to the standard test data and the real-time test data to prompt the staff to promptly maintain the target fault object; wherein, the first abnormal prompt information can be presented in the form of "chart + text".
[0055] In one embodiment, after step S150, it also includes: performing multiple repeated tests on the target fault object based on the fault scenario template and the preset number of tests to obtain multiple target test results; obtaining a test pass rate based on the multiple target test results; if the test pass rate is less than a preset pass rate threshold, generating a corresponding second abnormal prompt information based on the test pass rate and the pass rate threshold.
[0056] In this embodiment, the target fault object is repeatedly tested multiple times based on the fault scenario template and the preset number of tests to obtain multiple target test results; the test pass rate is obtained based on the multiple target test results; for example, when the number of tests is 100 times, the target fault object is repeatedly tested multiple times based on the fault scenario template and the preset number of tests to obtain 100 target test results; when 98 target test results pass the test and 2 target test results fail the test, the obtained test pass rate is 98%; if the test pass rate is greater than or equal to the preset pass rate threshold, it is determined that the target fault object has passed the test of the fault scenario template; if the test pass rate is less than the preset pass rate threshold, it can be considered that there is a potential problem with the target fault object. At this time, a corresponding second abnormal prompt information is generated based on the test pass rate and the pass rate threshold to prompt the staff to maintain the target fault object.
[0057] In summary, the embodiments of the present invention can automatically perform abnormal testing on the target fault object through predefined fault scenario templates. This automated approach can effectively improve test efficiency and test accuracy.
[0058] Figure 2 A schematic block diagram of an automated device for database anomaly testing provided by an embodiment of the present invention. Figure 2 As shown, corresponding to the above automated method for database anomaly testing, the present invention also provides an automated device for database anomaly testing, the device being configured as follows Figure 4 In an application environment, a computer device communicates with at least one host device via a network; the computer device may be a server or a personal computer, wherein the server may be implemented as an independent server or a server cluster consisting of multiple servers; the host device may be, but is not limited to, a server, a smart phone, a tablet computer, a desktop computer, or other electronic device. Figure 2 The automated device 700 for database anomaly testing includes:
[0059] The template acquisition unit 701 is configured to acquire a predefined fault scenario template; wherein the fault scenario template includes target fault object configuration information, load configuration information, and fault type configuration information;
[0060] A determining unit 702 is configured to determine a target fault object according to the target fault object configuration information;
[0061] A first acquiring unit 703 is configured to initiate a service load on the target fault object according to the load configuration information to obtain standard test data;
[0062] A second acquiring unit 704 is configured to inject a fault into the target fault object according to the fault type configuration information to obtain real-time test data;
[0063] The target test result obtaining unit 705 is configured to compare the standard test data and the real-time test data to obtain a corresponding target test result.
[0064] In some embodiments, when performing the step of comparing the standard test data and the real-time test data to obtain the corresponding target test result, the target test result obtaining unit 705 is specifically configured to:
[0065] Determine the target floating range based on the preset threshold and the standard test data;
[0066] Determine whether the real-time test data is always within the target floating range, and obtain a determination result;
[0067] If the judgment result is yes, the target test result of passing the test is obtained;
[0068] If the judgment result is no, the target test result of test failure is obtained.
[0069] In some embodiments, after executing the step of obtaining a target test result indicating a test failure if the judgment result is negative, the target test result obtaining unit 705 is further configured to:
[0070] Generate corresponding first abnormal prompt information according to the standard test data and the real-time test data.
[0071] In some embodiments, when executing the step of injecting a fault into the target fault object according to the fault type configuration information to obtain real-time test data, the second obtaining unit 704 is specifically configured to:
[0072] Determine the fault type, fault parameters and fault execution parameters according to the fault type configuration information;
[0073] The steps of injecting faults into the target fault object according to the fault type and fault parameters are cyclically executed according to the fault execution parameters, and real-time test data is recorded.
[0074] In some embodiments, after performing the step of comparing the standard test data and the real-time test data to obtain the corresponding target test result, the target test result obtaining unit 705 is further configured to:
[0075] Repeat the test on the target fault object multiple times based on the fault scenario template and the preset test times to obtain multiple target test results;
[0076] Obtaining a test pass rate according to the plurality of target test results;
[0077] If the test pass rate is less than a preset pass rate threshold, corresponding second abnormality prompt information is generated based on the test pass rate and the pass rate threshold.
[0078] In some embodiments, after executing the step of obtaining a predefined fault scenario template, the template obtaining unit 701 is further configured to:
[0079] If a template adjustment instruction is detected, a new fault scenario template is generated according to the adjustment information in the template adjustment instruction; wherein the new fault scenario template includes new target fault object configuration information, new load configuration information and new fault type configuration information.
[0080] In some embodiments, after executing the step of injecting a fault into the target fault object according to the fault type configuration information to obtain real-time test data, the second obtaining unit 704 is further configured to:
[0081] The standard test data and the real-time test data are displayed in a graphical form.
[0082] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned automated device and each unit of the database anomaly test can refer to the corresponding description in the aforementioned method embodiment. For the convenience and brevity of the description, it will not be repeated here.
[0083] The above-mentioned automated device for database anomaly testing can be implemented in the form of a computer program. The computer program can be used in Figure 3 Runs on the electronic devices shown.
[0084] See also Figure 3 , Figure 3 8 is a schematic block diagram of an electronic device provided by an embodiment of the present invention. The electronic device 800 can be a terminal or a server, wherein the terminal can be an electronic device with communication functions. The server can be a standalone server or a server cluster consisting of multiple servers.
[0085] See Figure 3 The electronic device 800 includes a processor 802 , a memory, and a network interface 805 connected via a system bus 801 , wherein the memory may include a non-volatile storage medium 803 and an internal memory 804 .
[0086] The non-volatile storage medium 803 can store an operating system 8031 and a computer program 8032. The computer program 8032 includes program instructions, which, when executed, can enable the processor 802 to execute an automated method for database anomaly testing.
[0087] The processor 802 is used to provide computing and control capabilities to support the operation of the entire electronic device 800.
[0088] The internal memory 804 provides an environment for the operation of the computer program 8032 in the non-volatile storage medium 803. When the computer program 8032 is executed by the processor 802, the processor 802 can execute an automated method for database anomaly testing.
[0089] The network interface 805 is used to communicate with other devices over the network. Figure 3The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present invention, and does not constitute a limitation on the electronic device 800 to which the solution of the present invention is applied. The specific electronic device 800 may include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0090] The processor 802 is configured to execute a computer program 8032 stored in the memory to implement the following steps:
[0091] Obtain a predefined fault scenario template; wherein the fault scenario template includes target fault object configuration information, load configuration information, and fault type configuration information;
[0092] Determine a target fault object according to the target fault object configuration information;
[0093] Initiate a service load on the target fault object according to the load configuration information to obtain standard test data;
[0094] Injecting a fault into the target fault object according to the fault type configuration information to obtain real-time test data;
[0095] The standard test data and the real-time test data are compared to obtain corresponding target test results.
[0096] In some embodiments, when the processor 802 compares the standard test data and the real-time test data to obtain the corresponding target test result, the processor 802 specifically implements the following steps:
[0097] Determine the target floating range based on the preset threshold and the standard test data;
[0098] Determine whether the real-time test data is always within the target floating range, and obtain a determination result;
[0099] If the judgment result is yes, the target test result of passing the test is obtained;
[0100] If the judgment result is no, the target test result of test failure is obtained.
[0101] In some embodiments, after implementing the step of obtaining a target test result indicating test failure if the determination result is negative, the processor 802 further implements the following steps:
[0102] Generate corresponding first abnormal prompt information according to the standard test data and the real-time test data.
[0103] In some embodiments, when implementing the step of injecting a fault into the target fault object according to the fault type configuration information to obtain real-time test data, the processor 802 specifically implements the following steps:
[0104] Determine the fault type, fault parameters and fault execution parameters according to the fault type configuration information;
[0105] The steps of injecting faults into the target fault object according to the fault type and fault parameters are cyclically executed according to the fault execution parameters, and real-time test data is recorded.
[0106] In some embodiments, after the processor 802 implements the step of comparing the standard test data and the real-time test data to obtain the corresponding target test result, it further implements the following steps:
[0107] Repeat the test on the target fault object multiple times based on the fault scenario template and the preset test times to obtain multiple target test results;
[0108] Obtaining a test pass rate according to the plurality of target test results;
[0109] If the test pass rate is less than a preset pass rate threshold, corresponding second abnormality prompt information is generated based on the test pass rate and the pass rate threshold.
[0110] In some embodiments, after implementing the step of obtaining a predefined fault scenario template, the processor 802 further implements the following steps:
[0111] If a template adjustment instruction is detected, a new fault scenario template is generated according to the adjustment information in the template adjustment instruction; wherein the new fault scenario template includes new target fault object configuration information, new load configuration information and new fault type configuration information.
[0112] In some embodiments, after implementing the step of injecting a fault into the target fault object according to the fault type configuration information to obtain real-time test data, the processor 802 further implements the following steps:
[0113] The standard test data and the real-time test data are displayed in a graphical form.
[0114] It should be understood that in the embodiment of the present invention, the processor 802 may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0115] Those skilled in the art will appreciate that all or part of the steps in the method of the above-described embodiment can be implemented by instructing the relevant hardware through a computer program. The computer program includes program instructions, which can be stored in a storage medium that is computer-readable. The program instructions are executed by at least one processor in the computer system to implement the steps in the method of the above-described embodiment.
[0116] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor performs the following steps:
[0117] Obtain a predefined fault scenario template; wherein the fault scenario template includes target fault object configuration information, load configuration information, and fault type configuration information;
[0118] Determine a target fault object according to the target fault object configuration information;
[0119] Initiate a service load on the target fault object according to the load configuration information to obtain standard test data;
[0120] Injecting a fault into the target fault object according to the fault type configuration information to obtain real-time test data;
[0121] The standard test data and the real-time test data are compared to obtain corresponding target test results.
[0122] In one embodiment, when the processor executes the program instructions to compare the standard test data and the real-time test data to obtain the corresponding target test result, the processor specifically implements the following steps:
[0123] Determine the target floating range based on the preset threshold and the standard test data;
[0124] Determine whether the real-time test data is always within the target floating range, and obtain a determination result;
[0125] If the judgment result is yes, the target test result of passing the test is obtained;
[0126] If the judgment result is no, the target test result of test failure is obtained.
[0127] In one embodiment, after executing the program instructions to implement the step of obtaining a target test result indicating test failure if the judgment result is negative, the processor further implements the following steps:
[0128] Generate corresponding first abnormal prompt information according to the standard test data and the real-time test data.
[0129] In one embodiment, when the processor executes the program instructions to implement the step of injecting a fault into the target fault object according to the fault type configuration information and obtaining real-time test data, the processor specifically implements the following steps:
[0130] Determine the fault type, fault parameters and fault execution parameters according to the fault type configuration information;
[0131] The steps of injecting faults into the target fault object according to the fault type and fault parameters are cyclically executed according to the fault execution parameters, and real-time test data is recorded.
[0132] In one embodiment, after the processor executes the program instructions to compare the standard test data and the real-time test data to obtain the corresponding target test result, it further implements the following steps:
[0133] Repeat the test on the target fault object multiple times based on the fault scenario template and the preset test times to obtain multiple target test results;
[0134] Obtaining a test pass rate according to the plurality of target test results;
[0135] If the test pass rate is less than a preset pass rate threshold, corresponding second abnormality prompt information is generated based on the test pass rate and the pass rate threshold.
[0136] In one embodiment, after executing the program instructions to implement the step of obtaining a predefined fault scenario template, the processor further implements the following steps:
[0137] If a template adjustment instruction is detected, a new fault scenario template is generated according to the adjustment information in the template adjustment instruction; wherein the new fault scenario template includes new target fault object configuration information, new load configuration information and new fault type configuration information.
[0138] In one embodiment, after executing the program instructions to inject a fault into the target fault object according to the fault type configuration information and obtain real-time test data, the processor further implements the following steps:
[0139] The standard test data and the real-time test data are displayed in a graphical form.
[0140] The storage medium may be any computer-readable storage medium that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk.
[0141] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0142] In the several embodiments provided herein, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the various units is merely a logical functional division, and actual implementation may employ other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.
[0143] The steps in the methods of the embodiments of the present invention may be adjusted in order, combined, or deleted as needed. The units in the devices of the embodiments of the present invention may be combined, divided, or deleted as needed. Furthermore, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit.
[0144] If this integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing an electronic device (such as a personal computer, terminal, or network device) to execute all or part of the steps of the method described in various embodiments of the present invention.
[0145] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. An automated method for database anomaly testing, characterized in that: The method comprises: Obtain a predefined fault scenario template; wherein the fault scenario template includes target fault object configuration information, load configuration information, and fault type configuration information; Determine a target fault object according to the target fault object configuration information; Initiate a service load on the target fault object according to the load configuration information to obtain standard test data; Injecting a fault into the target fault object according to the fault type configuration information to obtain real-time test data; The standard test data and the real-time test data are compared to obtain corresponding target test results.
2. The automated method for database anomaly testing according to claim 1, characterized in that: The comparing the standard test data and the real-time test data to obtain corresponding target test results includes: Determine the target floating range based on the preset threshold and the standard test data; Determine whether the real-time test data is always within the target floating range, and obtain a determination result; If the judgment result is yes, the target test result of passing the test is obtained; If the judgment result is no, the target test result of test failure is obtained.
3. The automated method for database anomaly testing according to claim 2, characterized in that: If the judgment result is no, after obtaining the target test result of test failure, the method further includes: Generate corresponding first abnormal prompt information according to the standard test data and the real-time test data.
4. The automated method for database anomaly testing according to claim 1, characterized in that: The injecting a fault into the target fault object according to the fault type configuration information to obtain real-time test data includes: Determine the fault type, fault parameters and fault execution parameters according to the fault type configuration information; The steps of injecting faults into the target fault object according to the fault type and fault parameters are cyclically executed according to the fault execution parameters, and real-time test data is recorded.
5. The automated method for database anomaly testing according to claim 1, characterized in that: After comparing the standard test data and the real-time test data to obtain corresponding target test results, the method further includes: Repeat the test on the target fault object multiple times based on the fault scenario template and the preset test times to obtain multiple target test results; Obtaining a test pass rate according to the plurality of target test results; If the test pass rate is less than a preset pass rate threshold, corresponding second abnormality prompt information is generated based on the test pass rate and the pass rate threshold.
6. The automated method for database anomaly testing according to claim 1, characterized in that: After obtaining the predefined fault scenario template, the method further includes: If a template adjustment instruction is detected, a new fault scenario template is generated according to the adjustment information in the template adjustment instruction; wherein the new fault scenario template includes new target fault object configuration information, new load configuration information and new fault type configuration information.
7. The automated method for database anomaly testing according to claim 1, characterized in that: After injecting a fault into the target fault object according to the fault type configuration information and obtaining real-time test data, the method further includes: The standard test data and the real-time test data are displayed in a graphical form.
8. An automated device for database anomaly testing, characterized in that: The device comprises: A template acquisition unit, configured to acquire a predefined fault scenario template; wherein the fault scenario template includes target fault object configuration information, load configuration information, and fault type configuration information; a determining unit, configured to determine a target fault object according to the target fault object configuration information; A first acquiring unit is configured to initiate a service load on the target fault object according to the load configuration information to obtain standard test data; A second acquisition unit is configured to inject a fault into the target fault object according to the fault type configuration information to obtain real-time test data; The target test result acquisition unit is used to compare the standard test data and the real-time test data to obtain a corresponding target test result.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the automated method for database anomaly testing according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The storage medium stores a computer program, which includes program instructions. When the program instructions are executed by a processor, the processor executes the automated method for database anomaly testing according to any one of claims 1 to 7.