Test case input parameter detection method and system, terminal and medium
By building an input parameter error database and configuring detection rules, the system automatically detects and corrects input parameter errors in test cases, solving the inefficiency problem when dealing with a large number of test cases and achieving an efficient and accurate testing process.
Patent Information
- Application Number
- CN202411154080.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-11-22
AI Technical Summary
In existing technologies, when the number of test cases is large, it is time-consuming and laborious for testers to analyze logs one by one and correct input parameter errors, which affects testing efficiency.
Build an input parameter error database, configure error detection rules, check the input parameters before test cases are executed, and automatically identify and correct errors using the error detection rules.
It improves the efficiency and accuracy of test case execution, and reduces the probability of test failure and subsequent repair costs.
Smart Images

Figure CN119003362A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of test case detection, and in particular to a test case input parameter detection method, system, terminal and medium. Background Art
[0002] Automated testing refers to the use of scripts or automated testing platforms to pre-configure the relevant environment and execute test cases in batches, with no human intervention or only a small amount of manual operation during the testing process. The usual automated testing process for automated testing of test cases using an automated testing platform is to import the test cases into the automated testing platform, run the test cases through the test scripts, wait for the automated testing to complete, and export the test results and test execution logs.
[0003] When the test environment is stable and the test script quality is high, the reason for the test case failure is usually that the test case input is incorrect. The conventional process to solve this problem is for testers to manually check and analyze the test logs, then correct the test case inputs one by one, and test again. However, if the number of test cases is large, it will take a lot of time for testers to analyze the logs one by one, correct the inputs, and execute the test cases again after the test is executed. It may even require multiple executions of the test cases, which greatly affects the test efficiency. Summary of the invention
[0004] To solve the above problems, the present invention provides a test case input parameter detection method, system, terminal and medium, which detect the input parameters before the test case is executed, and promptly discover input parameter errors so that they can be corrected before the test case is executed, thereby reducing the probability of test case execution failure and effectively improving the test case execution efficiency.
[0005] In a first aspect, the technical solution of the present invention provides a test case input parameter detection method, comprising the following steps: An input parameter error database is constructed based on the historical test case execution results. The input parameter error database contains a number of input parameter error messages, each of which contains an error type and an error content. The error type points to a functional module of the test case. Configure error detection rules for each input parameter error message based on the error content of each input parameter error message; Before executing the current test case, call the input parameter error database, compare the input parameter error information in the input parameter error database, use the corresponding error detection rules to perform input parameter detection on each corresponding functional module in the current test case, and return the input parameter detection result of the current test case.
[0006] In an optional implementation, building an input parameter error database based on historical test case execution results specifically includes: Read and open the log files obtained from the historical execution of test cases; Split log files into lines; Traverse all the split lines until an error flag is found; Use the identifier to identify the line where the error mark is located and record it as the error line; The function module name obtained in the error row is used as the key, and the error content corresponding to the function module is put into the dictionary as the value. The format is {"function module name": "error content"}, which is recorded as the error dictionary; Create a database of input parameter errors in the target format; Load the input parameter error database in dictionary format; Add the key-value pairs of the error dictionary to the input parameter error database and save the input parameter error database.
[0007] In an optional embodiment, an error detection rule is configured for each input parameter error message, specifically including; Retrieve all input parameter error information from the input parameter error database and display it in list form; For each input parameter error message in the list, obtain the correct input rules for the input parameters based on the product design documents and test methods; Establishing error detection rules corresponding to error contents in input parameter error information according to correct input parameter input rules; Configure a unique identifier for each error detection rule; A mapping relationship between the error detection rule and the corresponding input parameter error information is created with the unique identifier of the error detection rule and the error type of the corresponding input parameter error information as a key-value pair.
[0008] In an optional implementation, the input parameter error database is retrieved, and the input parameter error information in the input parameter error database is compared with each corresponding functional module in the current test case, and the input parameter detection rule is used to detect the input parameter, and the input parameter detection result of the current test case is returned, which specifically includes: Get each functional module of the current test case and sort each functional module; For the first function module of the current test case, the function module name is sequentially compared with the error type of each input parameter error information in the input parameter error database; If an error type that matches the name of the current function module is matched, the input parameter error information of the error type is the input parameter error information of the current function module; According to the mapping relationship between the input parameter error information and the error detection rule, the error detection rule corresponding to the input parameter error information of the current function module is retrieved; According to the error detection rules called, the target parameters in the input parameters of the current functional module are detected, and the input parameter detection results of the current test case are returned; If the error type that matches the current function module name is not matched, then for the second function module of the current test case, the function module name is sequentially compared with the error type of each input parameter error information in the input parameter error database; And so on, until all functional modules of the current test case are traversed.
[0009] In an optional implementation, the error detection rule includes an input parameter parsing sub-rule for parsing input parameters, an intermediate parameter calculation sub-rule for calculating intermediate parameters based on the input parameters, and a detection result feedback sub-rule for feedback detection and error detection.
[0010] In an optional implementation, according to the retrieved error detection rule, the target parameter in the input parameter of the current functional module is detected, and the input parameter detection result of the current test case is returned, specifically including: Use the input parameter parsing sub-rule to parse the input parameters of the current function module, convert the input parameter string form into a dictionary form, and hide the parameter unit in the dictionary form; Use the intermediate parameter calculation sub-rule to calculate the input parameters to obtain the intermediate parameters; Use the test result feedback sub-rule to judge the intermediate parameters and return the input parameter test results of the current test case.
[0011] In an optional implementation, after establishing an error detection rule corresponding to the error content in the input parameter error information according to the correct input rule of the input parameter, the following steps are also included: For the target parameter among the input parameters that need to be repaired, a corresponding error repair rule is established according to the correct input rule of the target parameter; Configure a unique identifier for each error repair rule; Using the unique identifier of the error repair rule and the error type of the corresponding input parameter error information as a key-value pair, a mapping relationship between the error repair rule and the corresponding input parameter error information is created; After returning the input parameter detection result of the current test case, the following steps are also included: If the input detection result is an input error, detect whether there is an error repair rule for the current input parameter based on the mapping relationship between the input parameter error information and the error repair rule; If so, the corresponding error repair rule is retrieved, and the target parameter in the current input parameter is repaired according to the retrieved error repair rule.
[0012] In a second aspect, the technical solution of the present invention provides a test case input parameter detection system, comprising: Input parameter error database construction module: constructs an input parameter error database based on historical test case execution results. The input parameter error database contains a number of input parameter error messages, each of which contains an error type and error content; the error type points to the functional module of the test case; Error detection rule configuration module: configures error detection rules for each input parameter error message according to the error content of each input parameter error message; Error detection execution module: Before executing the current test case, call the input parameter error database, compare the input parameter error information in the input parameter error database, use the corresponding error detection rules to perform input parameter detection on each corresponding functional module in the current test case, and return the input parameter detection result of the current test case.
[0013] In a third aspect, the technical solution of the present invention provides a terminal, including: A memory, used for storing a test case input parameter detection program; A processor is used to implement the steps of the test case input parameter detection method as described in any of the above items when executing the test case input parameter detection program.
[0014] In a fourth aspect, the technical solution of the present invention provides a computer-readable storage medium, on which a test case input parameter detection program is stored. When the test case input parameter detection program is executed by a processor, the steps of the test case input parameter detection method as described in any of the above items are implemented.
[0015] A test case input parameter detection method, system, terminal and medium provided by the present invention have the following beneficial effects compared with the prior art: first, an input parameter error database is constructed through the test results of historical test cases, and error detection rules are configured, and then before the actual test case is executed, based on the input parameter error database, the error detection rules are used to detect specific test case input parameters in the test case that are more prone to errors, so as to promptly discover input parameter errors so as to correct them in time, and can automatically and quickly identify potential input parameter errors, thereby avoiding errors that are prone to occur in tests, reducing the probability of test case execution failure, significantly improving the efficiency and accuracy of test execution, and reducing subsequent repair and maintenance costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 It is a flow chart of a test case input parameter detection method provided by an embodiment of the present invention.
[0018] Figure 2 This is a schematic diagram of the first input parameter error database construction process provided by an embodiment of the present invention.
[0019] Figure 3 It is a schematic diagram of the error detection rule configuration process provided by an embodiment of the present invention.
[0020] Figure 4 It is a schematic diagram of the process of detecting input parameter errors in the test case provided by the embodiment of the present invention.
[0021] Figure 5 It is a schematic diagram of the input parameter detection and repair process provided by an embodiment of the present invention.
[0022] Figure 6 The present invention provides a test case input parameter detection system structure schematic diagram.
[0023] Figure 7 It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0025] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0026] The key terms appearing in the present invention are explained below.
[0027] JSON: A data interchange format.
[0028] raid: disk array.
[0029] Figure 1 1 is a flow chart of a test case input parameter detection method provided by an embodiment of the present invention. Figure 1 The execution subject may be a doctor-patient interaction management system. The test case input parameter detection method provided in the embodiment of the present invention is executed by a computer device, and accordingly, the test case input parameter detection system runs in the computer device. According to different requirements, the order of the steps in the flowchart can be changed, and some can be omitted.
[0030] like Figure 1 As shown, the method includes the following steps.
[0031] S1, builds an input parameter error database based on historical test case execution results.
[0032] The input parameter error database of this embodiment contains several pieces of input parameter error information, each piece of input parameter error information contains an error type and an error content; wherein the error type points to the functional module of the test case. That is, the input parameter error information indicates which error occurred in which functional module of the test case. This embodiment first constructs an input parameter error database through the execution results of historical test cases, and stores some input parameter error information that is prone to errors. Initially, input parameter error information can be selected or constructed based on experience, and subsequently, input parameter error information is continuously added, and the input parameter error database is continuously improved to cover more error situations.
[0033] S2, configuring an error detection rule for each piece of input parameter error information according to the error content of each piece of input parameter error information.
[0034] Error detection rules are used to automatically detect whether there are errors in certain input parameters of certain functional modules of the test case. For each input parameter error information in the input parameter error database, a corresponding error detection rule is configured to detect input parameter errors in these functional modules before the test case is executed.
[0035] S3, before executing the current test case, retrieve the input parameter error database, compare the input parameter error information in the input parameter error database, use the corresponding error detection rules to perform input parameter detection on each corresponding functional module in the current test case, and return the input parameter detection result of the current test case.
[0036] Before the test case is executed, this embodiment compares each input parameter error information in the input parameter error database to find out the functional modules that can be detected in the test case, and then uses the corresponding error detection rules to detect and feedback the detection results, so as to realize input parameter error detection before the test case is executed, and then repair it in time, reduce the probability of test case execution failure, significantly improve the efficiency and accuracy of test execution, and reduce subsequent repair and maintenance costs.
[0037] Figure 2 This is a schematic diagram of a process for constructing an input parameter error database provided by an embodiment of the present invention. The construction process is implemented based on the analysis of the test case log, and can automatically parse the test case log, and record the error type and error content of the test case into the test case error database. The recording format of the test case automation test log is [time; log level; function name; content]. By parsing the test case log, the 'function name' and 'content' therein are extracted, which correspond to the function module name and error content respectively, so as to construct the input parameter error database.
[0038] S101, read and open the log file obtained by historically executing the test case.
[0039] S102, splitting the log file into lines.
[0040] S103, traverse all the split lines until an error flag is found.
[0041] S104, using the identifier as the identifier to segment the row where the error mark is located, and record it as the error row.
[0042] S105, putting the function module name obtained in the error row as the key and the error content corresponding to the function module as the value into a dictionary in the format of {"function module name": "error content"}, recorded as the error dictionary.
[0043] Example 1: Use Python to read and open the log file, split the log file by line, and traverse all the split lines until the error flag 'error flag' is found. Use ';' as the symbol to split the line log where the 'error flag' is located, use the obtained 'function name' as the key, and put the 'content' corresponding to the 'function name' as the value into the dictionary in the format of {'function name': 'content'}, recorded as error_dict.
[0044] Example 2: A test log is recorded as follows.
[0045] … 2024-08-06 09:59:17,324; ERROR; [ns_module]; nlb less than 0! … The test log comes from daily testing. The "ERROR" character in the log is detected. Use Python to split the log according to ";", where [ns_module] is the function name and "nlb less than 0!" is the error content. Combined with the function name, the meaning of the error content is: when creating ns, nlb is less than 0; ns refers to namespace, and nlb refers to Number of Logical Blocks, which indicates the size of ns. The obtained 'ns_module' is used as the key, and the corresponding 'nlb less than 0' of 'ns_module' is put into the dictionary as the value.
[0046] S106, creating an input parameter error database in a target format.
[0047] S107, loading an input parameter error database in a dictionary format.
[0048] S108, adding the key-value pairs of the error dictionary to the input parameter error database, and saving the input parameter error database.
[0049] For example, create a test case error database in JSON format, denoted as all_error.json. Use Python to load all_error.json in dictionary format, denoted as all_error_dict, add the key and value of error_dict to all_error_dict, save all_error_dict to all_error.json, and close all_error.json.
[0050] In addition to building an error dictionary by parsing logs, this embodiment also provides another error dictionary construction method, which is based on the analysis of error codes and can automatically parse error codes, and then record the error type and error content of the test case into the test case error database. The error code contains three digits, generally three hexadecimal digits, the highest bit points to the wrong function module, and the lower two bits represent the sub-function module and the specific error content.
[0051] S111, obtain an error code comparison table.
[0052] S112, traverse the error code comparison table, and put each error code and its error content into a dictionary in the format of a key-value pair {"error code": "error content"}, which is recorded as an error dictionary.
[0053] For example, when creating a raid, the result is returned as a failure, and the error code 0x101 is returned. The highest bit of the error code is '1', which refers to the raid module, the second bit '0' refers to the raid creation function in the raid module, and the third bit '1' refers to the raid_size being invalid. Therefore, the meaning of the error code is that the raid_size used when creating the raid is invalid. The obtained error code 0x101 is used as the key, and the error content "raid_size is invalid" corresponding to the error code is put into the dictionary as the value. The error type is identified by the error code, which can point to the function module.
[0054] S113, creating an input parameter error database in a target format.
[0055] S114, loading an input parameter error database in a dictionary format.
[0056] S115, adding the key-value pairs of the error dictionary to the input parameter error database, and saving the input parameter error database.
[0057] Step S113 to step S115 are the same as the above-mentioned step S106 to step S108 and will not be repeated here.
[0058] This embodiment significantly reduces the time of manually finding and recording errors by automatically extracting error information from the log files of historically executed test cases, and realizes the rapid location and organization of error information. Errors are classified according to functional modules and stored in a dictionary (error dictionary), providing a clear structured view for error tracking. This structured error recording method facilitates subsequent error analysis, priority sorting, and repair progress tracking.
[0059] Figure 3 It is a schematic diagram of the error detection rule configuration process provided by an embodiment of the present invention. Corresponding error detection rules are formulated according to correct input rules and mapped to corresponding input parameter error information to achieve automatic matching and detection execution of subsequent error detection rules.
[0060] S201, retrieve all input parameter error information in the input parameter error database and display them in a list form.
[0061] The purpose of this step is to help testers find the correct input rules for each input parameter error message and display them in a list for easy viewing.
[0062] S202: For each input parameter error message in the list, obtain a correct input rule for the input parameter according to the product design document and the test method.
[0063] Load the correct input rule database, and analyze the cause of the parameter input error by finding the input specification of the relevant parameters in the correct input rule. The correct input rule database can be obtained through the product detailed design document and product detailed test plan.
[0064] S203: Establish an error detection rule corresponding to the error content in the input parameter error information according to the correct input rule of the input parameter.
[0065] The principle of the error detection rule is that if the correct input rule is met, the parameter input is correct, otherwise, it is considered that the input is wrong. Accordingly, the error detection rule of this embodiment includes an input parameter parsing sub-rule, an intermediate parameter calculation sub-rule, and a detection result feedback sub-rule. The input parameter parsing sub-rule is used to parse the input parameters to convert the input parameters into a specific format for subsequent calculations. The intermediate parameter calculation sub-rule is used to calculate the intermediate parameters based on the input parameters. The intermediate parameters can characterize whether the target parameters (referring to the parameters with errors) in the input parameters are wrong. The detection result feedback sub-rule is used to feedback the detection results, for example, using 0 to indicate that the target parameter is correctly input, and using 1 to indicate that the target parameter is incorrectly input.
[0066] S204: Configure a unique identifier for each error detection rule.
[0067] The purpose of this step is to facilitate the subsequent establishment of a mapping relationship so as to correctly retrieve the corresponding error detection rules.
[0068] S205 , using the unique identifier of the error detection rule and the error type of the corresponding input parameter error information as a key-value pair, create a mapping relationship between the error detection rule and the corresponding input parameter error information.
[0069] Establish a mapping relationship between error detection rules and corresponding input parameter error information to facilitate subsequent retrieval of correct error detection rules.
[0070] It should be noted that the correct input rule is still a natural language, while the detection rule is a specific function or a specific code that can be directly executed in the automated test process. Abstracting all the correct input rules and the combination of various correct input rules into code is a huge workload. Moreover, the purpose of the test is not to verify whether the input is correct or not, but to find the defects of the product itself. At the same time, the type and range of certain input parameters are very clear, and generally there will be no input errors. Based on this, this embodiment generates corresponding detection rules according to the specific errors found in the test process, and ensures the effectiveness of error detection on the basis of reducing the workload.
[0071] For example, use the use case input parameters to create a raid, the parameters are "raid_level=5;raid_size=100k;raid_id=0;disk_num=3;chunk_size=64k;pdid=[1,2,3]". The raid is created, and the result returns failure, returning the error code 0x101. The highest bit of the error code is '1', which refers to the raid module, the second bit '0' refers to the raid creation function in the raid module, and the third bit '1' means that the raid_size is invalid. Therefore, the meaning of the error code is that the raid_size used when creating the raid is invalid.
[0072] The detection method is to use raid_size to divide stripe_size. If the remainder is 0, the raid_size input is correct, otherwise the raid_size is incorrect. This is the natural language of the detection rule.
[0073] The detection code needs to be written manually. The following is the code corresponding to the detection rule, which only contains function functions and simple logic descriptions. The coding language is Python: decode_lgc_arg(arg): '''Function: Convert test case input parameters to a dictionary''' The input is "raid_level=5;raid_size=100k;raid_id=0;disk_num=3;chunk_size=64k;pdid=[1,2,3]" The output is {"raid_level": 5, "raid_size": 100, "raid_id": 0, "disk_num": 3, "chunk_size": 64, "pdid": [1,2,3]} get_raid_stripe_size(raid_id, raid_level, chunk_size, disk_num): '''Function: Calculate the stripe_size of raid''' Input is raid_id, raid_level, chunk_size, disk_num Output is stripe_size check_raid_size(raid_id, raid_size, stripe_size): '''Function: detect raid_size''' Input is raid_id, raid_size, stripe_size If raid_size is an integer multiple of stripe_size, it returns 0, otherwise it returns 1 (a non-zero value means failure).
[0074] Figure 4 It is a schematic diagram of the input parameter error detection process in the test case provided by an embodiment of the present invention. Before the test case is executed, it is matched with the input parameter error information in the input parameter error database, and error detection rules are used to perform error detection, so as to timely discover the input parameter errors in the test case.
[0075] S301, obtaining each functional module of the current test case and sorting each functional module.
[0076] S302: for the first function module of the current test case, the function module name is sequentially compared with the error type of each input parameter error information in the input parameter error database.
[0077] S303: If an error type consistent with the name of the current functional module is matched, the input parameter error information of the error type is the input parameter error information of the current functional module.
[0078] S304: According to the mapping relationship between the input parameter error information and the error detection rule, the error detection rule corresponding to the input parameter error information of the current function module is retrieved.
[0079] S305 , detecting the target parameters in the input parameters of the current functional module according to the retrieved error detection rule, and returning the input parameter detection result of the current test case.
[0080] S306, if the error type consistent with the current function module name is not matched, then for the second function module of the current test case, its function module name is compared and matched with the error type of each input parameter error information in the input parameter error database in turn; and so on, until all function modules of the current test case are traversed.
[0081] First, the functional modules of the current test case are checked to locate which functional modules need to be tested. To facilitate detection, the functional modules are sorted to achieve sequential detection. For each functional module, it is matched with the error type of each input parameter error information in the input parameter error database. The error type points to the functional module, and the comparison and matching with the functional module can be achieved. If there is an error type that matches the current functional module, it means that the current functional module needs to be tested. At this time, the corresponding error detection rules can be called for detection. Traverse all functional modules to achieve complete error detection of the test case.
[0082] Among them, according to the retrieved error detection rules, the target parameters in the input parameters of the current functional module are detected, and the input parameter detection results of the current test case are returned, which specifically includes the following steps.
[0083] S305.1, using the input parameter parsing sub-rule to parse the input parameters of the current function module, so that the input parameter string form is converted into a dictionary form, and the parameter unit is hidden in the dictionary form.
[0084] After receiving the test case input parameter, the input parameter is a string with certain rules. Use the input parameter parsing sub-rule (which can be an input parameter parsing function) to split the string according to certain rules, convert the text format in the string into the corresponding numerical format, and if there are units in the string, convert the units in the string accordingly. Save the parsed parameters in the dictionary ({key:value}) for subsequent use or related operations. Dictionary is a commonly used data type, key refers to the parameter name, and value refers to the parameter content.
[0085] S305.2, using the intermediate parameter calculation sub-rule, calculate the input parameters to obtain the intermediate parameters.
[0086] The intermediate parameter calculation sub-rule can be an intermediate parameter calculation function, which performs certain operations on the parsed input parameters to obtain the intermediate parameters. The intermediate parameters represent whether the target parameters in the input parameters are wrong.
[0087] S305.3, use the detection result feedback sub-rule to judge the intermediate parameters and return the input parameter detection result of the current test case.
[0088] The detection result feedback sub-rule may be a detection result feedback function, which judges the intermediate parameter, for example, whether it is greater than zero, or whether it is an integer, etc., and feeds back the detection result according to the judgment result.
[0089] Example 1: Use the automated test platform to execute automated test cases and test the raid function. Define a function to create a raid, named lgc_create_raid. The function requires input parameters: raid_level, raid_size, raid_id, disk_num, chunk_size, pdid. raid_level refers to the level of creating the raid, raid_size refers to the size of the created raid, raid_id refers to the number of creating the raid, disk_num refers to the number of disks used to create the raid, chunk_size refers to the stripe unit size, which means the data block written to a single physical disk each time, and pdid refers to the number of the physical disk used.
[0090] Creating a raid is a pre-step to test the raid function. In normal testing, the expected result of creating a raid is success. However, in actual testing, creating a raid often fails, which is usually caused by incorrect input parameters.
[0091] The reasons for input parameter errors may be: the tester's misunderstanding of the test parameter boundaries; the tester's lack of understanding of the logical relationship between test parameters; the developer changed the test parameter boundaries and failed to synchronize them to the tester in time. In addition, even if the tester checks the incorrect input, it is difficult for the testers to completely align the information of the same type of incorrect input, which makes the same type of errors occur repeatedly in actual testing and difficult to completely avoid.
[0092] Use the use case input parameters to create a raid, the parameters are "raid_level=5;raid_size=100k;raid_id=0;disk_num=3;chunk_size=64k;pdid=[1,2,3]". Create raid, the result returns failure, return error code 0x101, the highest bit of the error code is '1', referring to the raid module, the second bit '0' refers to the raid creation function in the raid module, and the third bit '1' means that raid_size is invalid. Therefore, the meaning of the error code is that the raid_size used when creating raid is invalid.
[0093] Use the input parameter parsing sub-rule to parse the input parameters. The input parameter before parsing is a string. The parsed parameters are {raid_level: 5, raid_size: 100, raid_id: 0, disk_num: 3, chunk_size: 64, pdid: [1,2,3]}, where raid_level, raid_id, disk_num are integers, raid_size, chunk_size are also integers, and the unit is k. The unit is hidden in the dictionary to facilitate value calculation. Use the intermediate parameter calculation sub-rule to calculate the stripe size (stripe_size) after parsing. The stripe_size is calculated to detect the raid_size. The stripe_size is calculated by subtracting the number of check disks (physical disks storing check data) from disk_num, and then multiplying it by the stripe unit size. The number of check disks is uniquely corresponding to raid_level. According to the input parameters, the value of raid_level is 5, so the number of check disks is 1 and the stripe size is 64 * (3- 1) = 128 (k).
[0094] Analyze the cause of the error, raid_size=100k, the size of the created raid is 100k. However, to create a raid, raid_size must comply with the correct rules - raid_size is an integer multiple of stripe_size. The stripe_size has been calculated to be 128k in the previous paragraph. 100k is obviously not an integer multiple of 128k, so the input raid_size is invalid.
[0095] Detection method: Use raid_size to divide stripe_size. If the remainder is 0, the raid_size input is correct, otherwise the raid_size is incorrect.
[0096] Example 2: Create a test case for ns, input parameters are "raid_size=10240k;chunk_size=64k;ns_num=5", the purpose of this test case is to test the use of 10M raid capacity, create 5 ns of the same size. raid_size refers to the size of the raid, chunk_size refers to the stripe unit size, stripe unit means each time write a single physical disk data block, ns_num refers to the number of created ns.
[0097] Using the above parameters to create ns, the result returns failure, as shown in the following test log: … 2024-08-06 09:59:17,324; ERROR; [ns_module]; nlb less than 0! … From the error log, we can see that nlb is less than 0, that is, the size of the created ns is less than 0.
[0098] Use the decode_lgc_arg mentioned above to parse the input parameters and get dict_arg={ "raid_size": 10240, "chunk_size": 64, "ns_num": 5}; define the function to calculate nlb, get_ns_nlb(raid_size, ns_num, chunk_size), the architecture design defines that each ns must be separated by 50*chunk_size, so the size of each ns, that is, nlb=[raid_size – (ns_num – 1)*50*chunk_size] / ns_num, "ns_num – 1" means that the number of intervals is 1 less than the number of ns. Use the parsed parameters to calculate nlb, nlb=[10240 – (5 – 1)*50*64] / 5, and get nlb=-512.
[0099] Define a function to check nlb, check_ns_nlb(raid_size, ns_num, chunk_size), first calculate nlb, if nlb is greater than 0, return 0, otherwise return 1 (non-zero value means failure).
[0100] Figure 5 It is a schematic diagram of the input parameter detection and repair process provided by an embodiment of the present invention, including steps SS1-SS5. On the basis of the input parameter detection in the above embodiment, it also automatically repairs after the error is detected. Configure error repair rules for input parameter error information that needs to be repaired. Specifically, after establishing error detection rules corresponding to the error content in the input parameter error information according to the correct input rules of the input parameters, establish corresponding error repair rules for the target parameters in the input parameters that need to be repaired according to the correct input rules of the target parameters, configure a unique identifier for each error repair rule, and use the unique identifier of the error repair rule and the error type of the corresponding input parameter error information as a key-value pair to create a mapping relationship between the error repair rule and the corresponding input parameter error information. The principle of the error repair rule is to make the repaired parameters conform to the correct input rules, and the repaired parameters meet the test purpose of this test case.
[0101] Furthermore, after detecting the input parameters and returning the input parameter detection result of the current test case, if the input detection result is an input error, it is detected whether there is an error repair rule for the current input parameter based on the mapping relationship between the input parameter error information and the error repair rule. If so, the corresponding error repair rule is called, and the target parameter in the current input parameter is repaired according to the called error repair rule.
[0102] For the repair method of Example 1 of creating a raid above, the correct input rules are known, requiring raid_size to be an integer multiple of stripe_size. Divide stripe_size by the parsed raid_size, add 1 to the result of the division, the purpose is to round up, multiply the result of adding 1 by stripe_size, get the new raid_size, and the repair is complete. Rounding up is to make the new raid_size conform to the correct input rules and be larger than the original raid_size, to avoid the repaired raid_size being smaller than the original raid_size, and introduce new errors. For example, the subsequent test steps read and write data of the entire raid size. If the repaired raid_size is smaller than the original raid_size, the read and write size will exceed the range of the raid, and the use case execution will fail.
[0103] After that, the test case can be executed using the repaired input parameters, and the test case results and the test case execution log are output. In this example 1, the values and units of raid_level, raid_size, raid_id, disk_num, chunk_size, and pdid can be flexibly changed. The error detection rule and error repair rule of this embodiment can detect and repair the raid_size error, and the multiplexing is very strong. The above is the detection and repair of raid_size, but it is not necessary to detect and repair chunk_size or raid_level, etc., because chunk_size is a fixed size of 64k, and the values of raid_level are 0, 1, 5, 6. They are relatively fixed in value or simple in boundary range, and generally will not make mistakes. Moreover, from the test case error record database, there is basically no input error of chunk_size or raid_level.
[0104] For the above example 2 of creating ns, the correctness of creating ns is the focus of the test. Therefore, only the correctness of the test parameters is tested, and the wrong parameters are not repaired. There is no corresponding repair rule. After receiving the test case parameter detection results, the tester can manually repair the parameters according to the actual test requirements, and use the repaired test parameters to test again.
[0105] An embodiment of a test case input parameter detection method is described in detail above. Based on the test case input parameter detection method described in the above embodiment, an embodiment of the present invention also provides a test case input parameter detection system corresponding to the method.
[0106] Figure 6 6 is a schematic block diagram of a test case input parameter detection system according to an embodiment of the present invention. In this embodiment, the test case input parameter detection system 600 can be divided into multiple functional modules according to the functions it performs, such as Figure 6 The functional modules may include: an input parameter error database construction module 610, an error detection rule configuration module 620, an error detection execution module 630, an error repair rule configuration module 640, and an error repair execution module 650. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory.
[0107] Input parameter error database construction module 610: constructs an input parameter error database according to historical test case execution results. The input parameter error database contains a number of input parameter error messages, each of which contains an error type and error content; wherein the error type points to the functional module of the test case.
[0108] Error detection rule configuration module 620: configures an error detection rule for each piece of input parameter error information according to the error content of each piece of input parameter error information.
[0109] Error detection execution module 630: Before executing the current test case, call the input parameter error database, compare the input parameter error information in the input parameter error database, use the corresponding error detection rules to perform input parameter detection on each corresponding functional module in the current test case, and return the input parameter detection result of the current test case.
[0110] In an optional implementation, the input parameter error database construction module 610 constructs an input parameter error database according to historical test case execution results, specifically including: Read and open the log files obtained by historically executing test cases; Split log files into lines; Traverse all the split lines until an error flag is found; Use the identifier to identify the line where the error mark is located and record it as the error line; The function module name obtained in the error row is used as the key, and the error content corresponding to the function module is put into the dictionary as the value. The format is {"function module name": "error content"}, which is recorded as the error dictionary; Create a database of input parameter errors in the target format; Load the input parameter error database in dictionary format; Add the key-value pairs of the error dictionary to the input parameter error database and save the input parameter error database.
[0111] In an optional embodiment, the error detection rule configuration module 620 configures error detection rules for each input parameter error information, specifically including; Retrieve all input parameter error information from the input parameter error database and display it in list form; For each input parameter error message in the list, obtain the correct input rules for the input parameters based on the product design documents and test methods; Establishing error detection rules corresponding to error contents in input parameter error information according to correct input parameter input rules; Configure a unique identifier for each error detection rule; A mapping relationship between the error detection rule and the corresponding input parameter error information is created with the unique identifier of the error detection rule and the error type of the corresponding input parameter error information as a key-value pair.
[0112] In an optional implementation, the error detection execution module 630 retrieves an input parameter error database, compares the input parameter error information in the input parameter error database with each corresponding functional module in the current test case, uses corresponding error detection rules to detect the input parameters, and returns the input parameter detection result of the current test case, which specifically includes: Get each functional module of the current test case and sort each functional module; For the first function module of the current test case, the function module name is sequentially compared with the error type of each input parameter error information in the input parameter error database; If an error type that matches the name of the current function module is matched, the input parameter error information of the error type is the input parameter error information of the current function module; According to the mapping relationship between the input parameter error information and the error detection rule, the error detection rule corresponding to the input parameter error information of the current function module is retrieved; According to the error detection rules called, the target parameters in the input parameters of the current functional module are detected, and the input parameter detection results of the current test case are returned; If the error type that matches the current function module name is not matched, then for the second function module of the current test case, the function module name is sequentially compared with the error type of each input parameter error information in the input parameter error database; And so on, until all functional modules of the current test case are traversed.
[0113] In an optional implementation, the error detection rule includes an input parameter parsing sub-rule for parsing input parameters, an intermediate parameter calculation sub-rule for calculating intermediate parameters based on the input parameters, and a detection result feedback sub-rule for feedback detection and error detection.
[0114] In an optional implementation, according to the retrieved error detection rule, the target parameter in the input parameter of the current functional module is detected, and the input parameter detection result of the current test case is returned, specifically including: Use the input parameter parsing sub-rule to parse the input parameters of the current function module, convert the input parameter string form into a dictionary form, and hide the parameter unit in the dictionary form; Use the intermediate parameter calculation sub-rule to calculate the input parameters to obtain the intermediate parameters; Use the test result feedback sub-rule to judge the intermediate parameters and return the input parameter test results of the current test case.
[0115] In an optional embodiment, the system 600 further includes an error repair rule configuration module 640: for a target parameter in the input parameters to be repaired, a corresponding error repair rule is established according to a correct input rule of the target parameter; a unique identifier is configured for each error repair rule; a mapping relationship between the error repair rule and the corresponding input parameter error information is created using the unique identifier of the error repair rule and the error type of the corresponding input parameter error information as a key-value pair; System 600 also includes an error repair execution module 650: if the input detection result is an input error, it is detected whether there is an error repair rule for the current input parameter based on the mapping relationship between the input parameter error information and the error repair rule; if so, the corresponding error repair rule is called, and the target parameter in the current input parameter is repaired according to the called error repair rule.
[0116] The test case input parameter detection system of this embodiment is used to implement the aforementioned test case input parameter detection method. Therefore, the specific implementation method of the system can be seen in the embodiment part of the test case input parameter detection method in the previous text. Therefore, its specific implementation method can refer to the description of the corresponding embodiments of each part, which will not be elaborated here.
[0117] In addition, since the test case input parameter detection system of this embodiment is used to implement the aforementioned test case input parameter detection method, its function corresponds to that of the aforementioned method and will not be described in detail here.
[0118] Figure 7A schematic diagram of the structure of a terminal 700 provided in an embodiment of the present invention includes: a processor 720, a memory 720 and a communication unit 730. The processor 720 is used to implement the following steps when implementing the test case input parameter detection program stored in the memory 720: An input parameter error database is constructed based on the historical test case execution results. The input parameter error database contains a number of input parameter error messages, each of which contains an error type and an error content. The error type points to a functional module of the test case. Configure error detection rules for each input parameter error message; Before executing the current test case, call the input parameter error database, compare the input parameter error information in the input parameter error database, use the corresponding error detection rules to perform input parameter detection on each corresponding functional module in the current test case, and return the input parameter detection result of the current test case.
[0119] The terminal 700 includes a processor 720, a memory 720 and a communication unit 730. These components communicate via one or more buses. It can be understood by those skilled in the art that the structure of the server shown in the figure does not constitute a limitation of the present invention, and it can be a bus structure or a star structure, and can also include more or less components than shown in the figure, or combine some components, or arrange the components differently.
[0120] The memory 720 can be used to store the execution instructions of the processor 720, and the memory 720 can be implemented by any type of volatile or non-volatile storage terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. When the execution instructions in the memory 720 are executed by the processor 720, the terminal 700 can execute some or all of the steps in the following method embodiments.
[0121] The processor 720 is the control center of the storage terminal, and uses various interfaces and lines to connect various parts of the entire electronic terminal. It runs or executes software programs and / or modules stored in the memory 720, and calls data stored in the memory to perform various functions of the electronic terminal and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 720 can include only a central processing unit (CPU). In an embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.
[0122] The communication unit 730 is used to establish a communication channel so that the storage terminal can communicate with other terminals, receive user data sent by other terminals or send user data to other terminals.
[0123] The present invention also provides a computer storage medium, wherein the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0124] The computer storage medium stores a test case input parameter detection program, and when the test case input parameter detection program is executed by the processor, the following steps are implemented: An input parameter error database is constructed based on the historical test case execution results. The input parameter error database contains a number of input parameter error messages, each of which contains an error type and an error content. The error type points to a functional module of the test case. Configure error detection rules for each input parameter error message; Before executing the current test case, call the input parameter error database, compare the input parameter error information in the input parameter error database, use the corresponding error detection rules to perform input parameter detection on each corresponding functional module in the current test case, and return the input parameter detection result of the current test case.
[0125] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention, in essence or in other words, the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes, including several instructions for enabling a computer terminal (which can be a personal computer, a server, or a second terminal, a network terminal, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention.
[0126] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0127] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0128] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0129] The above disclosure is only a preferred embodiment of the present invention, but the present invention is not limited thereto. Any non-creative changes that can be thought of by a person skilled in the art, as well as several improvements and modifications made without departing from the principle of the present invention, should fall within the protection scope of the present invention.
Claims
1. A test case input parameter detection method, characterized in that: The following steps are involved: An input parameter error database is constructed based on the historical test case execution results. The input parameter error database contains a number of input parameter error messages, each of which contains an error type and an error content. The error type points to a functional module of the test case. Configure error detection rules for each input parameter error message based on the error content of each input parameter error message; Before executing the current test case, call the input parameter error database, compare the input parameter error information in the input parameter error database, use the corresponding error detection rules to perform input parameter detection on each corresponding functional module in the current test case, and return the input parameter detection result of the current test case.
2. The test case input parameter detection method according to claim 1, characterized in that: Build an input parameter error database based on historical test case execution results, including: Read and open the log files obtained from the historical execution of test cases; Split log files into lines; Traverse all the split lines until an error flag is found; Use the identifier to identify the line where the error mark is located and record it as the error line; The function module name obtained in the error row is used as the key, and the error content corresponding to the function module is put into the dictionary as the value. The format is {"function module name": "error content"}, which is recorded as the error dictionary; Create a database of input parameter errors in the target format; Load the input parameter error database in dictionary format; Add the key-value pairs of the error dictionary to the input parameter error database and save the input parameter error database.
3. The test case input parameter detection method according to claim 1, characterized in that: Configure error detection rules for each input parameter error message, including: Retrieve all input parameter error information from the input parameter error database and display it in list form; For each input parameter error message in the list, obtain the correct input rules for the input parameters based on the product design documents and test methods; Establishing error detection rules corresponding to error contents in input parameter error information according to correct input parameter input rules; Configure a unique identifier for each error detection rule; A mapping relationship between the error detection rule and the corresponding input parameter error information is created with the unique identifier of the error detection rule and the error type of the corresponding input parameter error information as a key-value pair.
4. The test case input parameter detection method according to claim 3, characterized in that: Retrieve the input parameter error database, compare the input parameter error information in the input parameter error database with the corresponding function modules in the current test case, use the corresponding error detection rules to detect the input parameters, and return the input parameter detection results of the current test case, including: Get each functional module of the current test case and sort each functional module; For the first function module of the current test case, the function module name is sequentially compared with the error type of each input parameter error information in the input parameter error database; If an error type that matches the name of the current function module is matched, the input parameter error information of the error type is the input parameter error information of the current function module; According to the mapping relationship between the input parameter error information and the error detection rule, the error detection rule corresponding to the input parameter error information of the current function module is retrieved; According to the error detection rules called, the target parameters in the input parameters of the current functional module are detected, and the input parameter detection results of the current test case are returned; If the error type that matches the current function module name is not matched, then for the second function module of the current test case, the function module name is sequentially compared with the error type of each input parameter error information in the input parameter error database; And so on, until all functional modules of the current test case are traversed.
5. The test case input parameter detection method according to claim 4, characterized in that: The error detection rules include input parameter parsing sub-rules for parsing input parameters, intermediate parameter calculation sub-rules for calculating intermediate parameters based on input parameters, and detection result feedback sub-rules for feedback detection and failure.
6. The test case input parameter detection method according to claim 5, characterized in that: According to the error detection rules called, the target parameters in the input parameters of the current functional module are detected, and the input parameter detection results of the current test case are returned, including: Use the input parameter parsing sub-rule to parse the input parameters of the current function module, convert the input parameter string form into a dictionary form, and hide the parameter unit in the dictionary form; Use the intermediate parameter calculation sub-rule to calculate the input parameters to obtain the intermediate parameters; Use the test result feedback sub-rule to judge the intermediate parameters and return the input parameter test results of the current test case.
7. The test case input parameter detection method according to any one of claims 3 to 6, characterized in that: After establishing an error detection rule corresponding to the error content in the input parameter error information according to the correct input rule of the input parameter, the following steps are also included: For the target parameter among the input parameters that need to be repaired, a corresponding error repair rule is established according to the correct input rule of the target parameter; Configure a unique identifier for each error repair rule; Using the unique identifier of the error repair rule and the error type of the corresponding input parameter error information as a key-value pair, a mapping relationship between the error repair rule and the corresponding input parameter error information is created; After returning the input parameter detection result of the current test case, the following steps are also included: If the input detection result is an input error, detect whether there is an error repair rule for the current input parameter based on the mapping relationship between the input parameter error information and the error repair rule; If so, the corresponding error repair rule is retrieved, and the target parameter in the current input parameter is repaired according to the retrieved error repair rule.
8. A test case input parameter detection system, characterized in that: include, Input parameter error database construction module: constructs an input parameter error database based on historical test case execution results. The input parameter error database contains a number of input parameter error messages, each of which contains an error type and error content; the error type points to the functional module of the test case; Error detection rule configuration module: configures error detection rules for each input parameter error message according to the error content of each input parameter error message; Error detection execution module: Before executing the current test case, call the input parameter error database, compare the input parameter error information in the input parameter error database, use the corresponding error detection rules to perform input parameter detection on each corresponding functional module in the current test case, and return the input parameter detection result of the current test case.
9. A terminal, characterized in that: include: A memory, used for storing a test case input parameter detection program; A processor, used to implement the steps of the test case input parameter detection method as described in any one of claims 1 to 7 when executing the test case input parameter detection program.
10. A computer-readable storage medium, characterized in that: The readable storage medium stores a test case input parameter detection program, and when the test case input parameter detection program is executed by the processor, the steps of the test case input parameter detection method according to any one of claims 1 to 7 are implemented.
