Script data testing method and device, equipment, storage medium and program product

By executing fault detection and repair scripts in distributed clusters, fault injection and repair are automatically handled, which solves the problem of multiple fault types and difficult to estimate time consumption in high availability testing, and improves testing efficiency and cluster stability.

CN118796715AInactive Publication Date: 2024-10-18SUZHOU JIBEISI DATA TECHNOLOGY CO LTD +1

Patent Information

Application Number
CN202411275681.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2024-10-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

High availability testing in distributed clusters requires a lot of manpower and time costs due to the many types of faults and the difficulty in estimating the time required for faults and repairs, and it is difficult to achieve automated and repeatable fault detection and repair with existing technology.

Method used

By executing the fault detection script to identify the fault type, inject the corresponding fault type script and obtain the execution results, and then call the corresponding fault repair script to repair. Finally, based on the repair results, the test results of the distributed cluster database are determined, and the scripting method is used to realize the cycle Flexible and automated fault injection and repair.

Benefits of technology

It realizes the rapid discovery and repair of problems in distributed clusters, ensures that the cluster is always in a high-availability state, improves testing efficiency, reduces human errors, and enhances the stability of server nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796715A_ABST
    Figure CN118796715A_ABST
Patent Text Reader

Abstract

The invention provides a script data testing method and device, equipment, a storage medium and a program product, and can be applied to the technical field of database testing. The method comprises the following steps: in response to a script execution command, executing a fault detection script for a distributed cluster database to obtain a fault type; injecting a fault type script associated with the fault type into the distributed cluster database, so that the fault type script is executed in the distributed cluster database to obtain a fault execution result; calling a fault repair script corresponding to the fault execution result, and performing fault repair on the distributed cluster database to obtain a fault repair result; and determining a test result related to the distributed cluster database based on the fault repair result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database testing, and in particular to a script data testing method and device, equipment, storage medium and program product. Background Art

[0002] Distributed clusters are usually composed of multiple server nodes, which are distributed in different physical locations or virtual environments. The distributed cluster architecture can improve the reliability and performance of the system and keep the overall cluster available when some server nodes fail. High availability testing can verify the performance of the system in the face of various failures, such as node failures, network problems, resource exhaustion, etc., and then identify potential single-node failures to improve system design. However, high availability testing has many types of failures, it is difficult to predict the time it takes to fail and repair, and it requires a lot of manpower and time costs. Summary of the invention

[0003] In view of the above problems, the present invention provides a script data testing method and apparatus, device, storage medium and program product.

[0004] According to a first aspect of the present invention, there is provided a script data testing method, comprising:

[0005] In response to a script execution command, a fault detection script is executed for a distributed cluster database to obtain a fault type; a fault type script associated with the fault type is injected into the distributed cluster database so that the fault type script is executed in the distributed cluster database to obtain a fault execution result; a fault repair script corresponding to the fault execution result is called to perform fault repair on the distributed cluster database to obtain a fault repair result; and based on the fault repair result, a test result related to the distributed cluster database is determined.

[0006] Optionally, the fault type script is executed in the distributed cluster database, and the fault execution results include:

[0007] Obtain the target permissions of the distributed cluster database; obtain the calling information of the test component corresponding to the server node from the fault type script according to the server node address in the configuration file, wherein the calling information includes the test component path, connection process and corresponding physical file; based on the calling information, call the test component to execute the fault type script to obtain the fault execution result.

[0008] Optionally, the script data testing method also includes:

[0009] When the fault repair result indicates that the repair is successful, the first data and the second data are checked for data consistency to obtain a check result, wherein the first data indicates the table backup data in the cluster distributed database before the fault type script is injected, and the second data indicates the table repair data in the cluster distributed database after the repair is successful; when the fault repair result indicates that the repair is unsuccessful, the first data, the second data and the fault repair result are written to the monitoring log.

[0010] Optionally, performing a data consistency check on the first data and the second data, and obtaining a check result includes:

[0011] Perform a data consistency check on the first data and the second data according to the data table verification method to obtain a first verification result; perform a data consistency check on the hash value of the first data and the hash value of the second data to obtain a second verification result; and obtain a verification result based on the first verification result and the second verification result.

[0012] Optionally, the test component is called to execute the fault type script, and the fault execution results obtained include:

[0013] In the case where the fault type represents a lock conflict type, the distributed cluster database is connected to the first server node and the second server node respectively; the test component corresponding to the first server node is called to execute a first fault type script corresponding to the lock conflict type, wherein the first fault type script includes a first read-write operation script and a lock target table script for a target table in the distributed cluster database; the test component corresponding to the second server node is called to execute a second fault type script corresponding to the lock conflict type to obtain a fault execution result representing a successful fault injection, wherein the second fault type script includes a second read-write operation script for the target table.

[0014] Optionally, the test component is called to execute the fault type script, and the fault execution results obtained include:

[0015] When the fault type represents the type of insufficient CPU space, the test component is called to execute the fault type script corresponding to the type of insufficient CPU space to obtain a fault execution result representing successful fault injection, wherein the fault type script includes a loop-executed intensive task script and / or a parallel task script.

[0016] A second aspect of the present invention provides a script data testing device, comprising:

[0017] A response module, used to execute a fault detection script for a distributed cluster database in response to a script execution command to obtain a fault type;

[0018] An injection module is used to inject a fault type script associated with the fault type into the distributed cluster database, so that the fault type script is executed in the distributed cluster database to obtain a fault execution result;

[0019] A repair module, used to call a fault repair script corresponding to the fault execution result, perform fault repair on the distributed cluster database, and obtain a fault repair result; and

[0020] The determination module is used to determine the test results related to the distributed cluster database based on the fault repair results.

[0021] The third aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned script data testing method.

[0022] The fourth aspect of the present invention also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned script data testing method.

[0023] The fifth aspect of the present invention also provides a computer program product, including a computer program, which implements the above-mentioned script data testing method when executed by a processor.

[0024] According to the script data testing method and apparatus, device, storage medium and program product provided by the present invention, by injecting a fault type script associated with the fault type into the distributed cluster database, executing the fault type script, and obtaining the fault execution result; according to the fault type, finding the corresponding fault repair script, repairing the fault according to the fault repair script, obtaining the fault repair result, and performing a cluster status check on the distributed cluster database according to the fault repair result. Since the distributed cluster database is tested after simulating the injection of faults and repairing the faults in advance, the periodic, automated and repeatable characteristics of high-availability fault type scripts and fault repair scripts can be used to quickly discover problems in the cluster and repair them, ensuring that the cluster is always in a highly available state; fault detection scripts, fault type scripts and fault repair scripts can be applied to high-availability testing in a variety of scenarios, which improves test efficiency, reduces human errors, and improves the stability of operation of each server node in the cluster. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The above 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:

[0026] Figure 1 An application scenario of the script data testing method according to an embodiment of the present invention is shown;

[0027] Figure 2 A flowchart of a script data testing method according to an embodiment of the present invention is shown;

[0028] Figure 3 An example schematic diagram of generating a test result according to an embodiment of the present invention is shown;

[0029] Figure 4 An example schematic diagram of a monitoring log according to an embodiment of the present invention is shown;

[0030] Figure 5 It shows a structural block diagram of a script data testing device according to an embodiment of the present invention;

[0031] Figure 6 A block diagram of an electronic device suitable for implementing a script data testing method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0032] 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.

[0033] 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 features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0034] 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.

[0035] 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.).

[0036] In the process of implementing the present invention, it is found that a distributed cluster is usually composed of multiple server nodes, and the server nodes are distributed in different physical locations or virtual environments, so that the distributed cluster architecture can improve the reliability and performance of the system, and keep the overall cluster available when some server nodes fail. High availability testing can verify the performance of the system in the face of various failures, such as node failures, network problems, resource exhaustion, etc., and then potential single-node failures can be discovered to improve the system design. However, high availability testing has the problems of multiple types of failures, failures and repairs that are difficult to predict, and require a lot of manpower and time costs.

[0037] In view of this, an embodiment of the present invention provides a script data testing method and apparatus, device, storage medium and program product. The method includes: in response to a script execution command, executing a fault detection script for a distributed cluster database to obtain a fault type; injecting a fault type script associated with the fault type into the distributed cluster database so that the fault type script is executed in the distributed cluster database to obtain a fault execution result; calling a fault repair script corresponding to the fault execution result to repair the distributed cluster database to obtain a fault repair result; and determining a test result related to the distributed cluster database based on the fault repair result.

[0038] 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 relevant laws, regulations and standards, 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.

[0039] Figure 1 An application scenario of the script data testing method according to an embodiment of the present invention is shown.

[0040] like Figure 1 As shown, the business system architecture 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 cluster 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 cluster server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0041] 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 cluster 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).

[0042] 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.

[0043] The cluster 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 cluster distributed database is deployed on the cluster server 105, and the cluster server 105 includes multiple server nodes that can analyze and process the received user request and other data, and feed back the processing results (such as web pages, information, or data obtained or generated according to the user request) to the terminal device.

[0044] It should be noted that the script data testing method provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the script data testing device provided in the embodiment of the present invention can generally be set in the server 105. The script data testing method provided in the embodiment of the present invention can also be executed 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 cluster server 105. Accordingly, the script data 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 cluster server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the cluster server 105.

[0045] Alternatively, the script data testing method provided in the embodiment of the present invention may also be executed by the first terminal device 101, the second terminal device 102 or the third terminal device 103, or may also be executed by other terminal devices different from the first terminal device 101, the second terminal device 102 or the third terminal device 103. Accordingly, the script data testing apparatus provided in the embodiment of the present invention may also be arranged in the first terminal device 101, the second terminal device 102 or the third terminal device 103, or may be arranged in other terminal devices different from the first terminal device 101, the second terminal device 102 or the third terminal device 103.

[0046] 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 the implementation requirements.

[0047] It should be noted that the sequence numbers of the operations in the following method are only used as representations of the operations for the purpose of description, and should not be regarded as representing the execution order of the operations. Unless explicitly stated, the method does not need to be executed completely in the order shown.

[0048] Figure 2 A flow chart of a script data testing method according to an embodiment of the present invention is shown.

[0049] like Figure 2 As shown, the method 200 includes operations S210 to S240.

[0050] In operation S210 , in response to a script execution command, a fault detection script is executed for a distributed cluster database to obtain a fault type.

[0051] Optionally, the script execution command represents a startup request for executing a fault detection script. The fault detection script records all fault types and type numbers corresponding to the fault types. The fault detection script also records the distributed cluster database name, fault type script path, and time interval range.

[0052] Optionally, the distributed cluster database is deployed on a cluster server node, and the server executes a fault detection script in response to a received script execution command to obtain a fault type.

[0053] Optionally, each fault type has an annotation and a corresponding type number in the fault detection script. When executing the fault detection script, the fault type script corresponding to the target type number can be directly injected or the type number can be randomly obtained and the corresponding fault type script can be injected.

[0054] For example, when the script execution command includes a target type number, the fault detection script is executed to match the fault type corresponding to the target type number; when the script execution command does not include a type number, the fault detection script is executed to randomly select a type number from all type numbers and match the fault type corresponding to the type number.

[0055] For example, the script execution command sh HA_xx_Automation.sh start 1 indicates the fault type with the execution type number 1. It stops immediately after being executed once, and no stop command operation is provided. If you need to stop, you can directly execute the exit command in the execution interface command.

[0056] Optionally, the fault type may be a data loss fault, a process abnormality fault, a node abnormality fault, etc.

[0057] Table 1 shows a table of correspondence between type numbers and fault types according to an embodiment of the present invention.

[0058]

[0059] Optionally, the random node data loss type failures in Table 1 are mainly aimed at the loss of physical files corresponding to the data; random node simulated disk type failures mainly include disk damage, node time asynchrony, data reading abnormalities and other scenarios; large concurrent business scenario types mainly include network card full, memory full and other scenarios; read and write test types will record the performance when processing read operations and write operations at the same time, such as the speed of reading data and the throughput of writing data; network fault test types include large delays, network jitter, limited network bandwidth, packet loss and other scenarios.

[0060] In operation S220, a fault type script associated with the fault type is injected into the distributed cluster database, so that the fault type script is executed in the distributed cluster database to obtain a fault execution result.

[0061] Optionally, the fault type script represents a programming language for simulating fault generation.

[0062] Optionally, a fault type script associated with the fault type is injected into the cluster server node where the distributed cluster database is located, and the fault type script is executed to obtain a fault execution result. The fault execution result indicates whether the injection is successful or failed.

[0063] Optionally, the execution of the fault type script requires that the current nodes of the cluster are in normal status. When stopping the fault type script, you can set it to wait for the fault injection to be completed and the cluster to be repaired before the fault type script automatically exits, or directly execute the exit command, such as "ctrl + C" to immediately stop and exit the execution program of the fault type script.

[0064] Optionally, the fault detection script also provides a help function. When an error occurs in executing a fault type script, the help function records the parameters used by the fault type script and their meanings.

[0065] In operation S230, a fault repair script corresponding to the fault execution result is called to perform fault repair on the distributed cluster database to obtain a fault repair result.

[0066] Optionally, the fault recovery script represents a program language for recovering the fault.

[0067] Optionally, when the fault execution result indicates that the injection is successful, the fault repair script is called to repair the cluster server node where the distributed cluster database is located to obtain a fault repair result. The fault repair result indicates that the repair is successful or failed.

[0068] Optionally, the time interval range in the fault detection script can be set according to the actual situation such as the amount of data in the distributed cluster database, and the time interval for each fault injection or fault repair can be modified. For example, a fault type script of type number 2 to 8 is randomly injected every 10 seconds to 100 seconds, and then the corresponding fault repair script is repaired after an interval of 100 seconds to 1000 seconds.

[0069] In operation S240 , based on the fault repair result, a test result related to the distributed cluster database is determined.

[0070] Optionally, a distributed cluster database test may be performed based on the fault repair result, such as a data verification test, a data recovery test, a load balancing test, a network fault test, etc., to obtain a test result. The test result represents the operating status of the cluster server node where the distributed cluster database is located.

[0071] For example, when the test result indicates that the cluster server node status is normal, the script execution command bound with the next type number is obtained; when the test result indicates that the cluster server node status is abnormal, the execution program is exited.

[0072] Optionally, since the distributed cluster database is tested after simulating the injection of faults in advance and repairing the faults, the high-availability fault type scripts and fault repair scripts are used to quickly discover problems in the cluster and repair them, ensuring that the cluster is always in a high-availability state; fault detection scripts, fault type scripts and fault repair scripts can be applied to high-availability testing in a variety of scenarios, which improves test efficiency, reduces human errors, and improves the stability of operation of each server node in the cluster.

[0073] Optionally, the fault type script is executed in the distributed cluster database, and the fault execution results include:

[0074] Obtain the target permissions of the distributed cluster database; obtain the calling information of the test component corresponding to the server node from the fault type script according to the server node address in the configuration file, wherein the calling information includes the test component path, connection process and corresponding physical file; based on the calling information, call the test component to execute the fault type script to obtain the fault execution result.

[0075] Optionally, the fault detection script, fault type script and fault repair script are delivered in the form of a complete compressed package. Each time the script is obtained, it is necessary to decompress the compressed package and then open the configuration manual. The configuration manual records the usage of all scripts, the content of the configuration file that needs to be modified, the target permissions that need to be obtained during the execution of each script, and the possible risks, so as to prevent the environment from crashing or data loss due to improper script operation.

[0076] Optionally, the target permission represents the administrator's operation permission, and different target permissions need to be set for different fault types.

[0077] For example, for network card and machine fault types, when injecting faults, you need to obtain the operating permissions of the administrator or super administrator to perform mandatory operations such as restarting the machine (reboot) or disabling the network interface (ifdown). In this case, you need to set the target permissions for execution by the administrator or super administrator in the configuration manual, and grant the script storage path (chmod -R 777) permissions to the fault type script and its path. If you do not need to execute this type of fault, use the target permissions for execution by ordinary users.

[0078] Optionally, after reading the configuration manual, you need to modify the configuration file. The configuration file needs to write the server node address of each test component, cluster distributed database information, and call information according to the cluster distributed database architecture. The server node addresses that make up each instance in the cluster are written in the order of the test component types in the cluster distributed database, so that different test components can be accurately called during the execution of the fault type script to inject different types of faults. The four contents of the cluster distributed database information need to be edited: library name, port number, user, and password.

[0079] Optionally, in the process of executing the fault type script corresponding to the fault type, it is necessary to call the test component corresponding to the injected fault type. For example, for injecting random component process faults and random node data loss faults, it is necessary to call four test components: coordinator, data node, global transaction manager, and high availability manager. Therefore, it is necessary to configure the file to obtain the corresponding call information.

[0080] Table 2 shows the test component types and functions according to an embodiment of the present invention.

[0081]

[0082] Optionally, the call information includes a test component path, a connection process, and a corresponding physical file. The test component path represents the location of the test component, the connection process represents the process established between the test component and the cluster server node, and the physical file represents the parameter configuration file required to call the test component.

[0083] Optionally, the test component is called according to the calling information, the fault type script is executed, and the fault execution result is obtained.

[0084] Figure 3 An example schematic diagram of generating a test result according to an embodiment of the present invention is shown.

[0085] like Figure 3 As shown, in response to the script execution command 301, a fault detection script is executed for the distributed cluster database to obtain a fault type 302; a fault type script 303 associated with the fault type is injected into the distributed cluster database; according to the server node address 304 in the configuration file, the call information 305 of the test component corresponding to the server node is obtained from the fault type script; based on the call information, the test component is called to execute the fault type script to obtain a fault execution result 306; the fault repair script 307 is executed to obtain a fault repair result 308; based on the fault repair result 308, the test result 309 related to the distributed cluster database is determined, and when the test result indicates that the cluster server node status is normal, the script execution command 301 bound to the next type number is obtained; when the test result indicates that the cluster server node status is abnormal, the execution program 310 is exited.

[0086] Optionally, the script data testing method also includes: when the fault repair result indicates that the repair is successful, performing a data consistency check on the first data and the second data to obtain a verification result, wherein the first data represents the table backup data in the cluster distributed database before the fault type script is injected, and the second data represents the table repair data in the cluster distributed database after the repair is successful; when the fault repair result indicates that the repair failed, writing the first data, the second data and the fault repair result to the monitoring log.

[0087] Optionally, when the fault repair result indicates that the repair is successful, a data consistency check is performed on the first data and the second data, for example, the first data before the fault injection and the second data after the fault repair are compared to see whether they are consistent, to obtain a check result. When the data are consistent, a check result indicating that the check is successful is obtained, otherwise a check result indicating that the check fails is obtained.

[0088] Optionally, the monitoring log includes a verification monitoring log and an execution monitoring log. The verification method, verification start time, verification end time, verification success or verification failure verification results are all written into the verification monitoring log.

[0089] Optionally, when the fault repair result indicates that the repair is successful, data recovery test, load balancing test, network fault test, etc. may also be performed.

[0090] Optional, data recovery test is used to test the backup recovery capability and specifications of the cluster distributed database. The backup recovery capability of the database is the ultimate guarantee of database high availability. After obtaining the fault repair result, you can execute the backup recovery script separately to restore the environment to its original state.

[0091] Optionally, the load balancing test is used to test whether requests can be evenly distributed to each server node after high-availability operations are performed on the cluster distributed database to prevent data skew. It can also test throughput and lock contention during concurrent read and write requests. The load balancing test script mainly connects to each server node through the server node address in the configuration file to perform network card checks and connect to the cluster distributed database, and performs data skew checks on each data node based on structured query statements.

[0092] Optionally, the network fault test script mainly simulates network anomalies that occur under non-human operation using the Transmission Control Protocol (TCP) tool.

[0093] Optionally, when the verification is successful and all tests are passed, a test result indicating that the cluster server node status is normal is obtained, a script execution command bound to the next type number is obtained, and a new fault is injected.

[0094] Optionally, if the verification fails, the execution program will be exited directly without injecting new faults.

[0095] Optionally, when encountering an unrepairable fault, a fault repair result indicating the repair failure is obtained. When the fault repair result indicates the repair failure, the first data, the second data and the fault repair result are written to the execution monitoring log, and a test result indicating that the cluster server node state is abnormal is obtained, and the execution program is directly exited.

[0096] Optionally, performing a data consistency check on the first data and the second data, and obtaining a check result includes:

[0097] Perform a data consistency check on the first data and the second data according to the data table verification method to obtain a first verification result; perform a data consistency check on the hash value of the first data and the hash value of the second data to obtain a second verification result; and obtain a verification result based on the first verification result and the second verification result.

[0098] Optionally, there are three data table verification methods. The first is to randomly select one or more data tables from the cluster distributed database. The first data is the table structure data and table content data before fault injection, and the second data is the table structure data and table content data after fault repair, and perform a complete query verification on the first data and the second data.

[0099] Optionally, the second method is to count whether the total number of rows in each data table has changed, the first data is the total number of rows before the fault injection, the second data is the total number of rows after the fault is repaired, and the table row number verification of the first data and the second data is performed.

[0100] Optionally, the third method is to randomly read the content of any one or more rows of a data table in the cluster distributed database. The first data is the content of one or more rows before the fault injection, and the second data is the content of one or more rows after the fault is repaired, and verify the data content of the first data and the second data. The response scenario is mainly a scenario with a small number of data tables but a large number of data rows.

[0101] Optionally, after obtaining a result of data consistency according to the data table verification method, a first verification result of recording content value being empty is obtained, otherwise a first verification result of recording data inconsistent content is obtained.

[0102] Optionally, the hash values ​​of the physical file addresses of all files in the data directory before the fault injection and after the fault repair are respectively obtained to obtain a second verification result with the same recorded hash values ​​or a second verification result with different recorded hash values.

[0103] Optionally, in case of a first verification result with an empty content value or a second verification result with the same hash value, a verification result indicating successful verification is obtained; otherwise, a verification result indicating failed verification is obtained.

[0104] Figure 4 An example schematic diagram of a monitoring log according to an embodiment of the present invention is shown.

[0105] like Figure 4 As shown, the execution monitoring log records the execution history of each script, including the injected fault type, the start and end time of fault injection, the intermediate waiting time, the start and end time of fault repair, and the repair time.

[0106] Optionally, when the script execution command 401 includes the target type number, the fault detection script is executed to match the fault type corresponding to the target type number; when the script execution command does not include the type number, the fault detection script is executed to randomly select a type number from all type numbers and match the fault type corresponding to the type number. The corresponding fault type script and fault repair script are determined according to the fault type; after the waiting time 402 selected by the random number is XX seconds, the timestamp of executing the fault type script is first recorded in the monitoring log 406, and then the fault type script 403 is executed. After the fault injection is completed, the current timestamp is recorded in the monitoring log 406.

[0107] Optionally, after a random number selection interval of 404XX seconds, first record the timestamp of executing the fault repair script in the monitoring log 406, and then execute the corresponding fault repair script 405. After the fault repair is completed, record the current timestamp in the monitoring log 406, and record the fault repair result and the verification result in the monitoring log 406; determine the test result 407 related to the distributed cluster database based on the fault repair result, and when the test result indicates that the cluster server node status is normal, obtain the script execution command 401 bound to the next type number; when the test result indicates that the cluster server node status is abnormal, automatically exit the execution program 408.

[0108] Optionally, the test component is called to execute the fault type script, and the fault execution results obtained include:

[0109] In the case where the fault type represents a lock conflict type, the distributed cluster database is connected to the first server node and the second server node respectively; the test component corresponding to the first server node is called to execute a first fault type script corresponding to the lock conflict type, wherein the first fault type script includes a first read-write operation script and a lock target table script for a target table in the distributed cluster database; the test component corresponding to the second server node is called to execute a second fault type script corresponding to the lock conflict type to obtain a fault execution result representing a successful fault injection, wherein the second fault type script includes a second read-write operation script for the target table.

[0110] Optionally, the first read-write operation script and the second read-write operation script can be used to query, delete, modify, etc. the target table using structured query statements. For example, the first read-write operation script updates a field value of the target table according to the first server node, and the second read-write operation script updates a field value of the target table according to the second server node. Since the target table locking script is executed while the first read-write operation script is executed, a lock conflict type fault is generated when the target table executes the second read-write operation script.

[0111] Optionally, the first server node executes a first fault type script corresponding to the lock conflict type, which requires calling a test component corresponding to the lock conflict type and deployed on the first server node, and then calling the test component corresponding to the first server node according to the calling information to execute the first fault type script corresponding to the lock conflict type.

[0112] Optionally, the second server node executes a second fault type script corresponding to the lock conflict type, which requires calling a test component corresponding to the lock conflict type and deployed on the second server node, and then calling the test component corresponding to the second server node according to the calling information to execute the second fault type script corresponding to the lock conflict type.

[0113] Optionally, the test component is called to execute the fault type script, and the fault execution results obtained include:

[0114] When the fault type represents the type of insufficient CPU space, the test component is called to execute the fault type script corresponding to the type of insufficient CPU space to obtain a fault execution result representing successful fault injection, wherein the fault type script includes a loop-executed intensive task script and / or a parallel task script.

[0115] Optionally, loop-executed intensive task scripts need to utilize a large amount of central processing unit computing resources, such as loop operation functions, mathematical calculations, etc.

[0116] Optionally, the number of parallel tasks and parallel execution commands are set in the parallel task script. Therefore, executing the fault type script will put too much pressure on the central processing unit, resulting in insufficient occupied space, and then injecting a fault of insufficient occupied space type of the central processing unit.

[0117] Optionally, the fault type may be further subdivided into multiple sub-fault types, and a fault type script may be executed to inject a fault corresponding to the fault type to simulate a fault scenario.

[0118] Table 3 shows a table of sub-fault types, fault scenarios, and fault type script execution logic according to an embodiment of the present invention.

[0119]

[0120] Based on the above script data testing method, the present invention also provides a script data testing device. Figure 5 The device is described in detail.

[0121] Figure 5 A structural block diagram of a script data testing device according to an embodiment of the present invention is shown.

[0122] like Figure 5As shown, the script data testing device 500 of this embodiment includes a response module 510 , an injection module 520 , a repair module 530 and a determination module 540 .

[0123] The response module 510 is used to execute the fault detection script for the distributed cluster database in response to the script execution command to obtain the fault type. In one embodiment, the response module 510 can be used to execute the operation S210 described above, which will not be described in detail here.

[0124] The injection module 520 is used to inject a fault type script associated with the fault type into the distributed cluster database so that the fault type script is executed in the distributed cluster database to obtain a fault execution result. In one embodiment, the injection module 520 can be used to perform the operation S220 described above, which will not be repeated here.

[0125] The repair module 530 is used to call the fault repair script corresponding to the fault execution result, perform fault repair on the distributed cluster database, and obtain the fault repair result. In one embodiment, the repair module 530 can be used to perform the operation S230 described above, which will not be repeated here.

[0126] The determination module 540 is used to determine the test result related to the distributed cluster database based on the fault repair result. In one embodiment, the determination module 540 can be used to perform the operation S240 described above, which will not be described in detail here.

[0127] Optionally, the injection module 520 includes an acquisition submodule, an execution submodule and a calling submodule.

[0128] Get submodule, used to obtain target permissions of distributed cluster database.

[0129] The execution submodule is used to obtain the calling information of the test component corresponding to the server node from the fault type script according to the server node address in the configuration file, wherein the calling information includes the test component path, the connection process and the corresponding physical file.

[0130] The calling submodule is used to call the test component to execute the fault type script based on the calling information and obtain the fault execution result.

[0131] Optionally, the script data testing device 500 further includes a first verification module and a second verification module.

[0132] The first verification module is used to perform data consistency verification on the first data and the second data to obtain a verification result when the fault repair result indicates that the repair is successful, wherein the first data represents the table backup data in the cluster distributed database before the fault type script is injected, and the second data represents the table repair data in the cluster distributed database after the repair is successful.

[0133] The second verification module is used to write the first data, the second data and the fault repair result into the monitoring log when the fault repair result indicates that the repair has failed.

[0134] Optionally, the first verification module includes a first verification submodule, a second verification submodule and a third verification submodule.

[0135] The first check submodule is used to perform a data consistency check on the first data and the second data according to a data table check method to obtain a first check result.

[0136] The second check submodule is used to perform data consistency check on the hash value of the first data and the hash value of the second data to obtain a second check result.

[0137] The third check submodule is used to obtain a check result according to the first check result and the second check result.

[0138] Optionally, the calling submodule includes a connecting unit, a first calling unit and a second calling unit.

[0139] The connection unit is used to connect to the distributed cluster database on the first server node and the second server node respectively when the fault type represents a lock conflict type.

[0140] The first calling unit is used to call the test component corresponding to the first server node to execute a first fault type script corresponding to the lock conflict type, wherein the first fault type script includes a first read and write operation script for a target table in a distributed cluster database and a lock target table script.

[0141] The second calling unit is used to call the test component corresponding to the second server node, execute the second fault type script corresponding to the lock conflict type, and obtain a fault execution result indicating that the fault injection is successful, wherein the second fault type script includes a second read and write operation script for the target table.

[0142] Optionally, the calling submodule also includes a third calling unit.

[0143] The third calling unit is used to call the test component when the fault type represents the type of insufficient CPU space usage, execute the fault type script corresponding to the type of insufficient CPU space usage, and obtain a fault execution result representing successful fault injection, wherein the fault type script includes a loop-executed intensive task script and / or a parallel task script.

[0144] Optionally, any multiple modules of the response module 510, the injection module 520, the repair module 530 and the determination module 540 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. Optionally, at least one of the response module 510, the injection module 520, the repair module 530 and the determination module 540 can 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 can 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 any appropriate combination of any of them. Alternatively, at least one of the response module 510, the injection module 520, the repair module 530 and the determination module 540 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be performed.

[0145] Figure 6 A block diagram of an electronic device suitable for implementing a script data testing method according to an embodiment of the present invention is shown.

[0146] Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0147] like Figure 6 As shown, a computer 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 into 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.

[0148] 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 programs 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 programs stored in one or more memories.

[0149] Optionally, 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.

[0150] Optionally, the method flow according to the embodiment of the present invention can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. 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-mentioned functions defined in the system of the embodiment of the present invention are executed. Optionally, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0151] 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 script data testing method according to the embodiment of the present invention is implemented.

[0152] Optionally, 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, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.

[0153] For example, optionally, the computer-readable storage medium may include the ROM 602 and / or the RAM 603 described above and / or one or more memories other than the ROM 602 and the RAM 603 .

[0154] An embodiment of the present invention also includes a computer program product, which includes a computer program, which contains program code for executing the method provided by the embodiment of the present invention. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the script data testing method provided by the embodiment of the present invention.

[0155] When the computer program is executed by the processor 601, the above functions defined in the system / device of the embodiment of the present invention are performed. Optionally, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0156] 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.

[0157] Optionally, 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, such as 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).

[0158] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different 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 flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments of the present invention can be combined and / or combined in various ways, even if such a combination or combination is not explicitly recorded in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features recorded in the various embodiments of the present invention can be combined and / or combined in various ways. All these combinations and / or combinations fall within the scope of the present invention.

[0159] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A script data testing method, characterized in that: The method comprises: In response to the script execution command, a fault detection script is executed for the distributed cluster database to obtain a fault type; Injecting a fault type script associated with the fault type into a distributed cluster database, so that the fault type script is executed in the distributed cluster database to obtain a fault execution result; Calling a fault repair script corresponding to the fault execution result to repair the fault of the distributed cluster database and obtain a fault repair result; and Based on the fault repair result, a test result related to the distributed cluster database is determined.

2. The method according to claim 1, characterized in that: The fault type script is executed in the distributed cluster database, and the fault execution result obtained includes: Obtain target permissions for the distributed cluster database; According to the server node address in the configuration file, the calling information of the test component corresponding to the server node is obtained from the fault type script, wherein the calling information includes the test component path, the connection process and the corresponding physical file; Based on the calling information, the test component is called to execute the fault type script to obtain a fault execution result.

3. The method according to claim 1, characterized in that Also includes: When the fault repair result indicates that the repair is successful, a data consistency check is performed on the first data and the second data to obtain a check result, wherein the first data indicates the table backup data in the cluster distributed database before the fault type script is injected, and the second data indicates the table repair data in the cluster distributed database after the repair is successful; When the fault repair result indicates a repair failure, the first data, the second data and the fault repair result are written into a monitoring log.

4. The method according to claim 3, characterized in that The performing a data consistency check on the first data and the second data to obtain a check result includes: Performing a data consistency check on the first data and the second data according to a data table check method to obtain a first check result; Performing a data consistency check on the hash value of the first data and the hash value of the second data to obtain a second check result; The verification result is obtained according to the first verification result and the second verification result.

5. The method according to claim 2, characterized in that: Calling the test component to execute the fault type script, obtaining the fault execution result includes: In the case where the fault type represents a lock conflict type, connecting the distributed cluster database on the first server node and the second server node respectively; Calling the test component corresponding to the first server node to execute a first fault type script corresponding to a lock conflict type, wherein the first fault type script includes a first read and write operation script for a target table in a distributed cluster database and a script for locking the target table; Call the test component corresponding to the second server node, execute the second fault type script corresponding to the lock conflict type, and obtain the fault execution result indicating successful fault injection, wherein the second fault type script includes a second read and write operation script for the target table.

6. The method according to claim 2, characterized in that Calling the test component to execute the fault type script, obtaining the fault execution result includes: In the case where the fault type represents the type of insufficient CPU space usage, the test component is called to execute the fault type script corresponding to the type of insufficient CPU space usage to obtain the fault execution result representing successful fault injection, wherein the fault type script includes loop-executed intensive task scripts and / or parallel task scripts.

7. A script data testing device, characterized in that: The device comprises: A response module, used to execute a fault detection script for a distributed cluster database in response to a script execution command to obtain a fault type; An injection module, used for injecting a fault type script associated with a fault type into a distributed cluster database, so that the fault type script is executed in the distributed cluster database to obtain a fault execution result; A repair module, used to call a fault repair script corresponding to the fault execution result, perform fault repair on the distributed cluster database, and obtain a fault repair result; and A determination module is used to determine a test result related to the distributed cluster database based on the fault repair result.

8. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more instructions, Wherein, when the one or more instructions are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: Executable instructions are stored thereon, and when the instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that When the computer program 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

  • Distributed database cloud service system, method and device and computer storage medium

    CN108833131A

  • Fault test method and device

    CN112596934A

  • Distributed system testing system and method, storage medium and electronic equipment

    CN113238950A

  • Distributed middleware system high availability test method, device, equipment and medium

    CN116820988A

  • Distributed database fault test method and device, electronic equipment and storage medium

    CN118312391A

Cited By

  • Database cluster test method, device and system, storage medium and program product

    CN119473904A

  • Database test method and device, electronic equipment and storage medium

    CN120448280A

  • A database testing method and device, electronic equipment and storage medium

    CN120448280B

  • Offline data processing method and device, terminal equipment and storage medium

    CN121597122A