Script execution method and device, electronic equipment and computer readable medium
Patent Information
- Application Number
- CN202210195520.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-01
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2042-03-01
AI Technical Summary
第一,故障模拟的自动化和精准化较低;
[0022]本公开的上述各个实施例具有如下有益效果:通过本公开的一些实施例的脚本执行方法,可以提升故障模拟的自动化和精准化程度,能够在多种模拟环境下进行测试。具体来说,造成相关故障模拟的自动化和精准化较低、压力测试和故障演练的场景较为单一,难以应对复杂场景下的突发问题的原因在于:通过人工分析模拟真实的场景,手动的进行压力测试和故障模拟。基于此,本公开的一些实施例的脚本执行方法自动分析被测系统,进行故障匹配后精准注入故障,并与多种压力测试场景进行结合,提供了多种测试场景。进而,可以提高故障模拟的自动化和精准化程度,同时可以在多种模拟环境下进行测试。从而,可以提高应对复杂场景下的突发问题的解决能力。
Smart Images

Figure CN114691458B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of this disclosure relate to the field of computer technology, and more particularly to script execution methods, apparatus, electronic devices, and computer-readable media. Background Technology
[0002] Before peak system access periods, stress testing and fault drills are often required. Currently, the common approach to stress testing and fault drills is to manually analyze and simulate real-world scenarios, and then manually conduct stress tests and fault simulations.
[0003] However, when using the above methods for stress testing and fault simulation, the following technical problems often arise: First, the automation and accuracy of fault simulation are relatively low; Second, the scenarios for stress tests and fault drills are relatively simple and cannot cope with unexpected problems in complex scenarios. Summary of the Invention
[0004] The summary portion of this disclosure is intended to provide a brief overview of the concepts, which will be described in detail in the detailed description portion. This summary portion is not intended to identify key or essential features of the claimed technical solutions, nor is it intended to limit the scope of the claimed technical solutions.
[0005] Some embodiments of this disclosure provide script execution methods, apparatuses, electronic devices, and computer-readable media to address one or more of the technical problems mentioned in the background section above.
[0006] In a first aspect, some embodiments of this disclosure provide a script execution method, which includes: scanning the system under test to obtain a compiler dependency graph; using pre-set mapping information between compilers and fault types, determining the fault type corresponding to the compiler at each leaf node in the compiler dependency graph as a target fault type, thereby obtaining a target fault type set; generating fault codes based on the target fault type set, and determining a fault script group set using the fault codes; combining the fault scripts in the fault script group set with the load test scripts in a pre-set load test script group set to obtain a script group set; injecting the scripts in each script group in the script group set into the system under test and executing the scripts in the script group set to obtain a script execution result.
[0007] Optionally, the above-mentioned method of injecting the scripts in each script group of the above-mentioned script group set into the above-mentioned system under test and executing the scripts in the above-mentioned script group to obtain the script execution result also includes: storing the fault type, stress test scenario, logs generated during the execution of the scripts in the above-mentioned script group and the identifier of the script execution result as test records.
[0008] Optionally, the above-mentioned method of injecting the scripts in each script group of the script group set into the system under test and executing the scripts in the script group to obtain the script execution result further includes: extracting test index values from the script execution result to obtain a set of test index values; in response to determining that there are test index values in the set of test index values that do not meet the corresponding threshold, marking the test records, and sending the marked test records to the target terminal.
[0009] Optionally, the above-mentioned combination of fault scripts in the fault script group set and load test scripts in the pre-set load test script group set to obtain a script group set includes: combining each fault script in the fault script group set with each load test script in the load test script group set to obtain a script group; combining each fault script in the fault script group set with each load test script in the load test script group set to obtain a script group; and combining each fault script in the fault script group set with each load test script in the load test script group set to obtain a script group.
[0010] Optionally, the above-mentioned scanning process of the system under test to obtain the compiler dependency graph includes: traversing the compiler packages in the library files of the system under test, and recursively decompressing to determine the dependency relationship of each compiler package to generate the compiler dependency graph.
[0011] Optionally, the above-mentioned scanning process of the system under test to obtain the compiler dependency graph includes: scanning and parsing the code of the system under test to obtain the compiler dependency graph.
[0012] Optionally, the above-mentioned generation of fault codes based on the target fault type set and determination of fault script group set using the fault codes include: determining whether each fault type in the pre-set fault type sequence matches any target fault type in the target fault type set; and in response to determining that the fault type matches any target fault type in the target fault type set, adjusting the value at the position corresponding to the fault type in the preset initial fault code to the target value; determining the adjusted initial fault code as the fault code; sequentially determining each fault script corresponding to the fault type represented by the position in the fault code where the value is the target value as a fault script group, thus obtaining a fault script group sequence; and combining each fault script group in the fault script group sequence that satisfies the preset conditions into a fault script group set.
[0013] Secondly, some embodiments of this disclosure provide a script execution apparatus, comprising: a scanning unit configured to scan the system under test to obtain a compiler dependency graph; a determining unit configured to use pre-set mapping information between compiler packages and fault types to determine the fault type corresponding to the compiler package at each leaf node in the compiler dependency graph as a target fault type, thereby obtaining a target fault type set; a generating and determining unit configured to generate fault codes based on the target fault type set and determine a fault script group set using the fault codes; a combining unit configured to combine fault scripts in the fault script group set and load test scripts in a pre-set load test script group set to obtain a script group set; and an injection and execution unit configured to inject the scripts in each script group in the script group set into the system under test and execute the scripts in the script group set to obtain a script execution result.
[0014] Optionally, the injection and execution unit also includes a storage subunit, which is configured to store the fault type corresponding to the script group, the load test scenario, the logs generated during the execution of the scripts in the script group, and the identifier of the script execution result as test records.
[0015] Optionally, the injection and execution unit further includes a storage subunit and a marking and sending subunit. The extraction subunit is configured to extract test indicator values from the script execution results to obtain a set of test indicator values; the marking and sending subunit is configured to, in response to determining that there are test indicator values in the set of test indicator values that do not meet the corresponding threshold, mark the test records and send the marked test records to the target terminal.
[0016] Optionally, the above-mentioned combination unit includes: a first combination subunit, a second combination subunit, and a third combination subunit. The first combination subunit is configured to combine each fault script in the fault script group set with each load test script in the load test script group set to obtain a script group; the second combination subunit is configured to combine each fault script in the fault script group set with each load test script in the load test script group set to obtain a script group; and the third combination subunit is configured to combine each fault script in the fault script group set with each load test script in the load test script group set to obtain a script group.
[0017] Optionally, the aforementioned scanning unit is further configured to traverse the compilation packages in the library files of the system under test, and recursively decompress to determine the dependency relationship of each compilation package, so as to generate a compilation package dependency graph.
[0018] Optionally, the aforementioned scanning unit is further configured to scan and parse the code of the system under test to obtain a compilation package dependency graph.
[0019] Optionally, the above-mentioned generation and determination unit includes: a first determination subunit, a second determination subunit, a third determination subunit, and a combination subunit. The first determination subunit is configured to determine whether each fault type in a pre-set fault type sequence matches any target fault type in the target fault type set, and in response to determining that the fault type matches any target fault type in the target fault type set, adjust the value at the position corresponding to the fault type in the preset initial fault code to a target value; the second determination subunit is configured to determine the adjusted initial fault code as a fault code; the third determination subunit is configured to sequentially determine each fault script corresponding to the fault type represented by the position in the fault code where the value is the target value as a fault script group, obtaining a fault script group sequence; the combination subunit is configured to combine each fault script group in the fault script group sequence that satisfies a preset condition into a fault script group set.
[0020] Thirdly, some embodiments of this disclosure provide an electronic device, including: one or more processors; and a storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation of the first aspect above.
[0021] Fourthly, some embodiments of this disclosure provide a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any of the implementations of the first aspect above.
[0022] The various embodiments of this disclosure have the following beneficial effects: The script execution methods of some embodiments of this disclosure can improve the automation and accuracy of fault simulation, enabling testing in various simulation environments. Specifically, the reason for the low automation and accuracy of related fault simulations, the relatively simple scenarios for stress testing and fault drills, and the difficulty in dealing with sudden problems in complex scenarios lies in the fact that real-world scenarios are simulated manually, and stress tests and fault simulations are performed manually. Based on this, the script execution methods of some embodiments of this disclosure automatically analyze the system under test, accurately inject faults after fault matching, and combine them with various stress test scenarios, providing multiple test scenarios. Therefore, the automation and accuracy of fault simulation can be improved, and testing can be performed in various simulation environments. This enhances the ability to solve sudden problems in complex scenarios. Attached Figure Description
[0023] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and elements are not necessarily drawn to scale.
[0024] Figure 1 This is an overall schematic diagram of some embodiments of this disclosure; Figure 2 This is a schematic diagram illustrating an application scenario of the script execution method according to some embodiments of this disclosure; Figure 3 This is a flowchart of some embodiments of the script execution method according to this disclosure; Figure 4 These are flowcharts of other embodiments of the script execution method according to this disclosure; Figure 5 This is a schematic diagram of the structure of some embodiments of the script execution device disclosed herein; Figure 6 This is a schematic diagram of the structure of an electronic device suitable for implementing some embodiments of the present disclosure. Detailed Implementation
[0025] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0026] It should also be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings. Unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other.
[0027] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0028] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0029] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0030] This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0031] Figure 1 This is an overall schematic diagram of some embodiments of this disclosure.
[0032] Figure 2 This is a schematic diagram illustrating an application scenario of the script execution method of some embodiments of this disclosure.
[0033] exist Figure 2 In the application scenario, firstly, the computing device 201 can scan the system under test 202 to obtain a compiler dependency graph 203. Then, the computing device 201 can use pre-set mapping information between compiler packages and fault types to determine the fault type corresponding to the compiler package at each leaf node in the compiler dependency graph 203 as the target fault type, obtaining a target fault type set 204. Next, the computing device 201 can generate a fault code 205 based on the target fault type set 204, for example, fault code 205 could be "001010", and use the fault code 205 to determine a fault script group set 206. Then, the computing device 201 can combine the fault scripts in the fault script group set 206 with the load testing scripts in the load testing script group set 207 to obtain a script group set 208. Finally, the computing device 201 can inject the scripts in each script group in the script group set 208 into the system under test 202 and execute the scripts in the script groups to obtain a script execution result 209.
[0034] It should be noted that the aforementioned computing device 201 can be either hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster consisting of multiple servers or terminal devices, or as a single server or a single terminal device. When the computing device is software, it can be installed in the hardware devices listed above. It can be implemented as, for example, multiple software programs or software modules used to provide distributed services, or as a single software program or software module. No specific limitations are made here.
[0035] It should be understood that Figure 2 The number of computing devices shown is merely illustrative. Any number of computing devices can be used depending on implementation needs.
[0036] Continue to refer to Figure 3 The diagram illustrates a flow 300 of some embodiments of a script execution method according to the present disclosure. This script execution method includes the following steps: Step 301: Scan the system under test to obtain the dependency graph of the compilation package.
[0037] In some embodiments, the execution body of the script execution method (such as...) Figure 2 The computing device 201 shown can scan the system under test to obtain a compiler dependency graph. This compiler dependency graph can be represented as a compiler dependency tree.
[0038] The aforementioned execution entity can traverse the compiled packages in the library files of the system under test. It then obtains each compiled package of the system under test from these library files. Next, it recursively decompresses the packages to determine their dependencies, generating a compiled package dependency graph. The compiled package can be decompressed, and its contents can be analyzed to determine if it references other compiled packages. If it is determined that the package references other compiled packages, these other compiled packages are added as parent packages of the current package, and the recursive decompression of these other packages continues. If it is determined that the package is not referenced by other compiled packages, it can be added as a leaf node in the compiled package dependency graph.
[0039] As an example, the library file mentioned above can be a lib file. The compiled package mentioned above can be a jar file.
[0040] Optionally, the execution entity can scan and parse the code of the system under test to obtain a compiler dependency graph. The execution entity can parse statements representing specific syntax references to compiler packages from the code of the system under test. Furthermore, it can obtain the various compiler packages referenced by the system under test. Then, it recursively decompresses these compiler packages to generate the compiler dependency graph.
[0041] As an example, the statement that represents the specific syntax of a compiled package reference could be an import statement.
[0042] Optionally, the aforementioned execution entity can also scan and parse the code of the system under test and the class files in the lib directory of the code project of the system under test to obtain a compilation package dependency graph.
[0043] Step 302: Using the pre-set mapping information between compilation packages and fault types, determine the fault type corresponding to the compilation package at each leaf node in the compilation package dependency graph as the target fault type, and obtain the target fault type set.
[0044] In some embodiments, the execution entity can utilize pre-defined mapping information between compiled packages and fault types to determine the fault type corresponding to the compiled package at each leaf node of the compiled package dependency graph as the target fault type, thereby obtaining a set of target fault types. The mapping information between the compiled packages and fault types may include a compiled package identifier and a fault type. The compiled package identifier may be a compiled package name or a compiled package identifier number, etc.
[0045] As an example, the fault types included in the mapping information between each compilation package and fault type can be: network jitter, network latency, network congestion, middleware-redis, middleware-zookeeper, single machine-cpu, single machine-memory, single machine-disk, etc.
[0046] Step 303: Generate fault codes based on the target fault type set, and use the fault codes to determine the fault script group set.
[0047] In some embodiments, the execution entity may generate fault codes based on the target fault type set and use the fault codes to determine a fault script group set.
[0048] The fault types can be pre-sorted according to their respective impacts on the system under test, resulting in a fault type sequence. Then, each fault type in this sequence is encoded. The sequence number of the fault type within the fault type sequence can be used as its code. The codes of fault types in the sequence that are identical to any target fault type in the target fault type set can be combined to obtain fault codes. Then, the fault script corresponding to each code can be searched to generate a fault script group, resulting in a fault script group set. The relationship between the codes and fault scripts can be pre-stored. Furthermore, the corresponding fault script can be found using the codes.
[0049] As an example, the relationship between codes and fault scripts can be stored in the form of <code, {fault script identifier 1, fault script identifier 2, ...}>.
[0050] In some optional implementations of certain embodiments, the execution entity generating fault codes based on the target fault type set and determining a fault script group set using the fault codes may include the following steps: The first step involves determining whether each fault type in the pre-set fault type sequence matches any target fault type in the aforementioned target fault type set. In response to determining that a fault type matches any target fault type in the aforementioned target fault type set, the value at the position corresponding to the fault type in the pre-set initial fault code is adjusted to the target value. The initial fault code may consist of a pre-set number of first values. The target value is different from the first values. The pre-set number may be greater than or equal to the number of fault types.
[0051] If the aforementioned fault type is the same as any target fault type in the aforementioned set of target fault types, then it can be determined that the aforementioned fault type matches any target fault type in the aforementioned set of target fault types. If the aforementioned fault type is different from each of the target fault types in the aforementioned set of target fault types, then it can be determined that the aforementioned fault type does not match any target fault type in the aforementioned set of target fault types.
[0052] The fault types can be pre-sorted according to their respective impacts on the system under test, resulting in a fault type sequence. Each digit in the fault code can then correspond sequentially to a fault type within this sequence.
[0053] As an example, the first value mentioned above can be 0. The initial fault code mentioned above can be 000000. The first value mentioned above can be 1.
[0054] The second step is to determine the adjusted initial fault code as the fault code.
[0055] The fault type represented by the position of the above target value in the fault code is the matching fault type.
[0056] As an example, the adjusted initial fault code could be 001010. In the adjusted initial fault code, the 3rd and 5th bits are both 1. Therefore, it can be determined that the fault type in the fault type sequence that matches the 3rd and 5th bits of the adjusted initial fault code is the fault type.
[0057] The third step is to sequentially identify each fault script corresponding to the fault type represented by the position in the above fault code that is the above target value as a fault script group, and obtain the fault script group sequence.
[0058] The correspondence between fault types and fault scripts can be pre-stored. For example, the correspondence between fault types and fault scripts can be stored in the form of <fault type, {fault script identifier 1, fault script identifier 2, ...}>.
[0059] The fourth step is to combine the fault script groups that meet the preset conditions in the above fault script group sequence into a fault script group set. The preset condition can be that the fault script group is among the top N fault script groups in the above fault script group sequence, where N is a pre-set positive integer.
[0060] Each fault script group in the fault script group sequence corresponds to a fault type, and the relative order of the fault script groups in the sequence corresponds to the relative order of the fault types in the fault type sequence. The earlier a fault script group appears in the sequence, the greater its impact on the system under test. Therefore, grouping the fault script groups that meet the preset conditions from the above fault script group sequence into a fault script group set, and using this set for subsequent testing steps, can not only achieve better test results but also improve testing efficiency.
[0061] Step 304: Combine the fault scripts in the fault script group set with the load test scripts in the pre-set load test script group set to obtain the script group set.
[0062] In some embodiments, the execution entity may combine any number of fault scripts in the fault script group set and any number of load test scripts in the pre-set load test script group set to obtain a script group set.
[0063] In some optional implementations of certain embodiments, the execution entity combines the fault scripts in the fault script group set and the load test scripts in the pre-set load test script group set to obtain a script group set, which may include the following steps: The first step is to combine each fault script in the aforementioned fault script group set with each load test script in the load test script group set to obtain a script group. Each load test script group in the aforementioned load test script group set can represent a load test environment. The correspondence between fault scripts and load test scripts in the aforementioned script group is one-to-many.
[0064] The second step involves combining each fault script in the aforementioned fault script group set with each load test script in the load test script group set to obtain a script group. The correspondence between fault scripts and load test scripts within the script group is many-to-one.
[0065] The third step involves combining each fault script in the aforementioned fault script group set with each load test script in the load test script group set to obtain a script group. The correspondence between fault scripts and load test scripts within the script group is many-to-many.
[0066] Therefore, testing can be performed in multiple load testing scenarios for a single fault through a one-to-many correspondence between fault scripts and load testing scripts; testing can be performed in a single load testing scenario for multiple faults through a many-to-one correspondence between fault scripts and load testing scripts; and testing can be performed in multiple load testing scenarios for multiple faults through a many-to-many correspondence between fault scripts and load testing scripts. This enriches the types of faults in mixed load testing scenarios, making the test scenarios more closely resemble real-world scenarios and improving the accuracy of test results.
[0067] Step 305: Inject the scripts from each script group in the script group set into the system under test and execute the scripts in the script group to obtain the script execution results.
[0068] In some embodiments, the execution entity can inject scripts from each script group in the script set into the system under test and execute the scripts in the script groups to obtain script execution results. The execution time of the scripts in the script groups can be set to a target duration. In practice, the target duration can be preset. The script execution results can be stored as fault and load test reports. The script execution results include various metrics of the system under test when running the scripts in the script groups.
[0069] As an example, the above metrics may include, but are not limited to, CPU utilization and memory usage.
[0070] The various embodiments of this disclosure have the following beneficial effects: The script execution methods of some embodiments of this disclosure can improve the automation and accuracy of fault simulation, enabling testing in various simulation environments. Specifically, the reason for the low automation and accuracy of related fault simulations, the relatively simple scenarios for stress testing and fault drills, and the difficulty in dealing with sudden problems in complex scenarios lies in the fact that real-world scenarios are simulated manually, and stress tests and fault simulations are performed manually. Based on this, the script execution methods of some embodiments of this disclosure automatically analyze the system under test, accurately inject faults after fault matching, and combine them with various stress test scenarios, providing multiple test scenarios. Therefore, the automation and accuracy of fault simulation can be improved, and testing can be performed in various simulation environments. This enhances the ability to solve sudden problems in complex scenarios.
[0071] Further reference Figure 4This illustrates a flow 400 of another embodiment of the script execution method. The flow 400 of the script execution method includes the following steps: Step 401: Scan the system under test to obtain the dependency graph of the compilation package.
[0072] Step 402: Using the pre-set mapping information between compilation packages and fault types, determine the fault type corresponding to the compilation package at each leaf node in the compilation package dependency graph as the target fault type, and obtain the target fault type set.
[0073] Step 403: Generate fault codes based on the target fault type set, and use the fault codes to determine the fault script group set.
[0074] Step 404: Combine the fault scripts in the fault script group set with the load test scripts in the pre-set load test script group set to obtain the script group set.
[0075] In some embodiments, the specific implementation of steps 401-404 and the resulting technical effects can be found in [reference needed]. Figure 2 Steps 201-204 in the corresponding embodiments will not be repeated here.
[0076] Step 405: Inject the scripts from each script group in the script group set into the system under test and execute the scripts in the script group to obtain the script execution results.
[0077] In some embodiments, the execution body of the script execution method (such as...) Figure 2 The computing device 201 shown can inject the scripts from each script group in the above-mentioned script set into the system under test and execute the scripts in the script groups to obtain script execution results. The execution time of the scripts in the above-mentioned script groups can be set to a target duration. In practice, the target duration can be preset. The script execution results can be stored as fault and stress test reports. The script execution results may include, but are not limited to: tp99, tp999, tps (Transactions Per Second) success rate, qps (Query Per Second) success rate, etc.
[0078] The aforementioned execution entity combines the fault scripts in the aforementioned fault script group set with the load test scripts in the pre-set load test script group set to obtain a script group set. It may also include the following steps: Step 4051: Store the fault type, stress test scenario, logs generated during the execution of the scripts in the script group, and the identifiers of the script execution results as test records.
[0079] This facilitates subsequent analysis of the impact of fault types on the tested system, and allows for targeted improvements to the tested system.
[0080] Step 4052: Extract test indicator values from the script execution results to obtain a set of test indicator values.
[0081] The TP99, TP999, TPS success rate, and QPS success rate included in the above script execution results can be extracted and used as test metric values.
[0082] Step 4053: In response to determining that there are test index values in the set of test index values that do not meet the corresponding threshold, mark the test record and send the marked test record to the target terminal.
[0083] The target terminal mentioned above can be the monitoring terminal used by the testers. Thresholds corresponding to each test metric value can be preset. If any of the test metric values (TP99, TP999, TPS success rate, QPS success rate) are lower than their corresponding thresholds, it can be determined that there are test metric values in the test metric value set that do not meet the corresponding thresholds. Then, the test metric values that do not meet the corresponding thresholds in the script execution results of the test records can be marked.
[0084] This allows testers to optimize the system under test at the application level based on the information included in the test logs. For example, by obtaining the method call chain during the execution of the system under test, and saving the classes and methods, input and output parameters, and execution time data on the call chain to the cache, more targeted optimizations can be made to specific classes and methods at the application level.
[0085] from Figure 4 It can be seen from this that, with Figure 3 Compared to the description of some corresponding embodiments, Figure 4 The script execution method flow 400 in some corresponding embodiments embodies the subsequent processing steps for the script execution results. Therefore, the solutions described in these embodiments can store the fault types corresponding to the script group, the load testing scenario, the logs generated during the execution of the scripts in the script group, and the identifiers of the script execution results as test records. This facilitates subsequent analysis of the impact of fault types on the system under test, and allows for targeted enhancements to the system under test. It also enables testers to perform application-level optimizations of the system under test based on the information included in the test records.
[0086] Further reference Figure 5 As an implementation of the methods shown in the above figures, this disclosure provides some embodiments of a script execution device, which are similar to... Figure 3 Corresponding to the method embodiments shown, the device can be specifically applied to various electronic devices.
[0087] like Figure 5 As shown, the script execution device 500 in some embodiments includes: a scanning unit 501, a determining unit 502, a generating and determining unit 503, a combining unit 504, and an injection and execution unit 505. The scanning unit 501 is configured to scan the system under test to obtain a compiler dependency graph; the determining unit 502 is configured to use pre-set mapping information between compiler packages and fault types to determine the fault type corresponding to the compiler package at each leaf node in the compiler dependency graph as a target fault type, obtaining a target fault type set; the generating and determining unit 503 is configured to generate fault codes based on the target fault type set and determine a fault script group set using the fault codes; the combining unit 504 is configured to combine the fault scripts in the fault script group set with the load test scripts in a pre-set load test script group set to obtain a script group set; the injection and execution unit 505 is configured to inject the scripts in each script group in the script group set into the system under test and execute the scripts in the script group to obtain a script execution result.
[0088] In some optional implementations of the embodiments, the injection and execution unit further includes a storage subunit, which is configured to store the fault type corresponding to the script group, the stress test scenario, the logs generated during the execution of the scripts in the script group, and the identifier of the script execution result as test records.
[0089] In some optional implementations of embodiments, the injection and execution unit further includes a storage subunit and a marking and sending subunit. The extraction subunit is configured to extract test indicator values from the script execution results to obtain a set of test indicator values; the marking and sending subunit is configured to, in response to determining that there are test indicator values in the set of test indicator values that do not meet the corresponding threshold, mark the test records and send the marked test records to the target terminal.
[0090] In some optional implementations of embodiments, the above-mentioned combining unit includes: a first combining subunit, a second combining subunit, and a third combining subunit. The first combining subunit is configured to combine each fault script in the fault script group set with each load test script in the load test script group set to obtain a script group; the second combining subunit is configured to combine each fault script in the fault script group set with each load test script in the load test script group set to obtain a script group; and the third combining subunit is configured to combine each fault script in the fault script group set with each load test script in the load test script group set to obtain a script group.
[0091] In some optional implementations of the embodiments, the scanning unit is further configured to traverse the compilation packages in the library files of the system under test, and recursively decompress to determine the dependency relationship of each compilation package, so as to generate a compilation package dependency graph.
[0092] In some optional implementations of the embodiments, the scanning unit is further configured to scan and parse the code of the system under test to obtain a compilation package dependency graph.
[0093] In some optional implementations of embodiments, the generation and determination unit includes: a first determination subunit, a second determination subunit, a third determination subunit, and a combination subunit. The first determination subunit is configured to determine whether each fault type in a pre-set fault type sequence matches any target fault type in the target fault type set, and in response to determining that the fault type matches any target fault type in the target fault type set, adjust the value at the position corresponding to the fault type in a preset initial fault code to a target value. The second determination subunit is configured to determine the adjusted initial fault code as a fault code. The third determination subunit is configured to sequentially determine each fault script corresponding to the fault type represented by the position in the fault code where the value is the target value as a fault script group, obtaining a fault script group sequence. The combination subunit is configured to combine each fault script group in the fault script group sequence that satisfies a preset condition into a fault script group set.
[0094] It is understandable that the units described in the device 500 are related to the reference. Figure 3 The steps in the described method correspond accordingly. Therefore, the operations, features, and beneficial effects described above for the method also apply to the device 500 and the units contained therein, and will not be repeated here.
[0095] The following is for reference. Figure 6 It shows a schematic diagram of the structure of an electronic device 600 suitable for implementing some embodiments of the present disclosure. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0096] like Figure 6As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0097] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 6 Each box shown can represent a device or multiple devices as needed.
[0098] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, it performs the functions defined above in the methods of some embodiments of this disclosure.
[0099] It should be noted that, in some embodiments of this disclosure, the computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In some embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In some embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0100] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0101] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs. When the aforementioned one or more programs are executed by the electronic device, the electronic device causes the following: it scans the system under test to obtain a compiler dependency graph; using pre-set mapping information between compilers and fault types, it determines the fault type corresponding to the compiler at each leaf node in the compiler dependency graph as the target fault type, obtaining a target fault type set; it generates fault codes based on the target fault type set, and uses the fault codes to determine a fault script group set; it combines the fault scripts in the fault script group set with the load test scripts in a pre-set load test script group set to obtain a script group set; it injects the scripts in each script group of the script group set into the system under test and executes the scripts in the script group set to obtain script execution results.
[0102] Computer program code for performing operations of some embodiments of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0103] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0104] The units described in some embodiments of this disclosure can be implemented in software or hardware. The described units can also be housed in a processor; for example, a processor may be described as including a scanning unit, a determining unit, a generating and determining unit, a combining unit, and an injection and execution unit. The names of these units do not necessarily limit the specific unit; for example, a scanning unit may also be described as a "system under test scanning unit."
[0105] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
Claims
1. A script execution method, comprising: The system under test is scanned to obtain a dependency graph of the compiled packages; By using the pre-set mapping information between compilation packages and fault types, the fault type corresponding to the compilation package at each leaf node in the compilation package dependency graph is determined as the target fault type, thus obtaining a set of target fault types; Generating fault codes based on the target fault type set, and determining a fault script group set using the fault codes, includes: determining whether each fault type in a pre-set fault type sequence matches any target fault type in the target fault type set; and in response to determining that the fault type matches any target fault type in the target fault type set, adjusting the value at the position corresponding to the fault type in the preset initial fault code to a target value; determining the adjusted initial fault code as a fault code; sequentially determining each fault script corresponding to the fault type represented by the position in the fault code where the value is the target value as a fault script group, obtaining a fault script group sequence; and combining each fault script group in the fault script group sequence that meets a preset condition into a fault script group set. The fault scripts in the fault script group set and the load test scripts in the pre-set load test script group set are combined to obtain a script group set. Among them, the test of multiple load test scenarios for a single fault is realized through the one-to-many correspondence between fault scripts and load test scripts, the test of a single load test scenario for multiple faults is realized through the many-to-one correspondence between fault scripts and load test scripts, and the test of multiple load test scenarios for multiple faults is realized through the many-to-many correspondence between fault scripts and load test scripts. The scripts in each script group of the script group set are injected into the system under test and the scripts in the script group are executed to obtain the script execution results.
2. The method according to claim 1, wherein, The step of injecting the scripts from each script group in the script group set into the system under test and executing the scripts in the script group to obtain the script execution results includes: The fault type, stress test scenario, logs generated during the execution of the scripts in the script group, and the identifier of the script execution result are stored as test records.
3. The method according to claim 2, wherein, The step of injecting scripts from each script group in the script group set into the system under test and executing the scripts in the script group to obtain script execution results further includes: Extract test indicator values from the script execution results to obtain a set of test indicator values; In response to determining that there are test index values in the set of test index values that do not meet the corresponding threshold, the test record is marked and the marked test record is sent to the target terminal.
4. The method according to claim 1, wherein, The step of combining the fault scripts in the fault script group set and the load test scripts in the pre-set load test script group set to obtain a script group set includes: Each fault script in the fault script group set is combined with each load test script in the load test script group set to obtain a script group; Each fault script in the fault script group set is combined with each load test script in the load test script group set to obtain a script group; The fault scripts in the fault script group set are combined with the load test scripts in the load test script group set to obtain a script group.
5. The method according to claim 1, wherein, The scanning process of the system under test to obtain the compiler dependency graph includes: The compiler packages in the library files of the system under test are traversed, and the dependencies of each compiler package are determined by recursive decompression to generate a compiler package dependency graph.
6. The method according to claim 1, wherein, The scanning process of the system under test to obtain the compiler dependency graph includes: The code of the system under test is scanned and parsed to obtain a dependency graph of the compilation packages.
7. A script execution device, comprising: The scanning unit is configured to scan the system under test to obtain a dependency graph of the compiled packages; The determining unit is configured to use the pre-set mapping information between the compilation package and the fault type to determine the fault type corresponding to the compilation package at each leaf node of the compilation package dependency graph as the target fault type, thereby obtaining a set of target fault types; The generation and determination unit is configured to generate fault codes based on the target fault type set, and to determine a set of fault script groups using the fault codes; The combination unit is configured to combine the fault scripts in the fault script group set and the load test scripts in the pre-set load test script group set to obtain a script group set. The test of multiple load test scenarios for a single fault is realized through a one-to-many correspondence between fault scripts and load test scripts, the test of a single load test scenario for multiple faults is realized through a many-to-one correspondence between fault scripts and load test scripts, and the test of multiple load test scenarios for multiple faults is realized through a many-to-many correspondence between fault scripts and load test scripts. The injection and execution unit is configured to inject the scripts in each script group in the script group set into the system under test and execute the scripts in the script group to obtain the script execution result; The generation and determination unit includes: a first determination subunit, a second determination subunit, a third determination subunit, and a combination subunit; wherein, the first determination subunit is configured to determine whether each fault type in a pre-set fault type sequence matches any target fault type in the target fault type set, and in response to determining that the fault type matches any target fault type in the target fault type set, adjust the value at the position corresponding to the fault type in the preset initial fault code to the target value; the second determination subunit is configured to determine the adjusted initial fault code as a fault code; the third determination subunit is configured to sequentially determine each fault script corresponding to the fault type represented by the position in the fault code where the value is the target value as a fault script group, thereby obtaining a fault script group sequence; the combination subunit is configured to combine each fault script group in the fault script group sequence that meets a preset condition into a fault script group set.
8. An electronic device, comprising: One or more processors; A storage device having stored one or more programs thereon, which, when executed by the one or more processors, cause the one or more processors to implement the method as described in any one of claims 1-6.
9. A computer-readable medium having a computer program stored thereon, wherein, When the program is executed by the processor, it implements the method as described in any one of claims 1-6.
Citation Information
Patent Citations
System testing method and apparatus thereof
CN105868097A
PaaS cloud platform fault test method and device
CN113157577A