A testing method, device, equipment and storage medium
By decomposing the test script into multiple subscripts in parallel testing and using multiple script executors for parallel testing, the problem of low testing efficiency under the rapid construction of cloud resource pools is solved, and efficient batch script testing is achieved.
Patent Information
- Application Number
- CN202110343114.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-30
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2041-03-30
AI Technical Summary
The existing script testing solution cannot meet the large number of product testing needs under the rapid construction of cloud resource pools, and the testing efficiency is inefficient.
By decomposing the test script into multiple test subscripts and using multiple script executors for parallel testing, the sub-results are merged to obtain the final test result.
Improve script testing efficiency, implement batch script testing, and shorten test time.
Smart Images

Figure CN115145803B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to automated testing technology, and in particular to a testing method, apparatus, device, and storage medium. Background Art
[0002] Currently, script testing is done by configuring the variables in the script file to the physical address and port of the execution machine. The script file can be transferred to the execution machine based on the physical address and port, and the tester manually starts the script test to finally complete the script test.
[0003] However, the existing script testing solution uses a single executor to test the test script. With the rapid construction of cloud resource pools, the product testing workload has increased dramatically. The existing script testing efficiency can no longer meet the testing needs of a large number of products, and the testing efficiency is low. Summary of the Invention
[0004] In order to solve the above technical problems, the present application provides a testing method, apparatus, device and storage medium.
[0005] The technical solution of this application is achieved as follows:
[0006] In a first aspect, a script testing method is provided, the method comprising:
[0007] Obtain at least one test script to be tested;
[0008] Decomposing a target test script in the at least one test script according to script functions to obtain M test sub-scripts; wherein the target test script is any one of the at least one test script;
[0009] According to a preset resource allocation strategy, determine N script executors for executing the M test sub-scripts; wherein M and N are integers greater than 1;
[0010] Controlling the N script executors to perform parallel testing on the M test sub-scripts to obtain M test sub-results corresponding to the target test script;
[0011] The M test sub-results are merged to obtain a test result corresponding to the target test script.
[0012] In the above scheme, obtaining at least one test script to be tested includes: obtaining at least one test script information corresponding to the at least one test script from the first message queue; and obtaining at least one test script from the script storage unit based on the at least one test script information.
[0013] In the above scheme, before obtaining at least one test script information corresponding to the at least one test script from the first message queue, the method also includes: receiving at least one script request information; using a preset verification algorithm to verify whether the information type of the at least one script request information is consistent with the information type of the preset request information; if the verification is consistent, decomposing the at least one script request information according to the preset information requirements to obtain the at least one test script information; and storing the at least one test script information in the first message queue.
[0014] In the above scheme, the test script information includes: identification information and execution volume of the test script; after obtaining at least one test script information corresponding to the at least one test script from the first message queue, the method also includes: determining the execution volume of the at least one test script from the at least one test script information; obtaining the idle execution volume of the idle script executor in the script execution unit; judging whether the execution condition is met based on the execution volume of the at least one test script and the idle execution volume; determining that the execution condition is met, obtaining at least one test script from the script storage unit based on the identification information of the at least one test script.
[0015] In the above scheme, the determination that the execution condition is met and the acquisition of the at least one test script from the script storage unit based on the identification information of the at least one test script include: when it is determined that the execution condition is met, determining to execute at least one thread corresponding to the at least one test script; executing the at least one thread and sending the at least one test script information to the script analysis unit based on the script analysis unit address information; controlling the script analysis unit to allocate the corresponding at least one analyzer based on the identification information of the at least one test script; and controlling the at least one analyzer to acquire the at least one test script from the script storage unit based on the identification information of the at least one test script.
[0016] In the above scheme, after merging the M test sub-results to obtain the test results corresponding to the target test script, the method also includes: sending at least one test result corresponding to the at least one test script to the at least one analyzer; controlling the at least one analyzer to send the at least one test result to the script analysis unit; controlling the script analysis unit to store the at least one test result in a second message queue; obtaining the at least one test result from the second message queue, and backfilling the at least one test result to the local database.
[0017] In the above scheme, the method also includes: if the verification is consistent, decomposing the at least one script request information according to the preset information requirements to obtain at least one identification information of the recorded test result; storing the identification information of the at least one recorded test result to the local database, so that the at least one test result is backfilled based on the identification information of the at least one recorded test result.
[0018] In the above scheme, after obtaining at least one test script information corresponding to the at least one test script from the first message queue, the method also includes: based on the target test script information in the at least one test script information, failing to obtain the target test script corresponding to the target test script information from the script storage unit; if the number of failed acquisitions is less than or equal to the preset number threshold, storing the target test script information in the third message queue, waiting to be acquired again.
[0019] In the above scheme, the merging of the M test sub-results to obtain the test results corresponding to the target test script includes: sorting the M test sub-results according to the order in which the target test script in the at least one test script is decomposed; and using the sorted M test sub-results as the test results corresponding to the target test script.
[0020] In a second aspect, a script testing device is provided, the device comprising:
[0021] An acquiring unit, configured to acquire at least one test script to be tested;
[0022] a decomposition unit, configured to decompose a target test script in the at least one test script to obtain M test sub-scripts; wherein the target test script is any one of the at least one test script;
[0023] A determining unit, configured to determine N script executors for executing the M test sub-scripts according to a preset resource allocation strategy; wherein M and N are integers greater than 1;
[0024] A testing unit, configured to control the N script executors to perform parallel testing on the M test sub-scripts, and obtain M test sub-results corresponding to the target test script;
[0025] The merging unit is used to merge the M test sub-results to obtain the test result corresponding to the target test script.
[0026] According to a third aspect, a script testing device is provided, comprising: a processor and a memory configured to store a computer program that can be run on the processor, wherein the processor is configured to execute the steps of the aforementioned method when running the computer program.
[0027] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, wherein the computer program implements the steps of the aforementioned method when executed by a processor.
[0028] Adopting the above technical solution, obtain at least one test script to be tested; decompose the target test script in at least one test script according to the script function to obtain M test sub-scripts; wherein, the target test script is any one of the at least one test script; according to the preset resource allocation strategy, determine N script executors to execute the M test sub-scripts; wherein, M and N are integers greater than 1; control the N script executors to perform parallel testing on the M test sub-scripts to obtain M test sub-results corresponding to the target test script; merge the M test sub-results to obtain the test result corresponding to the target test script. In this way, a decomposed test script is tested in parallel by multiple script executors. Compared with the existing one script executor that can only test one test script, the test time is shortened and the script testing efficiency is improved. At the same time, multiple test scripts can also be tested in parallel, realizing batch script testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 This is a schematic diagram of the first flow chart of the script testing method in an embodiment of the present application;
[0030] Figure 2 This is a second flow chart of the script testing method in an embodiment of the present application;
[0031] Figure 3 This is a third flow chart of the script testing method in an embodiment of the present application;
[0032] Figure 4 This is a fourth flow chart of the script testing method in an embodiment of the present application;
[0033] Figure 5 This is a schematic diagram of the workflow of the RobotAPI service in the embodiment of this application;
[0034] Figure 6 A flowchart illustrating the analysis of test results during execution in an embodiment of the present application;
[0035] Figure 7 This is a schematic diagram of the structure of the script testing device in an embodiment of the present application;
[0036] Figure 8 This is a structural diagram of the script testing device in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below with reference to the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.
[0038] This application embodiment provides a script testing method, Figure 1 This is a first flow chart of the script testing method in the embodiment of the present application. Figure 1 As shown, the script testing method may specifically include:
[0039] Step 101: Obtain at least one test script to be tested;
[0040] It should be noted that when testing a test script, the script can be obtained directly, or the test script information corresponding to the test script can be stored in the message queue first, and then the test script can be obtained based on the test script information when the test is actually executed, and then the script can be tested.
[0041] It should be noted that the test script information is unique information of the test script and is used to distinguish it from other test scripts.
[0042] In some embodiments, this step specifically includes: obtaining at least one test script information corresponding to the at least one test script from the first message queue; and obtaining at least one test script from the script storage unit based on the at least one test script information.
[0043] It should be noted that a message queue is a communication method between applications. The message queue data structure is a first-in, first-out data structure. Message queues have the functions of receiving, storing, and forwarding data.
[0044] Here, before testing the test script, at least one test script information corresponding to the at least one test script is received and stored using the first-in, first-out feature of the first message queue. The purpose of storing the at least one test script information in the first message queue is to retrieve the at least one test script information from the first message queue when testing the test script, then retrieve the at least one test script corresponding to the at least one test script information and perform script testing based on the at least one test script information.
[0045] It should be noted that when the script storage unit stores at least one test script, it stores it according to the corresponding at least one test script information, so that it is convenient to directly obtain the corresponding at least one test script from the script storage unit according to the at least one test script information.
[0046] In the above-mentioned process of using message queues to implement communication between applications, the status information of each message in the message queue will be recorded in real time, so that there is no loss of information and the consistency, validity and idempotence of the messages in the entire communication process are guaranteed.
[0047] Step 102: Decompose a target test script in the at least one test script according to script functions to obtain M test sub-scripts; wherein the target test script is any one of the at least one test script;
[0048] It should be noted that each test script function is composed of multiple sub-script functions, that is, each test script includes multiple test sub-scripts with different functions.
[0049] Here, each test script is decomposed into M test sub-scripts according to the functions of the test sub-scripts. When the test script is subsequently tested, the decomposed M test sub-scripts can be tested in parallel, thereby improving the testing efficiency of the script.
[0050] Step 103: Determine N script executors for executing the M test sub-scripts according to a preset resource allocation strategy; wherein M and N are integers greater than 1;
[0051] It should be noted that the assignment of the script executor to the test sub-script is performed by the script execution unit.
[0052] It should be noted that the preset resource allocation strategy refers to determining the script executor corresponding to each test sub-script as long as the idle execution volume of the script executor is greater than or equal to the execution volume of the corresponding test sub-script.
[0053] Here, when assigning corresponding script executors to M test sub-scripts, the sum of the execution loads corresponding to the M test sub-scripts is less than or equal to the sum of the idle execution loads corresponding to N script executors. M may be greater than or equal to N, or may be less than N.
[0054] Step 104: Control the N script executors to perform parallel testing on the M test sub-scripts to obtain M test sub-results corresponding to the target test script;
[0055] Here, the script execution unit controls N script executors to perform parallel testing on M test sub-scripts, thereby improving the test efficiency of the script.
[0056] Step 105: Merge the M test sub-results to obtain the test result corresponding to the target test script.
[0057] It should be noted that the N script executors submit the test sub-results to the script execution unit respectively, and the script execution unit merges the M test sub-results to obtain the test result of the target test script.
[0058] In some embodiments, this step specifically includes: sorting the M test sub-results according to the order in which the target test script in the at least one test script is decomposed; and using the sorted M test sub-results as the test results corresponding to the target test script.
[0059] That is, when the script execution unit merges the M test sub-results, it sorts the M test sub-results according to the order of the M test sub-scripts after decomposition, and uses the sorted M test sub-results as the test results of the target test script.
[0060] In some embodiments, after merging the M test sub-results to obtain the test results corresponding to the target test script, the method further includes: sending at least one test result corresponding to at least one test script to the at least one analyzer; controlling the at least one analyzer to send at least one test result of the at least one test script to the script analysis unit; controlling the script analysis unit to store the at least one test result in a second message queue; obtaining the at least one test result from the second message queue, and backfilling the at least one test result to the local database.
[0061] Here, after the script execution unit obtains at least one test result, it returns the at least one test result to the corresponding at least one analyzer, controls the script analysis unit to obtain at least one test result corresponding to the at least one analyzer, and stores it in the second message queue, obtains at least one test result from the second message queue, and then based on the identification information of at least one record test result corresponding to the at least one test result, backfills the at least one test result to the corresponding position in the local database.
[0062] Here, the execution subject of steps 101 to 105 may be a processor of the script testing device.
[0063] Adopting the above technical solution, obtain at least one test script to be tested; decompose the target test script in at least one test script according to the script function to obtain M test sub-scripts; wherein, the target test script is any one of the at least one test script; according to the preset resource allocation strategy, determine N script executors to execute the M test sub-scripts; wherein, M and N are integers greater than 1; control the N script executors to perform parallel testing on the M test sub-scripts to obtain M test sub-results corresponding to the target test script; merge the M test sub-results to obtain the test result corresponding to the target test script. In this way, a decomposed test script is tested in parallel by multiple script executors. Compared with the existing one script executor that can only test one test script, the test time is shortened and the script testing efficiency is improved. At the same time, multiple test scripts can also be tested in parallel, realizing batch script testing.
[0064] The present application also provides a script testing method. Figure 2 This is a second flow chart of the script testing method in the embodiment of the present application, as shown in FIG. Figure 2 As shown, the script testing method may specifically include:
[0065] Step 201: Obtain at least one test script information corresponding to the at least one test script from the first message queue;
[0066] It should be noted that a message queue is a communication method between applications. The message queue data structure is a first-in, first-out data structure. Message queues have the functions of receiving, storing, and forwarding data.
[0067] It should be noted that the test script information is unique information of the test script and is used to distinguish it from other test scripts.
[0068] Here, before testing the test script, at least one test script information corresponding to the at least one test script is received and stored using the first-in, first-out feature of the first message queue. The purpose of storing the at least one test script information in the first message queue is to retrieve the at least one test script information from the first message queue when testing the test script, then retrieve the at least one test script corresponding to the at least one test script information and perform script testing based on the at least one test script information.
[0069] In some embodiments, before obtaining at least one test script information corresponding to the at least one test script from the first message queue, the method also includes: receiving at least one script request information; using a preset verification algorithm to verify whether the information type of the at least one script request information is consistent with the information type of the preset request information; if the verification is consistent, decomposing the at least one script request information according to the preset information requirements to obtain the at least one test script information; and storing the at least one test script information in the first message queue.
[0070] It should be noted that the at least one script request information is at least one script information to be tested. Here, only when the information type of the script request information is an information type that can be processed during script testing, can the requested script be tested.
[0071] It should be noted that the information type of the preset request information is an information type that can be processed during script testing. Here, the preset verification algorithm is used to verify whether the information type of the script request information is consistent with the information type of the preset request information. If the verification is consistent, it means that the script corresponding to the script request information can be script tested; if the verification is inconsistent, it means that the script testing cannot be performed.
[0072] It should be noted that the preset information requirement can be understood as the information required for the script testing process. Here, since the script needs to be obtained through the information used to identify the script before the script testing, before the script corresponding to the script request information is script tested, the script request information is decomposed to obtain the test script information (including the information used to identify the script).
[0073] Here, at least one script request information that has passed verification is decomposed to obtain at least one test script information, and the at least one test script information is stored in the first message queue in sequence according to the decomposition order.
[0074] In some embodiments, the method further includes: if the verification is consistent, decomposing the at least one script request information according to the preset information requirements to obtain identification information of at least one recorded test result; storing the identification information of the at least one recorded test result to a local database, so that the at least one test result is backfilled based on the identification information of the at least one recorded test result.
[0075] It should be noted that since the test results of the script need to be recorded, after decomposing the script request information, corresponding identification information for recording the test results is also obtained, and the identification information for recording the test results is stored in the local database. Here, the identification information for recording the test results includes information identifying the script, information indicating whether the test result failed or succeeded, etc.
[0076] Furthermore, after testing each test script and obtaining the test results, the test results are backfilled into the corresponding location in the local database based on the corresponding identification information of the recorded test results, so that the tester can directly retrieve the content in the local database to know the test results of the corresponding test script.
[0077] In some embodiments, after obtaining at least one test script information corresponding to the at least one test script from the first message queue, the method further includes: based on the target test script information in the at least one test script information, failing to obtain the target test script corresponding to the target test script information from the script storage unit; if the number of failed acquisitions is less than or equal to a preset threshold, storing the target test script information in the second message queue, waiting to be acquired again.
[0078] It should be noted that the second message queue stores information of at least one test script that failed.
[0079] Here, due to network failure or other situations, the acquisition of the target test script in at least one test script from the script storage unit may fail. The target test script information corresponding to the failed target test script needs to be stored in the second message queue and wait to be acquired again.
[0080] It should be noted that the preset number threshold is the rated number of acquisition failures. Only when the number of acquisition failures is less than or equal to the preset number threshold, the target test script information stored in the second message queue can be retrieved; otherwise, the target test script information is discarded.
[0081] Step 202: Based on the at least one test script information, obtain at least one test script from a script storage unit.
[0082] It should be noted that when the script storage unit stores at least one test script, it stores it according to the corresponding at least one test script information, so that it is convenient to directly obtain the corresponding at least one test script from the script storage unit according to the at least one test script information.
[0083] In some embodiments, the test script information includes: identification information and execution volume of the test script; this step specifically includes: determining the execution volume of the at least one test script from the at least one test script information; obtaining the idle execution volume of the idle script executor in the script execution unit; judging whether the execution condition is met based on the execution volume of the at least one test script and the idle execution volume; determining that the execution condition is met, and obtaining the at least one test script from the script storage unit based on the identification information of the at least one test script.
[0084] It should be noted that the test script information includes identification information and execution volume of the test script. The identification information of the test script refers to information identifying the test script, and the execution volume refers to the execution volume required to test the test script.
[0085] It should be noted that before obtaining the corresponding at least one test script from the script storage unit based on the at least one test script information, it is necessary to first determine whether the at least one test script can be tested by the current script execution unit.
[0086] Here, the execution amount of the target test script in at least one acquired test script and the idle execution amount of the idle script executors in the current script execution unit are used to determine whether the target test script can be tested (i.e., whether the execution condition is met). If the target test script can be tested (i.e., the execution condition is met), the corresponding test script is retrieved from the script storage unit based on the identification information of the target test script; if the target test script cannot be tested (i.e., the execution condition is not met), the target test script is transferred to the second message queue and waits to be retrieved again.
[0087] Specifically, if the execution amount of the target test script in at least one test script is less than or equal to the idle execution amount of the idle script executor in the current script execution unit, it indicates that the target test script can be tested. If the execution amount of the target test script in at least one test script is greater than the idle execution amount of the idle script executor in the current script execution unit, it indicates that the target test script cannot be tested.
[0088] In some embodiments, judging whether the execution condition is met based on the execution amount of the at least one test script and the idle execution amount includes: when the execution amount of the test script is less than or equal to the idle execution amount, determining that the execution condition is met; when the execution amount of the test script is greater than the idle execution amount, determining that the execution condition is not met.
[0089] In some embodiments, after transferring the at least one test script information to the third message queue, the method further includes: transferring the at least one test script information in the third message queue to the first message queue, waiting to be retrieved again.
[0090] It should be noted that at least one untested test script information is stored in the third message queue. Since, when testing at least one test script, at least one test script information is obtained from the first message queue, and then at least one test script is obtained from the script storage unit based on the at least one test script information, when testing the test script corresponding to the at least one untested test script information in the third message queue, the at least one untested test script information in the third message queue must first be transferred to the first message queue and then wait for it to be retrieved again.
[0091] It should also be noted that at least one untested test script information in the third message queue can be transferred to the first message queue according to a preset time period; or when there is an available storage location in the first message queue, at least one untested test script information in the third message queue can be transferred to the first message queue.
[0092] In some embodiments, the determining that the execution condition is met and obtaining at least one test script from the script storage unit based on the identification information of the at least one test script includes: determining to execute at least one thread corresponding to the at least one test script when it is determined that the execution condition is met; executing the at least one thread and sending the at least one test script information to the script analysis unit based on the script analysis unit address information; controlling the script analysis unit to allocate the corresponding at least one analyzer based on the identification information of the at least one test script; and controlling the at least one analyzer to obtain the at least one test script from the script storage unit based on the identification information of the at least one test script.
[0093] That is, the at least one analyzer allocated by the control script analyzing unit obtains the at least one test script from the script storage unit based on the identification information of the at least one test script.
[0094] Step 203: Decompose the target test script in the at least one test script according to script functions to obtain M test sub-scripts; wherein the target test script is any one of the at least one test script;
[0095] Step 204: Determine N script executors for executing the M test sub-scripts according to a preset resource allocation strategy; wherein M and N are integers greater than 1;
[0096] Step 205: Control the N script executors to perform parallel testing on the M test sub-scripts to obtain M test sub-results corresponding to the target test script;
[0097] Step 206: Merge the M test sub-results to obtain the test result corresponding to the target test script.
[0098] In some embodiments, this step specifically includes: sorting the M test sub-results according to the order in which the target test script in the at least one test script is decomposed; and using the sorted M test sub-results as the test results corresponding to the target test script.
[0099] In some embodiments, after merging the M test sub-results to obtain the test results corresponding to the target test script, the method further includes: sending at least one test result corresponding to at least one test script to the at least one analyzer; controlling the at least one analyzer to send the at least one test result to the script analysis unit; controlling the script analysis unit to store the at least one test result in a second message queue; obtaining the at least one test result from the second message queue, and backfilling the at least one test result to the local database.
[0100] Adopting the above technical solution, obtain at least one test script to be tested; decompose the target test script in at least one test script according to the script function to obtain M test sub-scripts; wherein, the target test script is any one of the at least one test script; according to the preset resource allocation strategy, determine N script executors to execute the M test sub-scripts; wherein, M and N are integers greater than 1; control the N script executors to perform parallel testing on the M test sub-scripts to obtain M test sub-results corresponding to the target test script; merge the M test sub-results to obtain the test result corresponding to the target test script. In this way, a decomposed test script is tested in parallel by multiple script executors. Compared with the existing one script executor that can only test one test script, the test time is shortened and the script testing efficiency is improved. At the same time, multiple test scripts can also be tested in parallel, realizing batch script testing.
[0101] This application embodiment provides a specific script testing method. Figure 3 This is a third flow chart of the script testing method in an embodiment of the present application.
[0102] like Figure 3 As shown, the script test mainly includes three modules: a central processing unit 30, a RobotAPI service 31 (ie, a script analysis unit) and a Hub node 32 (ie, a script execution unit).
[0103] The following is a detailed description of a test script.
[0104] Specifically, the central processing unit 30 obtains the test script information (including the identification information and execution amount of the test script) from the workQueue (i.e., the first message queue), and obtains the corresponding execution amount from the test script information, and compares the execution amount of the test script with the idle execution amount on the current Hub node 32. If the execution amount of the test script is greater than the idle execution amount, it means that there are no execution resources on the Hub node 32, and the test script information needs to be transferred to the RetryQueue (i.e., the second message queue) for delayed retry. During the delayed retry, the test script information needs to be transferred from the RetryQueue to the workQueue before it can be obtained by the central processing unit 30 again.
[0105] If the execution amount of the test script is less than or equal to the idle execution amount, it means that there are execution resources on the Hub node 32, and the test script corresponding to the test script information can be tested. Then the central processing unit 30 executes the thread corresponding to the test script and sends the test script information to the RobotAPI service 31 based on the address information of the RobotAPI service 31. The RobotAPI service 31 will allocate the corresponding analyzer based on the test script information. The analyzer schedules the corresponding test script from the script storage unit based on the test script information, that is, the scheduling is successful. Then the analyzer of the RobotAPI service 31 decomposes the test script into multiple sub-scripts and sends the decomposed multiple sub-scripts to the Hub node 32, so that the Hub node 32 dynamically allocates the corresponding script executor to each sub-script and tests each sub-script. The script executor may succeed during the test process, or may fail due to network failure or other situations. Each script executor sends the test results to the Hub node 32. The Hub node 32 sends the test results of multiple sub-scripts in the test script to the analyzer. The analyzer sends the test results to the script RobotAPI service 31. The RobotAPI service 31 stores the test results in the ReturnQueue (i.e., the second message queue). The central processing unit 30 obtains the test results from the ReturnQueue and stores them in the corresponding location in the database.
[0106] In addition, when the analyzer retrieves the corresponding test script from the script storage unit based on the test script information, the analyzer may not schedule the test script due to network failure or other reasons, that is, scheduling failure. In this case, the RobotAPI service 31 sends the scheduling failure result to the ReturnQueue. The central processing unit 30 obtains the scheduling failure result from the ReturnQueue and stores it in the corresponding location in the database. It also stores the test script information corresponding to the test script in the RetryQueue for delayed retry. Here, if the number of scheduling failures exceeds the number of times specified in the established rules, the treatment is abandoned.
[0107] Based on the above embodiments, the present application provides a script testing method. Figure 4 This is a fourth flow chart of the script testing method in the embodiment of this application. Figure 4 shown, specifically,
[0108] Step 401: Start;
[0109] Step 402: Request execution of data body structure;
[0110] The data body structure here refers to the script request information.
[0111] Step 403: Verify whether the data body structure is complete; if so, execute step 404; if not, execute step 413;
[0112] This step verifies whether the data body structure is complete, that is, whether the information type of the script request information is the information type that can be processed during script testing. If so, it means that the data body structure is complete; if not, it means that the data body structure is incomplete.
[0113] Step 404: extracting execution body information and storage information from the data body structure;
[0114] This step extracts the execution body information and storage information from the data body structure, that is, decomposing the script request information into test script information (ie, execution body information) and identification information recording the test results (ie, storage information).
[0115] Step 405: Store the test script information in the first message queue, and store the identification information of the test result in the local database;
[0116] Here, the test script information is stored in the first message queue. The test script information includes: identification information and execution amount of the test script; wherein the identification information of the test script refers to information identifying the test script, and the execution amount refers to the execution amount required to test the test script.
[0117] Here, the identification information of the recorded test results is stored in the local database, so that the corresponding test results are backfilled based on the identification information of the recorded test results.
[0118] Step 406: Obtain the idle execution amount of the idle script executor;
[0119] Here, the idle execution amount of the idle script executor is obtained by accessing the address information of the Hub node 407.
[0120] Step 408: Determine whether the test script execution amount is less than or equal to the idle execution amount; if so, execute step 409; if not, execute step 413;
[0121] Here, the test script information is obtained from the first message queue, the execution amount of the test script is obtained from the test script information, and the execution amount is compared with the idle execution amount. If the execution amount is less than or equal to the idle execution amount, it means that the Hub node 407 (that is, the script execution unit) has execution resources; if the execution amount is greater than the idle execution amount, it means that the Hub node 407 does not have execution resources. Specifically, it is first stored in the third message queue, and then transferred to the first message queue when waiting to be retrieved.
[0122] Step 409: Execute the thread and send the RobotAPI service address information;
[0123] Specifically, the execution thread sends the test script information to the RobotAPI service 410 (ie, the script analysis unit) based on the RobotAPI service address information.
[0124] Here, when there are multiple test script information, multiple threads are executed in parallel to achieve the most efficient execution control.
[0125] Step 411: Is the test script scheduled? If yes, go to step 412; if no, go to step 413;
[0126] Here, the RobotAPI service 410 schedules the corresponding test script from the storage unit based on the identification information of the test script in the test script information. The corresponding test script may not be scheduled due to network failure or other circumstances.
[0127] Step 412: backfill the scheduling results to the local database;
[0128] Specifically, the RobotAPI service 410 stores the scheduling result in the second message queue, so that the central processor obtains the scheduling result from the second message queue and backfills the scheduling result to the corresponding position in the local database.
[0129] Step 413: End.
[0130] The following is a detailed description of the RobotAPI service 410. Figure 5 This is a schematic diagram of the workflow of the RobotAPI service in the embodiment of this application.
[0131] like Figure 5 As shown, the process of dispatching to the test script in step 411 is specifically described, and the steps mainly include:
[0132] Step 501: Start;
[0133] Step 502: The RobotAPI service allocates a corresponding analyzer based on the identification information of the test script;
[0134] Step 503: Obtain the test script corresponding to the identification information of the test script;
[0135] Here, specifically, the control analyzer obtains the corresponding test script from the script storage unit based on the identification information of the test script.
[0136] If identification information of multiple test scripts exists, multiple analyzers are controlled to obtain the multiple test scripts from the script storage unit in parallel based on the identification information of the multiple test scripts.
[0137] Step 504: Decompose the test script into multiple test sub-scripts and send them to the Hub node;
[0138] Step 505: multiple script executors run in a distributed manner;
[0139] Here, the Hub node allocates multiple script executors corresponding to the multiple test sub-scripts, and performs script tests on the multiple test sub-scripts in parallel through the multiple script executors.
[0140] Step 506: Analyze the test results of the execution process;
[0141] Here, multiple test sub-results from multiple script executors are received and stored in the second message queue; the central processor is waited for to obtain multiple test sub-results from the second message queue and store them in the local database, so that the test results corresponding to the test script can be intuitively viewed by querying the database.
[0142] Step 507: End.
[0143] The following further describes step 506 in detail. Figure 6 Schematic diagram of the process of analyzing the test results in the embodiment of the present application. Figure 6 shown, specifically,
[0144] Step 601: Start;
[0145] Step 602: Verify whether the test results are complete; if so, proceed to step 603; if not, proceed to step 607;
[0146] That is, to verify whether the test result information is consistent with the preset result information.
[0147] Step 603: Download the test results and extract valid key information from the test results;
[0148] Step 604: Store the valid key information;
[0149] Here, valid key information is stored in the global search service 605, a search index is established, and an application program interface service is provided externally;
[0150] Step 606: Update the database;
[0151] Update the database with valid key information.
[0152] Step 607: End.
[0153] The present application embodiment provides a script testing device, Figure 7 This is a schematic diagram of the structure of the script testing device in the embodiment of the present application. Figure 7 As shown, the device includes:
[0154] An acquisition unit 701 is configured to acquire at least one test script to be tested;
[0155] A decomposition unit 702 is configured to decompose a target test script in the at least one test script according to script functions to obtain M test sub-scripts; wherein the target test script is any one of the at least one test script;
[0156] A determining unit 703 is configured to determine N script executors for executing the M test sub-scripts according to a preset resource allocation strategy; wherein M and N are integers greater than 1;
[0157] The testing unit 704 is configured to control the N script executors to perform parallel testing on the M test sub-scripts to obtain M test sub-results corresponding to the target test script;
[0158] The merging unit 705 is configured to merge the M test sub-results to obtain a test result corresponding to the target test script.
[0159] In some embodiments, the device includes: the acquisition unit 701, which is specifically used to acquire at least one test script information corresponding to the at least one test script from the first message queue; and acquire at least one test script from the script storage unit based on the at least one test script information.
[0160] In some embodiments, before obtaining at least one test script information corresponding to the at least one test script from the first message queue, at least one script request information is received; a preset verification algorithm is used to verify whether the information type of the at least one script request information is consistent with the information type of the preset request information; if the verification is consistent, the at least one script request information is decomposed according to the preset information requirements to obtain the at least one test script information; and the at least one test script information is stored in the first message queue.
[0161] In some embodiments, the test script information includes: identification information and execution volume of the test script; after obtaining at least one test script information corresponding to the at least one test script from the first message queue, determining the execution volume of the at least one test script from the at least one test script information; obtaining the idle execution volume of the idle script executor in the script execution unit; judging whether the execution condition is met based on the execution volume of the at least one test script and the idle execution volume; determining that the execution condition is met, obtaining at least one test script from the script storage unit based on the identification information of the at least one test script.
[0162] In some embodiments, the determining that the execution condition is met and obtaining the at least one test script from the script storage unit based on the identification information of the at least one test script includes: determining to execute at least one thread corresponding to the at least one test script when it is determined that the execution condition is met; executing the at least one thread and sending the at least one test script information to the script analysis unit based on the script analysis unit address information; controlling the script analysis unit to allocate the corresponding at least one analyzer based on the identification information of the at least one test script; and controlling the at least one analyzer to obtain the at least one test script from the script storage unit based on the identification information of the at least one test script.
[0163] In some embodiments, after merging the M test sub-results to obtain the test result corresponding to the target test script, the method further includes: sending at least one test result corresponding to the at least one test script to the at least one analyzer; controlling the at least one analyzer to send the at least one test result to the script analysis unit; controlling the script analysis unit to store the at least one test result in a second message queue; obtaining the at least one test result from the second message queue, and backfilling the at least one test result to the local database.
[0164] In some embodiments, if the verification is consistent, the at least one script request information is decomposed according to the preset information requirements to obtain identification information of at least one recorded test result; the identification information of the at least one recorded test result is stored in a local database so that the at least one test result is backfilled based on the identification information of the at least one recorded test result.
[0165] In some embodiments, after obtaining at least one test script information corresponding to the at least one test script from the first message queue, the method further includes: based on the target test script information in the at least one test script information, failing to obtain the target test script corresponding to the target test script information from the script storage unit; if the number of failed acquisitions is less than or equal to a preset threshold, storing the target test script information in the third message queue and waiting to be acquired again.
[0166] In some embodiments, the device includes: the merging unit 705, which is specifically used to sort the M test sub-results according to the order in which the target test script in the at least one test script is decomposed; and use the sorted M test sub-results as the test results corresponding to the target test script.
[0167] In this way, a decomposed test script can be tested in parallel through multiple script executors. Compared with the existing one script executor which can only test one test script, the test time is shortened and the script testing efficiency is improved. At the same time, multiple test scripts can also be tested in parallel, realizing batch script testing.
[0168] The present application embodiment provides a script testing device, Figure 8 This is a schematic diagram of the structure of the script testing device in the embodiment of the present application. Figure 8 As shown, the script testing device includes: a processor 801 and a memory 802 configured to store a computer program that can be run on the processor;
[0169] The processor 801 is configured to execute the steps of the shooting control method in the aforementioned embodiment when running the computer program.
[0170] Of course, in actual application, Figure 8 As shown in FIG, the various components in the entry and exit identification device are coupled together via a bus system 803. It is understood that the bus system 803 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 803 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 8 Various buses are labeled as bus system 803.
[0171] In practical applications, the processor may be at least one of an application-specific integrated circuit (ASIC), a digital signal processing device (DSPD), a programmable logic device (PLD), a field-programmable gate array (FPGA), a controller, a microcontroller, and a microprocessor. It is understood that for different devices, the electronic device used to implement the functions of the processor may also be other, and the embodiments of the present application do not specifically limit this.
[0172] The above-mentioned memory can be a volatile memory (volatile memory), such as a random-access memory (RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (ROM), a flash memory, a hard disk (HDD) or a solid-state drive (SSD); or a combination of the above types of memory, and provides instructions and data to the processor.
[0173] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program.
[0174] Optionally, the computer-readable storage medium can be applied to any one of the methods in the embodiments of the present application, and the computer program enables the computer to execute the corresponding processes implemented by the processor in each method in the embodiments of the present application. For the sake of brevity, they are not repeated here.
[0175] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0176] The units described above as separate components may or may not be physically separated, and the components displayed 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.
[0177] In addition, the functional units in the embodiments of the present invention can all be integrated into one processing module, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above-mentioned integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units. It can be understood by those skilled in the art that all or part of the steps of the above-mentioned method embodiments can be completed by hardware related to program instructions, and the above-mentioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiments; and the above-mentioned storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROMs), random access memories (RAMs), magnetic disks or optical disks.
[0178] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0179] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0180] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0181] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A script testing method, characterized in that: The method comprises: Obtain at least one test script to be tested; Decomposing a target test script in the at least one test script according to script functions to obtain M test sub-scripts; wherein the target test script is any one of the at least one test script; According to a preset resource allocation strategy, determine N script executors for executing the M test sub-scripts; wherein M and N are integers greater than 1; Controlling the N script executors to perform parallel testing on the M test sub-scripts to obtain M test sub-results corresponding to the target test script; Merging the M test sub-results to obtain a test result corresponding to the target test script; The obtaining of at least one test script to be tested includes: Obtaining at least one test script information corresponding to the at least one test script from the first message queue; Retrieve at least one test script from a script storage unit based on the at least one test script information; Before obtaining at least one test script information corresponding to the at least one test script from the first message queue, the method further includes: receiving at least one script request information; Verifying, using a preset verification algorithm, whether an information type of the at least one script request information is consistent with an information type of preset request information; If the verification is consistent, the at least one script request information is decomposed according to the preset information requirements to obtain the at least one test script information; Storing the at least one test script information in the first message queue; The test script information includes: identification information and execution amount of the test script; The acquiring at least one test script from the script storage unit based on the at least one test script information includes: determining an execution amount of the at least one test script from the at least one test script information; Get the idle execution amount of the idle script executor in the script execution unit; determining whether an execution condition is satisfied based on the execution amount of the at least one test script and the idle execution amount; Determine whether the execution condition is met, and obtain the at least one test script from the script storage unit based on the identification information of the at least one test script; wherein, if it is determined that the execution condition is not met, transfer the test script information to a second message queue, and the second message queue is used to transfer the test script information that does not meet the execution condition to the first message queue.
2. The method according to claim 1, characterized in that The determining that the execution condition is satisfied, and obtaining the at least one test script from the script storage unit based on the identification information of the at least one test script, includes: When it is determined that the execution condition is met, determining to execute at least one thread corresponding to the at least one test script; executing the at least one thread, and sending the at least one test script information to the script analysis unit based on the script analysis unit address information; Controlling the script analysis unit to allocate at least one corresponding analyzer based on identification information of the at least one test script; The at least one analyzer is controlled to obtain the at least one test script from the script storage unit based on identification information of the at least one test script.
3. The method according to claim 2, characterized in that After merging the M test sub-results to obtain the test result corresponding to the target test script, the method further includes: sending at least one test result corresponding to the at least one test script to the at least one analyzer; controlling the at least one analyzer to send the at least one test result to the script analysis unit; controlling the script analysis unit to store the at least one test result in a second message queue; The at least one test result is obtained from the second message queue, and the at least one test result is backfilled into the local database.
4. The method according to claim 3, characterized in that The method further comprises: If the verification is consistent, the at least one script request information is decomposed according to the preset information requirements to obtain at least one identification information recording the test result; The identification information of the at least one recorded test result is stored in a local database, so that the at least one test result is backfilled based on the identification information of the at least one recorded test result.
5. The method according to claim 1, characterized in that After obtaining at least one test script information corresponding to the at least one test script from the first message queue, the method further includes: Based on the target test script information in the at least one test script information, obtaining the target test script corresponding to the target test script information from the script storage unit fails; If the number of failed acquisitions is less than or equal to a preset threshold, the target test script information is stored in a third message queue, waiting to be acquired again.
6. The method according to claim 1, characterized in that The merging of the M test sub-results to obtain a test result corresponding to the target test script includes: sorting the M test sub-results according to the order in which the target test script in the at least one test script is decomposed; The sorted M test sub-results are used as the test results corresponding to the target test script.
7. A script testing device, characterized in that: The device comprises: An acquisition unit, used to acquire at least one test script to be tested; specifically used to acquire at least one test script information corresponding to the at least one test script from the first message queue; based on the at least one test script information, acquire at least one test script from the script storage unit; before acquiring the at least one test script information corresponding to the at least one test script from the first message queue, receive at least one script request information; use a preset verification algorithm to verify whether the information type of the at least one script request information is consistent with the information type of the preset request information; if the verification is consistent, decompose the at least one script request information according to the preset information requirements to obtain the at least one test script information; store the at least one test script information in the first message queue; a decomposition unit, configured to decompose a target test script in the at least one test script to obtain M test sub-scripts; wherein the target test script is any one of the at least one test script; A determining unit, configured to determine N script executors for executing the M test sub-scripts according to a preset resource allocation strategy; wherein M and N are integers greater than 1; A testing unit, configured to control the N script executors to perform parallel testing on the M test sub-scripts, and obtain M test sub-results corresponding to the target test script; a merging unit, configured to merge the M test sub-results to obtain a test result corresponding to the target test script; The test script information includes: identification information and execution volume of the test script; after obtaining at least one test script information corresponding to the at least one test script from the first message queue, determining the execution volume of the at least one test script from the at least one test script information; obtaining the idle execution volume of the idle script executor in the script execution unit; judging whether the execution condition is met based on the execution volume of the at least one test script and the idle execution volume; determining that the execution condition is met, obtaining at least one test script from the script storage unit based on the identification information of the at least one test script; wherein, if it is determined that the execution condition is not met, the test script information is transferred to the second message queue, and the second message queue is used to transfer the test script information whose execution condition is not met to the first message queue.
8. A script testing device, characterized in that: The script testing device includes: a processor and a memory configured to store a computer program that can be run on the processor. Wherein, the processor is configured to execute the steps of the method according to any one of claims 1 to 6 when running the computer program.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Performance test method and device for Web application
CN111752828A