Test script generation method and device, electronic equipment and product
By automating the generation of test scripts through a graphical user interface and parameter models, the problem of errors easily caused by manually writing test scripts is solved, and efficient and reliable test script generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JINAN INSPUR DATA TECH CO LTD
- Filing Date
- 2026-02-27
- Publication Date
- 2026-06-19
AI Technical Summary
In existing technologies, test scripts rely entirely on manual completion using a text editor, which can easily lead to test failures due to spelling errors or incorrect parameter formats.
The user enters keywords through a graphical user interface to determine the operation command, and then uses a parameter model to verify it. After ensuring that the command meets the preset standards, it is serialized into a test script.
It improves the efficiency and quality of test script generation, reduces test failures caused by spelling errors and incorrect parameter formats, and enhances the reliability and efficiency of testing.
Smart Images

Figure CN122240001A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a method, apparatus, electronic device, and product for generating test scripts. Background Technology
[0002] In the current field of high-performance storage system testing, especially when using vdbench for I / O performance testing of storage devices and systems, test scripts are entirely written manually using text editors. Test engineers often need to frequently consult the vdbench user manual to ensure the correct use of each parameter. However, in practice, manual input is prone to spelling errors and incorrect parameter formats, causing the test scripts to fail to be correctly parsed and executed by vdbench.
[0003] In related technologies, test scripts rely entirely on manual completion using text editors, which can easily lead to test failures due to spelling errors or incorrect parameter formats. No effective solution has yet been proposed. Summary of the Invention
[0004] This application provides a method, apparatus, electronic device, and product for generating test scripts, to at least solve the problem in the related art where test scripts rely entirely on manual completion using a text editor, which is prone to test failure due to spelling errors or incorrect parameter formats.
[0005] This application provides a method for generating a test script, comprising: determining a first operation instruction based on keywords input by a target object in a graphical user interface, wherein the first operation instruction is used to form a test case, and the test case is used to generate a test script; verifying the first operation instruction through a parameter model to determine whether the first operation instruction conforms to a preset standard; and, if the first operation instruction conforms to the preset standard, serializing the first operation instruction into a first test script.
[0006] This application also provides a test script generation apparatus, comprising: a determining module, configured to determine a first operation instruction based on keywords input by a target object in a graphical user interface, wherein the first operation instruction is used to form test cases, and the test cases are used to generate a test script; a verification module, configured to verify the first operation instruction through a parameter model to determine whether the first operation instruction conforms to a preset standard; and a generation module, configured to serialize the first operation instruction into a first test script if the first operation instruction conforms to the preset standard.
[0007] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described test script generation methods when executing the computer program.
[0008] This application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of any of the above-described test script generation methods.
[0009] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described test script generation methods.
[0010] This application determines a first operation instruction based on keywords entered by the target object in a graphical user interface. The first operation instruction is used to form test cases, which in turn generate test scripts. The first operation instruction is validated using a parameter model to determine if it conforms to a preset standard. If the first operation instruction conforms to the preset standard, it is serialized into a first test script. Therefore, this addresses the problem in related technologies where test scripts rely entirely on manual text editing, leading to test failures due to spelling errors or incorrect parameter formats, thus effectively improving testing efficiency. Attached Figure Description
[0011] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 A hardware structure block diagram of a test script generation method provided in an embodiment of this application;
[0013] Figure 2 A flowchart illustrating a method for generating a test script as provided in an embodiment of this application;
[0014] Figure 3 A schematic diagram illustrating a method for generating a test script according to an embodiment of this application;
[0015] Figure 4 This is a structural block diagram of a test script generation device provided in an embodiment of this application. Detailed Implementation
[0016] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0017] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0018] The methods and embodiments provided in this application can be executed on a server device or a similar computing device. Taking running on a server device as an example, Figure 1 This is a hardware structure block diagram of a test script generation method according to an embodiment of this application. For example... Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a central processing unit (CPU), microprocessor (MCU), or field-programmable gate array (FPGA)) and a memory 104 for storing data are also shown. The server device may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the server equipment described above. For example, the server equipment may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0019] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the test script generation method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thus implementing the aforementioned test script generation method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to server devices via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0020] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the server device. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0021] An embodiment of this application provides a method for generating test scripts, which is applied to the aforementioned server device. Figure 2 This is a flowchart of a test script generation method according to an embodiment of this application, such as... Figure 2 As shown, the process includes the following steps:
[0022] Step S202: Determine the first operation instruction based on the keywords entered by the target object in the graphical user interface, wherein the first operation instruction is used to form a test case, and the test case is used to generate a test script;
[0023] Step S204: Verify the first operation instruction using a parameter model to determine whether the first operation instruction conforms to a preset standard;
[0024] Step S206: If it is determined that the first operation instruction conforms to the preset standard, the first operation instruction is serialized into a first test script.
[0025] Through the above steps, the first operation instruction is determined based on the keywords entered by the target object in the graphical user interface. The first operation instruction is used to form test cases, and the test cases are used to generate test scripts. The first operation instruction is validated through a parameter model to determine whether it meets the preset standard. If the first operation instruction meets the preset standard, it is serialized into the first test script. Therefore, this solves the problem in related technologies where test scripts rely entirely on manual completion using a text editor, which is prone to test failure due to spelling errors and incorrect parameter formats, effectively improving testing efficiency.
[0026] In one exemplary embodiment, determining a first operation instruction based on a keyword input by a target object in a graphical user interface includes: determining a plurality of first parameters matching the keyword, and displaying the plurality of first parameters on the graphical user interface to instruct the target object to determine a second parameter among the plurality of first parameters; receiving the second parameter fed back by the target object, and determining the first operation instruction based on the second parameter.
[0027] When a user (target object) enters keywords in the graphical user interface, the system responds quickly, using its internal parameter indexing and matching algorithm to automatically filter out a series of parameters (multiple first parameters) that match the keyword, and displays these parameters on the user interface in real time. This feature greatly simplifies the parameter search process; users no longer need to sift through lengthy manuals or documents, but can intuitively select the parameters that best meet their current testing needs from the recommended list. In the parameter recommendation list, the user (target object) can easily identify and determine the required parameters (second parameters) and directly select or further configure these parameters in the interface. The system then receives the user's selection and configuration information, converting it into operation instructions during the vdbench script generation process (first operation instructions). For example, if the user enters the keyword "read" in the search box, the system will immediately display all parameters related to read operations, such as read, seekpct (if the value is sequential, it is related to read operations), and xfersize (read block size). The user selects read and xfersize from these recommended parameters, setting read to 80 (meaning read operations account for 80% in the test) and xfersize to 64k (read block size). After receiving these configurations, the system will determine the corresponding operation instructions, update the internal parameter model, and generate a preview script in real time for users to check and confirm.
[0028] In this embodiment, users can dynamically load and configure parameters directly through forms, dropdown lists, checkboxes, etc., on the graphical user interface, replacing manual input. This improves the user-friendliness and efficiency of the interaction, reduces errors in parameter selection and input, and thus greatly improves the speed and quality of test script generation.
[0029] In an exemplary embodiment, verifying the first operation instruction through a parameter model includes: performing validity and integrity verification on a plurality of second parameters in the first operation instruction through the parameter model, wherein the validity verification includes at least one of the following: determining whether the first parameter values of the plurality of second parameters are respectively within a plurality of preset ranges, determining whether the first unit of the plurality of second parameters is correct, and the plurality of second parameters correspond one-to-one with the plurality of preset ranges; the integrity verification includes: determining whether the first subordinate parameter of the plurality of second parameters has been set, wherein the first subordinate parameter is a sub-parameter of the plurality of second parameters.
[0030] When a user inputs operation commands (first operation commands) through the graphical user interface, the parameter model immediately compares and verifies the parameters (multiple second parameters) in these commands. This verification process consists of two main parts: validity verification and integrity verification. Validity verification covers the reasonableness of parameter values and the accuracy of units. Specifically, the parameter model checks whether the first parameter value of each parameter falls within its preset value range. For example, the value of the xfersize parameter should be a block size like 4k, 64k, or 1m, not an arbitrary value outside the range. Furthermore, it verifies whether the parameter units are correct; for example, the unit of the duration parameter should be seconds, not milliseconds or other units. This verification ensures that the parameter values conform to the vdbench specification, avoiding script failures due to unreasonable parameter values or incorrect units. Integrity verification mainly focuses on the completeness of parameters and their sub-parameters (first-level parameters). In vdbench scripts, some parameters may require lower-level sub-parameters to complete their definitions. For example, a file system definition needs specific storage device paths and other sub-parameters to fully describe a storage device. The integrity check verifies whether all sub-parameters of each parameter have been set correctly. If not, it prompts the user to supplement them, ensuring that every part of the script is complete and can be executed smoothly.
[0031] Implementing these validation mechanisms can significantly improve the quality and reliability of vdbench test scripts. Specifically: the built-in parameter validity validation mechanism can promptly detect and prevent errors in parameter values and units, significantly reducing the error rate during script generation. Integrity validation ensures that all necessary parameters and sub-parameters are correctly configured, avoiding script execution anomalies caused by missing parameters.
[0032] In an exemplary embodiment, after validating the first operation instruction using a parameter model, the method further includes: if the plurality of second parameters pass the validity check and the integrity check, determining that the first operation instruction has been successfully verified, and serializing the first operation instruction into the first test script; if the plurality of second parameters fail the validity check or the integrity check, determining that the first operation instruction has failed, and determining the reason for the failure of the first operation instruction; if the reason is determined to be that a second parameter value among the plurality of first parameter values is not within a first preset range corresponding to the second parameter value, sending the first preset range to the target object to instruct the target object to determine a third parameter value from the first preset range; if the reason is determined to be that a second unit among the plurality of first units is incorrect, determining a third parameter corresponding to the second unit, and determining a correct third unit corresponding to the third parameter, wherein the plurality of second parameters includes the third parameter; if the reason is determined to be that a second lower-level parameter among the plurality of first lower-level parameters is not set, determining a fourth parameter corresponding to the second lower-level parameter, and setting a third lower-level parameter for the fourth parameter, wherein the plurality of second parameters includes the fourth parameter, and the third lower-level parameter is a sub-parameter of the fourth parameter.
[0033] If all parameters pass validation, the first operation command is considered successfully validated. The serialization process then begins, converting all user commands into script text conforming to the vdbench syntax standard (the first test script). The real-time generated script syntax updates are highlighted in the preview area of the graphical user interface for user review and subsequent execution. Conversely, if a problem is found during validity or integrity validation, the first operation command validation is explicitly marked as failed. In this case, the reasons for the validation failure are analyzed in detail, and targeted help information is provided. For example, if a parameter value exceeds the allowed range, the user is informed of the parameter's valid value range (the first preset range), guiding them to reselect; if the parameter unit is incorrect, the incorrect unit is identified, and the correct unit type is provided for correction; if any sub-parameters are missing, the user is prompted to identify which sub-parameters are missing and guided to configure them.
[0034] By providing real-time feedback on parameter configuration errors, users can quickly locate and correct problems, avoiding test delays caused by incorrect parameter settings and greatly improving the success rate and speed of test script generation. Furthermore, parameter validation ensures that all configurations conform to vdbench specifications, effectively preventing human error and significantly enhancing the professionalism and reliability of the generated scripts.
[0035] In an exemplary embodiment, serializing the first operation instruction into a first test script includes: traversing multiple objects in the first operation instruction in a preset order using a serialization function to obtain multiple serialization results corresponding one-to-one with the multiple objects; and concatenating the serialization results in the preset order to obtain the first test script.
[0036] In an exemplary embodiment, traversing multiple objects in the first operation instruction in a preset order using a serialization function includes: traversing multiple host-defined objects in the first operation instruction using the serialization function; for each first object among the multiple host-defined objects, traversing the first object using the serialization function to determine the storage device and storage environment of the first object; traversing the storage device using the serialization function to determine the workload characteristics of the storage device; and determining the execution definition of the first test script, wherein the execution definition is used to control the execution of the first test script, the multiple objects include the multiple host-defined objects, multiple storage devices, multiple storage environments, multiple workload characteristics, and multiple execution definitions, and the preset order is used to characterize the determination order of the multiple objects.
[0037] Serializing the structured parameter model into a plain text script conforming to the vdbench syntax specification is a key technical step. First, an empty string is created to store the script content to be generated. A traversal function is designed to recursively access all objects in the model and extract parameter information according to a preset order (Host Definition (hd) -> File System Definition (fsd) -> File Workload Definition (fwd) -> Run Definition (rd)). First, all hd objects are traversed. For each hd object, the serialization function is called to convert its attributes to the vdbench script format and the result is added to the script string. The serialization function correctly handles hd-specific parameters, such as hostname and host type, and ensures syntactic consistency. For each fsd within an hd, the recursive traversal continues. An fsd may contain definitions of multiple storage devices, each with its own specific parameters, such as storage type and storage path. The serialization function captures these parameters and converts them into the vdbench script format, adding the conversion results line by line to the script string. Next, it iterates through the fwds within the fsd. The fwds define the workload characteristics on the file system, such as read / write ratios and file size distribution. For each fwd object, the serialization function is called to process these complex parameters and add them to the script string with correct syntax. Finally, the rd is iterated and processed, including details such as test duration, loop count, and latency strategy. The rd is the final step in the test script, and its parameter serialization must closely follow the structure of the preceding layers to ensure the integrity and consistency of the test scenario. After all objects and parameters of the model have been iterated and serialized, the result strings of each part are concatenated according to the vdbench script format requirements. After concatenation, the generated string is the complete vdbench test script. At this point, the script's format and syntax should conform to vdbench requirements and can be used directly for testing.
[0038] Optionally, suppose the user specifies a host on the graphical user interface, for example, the hostname is testhost and the type is linux. The user then adds a file system definition for testhost, specifying the storage device type as disk and the storage path as / mnt / testdisk. Next, the user defines a file workload, setting the read operation ratio to 80%, the write operation ratio to 20%, and the block size to 64k. Finally, the user determines the test runtime to be 1800 seconds (i.e., 30 minutes) and selects to start the test. The corresponding serialization process is as follows: Create an empty string to prepare to receive the serialized script content. First, process the hd object testhost. The serialization function will extract its hostname and type and convert it to vdbench syntax: [hd.testhost] type = linux. Next, process the fsd object. For the storage device definition under testhost, the serialization function will convert its type and path information: [fsd] sd1 = / mnt / testdisk. For the defined file workload, the serialization function will convert parameters such as read / write ratio and block size according to vdbench's syntax requirements: [fwd] read = 80 write = 20 xfersize = 64k. Finally, the rd object is processed, and the test duration parameter is converted: [rd] duration = 1800. The contents of the above parts are concatenated in order, with appropriate line breaks and indentation added to conform to the format requirements of the vdbench script. The final generated script string may look like this:
[0039] [hd.testhost]
[0040] type = linux
[0041] [fsd]
[0042] sd1 = / mnt / testdisk
[0043] [fwd]
[0044] read = 80
[0045] write = 20
[0046] xfersize = 64k
[0047] [rd]
[0048] duration = 1800
[0049] The above steps demonstrate that the serialization process converts user commands on the graphical user interface into a vdbench-compatible script format. Each step of this process strictly adheres to vdbench's parameter hierarchy and syntax requirements, ensuring that the generated script is both correct and efficient.
[0050] In an exemplary embodiment, after serializing the first operation instruction into a first test script, the method further includes: storing the first test script in a script database; and, upon receiving a target test instruction through the graphical user interface, calling the first test script from the script database and executing the first test script, wherein the target test instruction corresponds to the first test script.
[0051] Once the user completes all necessary configurations through the graphical interface, and all operation commands have been rigorously validated and confirmed to be correct by the parameter model, the generated first test script is automatically stored in a dedicated script database. This step aims to achieve persistent storage and centralized management of scripts, ensuring that all valid and validated test scripts can be securely retained and categorized, providing convenient access and reuse for future tests. When performing the same or similar tests again, the user can input target test commands through the graphical user interface. These commands are essentially descriptions of specific test scenarios or requirements for a certain type of test. Upon receiving the target test command, the system can quickly perform a matching query in the script database, identify the corresponding first test script, and then directly call and execute this script, eliminating the tedious process of repeated configuration.
[0052] By storing test scripts in a script database and supporting intelligent invocation and execution based on target test instructions, users no longer need to configure scripts from scratch each time. Previously successfully executed test scripts can be easily invoked, saving significant time and effort, especially for periodic or routine testing tasks. Furthermore, the introduction of a script database provides a systematic and structured way to store and manage large numbers of test scripts, facilitating version control and historical tracking.
[0053] In an exemplary embodiment, after serializing the first operation instruction into a first test script, the method further includes: if a fifth parameter in the first test script is detected to have been modified, storing the modified fifth parameter in the script database, and sending a modification instruction to the target object to instruct the target object to determine a second test script to be executed, wherein the second test script includes: an unmodified first test script and a modified first test script.
[0054] To maintain the update and accuracy of the script database and improve user flexibility in modifying and executing test scripts, immediate action is taken when any modification to a parameter in the first test script (specifically the fifth parameter) is detected. First, the modified fifth parameter information is stored in the script database to ensure that the script content in the database remains consistent with the user's last modification, achieving version control and update management of the scripts. Next, a proactive response is sent to the user regarding the modification instruction. This feedback guides the user to confirm and select the version of the test script to execute next—either the original, unmodified version of the first test script or the version containing the user's latest modifications.
[0055] In this embodiment, users can quickly adjust test scripts in the face of constantly changing test requirements and environmental conditions. The system's immediate response and storage of modified parameters ensures this flexibility while also maintaining the integrity and consistency of the test scripts.
[0056] To better understand the process of generating the test scripts described above, the method for generating the test scripts will be further explained below with reference to optional embodiments, but this is not intended to limit the technical solutions of the embodiments of this application.
[0057] Figure 3 This is a schematic diagram of a test script generation method according to an embodiment of this application, such as... Figure 3 As shown, it specifically includes the following:
[0058] The system starts and loads the graphical user interface (GUI), while simultaneously building an empty vdbench model instance in memory as the skeleton for subsequent parameter configuration. Users then interact through the intuitive GUI, performing operations such as adding new host definitions, setting specific parameter values, or selecting preset templates from the existing template library. These user actions are then translated into API calls to the vdbench model, such as adding host definitions and modifying parameter values. These commands are received and executed by the parameter model management module, triggering the model's verification mechanism to ensure that parameter settings conform to vdbench specifications, such as threads values between 1 and 256, effectively preventing script failures or test result deviations due to incorrect parameter settings. The template application function further enhances the system's flexibility, allowing users to retrieve pre-saved model snapshots from the database to quickly build test scenarios. Whether replacing the current model or merging it, the modified results can be previewed in real time, ensuring the immediate availability of the test scripts. Once the parameter model is updated, the script generation engine responds immediately, traversing the entire model to generate a script string that conforms to vdbench syntax in real time. The updated script content is then displayed in the preview panel of the graphical user interface, and highlighted, allowing users to intuitively check and confirm the correctness of the script.
[0059] When the user is satisfied with the configuration and selects to export, the script generation engine will execute the final script build. The system then saves the complete script content as a text file by calling the operating system API. This file can be directly read and executed by the vdbench command-line tool, seamlessly integrating with the testing process. Furthermore, to facilitate project management and subsequent reuse, the system provides configuration persistence functionality, allowing users to serialize the current vdbench model into a custom .vdbproj file format and save it to disk. This creates a highly efficient test script generation platform that integrates parameter configuration, model validation, script generation, template reuse, script export, and project persistence. This greatly simplifies the creation and management of test scripts, reduces the learning curve for test engineers, and improves the overall efficiency of storage system testing.
[0060] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0061] Embodiments of this application also provide a test script generation apparatus. Figure 4 A structural block diagram of a test script generation device provided in this application embodiment is shown below. Figure 4 As shown, the device includes:
[0062] The determination module 42 is used to determine a first operation instruction based on the keywords input by the target object in the graphical user interface, wherein the first operation instruction is used to form a test case, and the test case is used to generate a test script;
[0063] Verification module 44 is used to verify the first operation instruction through the parameter model to determine whether the first operation instruction conforms to the preset standard;
[0064] The generation module 46 is used to serialize the first operation instruction into a first test script when it is determined that the first operation instruction conforms to the preset standard.
[0065] In this embodiment, a first operation instruction is determined based on the keywords input by the target object in the graphical user interface. The first operation instruction is used to form test cases, and the test cases are used to generate test scripts. The first operation instruction is validated through a parameter model to determine whether it conforms to a preset standard. If the first operation instruction conforms to the preset standard, it is serialized into a first test script. Therefore, this solves the problem in related technologies where test scripts rely entirely on manual completion using a text editor, which is prone to test failure due to spelling errors or incorrect parameter formats, effectively improving testing efficiency.
[0066] In an exemplary embodiment, the determining module 42 is further configured to determine a plurality of first parameters matching the keyword based on the keyword, and display the plurality of first parameters on the graphical user interface to instruct the target object to determine a second parameter among the plurality of first parameters; receive the second parameter fed back by the target object, and determine the first operation instruction based on the second parameter.
[0067] In an exemplary embodiment, the verification module 44 is further configured to perform validity verification and integrity verification on a plurality of second parameters in the first operation instruction through the parameter model, wherein the validity verification includes at least one of the following: determining whether the first parameter values of the plurality of second parameters are respectively within a plurality of preset ranges, determining whether the first unit of the plurality of second parameters is correct, and the plurality of second parameters correspond one-to-one with the plurality of preset ranges; the integrity verification includes: determining whether the first subordinate parameter of the plurality of second parameters has been set, wherein the first subordinate parameter is a sub-parameter of the plurality of second parameters.
[0068] In an exemplary embodiment, the verification module 44 is further configured to: determine that the first operation instruction has been successfully verified if the plurality of second parameters pass the validity verification and the integrity verification, and serialize the first operation instruction into the first test script; determine that the first operation instruction has failed verification if the plurality of second parameters fail the validity verification or the integrity verification, and determine the reason for the failure of the first operation instruction verification; send the first preset range to the target object if the reason is that a second parameter value among the plurality of first parameter values is not within the first preset range corresponding to the second parameter value, to instruct the target object to determine a third parameter value from the first preset range; determine the third parameter corresponding to the second unit if the reason is that a second unit among the plurality of first units is incorrect, and determine the correct third unit corresponding to the third parameter, wherein the plurality of second parameters includes the third parameter; determine the fourth parameter corresponding to the second lower-level parameter if the reason is that a second lower-level parameter among the plurality of first lower-level parameters is not set, and set a third lower-level parameter for the fourth parameter, wherein the plurality of second parameters includes the fourth parameter, and the third lower-level parameter is a sub-parameter of the fourth parameter.
[0069] In an exemplary embodiment, the generation module 46 is further configured to traverse multiple objects in the first operation instruction in a preset order using a serialization function to obtain multiple serialization results corresponding one-to-one with the multiple objects; and to concatenate the serialization results in the preset order to obtain the first test script.
[0070] In an exemplary embodiment, the generation module 46 is further configured to traverse a plurality of host definition objects in the first operation instruction through the serialization function; for each first object among the plurality of host definition objects, traverse the first object through the serialization function to determine the storage device and storage environment of the first object; traverse the storage device through the serialization function to determine the workload characteristics of the storage device; determine the execution definition of the first test script, wherein the execution definition is used to control the execution of the first test script, the plurality of objects include the plurality of host definition objects, the plurality of storage devices, the plurality of storage environments, the plurality of workload characteristics and the plurality of execution definitions, and the preset order is used to characterize the determination order of the plurality of objects.
[0071] In an exemplary embodiment, the generation module 46 is further configured to store the first test script in a script database; and, upon receiving a target test instruction through the graphical user interface, to call the first test script from the script database and execute the first test script, wherein the target test instruction corresponds to the first test script.
[0072] It should be noted that the description of the features in the embodiment corresponding to the test script generation device can be found in the relevant description of the embodiment corresponding to the test script generation method, and will not be repeated here.
[0073] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above-described test script generation method embodiments.
[0074] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described test script generation method embodiments at runtime.
[0075] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0076] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described test script generation method embodiments.
[0077] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described test script generation method embodiments.
[0078] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0079] The foregoing has provided a detailed description of a test script generation method, apparatus, electronic device, and product provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to aid in understanding the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A method for generating test scripts, characterized in that, include: The first operation instruction is determined based on the keywords entered by the target object in the graphical user interface, wherein the first operation instruction is used to form a test case, and the test case is used to generate a test script; The first operation instruction is verified by using a parameter model to determine whether the first operation instruction meets the preset standard. If the first operation instruction is determined to meet the preset standard, the first operation instruction is serialized into a first test script.
2. The method for generating test scripts according to claim 1, characterized in that, The first operation instruction is determined based on the keywords entered by the target object in the graphical user interface, including: Based on the keyword, a plurality of first parameters matching the keyword are determined, and the plurality of first parameters are displayed on the graphical user interface to instruct the target object to determine a second parameter from the plurality of first parameters; The system receives the second parameter from the target object and determines the first operation instruction based on the second parameter.
3. The method for generating test scripts according to claim 1, characterized in that, The first operation instruction is validated using a parameter model, including: The parameter model is used to perform validity and integrity checks on multiple second parameters in the first operation instruction. The validity check includes at least one of the following: determining whether the first parameter values of the multiple second parameters are respectively within multiple preset ranges, determining whether the first unit of the multiple second parameters is correct, and the multiple second parameters correspond one-to-one with the multiple preset ranges; the integrity check includes: determining whether the first subordinate parameter of the multiple second parameters has been set, and the first subordinate parameter is a sub-parameter of the multiple second parameters.
4. The method for generating test scripts according to claim 3, characterized in that, After verifying the first operation instruction using a parameter model, the method further includes: If the multiple second parameters pass the validity check and the integrity check, it is determined that the first operation instruction has been successfully verified, and the first operation instruction is serialized into the first test script; If the multiple second parameters fail the validity check or the integrity check, it is determined that the first operation instruction verification failed, and the reason for the failure of the first operation instruction verification is determined. If it is determined that the reason is that there is a second parameter value among the multiple first parameter values that is not within the first preset range corresponding to the second parameter value, the first preset range is sent to the target object to instruct the target object to determine the third parameter value from the first preset range; If it is determined that the cause is an error in a second unit among the multiple first units, a third parameter corresponding to the second unit is determined, and a correct third unit corresponding to the third parameter is determined, wherein the multiple second parameters include the third parameter; If it is determined that the reason is that a second lower-level parameter is not set among the multiple first lower-level parameters, a fourth parameter corresponding to the second lower-level parameter is determined, and a third lower-level parameter is set for the fourth parameter, wherein the multiple second parameters include the fourth parameter, and the third lower-level parameter is a sub-parameter of the fourth parameter.
5. The method for generating test scripts according to claim 1, characterized in that, Serializing the first operation instruction into a first test script includes: The serialization function iterates through multiple objects in the first operation instruction in a preset order to obtain multiple serialization results that correspond one-to-one with the multiple objects. The serialization results are concatenated according to the preset order to obtain the first test script.
6. The method for generating test scripts according to claim 5, characterized in that, The serialization function iterates through multiple objects in the first operation instruction in a preset order, including: The serialization function iterates through multiple host-defined objects in the first operation instruction; For each first object among the plurality of host definition objects, the first object is traversed through the serialization function to determine the storage device and storage environment of the first object; The storage device is traversed using the serialization function to determine the workload characteristics of the storage device. The execution definition of the first test script is determined, wherein the execution definition is used to control the execution of the first test script, the plurality of objects include the plurality of host definition objects, the plurality of storage devices, the plurality of storage environments, the plurality of workload characteristics and the plurality of execution definitions, and the preset order is used to characterize the determination order of the plurality of objects.
7. The method for generating test scripts according to claim 1, characterized in that, After serializing the first operation instruction into a first test script, the method further includes: Store the first test script in the script database; Upon receiving a target test instruction through the graphical user interface, the first test script is invoked from the script database and executed, wherein the target test instruction corresponds to the first test script.
8. A test script generation apparatus, characterized in that, include: The determination module is used to determine a first operation instruction based on the keywords input by the target object in the graphical user interface, wherein the first operation instruction is used to form a test case, and the test case is used to generate a test script; The verification module is used to verify the first operation instruction through the parameter model to determine whether the first operation instruction conforms to the preset standard. The generation module is used to serialize the first operation instruction into a first test script when it is determined that the first operation instruction conforms to the preset standard.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the test script generation method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the test script generation method as described in any one of claims 1 to 7.