Automatic script execution method, system, server, medium and program product
By obtaining network delay and packet loss rate indicators before the execution of an automated script, dynamically adjusting the timeout time, and automatically retrying it in case of failure, the timeout problem caused by network delay is solved, which improves the reliability and efficiency of script execution and reduces the cost of manual intervention.
Patent Information
- Application Number
- CN202510864410.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-25
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-06-25
AI Technical Summary
In the prior art, timeout problems caused by network delay or slow BMC response during the execution of automated scripts affect reliability and increase management complexity, and static timeout settings and manual intervention are inefficient and costly.
By obtaining network delay and packet loss rate indicators, the timeout time is dynamically adjusted and retry automatically when it fails, combining network monitoring, response time duration monitoring and timeout management modules, the dynamic adjustment and retry mechanism of timeout time is realized.
Improves the reliability and success rate of automated script execution, reduces failures caused by network fluctuations or response delays, and reduces the cost and complexity of manual intervention.
Smart Images

Figure CN120353543B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an automated script execution method, system, server, medium, and program product. Background Art
[0002] During the execution of automated management scripts, network latency or slow response from the BMC (Baseboard Management Controller) can cause script execution timeouts, leading to use case failures. This not only affects script execution reliability but also increases management complexity.
[0003] Related technologies typically use static timeout settings and manual intervention to address script execution anomalies. Specifically, static timeout settings refer to manually setting a fixed time threshold as a timeout before script execution. If the script execution time exceeds this preset timeout, the system determines that the script execution has timed out and takes appropriate processing measures (such as interrupting execution, recording error logs, etc.), but this method may lead to unnecessary timeout judgments or miss the real timeout problem. When the script execution times out or fails, the system needs to rely on manual intervention by testers or managers to find the cause of the problem and handle it. This method requires high labor and time costs and is prone to human errors. When faced with large-scale or high-concurrency test scenarios, the efficiency of manual intervention will be severely limited. Summary of the Invention
[0004] The present application provides an automated script execution method, system, server, medium and program product to at least solve the problems of poor flexibility, low efficiency and high cost in executing scripts using technical means such as fixed timeouts set by related technologies and manual intervention.
[0005] This application provides a method for executing an automated script, comprising: obtaining a network delay indicator and a packet loss rate indicator of current network data before executing the automated script; determining the current network status based on the network delay indicator and the packet loss rate indicator, and determining an initial timeout period for the automated script based on the current network status; executing the automated script with the initial timeout period as a constraint, obtaining the response time of a target terminal during the execution of the automated script, and adjusting the initial timeout period based on the response time.
[0006] The present application also provides an automated script execution system, including: a network monitoring module for monitoring the network delay index and packet loss rate index of the current network data; a monitoring module for monitoring the response time of the target terminal during the execution of the automated script; a timeout management module for predicting the target timeout time based on historical execution time data, network delay index, packet loss rate index and response time; a retry mechanism module for executing the target processing action according to the error type during the execution of the automated script when the execution status of the automated script is a failure state; and a log collection module for collecting the execution results to the script log or machine log after the execution of the automated script is completed.
[0007] The present application also provides a server, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned automated script execution methods when executing the computer program.
[0008] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned automated script execution methods are implemented.
[0009] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned automated script execution methods when executed by a processor.
[0010] The embodiments of the present application utilize a dynamic timeout management and retry mechanism to dynamically adjust the script execution timeout based on the current network status and the response of the target terminal, and automatically retry when execution fails. This avoids script execution failures caused by network fluctuations or response delays, and improves the reliability and success rate of script execution. This solves the problems of fixed timeouts set in related technologies and manual intervention in script execution, which suffer from poor flexibility, low efficiency, and high cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0012] Figure 1 A flowchart of an automated script execution method provided in an embodiment of the present application;
[0013] Figure 2 A schematic diagram of an automated script execution system provided in an embodiment of the present application;
[0014] Figure 3 A block diagram of an automated script execution device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0015] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0016] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0017] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0018] The embodiment of the present application provides an automated script execution method, and the execution flow of the automated script execution method is summarized and the method is described in detail. Figure 1 As shown, the following steps are included:
[0019] In step S101, before the automation script is executed, the network delay index and packet loss rate index of the current network data are obtained.
[0020] In one embodiment of the present application, obtaining a packet loss rate indicator and a network delay indicator of current network data includes: sending a preset number of data packets to a target terminal, wherein the target terminal generates a response signal for the data packet; determining the number of lost data packets based on the response signal of the data packet, and determining the packet loss rate indicator of the current network data based on the number of lost data packets; sending an echo request to the target terminal, wherein the target terminal receives the echo request and generates a response signal; calculating the round-trip time from sending the echo request to receiving the response signal, and determining the network delay indicator of the current network data based on the round-trip time.
[0021] It is understandable that before the automated script is formally executed, the embodiment of the present application can detect the current network connection status between the target terminal (such as BMC) to obtain key performance indicators reflecting the current network quality, including network delay indicators and packet loss rate indicators, so as to fully understand the current network environment status before the script is executed, and provide key input information for subsequent timeout control.
[0022] Specifically, for the network delay indicator, the embodiment of the present application can send one or more echo requests to the target terminal (such as the BMC management interface), for example, using the Ping command in the ICMP protocol; after receiving the echo request, the target terminal returns a corresponding response signal (i.e., an echo reply Echo Reply); during the actual execution process, the embodiment of the present application can record the time difference between sending the echo request and receiving the echo reply, which is the round-trip time; in order to further ensure the accuracy of the data, the embodiment of the present application can calculate the average round-trip time based on multiple measurement results as a comprehensive indicator to measure the current network delay level.
[0023] For the packet loss rate indicator, the embodiment of the present application can send a preset number of data packets to the target terminal (for example, sending 5 ICMP data packets continuously); at the same time, monitor the response signal returned by the target terminal, count the number of response data packets actually received, and calculate the packet loss rate indicator using the following formula:
[0024] Packet loss rate = (number of packets that did not receive a response / total number of packets sent) 100%.
[0025] In step S102, the current network state is determined according to the network delay index and the packet loss rate index, and the initial timeout period of the automation script is determined based on the current network state.
[0026] After obtaining the network delay index and packet loss rate index based on the above embodiment, the embodiment of the present application can further comprehensively evaluate the current network status and dynamically set the initial timeout time during the execution of the automated script. For example, when the network status is poor, the timeout time is appropriately extended; when the network status is good, the timeout time is shortened to improve the adaptability and stability of the script execution.
[0027] Specifically, the embodiment of the present application can divide the current network status into multiple levels (such as excellent, good, and poor) according to the network delay index and the packet loss rate index. For example, when the network delay range is less than 50ms or the packet loss rate range is less than 1%, the embodiment of the present application can determine that the current network status is excellent.
[0028] Furthermore, embodiments of the present application can dynamically calculate an initial timeout based on the current network status level. Specifically, embodiments of the present application can initialize a default timeout, for example, to 30 seconds, before script execution. Based on the current network status level, a different timeout coefficient factor (e.g., Excellent: 0.6; Good: 0.8; Poor: 1.2) is set. The actual initial timeout = default timeout × timeout coefficient factor. For example, if the default timeout is 30 seconds and the current network status is "Fair," the initial timeout is 24 seconds.
[0029] In step S103, the automation script is executed with the initial timeout as a constraint condition, and the response duration of the target terminal during the execution of the automation script is obtained, and the initial timeout is adjusted according to the response duration.
[0030] It is understandable that during the script execution process, the embodiment of the present application can perform execution control based on the initial timeout period, and also collect the actual response time of the target terminal (such as BMC) at each key operation node in real time. Based on this dynamic feedback data, the timeout period setting of the subsequent stage is adaptively adjusted, thereby achieving more refined and intelligent script execution control. Therefore, the embodiment of the present application not only takes into account the impact of historical time execution data, but also comprehensively considers the current network status and real-time response behavior, and can adapt to different network environments and response situations, effectively improving the execution success rate and stability of automated scripts in unstable network conditions.
[0031] During the actual execution process, the embodiment of the present application can record the command sending time and response time during the script execution process to calculate the response time. The embodiment of the present application flexibly adjusts the timeout setting according to the response time.
[0032] In one embodiment of the present application, the initial timeout period is adjusted according to the response time, including: obtaining historical execution time data and current monitoring data of the automation script, wherein the current monitoring data is a network delay index and a packet loss rate index when executing the automation script; predicting a target timeout period based on the historical execution time data, the response time, the network delay index and the packet loss rate index when executing the automation script; and adjusting the initial timeout period according to the target timeout period.
[0033] Among them, historical execution time data refers to the operation time consumed during the previous execution of the automation script, and current monitoring data refers to the network delay index and packet loss rate index when executing the automation script.
[0034] Specifically, the target timeout time is predicted based on the historical execution time data, response time, network delay index and packet loss rate index when executing the automated script, including: calculating the historical execution time data based on the weighted moving average algorithm to obtain a weighted average value; converting the packet loss rate index into an additional delay time, and setting the first to third weight coefficients for the network delay index, additional delay time and response time respectively; and calculating the target timeout time based on the weighted average value, additional delay time, network delay index, response time, and the first to third weight coefficients.
[0035] Among them, the calculation formula of the weighted moving average algorithm is:
[0036]
[0037] in, is the amount of historical execution time data, It is The weight of historical execution time data. It is The execution time of times.
[0038] Since packet loss will lead to retransmission, waiting and other behaviors, affecting the overall response efficiency, the system converts the packet loss rate into an additional delay time to correct the prediction results. The conversion of the packet loss rate indicator into the additional delay time includes: obtaining a correspondence table between the packet loss rate indicator and the additional delay time; and determining the additional delay time when executing the automation script based on the correspondence table and the packet loss rate indicator.
[0039] The correspondence table can be pre-calibrated through multiple experiments. In embodiments of the present application, after obtaining the packet loss rate indicator, the corresponding additional delay time can be accurately determined based on the correspondence table between the packet loss rate indicator and the additional delay time. For example, a packet loss rate of 5% can correspond to an additional delay time of 2 seconds, and a packet loss rate of 10% can correspond to an additional delay time of 5 seconds.
[0040] Furthermore, in the embodiment of the present application, first to third weight coefficients can be set for the network delay index, additional delay time, and response time respectively; the target timeout time is calculated based on the weighted average, additional delay time, network delay index, response time, and the first to third weight coefficients. The calculation formula for the target timeout time is:
[0041]
[0042] in, is the adjustment coefficient, Additional delay time The corresponding first weight coefficient is, Network latency indicator The corresponding second weight coefficient, Response time The corresponding third weight coefficient.
[0043] For example, if there are three pieces of historical execution time data, the first one is: execution time 10 seconds, weight 0.5; the second one is: execution time 12 seconds, weight 0.3; the third one is: execution time 10 seconds, weight 0.2; based on these data, the embodiment of the present application can calculate the weighted average value to be 10.6 seconds.
[0044] Furthermore, if the network delay index (RTT) is 15 ms, the packet loss rate index is 5%, and the response time is 5 seconds, the embodiment of the present application can determine the corresponding additional delay time of 2 seconds through the corresponding relationship table between packet loss rate and additional delay time. Set the additional delay time weight a = 0.4, the network delay weight b = 0.1, the response time weight c = 0.3, and the adjustment coefficient k = 0.5, where k is used to control the adjustment range (such as 0.5-2, which can be optimized through experiments). Substituting it into the calculation formula of the target timeout time in the above embodiment can be obtained About 22.8 seconds.
[0045] In some embodiments, the embodiments of the present application may further set a maximum timeout threshold and a minimum timeout threshold, and compare the calculated target timeout with the maximum timeout threshold and the minimum timeout threshold. If the calculated target timeout is greater than the maximum timeout threshold, the maximum timeout threshold is taken as the final target timeout. If the calculated target timeout is less than or equal to the maximum timeout threshold, the calculated target timeout is taken. If the calculated target timeout is less than the minimum timeout threshold, the minimum timeout threshold is taken, and the final target timeout is obtained as max(minimum value, min(maximum timeout threshold, calculated target timeout)). Thus, the embodiments of the present application avoid excessive adjustment by setting thresholds.
[0046] In one embodiment of the present application, after adjusting the initial timeout period according to the response duration, it also includes: detecting the execution status of the automation script; if the execution status is a failure state, identifying the error type during the execution of the automation script; and executing the target processing action according to the error type.
[0047] A failure state refers to a state in which a script or one of its execution steps fails to complete as expected and fails to achieve its intended goal. This state typically indicates that an error, exception, or unexpected behavior was encountered during execution, preventing the script from continuing normally or returning unexpected results.
[0048] It is understandable that after the automated script begins execution, the embodiment of the present application can also continuously monitor its running status. When the execution status is a failure state, the embodiment of the present application can identify the error type during the execution of the automated script and perform the target processing action based on the error type. Therefore, by detecting the execution status and identifying and processing the error type in a targeted manner when a failure occurs, the embodiment of the present application can intelligently respond to various abnormal situations instead of simply terminating the entire process, effectively improving the stability and fault tolerance of the script in complex environments.
[0049] In one embodiment of the present application, a target processing action is executed according to the error type, including: if the error type is an external type, a retry mechanism is triggered, and the automation script is re-executed according to the retry mechanism, wherein the external type is a temporary error caused by external factors; if the error type is an internal type, the execution result is recorded, and the retry mechanism is not triggered, wherein the internal type is an internal logical misalignment of the automation script.
[0050] The external type includes at least one of a network interruption, a hardware failure, and a response timeout; the internal type includes at least one of a code logic error, a configuration error, and a script design defect.
[0051] It is understandable that if the error type is identified as external, it can be explained that this type of error is often not a problem with the script itself, but is caused by environmental fluctuations, which has a certain degree of recoverability and uncertainty. The embodiment of the present application can trigger a retry mechanism to re-execute the script, which can effectively avoid temporary failures and improve the success rate of script execution.
[0052] If the error type is identified as internal, it indicates that this type of error will not automatically recover over time and must be corrected by modifying the script source code, adjusting the configuration, etc. This embodiment of the application can record the execution results (such as the timestamp of the error and the specific step or module where the error occurred) without triggering the retry mechanism. This avoids unnecessary re-execution, improves debugging efficiency, and helps quickly locate and fix script problems.
[0053] In one embodiment of the present application, re-executing the automation script according to the retry mechanism includes: obtaining the retry strategy and the current number of retries of the retry mechanism, wherein the retry strategy includes: a fixed interval retry strategy and an exponential backoff retry strategy; if the current number of retries is less than a preset number threshold, re-executing the automation script based on any one of the retry strategies.
[0054] The preset number threshold refers to a preset maximum number of retries, such as 3. If the maximum number of retries is exceeded, a failure is recorded and the administrator is notified.
[0055] It is understandable that when the script execution fails, the embodiment of the present application can automatically re-execute the script according to the retry mechanism. The retry strategy may include fixed interval retry and exponential backoff retry. Among them, the fixed interval retry can be set to retry three times, each with an interval of 5 seconds; the exponential backoff retry is the first retry interval of 5 seconds, the second retry interval of 10 seconds, and the third retry interval of 20 seconds. During the actual execution process, if the current number of retries is greater than or equal to 3 times, the retry mechanism is not triggered, and a retry failure prompt is generated to notify the user that the script execution task ultimately failed. Therefore, the embodiment of the present application prevents the waste of system resources caused by infinite loop retry by setting the maximum number of retries, and can actively end the task after reaching the maximum number of retries, avoiding long and invalid waiting, and at the same time generates a clear retry failure prompt message to facilitate subsequent location and repair of the problem.
[0056] The automated script execution method according to the embodiments of the present application, through dynamic timeout adjustment management and a retry mechanism, can dynamically adjust the script execution timeout according to the current network status and the response of the target terminal, and automatically retry when the execution fails, thereby avoiding script execution failures caused by network fluctuations or response delays, and improving the reliability and success rate of script execution. This solves the problems of fixed timeouts set in related technologies and manual intervention in script execution, which are poor in flexibility, inefficiency, and high cost.
[0057] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0058] The present application also provides an automated script execution system. Figure 2 As shown, it includes: a network monitoring module, which is used to monitor the network delay index and packet loss rate index of the current network data; a response monitoring module, which is used to monitor the response time of the target terminal during the execution of the automation script; a timeout management module, which is used to predict the target timeout time based on the historical execution time data, network delay index, packet loss rate index and response time; a retry mechanism module, which is used to execute the target processing action according to the error type during the execution of the automation script when the execution status of the automation script is a failure state; a log collection module, which is used to collect the execution results to the script log or machine log after the execution of the automation script is completed.
[0059] Specifically, the network monitoring module detects the current network status before the script is executed and feeds the monitoring results back to the timeout management module. For example, it detects indicators such as network delay and packet loss rate.
[0060] (1) Network status detection: Before the script is executed, the network monitoring module detects the current network status, including indicators such as network latency and packet loss rate. Latency detection: Send ICMP echo requests (ping) to the target server and measure the round-trip time (RTT). Packet loss rate detection: Send a certain number of data packets and calculate the number of lost packets.
[0061] (2) Feedback mechanism: Feedback the detection results to the timeout management module. For example, if the network delay exceeds 100ms, the timeout management module is notified to extend the timeout period.
[0062] The response monitoring module monitors the response time of the target terminal (BMC) in real time during the script execution process and feeds the monitoring results back to the timeout management module.
[0063] (1) Response time detection: During script execution, the BMC response monitoring module monitors the BMC response time in real time. For example, it records the sending time and response time of each BMC command and calculates the response time.
[0064] (2) Abnormal detection: If the BMC response time exceeds the preset threshold (e.g., 30 seconds), the abnormality is recorded and the timeout management module is notified.
[0065] (3) Feedback mechanism: Feedback the monitoring results to the timeout management module. For example, if the BMC response time is long, the timeout management module is notified to appropriately extend the timeout period.
[0066] The timeout management module dynamically adjusts the script's timeout based on the current network status and historical execution time data. For example, when network latency is high, the timeout is appropriately extended; when network status is good, the timeout is shortened.
[0067] (1) Initialization: Before the script is executed, the timeout management module initializes the default timeout period, for example, to 10 seconds.
[0068] (2) Dynamic Adjustment: Based on the feedback from the network monitoring module and the target response monitoring module, the timeout period is dynamically adjusted. An adaptive algorithm can be used to adjust the timeout period based on historical execution data and current monitoring data. For example, a weighted moving average algorithm can be used to predict the appropriate timeout period.
[0069] The retry mechanism module automatically retries script execution when the script execution times out or fails. The number of retries and the interval can be set according to the specific situation. For example, retry three times with an interval of 5 seconds between each.
[0070] (1) Retry strategy: When the script execution times out or fails, the retry mechanism module automatically retries the script execution. Retry strategies can include fixed interval retry and exponential backoff retry. Among them, fixed interval retry can be set to retry three times, each with an interval of 5 seconds; exponential backoff retry has a first retry interval of 5 seconds, a second retry interval of 10 seconds, and a third retry interval of 20 seconds.
[0071] (2) Retry times: The retry mechanism module can set a maximum number of retries, for example, 3. If the maximum number of retries is exceeded, the failure is recorded and the user is notified.
[0072] The retry mechanism module contains an intelligent error classification and processing mechanism to improve the efficiency and reliability of script execution and avoid repeated retries caused by problems in the script itself, which leads to a waste of time.
[0073] 1. During script execution, take appropriate processing strategies based on the error classification results.
[0074] 2. If the error is caused by a network or BMC response problem, the retry mechanism module retries.
[0075] 3. If the error is due to the script itself, log the error and stop retrying.
[0076] The log collection module collects script logs and machine logs after the script ends. It can record the results and error information of script execution in detail, providing administrators with rich data support, making it easier for administrators to analyze and handle problems, and improving user experience and management efficiency.
[0077] In addition, the embodiment of the present application also provides an automated script execution device 10, such as Figure 3 As shown, it includes: an acquisition module 101, a determination module 102 and an adjustment module 103.
[0078] Among them, the acquisition module 101 is used to obtain the network delay index and packet loss rate index of the current network data before the execution of the automation script; the determination module 102 is used to determine the current network status according to the network delay index and packet loss rate index, and determine the initial timeout time of the automation script based on the current network status; the adjustment module 103 is used to execute the automation script with the initial timeout time as a constraint condition, and obtain the response time of the target terminal during the execution of the automation script, and adjust the initial timeout time according to the response time.
[0079] In one embodiment of the present application, the adjustment module 103 is further used to obtain historical execution time data and current monitoring data of the automation script, wherein the current monitoring data is the network delay index and packet loss rate index when executing the automation script; predict the target timeout time based on the historical time execution data, response time, network delay index and packet loss rate index when executing the automation script; and adjust the initial timeout time according to the target timeout time.
[0080] In one embodiment of the present application, the adjustment module 103 is further used to predict the target timeout time based on historical execution time data, response time, network delay index and packet loss rate index when executing the automated script, including: calculating the historical execution time data based on the weighted moving average algorithm to obtain a weighted average value; converting the packet loss rate index into an additional delay time, and setting the first to third weight coefficients for the network delay index, additional delay time and response time respectively; calculating the target timeout time based on the weighted average value, additional delay time, network delay index, response time, and the first to third weight coefficients.
[0081] In one embodiment of the present application, the calculation formula of the weighted moving average algorithm is:
[0082]
[0083] in, is the amount of historical execution time data, It is The weight of historical execution time data. It is The execution time of times.
[0084] In one embodiment of the present application, the target timeout period is calculated as follows:
[0085]
[0086] in, is the adjustment coefficient, Additional delay time The corresponding first weight coefficient is, Network latency indicator The corresponding second weight coefficient, Response time The corresponding third weight coefficient.
[0087] In one embodiment of the present application, the automation script execution device 10 also includes: a detection module, which is used to detect the execution status of the automation script after adjusting the initial timeout period according to the response duration; an identification module, which is used to identify the error type in the execution process of the automation script if the execution status is a failure state; and an execution module, which is used to execute the target processing action according to the error type.
[0088] In one embodiment of the present application, the execution module is further used to trigger a retry mechanism if the error type is an external type, and re-execute the automation script according to the retry mechanism, wherein the external type is a temporary error caused by external factors; if the error type is an internal type, the execution result is recorded and the retry mechanism is not triggered, wherein the internal type is an internal logical misalignment of the automation script.
[0089] In one embodiment of the present application, the external type includes: at least one of: network interruption, hardware failure and response timeout; the internal type includes: at least one of: code logic error, configuration error, and script design defect.
[0090] In one embodiment of the present application, the execution module is further used to obtain the retry strategy and current retry count of the retry mechanism, wherein the retry strategy includes: a fixed interval retry strategy and an exponential backoff retry strategy; if the current retry count is less than a preset threshold, the automation script is re-executed based on any one of the retry strategies.
[0091] In one embodiment of the present application, the automated script execution device 10 further includes: a generation module for not triggering the retry mechanism if the current number of retries is greater than or equal to a preset number threshold, and generating a prompt indicating a retry failure.
[0092] In one embodiment of the present application, the acquisition module 101 is further used to send a preset number of data packets to the target terminal, wherein the target terminal generates a response signal for the data packet; determine the number of lost data packets based on the response signal of the data packet, and determine the packet loss rate index of the current network data based on the number of lost data packets; send an echo request to the target terminal, wherein the target terminal receives the echo request and generates a response signal; calculate the round-trip time from sending the echo request to receiving the response signal, and determine the network delay index of the current network data based on the round-trip time.
[0093] In one embodiment of the present application, the adjustment module 103 is further configured to obtain a correspondence table between a packet loss rate indicator and an additional delay time; and determine the additional delay time when executing the automation script according to the correspondence table and the packet loss rate indicator.
[0094] It should be noted that, for the description of the features in the embodiment corresponding to the automated script execution device, reference can be made to the relevant description of the embodiment corresponding to the automated script execution method, and no further details will be given here.
[0095] According to an embodiment of the present application, an automated script execution device is proposed. Through dynamic timeout adjustment management and a retry mechanism, the script execution timeout can be dynamically adjusted according to the current network status and the response of the target terminal, and automatically retry when execution fails. This avoids script execution failures caused by network fluctuations or response delays, and improves the reliability and success rate of script execution. This solves the problems of fixed timeouts set in related technologies and manual intervention in script execution, which are poor in flexibility, inefficiency, and high cost.
[0096] An embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above-mentioned embodiments of the automated script execution method.
[0097] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned automated script execution method embodiments when run.
[0098] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0099] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned automated script execution method embodiments are implemented.
[0100] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0101] The above is a detailed introduction to an automated script execution method provided by this application. Specific examples are used herein to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
Claims
1. An automated script execution method, characterized in that: include: Before executing the automation script, obtain the network delay and packet loss rate indicators of the current network data; Determining a current network state according to the network delay indicator and the packet loss rate indicator, and determining an initial timeout period of the automation script based on the current network state; Executing the automation script with the initial timeout as a constraint condition, obtaining a response duration of the target terminal during the execution of the automation script, and adjusting the initial timeout according to the response duration; The adjusting the initial timeout period according to the response duration includes: obtaining historical execution time data and current monitoring data of the automation script, wherein the current monitoring data is a network delay index and a packet loss rate index when executing the automation script; predicting a target timeout period according to the historical execution time data, the response duration, and the network delay index and packet loss rate index when executing the automation script; and adjusting the initial timeout period according to the target timeout period.
2. The automated script execution method according to claim 1, wherein: Predicting the target timeout time according to the historical execution time data, the response time, the network delay index and the packet loss rate index when executing the automation script includes: Calculating the historical execution time data based on a weighted moving average algorithm to obtain a weighted average value; Converting the packet loss rate indicator into an additional delay time, and setting first to third weight coefficients for the network delay indicator, the additional delay time, and the response time respectively; The target timeout time is calculated based on the weighted average, the additional delay time, the network delay index, the response time, and the first to third weight coefficients.
3. The automated script execution method according to claim 2, wherein: The calculation formula of the weighted moving average algorithm is: in, is the amount of historical execution time data, It is The weight of historical execution time data; It is The execution time of times.
4. The automated script execution method according to claim 2, wherein: The target timeout period is calculated as follows: in, is the adjustment coefficient, Additional delay time The corresponding first weight coefficient is, Network latency indicator The corresponding second weight coefficient, Response time The corresponding third weight coefficient.
5. The automated script execution method according to claim 1, wherein: After adjusting the initial timeout period according to the response duration, the method further includes: Detecting the execution status of the automation script; If the execution status is a failure status, identifying the error type during the execution of the automation script; Execute a target processing action according to the error type.
6. The automated script execution method according to claim 5, wherein: Execute target processing actions according to the error type, including: If the error type is an external type, a retry mechanism is triggered, and the automation script is re-executed according to the retry mechanism, wherein the external type is a temporary error caused by external factors; If the error type is an internal type, the execution result is recorded and the retry mechanism is not triggered, wherein the internal type is an internal logic misalignment of the automation script.
7. The automated script execution method according to claim 6, wherein: The external type includes at least one of a network interruption, a hardware failure, and a response timeout, and the internal type includes at least one of a code logic error, a configuration error, and a script design defect.
8. The automated script execution method according to claim 6, wherein: The re-executing the automation script according to the retry mechanism includes: Obtaining a retry strategy and a current number of retries of the retry mechanism, wherein the retry strategy includes: a fixed interval retry strategy and an exponential backoff retry strategy; If the current number of retries is less than a preset number threshold, the automation script is re-executed based on any one of the retry strategies.
9. The automated script execution method according to claim 8, wherein: Also includes: If the current number of retries is greater than or equal to the preset number threshold, the retry mechanism is not triggered, and a retry failure prompt is generated.
10. The automated script execution method according to claim 1, wherein: The obtaining of the packet loss rate indicator and network delay indicator of the current network data includes: sending a preset number of data packets to the target terminal, wherein the target terminal generates a response signal for the data packets; Determining the number of lost data packets according to the response signal of the data packet, and determining the packet loss rate indicator of the current network data according to the number of lost data packets; sending an echo request to the target terminal, wherein the target terminal receives the echo request and generates a response signal; A round trip time from sending the echo request to receiving the response signal is calculated, and a network delay index of the current network data is determined according to the round trip time.
11. An automated script execution system, characterized in that: include: Network monitoring module, used to monitor the network delay index and packet loss rate index of current network data; A response monitoring module is used to monitor the response time of the target terminal during the execution of the automation script; a timeout management module, configured to determine a current network state based on the network delay indicator and the packet loss rate indicator, determine an initial timeout period for the automation script based on the current network state, execute the automation script with the initial timeout period as a constraint, and adjust the initial timeout period based on a response time of a target terminal during execution of the automation script; A retry mechanism module is used to execute a target processing action according to the error type during the execution of the automation script when the execution status of the automation script is a failure state; A log collection module is used to collect the execution results into a script log or a machine log after the execution of the automation script is completed; The timeout management module is further used to: obtain historical execution time data and current monitoring data of the automation script, wherein the current monitoring data is a network delay index and a packet loss rate index when executing the automation script; A target timeout period is predicted based on the historical execution time data, the response time, the network delay index and the packet loss rate index when executing the automation script; and the initial timeout period is adjusted based on the target timeout period.
12. A server, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the automated script execution method according to any one of claims 1 to 10 when executing the computer program.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the automated script execution method according to any one of claims 1 to 10 are implemented.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the automated script execution method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Household appliance communication encryption method, household appliance and server
CN111212065A
Task processing method and device, equipment and storage medium
CN119065798A