A task scheduling method and task execution method for automated testing
By using host fields and a message publish-subscribe mechanism, precise matching of tasks and execution environments and efficient utilization of resources are achieved, solving the problem of inflexible task scheduling in distributed testing architectures and improving task execution success rate and resource utilization.
Patent Information
- Application Number
- CN202611620204.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-20
- Publication Date
- 2026-11-17
AI Technical Summary
In existing distributed testing architectures, the lack of flexibility in task scheduling leads to inaccurate task allocation, which may result in test failures or wasted resources.
Task routing is performed using the host field. Through the message publish-subscribe mechanism between the scheduler and the execution end, tasks are dynamically allocated between the dedicated task pool and the global task pool. This ensures that test tasks are accurately matched with specific execution environments and that the execution end can autonomously select tasks to achieve load balancing.
It improves the success rate of task execution and resource utilization, reduces the load on the scheduler, avoids long-term task delays and resource waste, and maintains scheduling performance without degradation when the number of execution ends increases.
Smart Images

Figure CN123114987A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automated testing technology, and more specifically, to an automated testing task scheduling method and task execution method. Background Technology
[0002] As web applications become increasingly complex and test cases grow from hundreds to thousands or even tens of thousands, UI automated testing has gradually shifted from a single-machine execution mode to a distributed testing architecture where tasks are uniformly allocated by a central scheduling service and executed in parallel by multiple execution nodes, in order to meet the needs of large-scale testing execution efficiency and multi-environment compatibility verification.
[0003] In existing distributed testing practices, node management typically involves operations personnel manually configuring the addresses and concurrency of each execution node in a static configuration method within the scheduling service; task scheduling, on the other hand, uses a single-layer task queue, where all test tasks enter a shared queue and are assigned to idle execution nodes in sequence by the scheduling service.
[0004] The above testing method suffers from insufficient flexibility in task scheduling. Summary of the Invention
[0005] The purpose of this application is to address the shortcomings of the prior art by providing an automated testing task scheduling method and task execution method, which can improve the flexibility of task scheduling.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, one embodiment of this application provides an automated testing task scheduling method, applied to a scheduling terminal, wherein the scheduling terminal is communicatively connected to multiple execution terminals, and the method includes: Receive the test task and extract the host field from the test task; If the host field is not empty, then based on the value of the host field, a specified execution terminal is determined from among the multiple execution terminals, and the test task is written into the dedicated task pool corresponding to the specified execution terminal; the dedicated task pool is only used by the corresponding execution terminal. If the host field is empty, the test task is written to the global task pool; the global task pool is shared and used by all execution terminals. After the writing is completed, a scheduling notification is broadcast through a message publish-subscribe mechanism to trigger each execution end to retrieve a task from its corresponding dedicated task pool. If there is no task to be executed in the corresponding dedicated task pool, a task is retrieved from the global task pool.
[0007] In some embodiments, broadcasting scheduling notifications via a message publish-subscribe mechanism includes: A notification message carrying a task start identifier is published through a pre-defined publish / subscribe message channel in the memory database, so that each execution end can respond to the notification message and enter the scheduling process after subscribing to the publish / subscribe message channel.
[0008] In some embodiments, the method further includes: Receive the registration request sent by each of the aforementioned execution terminals at startup; Register the execution terminal according to the registration request, and return a registration confirmation to the execution terminal.
[0009] In some embodiments, the registration request includes the address information of the execution terminal; after receiving the registration requests sent by each of the execution terminals at startup, the method further includes: Based on the address information of each execution terminal, the pool identifier of the dedicated task pool corresponding to each execution terminal is obtained by concatenation; The step of writing the test task into the dedicated task pool corresponding to the specified execution terminal includes: Write the test task into the dedicated task pool indicated by the pool identifier.
[0010] In some embodiments, the method further includes: Based on a preset heartbeat cycle, the heartbeat information reported by each of the execution terminals is received. The heartbeat information includes the address information of the corresponding execution terminal and the current number of concurrent tasks. The online status and current load of each execution terminal are updated based on the heartbeat information; the current load is determined based on the current number of concurrent tasks and the maximum number of concurrent tasks of the execution terminal. If the target execution terminal fails to report heartbeat information for a period of time greater than or equal to a preset duration, the online status of the target execution terminal will be marked as offline, and the writing of test tasks to the dedicated task pool of the target execution terminal will be stopped.
[0011] Secondly, another embodiment of this application provides a task execution method, applied to any execution terminal, wherein the execution terminal is communicatively connected to a scheduling terminal, the method comprising: Receive scheduling notifications broadcast by the scheduling terminal through a message publish-subscribe mechanism; In response to the scheduling notification, it is determined whether there are any tasks to be executed in the dedicated task pool corresponding to the execution terminal; the tasks in the dedicated task pool are written by the scheduling terminal when specifying the execution terminal in the host field of the test task. If there are tasks to be executed, then the tasks are retrieved from the dedicated task pool corresponding to the execution terminal; If there are no tasks to be executed, a task is retrieved from the global task pool that is shared and accessible to all execution ends; the tasks in the global task pool are written by the scheduler when the host field carried by the test task does not specify the execution end. Execute the retrieved task.
[0012] In some embodiments, performing the retrieved task includes: Run the retrieved task and update the current number of concurrent tasks on the execution end.
[0013] In some embodiments, before receiving the scheduling notification broadcast by the scheduling end through a message publish-subscribe mechanism, the method further includes: When the execution terminal starts, it obtains the address information of the execution terminal and sends a registration request to the scheduling terminal. The registration request includes the address information of the execution terminal, and the address information is used to form the pool identifier of the execution terminal's exclusive task pool. After successful registration, subscribe to the publish / subscribe message channel used by the scheduling terminal to receive the scheduling notification.
[0014] In some embodiments, the method further includes: The start time of the extracted task is recorded in the execution status record; According to the preset detection cycle, the execution start time of each task currently being executed in the execution status record is read, and for any task, the execution duration of the task is determined based on the execution start time of the task. When the execution time of the task exceeds a preset time threshold, the task execution timeout is determined, and the task timeout recovery process is performed.
[0015] In some embodiments, performing timeout recovery processing on the task includes: Delete the task information of this task from the execution status record; Terminate the process corresponding to the task and all its child processes. Based on the host field carried by the task, if the host field specifies an execution end, the task is rewritten into the dedicated task pool corresponding to the specified execution end; if the host field of the task does not specify an execution end, the task is rewritten into the global task pool. The scheduling notification is broadcast through the message publish-subscribe mechanism to trigger each execution end to retrieve and execute the task again.
[0016] Thirdly, another embodiment of this application provides an automated testing task scheduling device, the device comprising: a first receiving module, a first writing module, and a first publishing module; wherein: The first receiving module is used to receive test tasks and extract the host field from the test tasks. The first writing module is configured to, if the host field is not empty, determine a specified execution terminal from among the multiple execution terminals based on the value of the host field, and write the test task into the dedicated task pool corresponding to the specified execution terminal; the dedicated task pool is only used by the corresponding execution terminal; if the host field is empty, write the test task into the global task pool; the global task pool is shared and used by all execution terminals. The first publishing module is used to broadcast a scheduling notification through a message publish-subscribe mechanism after the writing is completed, so as to trigger each execution end to retrieve a task from its corresponding dedicated task pool. If there is no task to be executed in the corresponding dedicated task pool, the task is retrieved from the global task pool.
[0017] In some embodiments, the first publishing module is specifically used to publish a notification message carrying a task start identifier through a preset publish / subscribe message channel in the memory database, so that each execution end can respond to the notification message and enter the scheduling process after subscribing to the publish / subscribe message channel.
[0018] In some embodiments, the first receiving module is specifically used to receive registration requests sent by each of the execution terminals at startup; The first publishing module is specifically used to register the execution end according to the registration request and return a registration confirmation to the execution end.
[0019] In some embodiments, the first writing module is specifically used to concatenate the pool identifier of the dedicated task pool corresponding to each execution terminal according to the address information of each execution terminal; The first writing module is specifically used to write the test task into the dedicated task pool indicated by the pool identifier.
[0020] In some embodiments, the first receiving module is specifically configured to receive heartbeat information reported by each of the execution terminals based on a preset heartbeat period, the heartbeat information including the address information of the corresponding execution terminal and the current number of concurrent tasks; update the online status and current load of each of the execution terminals according to the heartbeat information; the current load is determined based on the current number of concurrent tasks and the maximum number of concurrent tasks of the execution terminal; when the target execution terminal has not reported heartbeat information for a period of time greater than or equal to a preset duration, mark the online status of the target execution terminal as offline, and stop writing test tasks to the dedicated task pool of the target execution terminal.
[0021] Fourthly, another embodiment of this application provides a task execution apparatus, the apparatus comprising: a second receiving module, a judging module, a second writing module, and an execution module; wherein: The second receiving module is used to receive the scheduling notification broadcast by the scheduling end through the message publish-subscribe mechanism; The judgment module is used to determine, in response to the scheduling notification, whether there are any tasks to be executed in the dedicated task pool corresponding to the execution end; the tasks in the dedicated task pool are written by the scheduling end when specifying the execution end in the host field of the test task. The second writing module is used to retrieve a task from the dedicated task pool corresponding to the execution end if there is a task to be executed; and to retrieve a task from the global task pool shared by all execution ends if there is no task to be executed. The tasks in the global task pool are written by the scheduling end when the host field carried by the test task does not specify the execution end. The execution module is used to execute the retrieved task.
[0022] In some embodiments, the execution module is specifically used to run the retrieved task and update the current number of concurrent tasks at the execution end.
[0023] In some embodiments, the second receiving module is specifically used to obtain the address information of the execution terminal when the execution terminal starts and send a registration request to the scheduling terminal. The registration request includes the address information of the execution terminal, and the address information is used to form the pool identifier of the execution terminal's dedicated task pool. After successful registration, it subscribes to the publish / subscribe message channel used by the scheduling terminal to receive the scheduling notification.
[0024] In some embodiments, the execution module is specifically configured to register the execution start time of the retrieved task to the execution status record; read the execution start time of each task being executed in the execution status record according to a preset detection period; for any task, determine the execution duration of the task based on the execution start time of the task; when the execution duration of the task exceeds a preset duration threshold, determine that the task execution has timed out, and perform timeout recovery processing on the task.
[0025] In some embodiments, the execution module is specifically configured to: delete the task information of the task from the execution status record; terminate the process corresponding to the task and all child processes of the process; rewrite the task into the dedicated task pool corresponding to the specified execution terminal when the host field of the task specifies an execution terminal, and rewrite the task into the global task pool when the host field of the task does not specify an execution terminal; and broadcast the scheduling notification through the message publish-subscribe mechanism to trigger each execution terminal to retrieve and execute the task again.
[0026] Fifthly, another embodiment of this application provides a scheduling terminal, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the scheduling terminal is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of any of the methods described in the first aspect above.
[0027] In a sixth aspect, another embodiment of this application provides an execution terminal, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the execution terminal is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of any of the methods described in the second aspect above.
[0028] In a seventh aspect, another embodiment of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the method as described in either the first or second aspect above.
[0029] The beneficial effects of this application are as follows: When the host field is not empty, the task is written to the dedicated task pool corresponding to the specified execution end and can only be used by that execution end. This achieves precise matching and targeted routing between test tasks and specific execution environments, ensuring that test tasks with environment dependencies are not mistakenly taken by other execution ends, thus improving the success rate and reliability of such task execution. When the host field is empty, the task is written to the global task pool for all execution ends to share and use. This allows general tasks without environment dependencies to be used by any idle execution end, avoiding resource idleness and improving resource utilization. At the same time, the scheduling notification is broadcast through a message publish-subscribe mechanism, triggering each execution end to retrieve tasks in an event-driven manner. This reduces the load on the scheduling end while ensuring high real-time performance. The priority reading from the dedicated pool and the fallback from the global pool allows the execution end to prioritize the tasks assigned to it and then retrieve global tasks when the dedicated task pool is empty. This balances targeted execution needs with global resource utilization, avoiding long-term stagnation of specified tasks and waste of resources on idle execution ends. Furthermore, the method provided in this application only requires the scheduler to write routes based on the host field and each execution terminal to autonomously select tasks according to priority. This eliminates the need for the scheduler to make centralized task allocation decisions, thus eliminating the allocation bottleneck of the central scheduler and ensuring that scheduling performance does not decrease as the number of execution terminals increases. Attached Figure Description
[0030] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 A flowchart illustrating a task scheduling method for automated testing according to an embodiment of this application is shown. Figure 2 A flowchart illustrating a task scheduling method for automated testing according to another embodiment of this application is shown; Figure 3 A flowchart illustrating a task scheduling method for automated testing according to another embodiment of this application is shown; Figure 4 A flowchart illustrating a task execution method according to an embodiment of this application is shown; Figure 5 A flowchart illustrating a task execution method according to another embodiment of this application is shown; Figure 6 A flowchart illustrating a task execution method according to another embodiment of this application is shown; Figure 7 A schematic diagram of the structure of an automated testing system provided in an embodiment of this application is shown; Figure 8 This illustration shows a schematic diagram of the structure of an automated testing task scheduling device provided in an embodiment of this application; Figure 9 This paper shows a schematic diagram of the structure of a task execution device provided in an embodiment of this application; Figure 10 This illustration shows a schematic diagram of the structure of a scheduling terminal according to an embodiment of this application; Figure 11 A schematic diagram of the structure of an execution terminal provided in an embodiment of this application is shown. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0033] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0034] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0035] This application relates to user interface (UI) automated testing technology in the field of World Wide Web application development and quality assurance. Specifically, it is applied to distributed UI automated testing scenarios consisting of a scheduler and multiple execution terminals. In these scenarios, the number of test cases is large and needs to cover compatibility verification requirements across multiple operating systems and browser versions. Typically, the scheduler receives and distributes test tasks uniformly, and multiple execution terminals deployed in different environments (such as Linux, Mac, and Windows) execute the test scripts in parallel, then aggregate the results. This improves execution efficiency while meeting multi-environment compatibility testing requirements.
[0036] Figure 1 This illustration shows a flowchart of an automated testing task scheduling method according to an embodiment of this application, applied to a scheduling terminal (also known as the main service), such as... Figure 1 As shown, the method includes steps 110-140, wherein: Step 110: Receive the test task and extract the host field from the test task.
[0037] The scheduler is the central scheduling service in the distributed testing system. It is responsible for receiving test tasks, writing routes based on the host field, broadcasting scheduling notifications, and managing the registration and heartbeat of the execution end.
[0038] A test task is an automated test unit submitted by an external system to the scheduler for execution. External systems can be, for example, continuous integration systems, test management platforms, or scheduled task schedulers.
[0039] Each test task should contain at least the following information: a task identifier (taskId), a number or string used to uniquely identify the test task; a script object (script), which describes the test script content to be executed by the test task, such as a Playwright script or a Selenium script; and a host field (host), which specifies the host of the execution server that will execute the test task.
[0040] The host field can be empty, or it can be the network address (such as an Internet Protocol IP address) or node name of a specific execution terminal. An empty host field indicates that the test task has not specified an execution terminal and can be used by any idle execution terminal; a non-empty host field indicates that the test task needs to be executed by a specific execution terminal.
[0041] In the embodiments of this application, the scheduling segment can obtain a task list, traverse each test task in the task list, extract and determine whether the host field of each task is empty.
[0042] If the host field is not empty, proceed to step 120: Based on the value of the host field, determine the specified execution end from multiple execution ends, and write the test task into the dedicated task pool corresponding to the specified execution end; the dedicated task pool can only be used by the corresponding execution end.
[0043] The designated execution end refers to the execution end selected from multiple execution ends based on the value of the host field, and is designated to perform the test task. The designated execution end is usually uniquely identified by the IP address or node name in the host field.
[0044] A dedicated task pool is a task queue that corresponds one-to-one with a specific execution end. Its key name or identifier contains the address information of the specified execution end. Tasks in the dedicated task pool can only be used by that specific execution end. Other execution ends, even if they are idle, cannot take tasks from the dedicated task pool, thus ensuring the targeted execution needs and preventing tasks from being mistakenly taken by other execution ends, which would lead to execution failure.
[0045] As an example, a test task needs to verify Internet Explorer compatibility on a Windows operating system. The host field value of the task is "192.168.1.101" (corresponding to the IP address of the Windows execution terminal). After receiving the test task, the scheduler extracts the host field, obtaining "192.168.1.101". If the host field is not empty, it determines that the specified execution terminal is the Windows node corresponding to this IP address and writes the test task to the dedicated task pool corresponding to "192.168.1.101". This method of specifying the execution terminal through the host field value ensures that UI defect tests that can only be reproduced in a Windows environment can be correctly routed to the Windows execution terminal, avoiding the task being assigned to a Linux or Mac execution terminal, which could lead to test failure or the test task not executing normally.
[0046] If the host field is empty, proceed to step 130: write the test task to the global task pool; the global task pool is shared and used by all execution ends.
[0047] An empty host field indicates that the test task does not specify an execution end, does not depend on a specific execution environment, and can be executed by any execution end.
[0048] The global task pool is a shared task queue that is not limited to any particular execution end. Its key name or identifier does not contain address information for a specific execution end. Tasks in the global task pool can be used by any idle execution end. That is, any execution end can retrieve a task from the global task pool and execute it when its own dedicated task pool is empty.
[0049] As an example, a test task is a general login verification function that does not depend on a specific operating system or browser version, and the host field of the task is empty. After receiving the test task, the scheduler extracts the host field, determines that the field is empty, and therefore confirms that the task can be used by any idle execution terminal, and writes the test task into the global task pool. This method of declaring the host field as empty declares that the task is a general task, not bound to a specific execution terminal, which can fully utilize the computing resources of any idle execution terminal in the cluster, improve global resource utilization, and avoid the problem of long waiting times due to a specified execution terminal being busy.
[0050] Step 140: After writing is complete, broadcast the scheduling notification through the message publish-subscribe mechanism to trigger each execution end to retrieve the task from its corresponding dedicated task pool. If there is no task to be executed in the corresponding dedicated task pool, retrieve the task from the global task pool.
[0051] The message publish / subscribe mechanism is a message communication mechanism based on the publish / subscribe pattern. The scheduler acts as the publisher, publishing scheduling notifications through a pre-defined message channel. Each execution end acts as a subscriber, subscribing to the message channel to receive scheduling notifications sent by the scheduler.
[0052] In some embodiments, a notification message carrying a task start identifier can be published through a pre-defined publish / subscribe (Pub / Sub) message channel in the memory database, so that each execution end can respond to the notification message and enter the scheduling process after subscribing to the publish / subscribe message channel.
[0053] Scheduling notifications are messages broadcast by the scheduler after a task is written to the task pool, triggering each execution end to enter the scheduling process. After the task is written, a scheduling notification is published through the Redis Pub / Sub channel. The scheduling notification can carry a task start identifier (such as startTask). Upon receiving the scheduling notification, the execution end enters the scheduling loop and begins retrieving tasks from the task pool.
[0054] Pub / Sub's event-driven mechanism offers high real-time performance, eliminating the need for the scheduler to query the status of each execution end individually, thus reducing the scheduler's load. At the same time, each execution end can respond in real time, avoiding polling delays.
[0055] Upon receiving a scheduling notification, the execution unit first retrieves tasks from its own dedicated task pool. When the execution unit's dedicated task pool is empty, it then retrieves tasks from the global task pool. This order of retrieving tasks from the dedicated pool first, followed by the global pool as a backup, ensures the normal operation of the two-layer queue routing strategy, achieving both precise routing and guaranteed global resource utilization.
[0056] In the embodiments of this application, the scheduling end is only responsible for writing tasks and broadcasting notifications, without making specific allocation decisions. Each execution end independently selects tasks based on its own concurrency capabilities, thereby naturally achieving load balancing.
[0057] The automated testing task scheduling method provided in this application involves the scheduler receiving test tasks and extracting the host field from them. When the host field is not empty, the task is written to the dedicated task pool corresponding to the specified execution end, and only that execution end can access it. This achieves precise matching and targeted routing between test tasks and specific execution environments, ensuring that environment-dependent test tasks are not mistakenly accessed by other execution ends, thus improving the success rate and reliability of such task execution. When the host field is empty, the task is written to the global task pool for all execution ends to share, allowing general tasks without environment dependencies to be accessed by any idle execution end, avoiding resource idleness and improving resource utilization. Simultaneously, a message publish-subscribe mechanism broadcasts scheduling notifications, triggering each execution end to retrieve tasks in an event-driven manner. This reduces the load on the scheduler while ensuring high real-time performance. The priority reading from the dedicated pool and the fallback from the global pool allows execution ends to prioritize tasks assigned to them, and only access global tasks when the dedicated task pool is empty. This balances targeted execution needs with global resource utilization, avoiding long-term stagnation of designated tasks and waste of resources on idle execution ends. Furthermore, the method provided in this application only requires the scheduler to write routes based on the host field and each execution terminal to autonomously select tasks according to priority. This eliminates the need for the scheduler to make centralized task allocation decisions, thus eliminating the allocation bottleneck of the central scheduler and ensuring that scheduling performance does not decrease as the number of execution terminals increases.
[0058] Figure 2 A flowchart illustrating a task scheduling method for automated testing according to another embodiment of this application is shown, as follows: Figure 2 As shown, the method further includes steps 150-160, wherein: Step 150: Receive the registration request sent by each execution terminal at startup.
[0059] Startup refers to the initialization phase before the executor process is launched and begins providing services. During the initialization phase, the executor has not yet entered the task waiting state, nor has it subscribed to the scheduler's publish / subscribe message channel.
[0060] A registration request is a communication request that the executor actively sends to the scheduler at startup to inform the scheduler that the executor is online. Registration requests can be sent via HTTP POST or other similar request methods.
[0061] In some embodiments, the registration request includes the address information of the execution end; the scheduler can construct the pool identifier of the dedicated task pool corresponding to each execution end based on the address information of each execution end; and write the test task into the dedicated task pool indicated by the pool identifier.
[0062] In some embodiments, the registration request may also include device capability parameters of the executing end, such as hostname, current number of concurrent tasks, number of central processing unit (CPU) cores, memory information, etc. The maximum number of concurrent tasks is used by the executing end to determine whether to continue retrieving tasks from the dedicated task queue and the global task queue.
[0063] The address information in the registration request is the local network address identifier reported by the executor to the scheduler when starting registration. It is used to uniquely identify the location of the executor in the cluster. The address information can be an IP address, hostname, node name, or other identifiers that can uniquely distinguish the executor.
[0064] Concatenation refers to the process by which the scheduler combines the address information of the execution end with a preset pool identifier prefix according to preset naming rules to generate a complete pool identifier for a dedicated task pool. This concatenation process ensures that the pool identifier of a dedicated task pool can uniquely correspond to a specific execution end, thereby guaranteeing the accuracy of task routing.
[0065] As an example, with the default prefix WEB_UI_TEST_PLATFORM:TASKS: and the current execution terminal's address information being 192.168.1.101, the pool identifier of the dedicated task pool corresponding to the current execution terminal, obtained by concatenation, is WEB_UI_TEST_PLATFORM:TASKS:192.168.1.101. The scheduler writes the test task into the dedicated task pool indicated by this pool identifier, thus completing the directed routing to the specified execution terminal.
[0066] The pool identifier of a dedicated task pool is used to uniquely identify the key name or index of that dedicated task pool in a distributed cache or message middleware. The pool identifier includes the address information of the executor, enabling dedicated task pools of different executors to be distinguished from each other and to avoid interference. The pool identifier allows the scheduler to accurately write test tasks to the dedicated task pool corresponding to a specified executor, and at the same time allows the executor to accurately retrieve tasks from its own dedicated task pool.
[0067] Each execution end is a set of execution end nodes deployed in the distributed testing system. They can be deployed on different operating systems (such as Linux, Mac, and Windows), run independently, and each needs to register with the scheduler at startup.
[0068] Step 160: Register the execution end according to the registration request and return the registration confirmation to the execution end.
[0069] After receiving the registration request, the scheduler records the address information and device capability parameters of the execution end in the scheduler's node management data for subsequent task routing, heartbeat status maintenance, and load management. The registered information includes, but is not limited to, the execution end's address information, maximum number of concurrent tasks, current number of concurrent tasks, and online status.
[0070] Registration confirmation is a response message returned by the scheduler to the executor after successful registration, informing the executor that registration has been successful. Registration confirmation can take the form of an HTTP response, message reply, or other similar format. Only after receiving registration confirmation can the executor proceed with subsequent processes such as subscribing to message channels and waiting for scheduling notifications. This prevents the executor from remaining in a task waiting state even if registration fails, thus improving system reliability.
[0071] Figure 3 This illustration shows a flowchart of a task scheduling method for automated testing according to another embodiment of this application, as shown below. Figure 3 As shown, the method further includes steps 170-190, wherein: Step 170: Receive heartbeat information reported by each execution terminal based on a preset heartbeat cycle. The heartbeat information includes the address information of the corresponding execution terminal and the current number of concurrent tasks.
[0072] The preset heartbeat cycle is a pre-agreed interval between the scheduler and the execution end, which is the time interval at which the execution end reports heartbeat information to the scheduler.
[0073] The preset heartbeat cycle can be sent from the scheduler to the execution end during registration confirmation, or it can be configured locally by the execution end.
[0074] In some possible embodiments, the preset heartbeat period can be set to 10 seconds, or it can be set to any time, such as 5 seconds, 8 seconds or 12 seconds. The specific preset heartbeat period time setting can be flexibly adjusted according to the user's requirements for practicality and communication overhead.
[0075] Heartbeat information is a status report message that the executor actively sends to the scheduler according to a preset heartbeat period. It is used to inform the scheduler that the executor is still online and the current load status of the executor.
[0076] Heartbeat information includes at least the address information of the executing end and the current number of concurrent tasks. The address information in the heartbeat information is used to identify which executing end the heartbeat information comes from. The scheduler uses the address information to match the heartbeat information with the registered executing ends, thereby updating the online status and current load of the corresponding executing end.
[0077] Compared to a registration request, which is a one-time message when the execution client starts up, a heartbeat message is a periodic message during the execution client's operation.
[0078] The current concurrent task count represents the number of tasks being executed by the execution server at the current moment. Each time the execution server retrieves a task and begins execution, the current concurrent task count increases by 1; each time a task is completed, the current concurrent task count decreases by 1. The current concurrent task count reflects the real-time load of the execution server.
[0079] Step 180: Update the online status and current load of each execution terminal based on the heartbeat information.
[0080] The scheduler writes the current number of concurrent tasks carried in the heartbeat information into the node management data, replacing the current number of concurrent tasks previously recorded by the execution end, so that the load information held by the scheduler is consistent with the actual load of the execution end.
[0081] The current load is determined based on the current number of concurrent tasks and the maximum number of concurrent tasks on the execution end. It is a quantitative representation of the current workload on the execution end and reflects how much spare capacity the execution end has to accept new tasks.
[0082] In one implementation, the current load can be expressed as the ratio of the current number of concurrent tasks to the maximum number of concurrent tasks (i.e., load rate). For example, when the maximum number of concurrent tasks is 3 and the current number of concurrent tasks is 2, the load rate is 2 / 3. Alternatively, the current load can also be expressed as the remaining available concurrent tasks, which is the maximum number of concurrent tasks minus the current number of concurrent tasks. For example, when the maximum number of concurrent tasks is 3 and the current number of concurrent tasks is 2, the remaining available concurrent tasks is 1.
[0083] As an example, if a certain execution endpoint has a maximum concurrent task count of 3, and its heartbeat information reports a current concurrent task count of 3, the scheduler calculates its load rate as 3 / 3 = 1, indicating that the execution endpoint is at full capacity. The scheduler will no longer prioritize assigning tasks to this execution endpoint in subsequent scheduling. Quantifying the workload of the execution endpoint through load rate allows the scheduler to identify fully loaded nodes, preventing instability caused by overload.
[0084] As an example, if a certain execution end has a maximum concurrent task count of 3, and the heartbeat information reports a current concurrent task count of 1, the scheduler calculates its remaining available concurrent task count as 3-1=2. Based on the remaining available concurrent task count, the scheduler can determine that the execution end still has the capacity to accept new tasks. The remaining available concurrent task count directly reflects the execution end's task acceptance capacity, providing a direct basis for task allocation by the scheduler.
[0085] Step 190: If the target execution terminal fails to report heartbeat information for a period of time greater than or equal to the preset duration, mark the online status of the target execution terminal as offline and stop writing test tasks to the target execution terminal's dedicated task pool.
[0086] Online status is an indicator from the scheduler indicating whether an execution end is currently available. Online status can be either online or offline. An execution end is marked as online upon successful registration; if the scheduler does not receive heartbeat information from an execution end continuously, it is marked as offline.
[0087] In some embodiments, if an execution terminal fails to report heartbeat information for several consecutive heartbeat cycles due to network interruption, the scheduler will mark the online status of the execution terminal as offline and clear its current load or mark it as unavailable, so that the load information of the offline execution terminal will no longer participate in the scheduling decision, thus preventing the scheduler from assigning tasks to the offline execution terminal.
[0088] Figure 4 This illustration shows a flowchart of a task execution method according to an embodiment of this application, applicable to any execution end, i.e., an execution node. The execution end is communicatively connected to the scheduling end, such as... Figure 4 As shown, the method further includes steps 210-250, wherein: Step 210: Receive scheduling notifications broadcast by the scheduling end through the message publish-subscribe mechanism.
[0089] The scheduler publishes the scheduling notification to a preset message channel. All execution ends that subscribe to the channel can receive the scheduling notification. The broadcast mechanism allows a single scheduling notification to reach multiple execution ends simultaneously, eliminating the need for the scheduler to send it to each one individually.
[0090] As an example, the scheduler receives a batch of test tasks, writes each task to its dedicated task pool or global task pool, and then broadcasts a scheduling notification (startTask) via the Redis Pub / Sub channel. Each execution end, after subscribing to this channel, receives the scheduling notification and enters the scheduling process. This event-driven broadcast mechanism ensures that the execution end is triggered immediately after the task is written, without waiting for the polling cycle, thus improving the real-time performance of scheduling.
[0091] Step 220: In response to the scheduling notification, determine whether there are any tasks to be executed in the dedicated task pool corresponding to the execution end.
[0092] Tasks in the dedicated task pool are written by the scheduler when specifying the execution end in the host field of the test task.
[0093] The execution end checks its own dedicated task pool for any tasks to be executed. This can be done by querying the number of elements in the dedicated task pool or by attempting to retrieve a task. The result of this check determines which task pool the execution end will subsequently retrieve a task from.
[0094] If there are tasks to be executed, proceed to step 230: retrieve the task from the dedicated task pool corresponding to the execution end.
[0095] When there are tasks to be executed in the dedicated task pool, the execution end retrieves the tasks from the corresponding dedicated pool and does not access the global task pool. This ensures that tasks to be executed in the dedicated task pool can be retrieved and processed by the execution end first, meeting the needs of targeted execution and preventing designated tasks from being delayed for a long time.
[0096] If there are no tasks to be executed, proceed to step 240: retrieve a task from the global task pool that is shared and accessible to all execution ends.
[0097] Tasks in the global task pool are written by the scheduler when the host field of the test task does not specify the execution host.
[0098] If the dedicated task pool is empty, the execution end will retrieve tasks from the global task pool to avoid the problem of the execution end being idle and improve resource utilization.
[0099] A global task pool is shared by all execution ends. Any execution end can retrieve tasks from the global task pool when its own dedicated task pool is empty. Tasks in the global task pool are not bound to any specific execution end and can be processed by any idle execution end. The shared access mechanism of the global task pool allows multiple execution ends to retrieve tasks concurrently, thereby achieving load balancing without the need for complex task allocation by the scheduler.
[0100] Step 250: Execute the retrieved task.
[0101] The execution end runs the retrieved test tasks, including starting test scripts, simulating user operations, and verifying page functions.
[0102] In some embodiments, the retrieved task is run, and the current number of concurrent tasks on the executor is updated. Specifically, the current number of concurrent tasks increases while the executor is executing a task, and decreases after the executor completes executing a task.
[0103] During execution, the executor can register the task's start time in the execution status record and update the current number of concurrent tasks. The execution status record is a data structure used by the executor to record the status information of tasks being executed, and it includes at least the task's start time.
[0104] Figure 5 A flowchart illustrating a task execution method according to another embodiment of this application is shown, as follows: Figure 5 As shown, before step 210, the method further includes steps 201-202, wherein: Step 201: When the execution end starts, obtain the address information of the execution end and send a registration request to the scheduling end.
[0105] The registration request includes the address information of this execution server, which is used to form the pool identifier of the execution server's dedicated task pool.
[0106] Obtaining address information refers to the process by which the executable automatically reads the local network address identifier upon startup. This can be done by: reading environment variables (such as MACHINE_IP); if the environment variable is not set, iterating through the local network interfaces to obtain non-internal Internet Protocol version 4 (IPv4) addresses. Alternatively, the hostname (such as the environment variable MACHINE_NAME or the operating system hostname) can be used as supplementary address information.
[0107] The pool identifier for a dedicated task pool is typically formed by concatenating a preset prefix with address information. For example, concatenating the preset prefix WEB_UI_TEST_PLATFORM:TASKS: with the address information 192.168.1.101 yields the pool identifier WEB_UI_TEST_PLATFORM:TASKS:192.168.1.101. This pool identifier allows dedicated task pools from different execution endpoints to be distinguished from each other, thereby ensuring the accuracy of directed routing.
[0108] Step 202: After successful registration, subscribe to the publish / subscribe message channel used by the scheduler to receive scheduling notifications.
[0109] After the executor sends a registration request, it receives a registration confirmation from the scheduler, confirming that the executor has been successfully registered by the scheduler. Successful registration is a prerequisite for the executor to enter the subscription step. If registration fails, the executor will not subscribe to the message channel to avoid receiving tasks without being registered by the scheduler.
[0110] Subscription refers to an execution end registering its interest in a specific message channel with a message broker (such as Redis), enabling it to receive messages published on that channel. After a successful subscription, the execution end becomes a subscriber to that channel, and scheduling notifications published to that channel by the scheduler will be pushed to the execution end. Subscription is a prerequisite for the execution end to receive scheduling notifications.
[0111] As an example, after a Linux execution client sends a registration request to the scheduler, it receives a registration confirmation from the scheduler. The Linux execution client then subscribes to the Redis Pub / Sub channel used by the scheduler and enters a task waiting state. When the scheduler writes a task and broadcasts a startTask notification, the execution client receives the notification and enters the scheduling process.
[0112] Figure 6 A flowchart illustrating a task execution method according to another embodiment of this application is shown, as follows. Figure 6 As shown, the method further includes steps 260-280, wherein: Step 260: Record the start time of the retrieved task in the execution status record.
[0113] The execution start time is the moment when the execution end actually begins running the task after retrieving it. The execution start time is used to subsequently calculate the task's execution duration. The execution start time can be accurate to the millisecond level for precise calculation of the execution duration.
[0114] An execution status record is a data structure used by the execution end to store the status information of tasks currently being executed. The execution status record can be implemented using a hash table structure, with the task identifier as the field key and task details (such as execution start time, execution end information, etc.) as field values. The execution status record provides the data foundation for subsequent timeout detection, allowing the execution end to periodically check the execution duration of each task.
[0115] Registration refers to the operation where the executor writes the task's execution start time into the execution status record. Registration occurs after the executor retrieves the task, before starting execution, or simultaneously with task execution. After registration, the task is included in the timeout detection scope.
[0116] As an example, a certain execution client has a maximum concurrent task count of 3, and currently executes 3 tasks simultaneously. The execution client registers the start time of each of the 3 tasks in an execution status record, with each record corresponding to one task. The execution status record supports parallel registration of multiple tasks, allowing the execution client to perform timeout checks on multiple tasks simultaneously, adapting to concurrent execution scenarios.
[0117] Step 270: Read the execution start time of each task being executed in the execution status record according to the preset detection cycle. For any task, determine the execution duration based on the task's execution start time.
[0118] The preset detection period is the time interval at which the execution end performs timeout checks. The execution end triggers the timeout detection process according to the preset detection period, reads the tasks being executed in the execution status record, and calculates the execution duration.
[0119] In the embodiments of this application, the preset detection period can be set to 5 minutes, or it can be set to any time such as 1 minute, 3 minutes or 6 minutes. The specific preset detection period time setting can be flexibly adjusted according to the user's needs for real-time performance and detection overhead. This application does not impose any restrictions here.
[0120] Reading the execution status record refers to the executor retrieving all entries of currently executing tasks from the execution status record in order to calculate the execution time of each task. The read operation can be achieved by reading all fields of the hash table.
[0121] Execution duration is the difference between the current time and the task's start time, reflecting the length of time the task has been executed. Execution duration = Current time Execution start time.
[0122] As an example, the preset detection cycle of a certain execution terminal is 5 minutes. Every 5 minutes, the execution terminal reads the execution start time of all currently executing tasks from the execution status record and calculates the execution duration of each task. For example, if the execution start time of a task is 10:30:00 and the current time is 12:35:00, then the execution duration of the task is 2 hours and 5 minutes.
[0123] Step 280: When the execution time of a task exceeds a preset time threshold, determine that the task execution has timed out and perform task execution timeout recovery processing.
[0124] The preset duration threshold is the critical value at which the executor determines whether a task has timed out. When the execution time of a task exceeds the preset duration threshold, the executor determines that the task has timed out.
[0125] The value of the preset duration threshold should take into account the normal execution time of the test task to avoid misjudging a normally executing task as a timeout. In some possible embodiments, the preset duration threshold can be set to 2 hours, but it can also be any time such as 1 hour or 1.5 hours.
[0126] Reasons for execution timeout include, but are not limited to: test script infinite loop, execution process crash, network interruption causing task suspension, and abnormal test environment. Execution timeout indicates that the task may not be able to complete normally and requires recovery processing.
[0127] In some embodiments, the executor can delete the task information of the task from the execution status record; terminate the process corresponding to the task and all child processes of the process; rewrite the task into the dedicated task pool corresponding to the specified executor when the host field of the task specifies the executor, and rewrite the task into the global task pool when the host field of the task does not specify the executor; and broadcast scheduling notifications through a message publish-subscribe mechanism to trigger each executor to retrieve and execute the task again.
[0128] As an example, a test script gets stuck in an infinite loop due to a logical flaw, exceeding the preset timeout threshold of 2 hours. The execution end determines the task has timed out during periodic checks, triggers timeout recovery processing, terminates the process tree corresponding to the task, deletes the task record from the execution status record, rewrites it into the corresponding task pool based on the original host field, and broadcasts a scheduling notification via a message publish-subscribe mechanism. Other execution ends, upon receiving the notification, enter the scheduling process, retrieve the task again, and execute it.
[0129] Figure 7 A schematic diagram of the structure of an automated testing system provided in an embodiment of this application is shown, as follows: Figure 7As shown, the automated testing system comprises, from top to bottom, the following layers: front-end layer, scheduling layer (server layer), execution layer (Agent layer), and data layer. The front-end layer is used to initiate configurations, and the server layer is used to return results. The server layer is also used to issue tasks, and the agent layer is used to report status. The agent layer is also used to read and write the task pool and status records. The server layer is also used to write test cases, plans, configurations, etc.
[0130] Continue as Figure 7 As shown, the front-end layer includes two types of clients: web clients and desktop clients (electron clients).
[0131] The web interface is the browser entry point and uses the following technical components: the front-end view framework Eact, the UI component library Ant Design, the front-end application framework Umi, the code editor Monaco-editor (for script editing), and the micro-front-end framework Qiankun (for integrating multiple sub-applications).
[0132] The desktop client (Electron client) includes offline management features for task management in offline scenarios.
[0133] Continue as Figure 7 As shown, the scheduling layer (server layer) is located below the front-end layer and is the central scheduling service of the system. The scheduling layer includes: user authentication, responsible for user identity authentication and access control; logging, used to record system operation logs and execution logs; test cases include: script editing, DingTalk notifications, and report viewing; test plans include: associated test cases, periodic settings, and scheduled tasks; configuration management includes: pages, applications, and environments; template data includes: template management, field management, and data management; and test script processing includes: variable substitution, system function substitution, and import processing.
[0134] The execution layer (Agent layer) is located below the scheduling layer and is the execution node for distributed testing. The execution layer includes: Agent node cluster and functional modules.
[0135] The Agent node cluster can include Agent1 (Linux), Agent2 (Mac), and Agent3 (Windows), which are deployed on different operating systems.
[0136] Functional modules may include: dynamic nodes, supporting dynamic addition / removal of nodes; task execution on specified nodes, supporting task routing to specified nodes; cross-platform deployment (Linux / Mac / Windows), supporting deployment on multiple operating systems; task interruption, supporting task interruption operations; task retry, supporting retry of failed tasks; task loss prevention mechanism (node offline, restart), preventing task loss through node offline and restart mechanisms; real-time logs and steps, real-time transmission of execution logs and step-level progress; test reports, generating test reports; CAPTCHA recognition, supporting CAPTCHA recognition; and component analysis (CA) testing, supporting HTTPS testing that requires a CA certificate.
[0137] Continue as Figure 7 As shown, the data layer is located at the bottom of the automated testing system and is divided into two types of storage: the in-memory database Redis and the relational database MySQL.
[0138] Redis includes a task pool, which stores a queue of tasks to be executed (corresponding to a dedicated task pool and a global task pool); and ongoing tasks, which stores the status records of tasks that are currently being executed (corresponding to execution status records).
[0139] MySQL includes test cases, which store test case data; plans, which store test plan data; configurations, which store configuration management data; and templates, which store template data.
[0140] The connection and data flow between layers can be as follows: the front-end layer connects with the server layer, the front-end initiates operations such as test case editing, plan configuration, and task triggering, and the server layer processes and returns the results.
[0141] The server layer connects with the agent layer. After receiving the test task, the server layer writes it into the corresponding task pool according to the host field and broadcasts the scheduling notification through the message publish-subscribe mechanism to trigger the agent layer to retrieve and execute the task.
[0142] The Agent layer connects with the data layer. The Agent layer retrieves tasks from the Redis task pool, registers the execution start time in the ongoing task record, and writes test reports and other data after execution.
[0143] The server layer connects with the data layer. The server layer writes data such as test cases, plans, configurations, and templates to MySQL; at the same time, it can read task status from Redis.
[0144] The Agent layer connects with the server layer, and the Agent layer reports heartbeat information, real-time progress, and execution results to the server layer.
[0145] Based on the same inventive concept, this application also provides an automated testing task scheduling device corresponding to the automated testing task scheduling method. Since the principle of the device in this application is similar to the automated testing task scheduling method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0146] Figure 8 This paper illustrates a schematic diagram of the structure of an automated testing task scheduling device provided in an embodiment of this application. Figure 8 As shown, the device includes: a first receiving module 310, a first writing module 320, and a first publishing module 330; wherein: The first receiving module 310 is used to receive the test task and extract the host field from the test task. The first writing module 320 is configured to, if the host field is not empty, determine a specified execution terminal from among the multiple execution terminals according to the value of the host field, and write the test task into the dedicated task pool corresponding to the specified execution terminal; the dedicated task pool is only used by the corresponding execution terminal; if the host field is empty, write the test task into the global task pool; the global task pool is shared by all execution terminals. The first publishing module 330 is used to broadcast a scheduling notification through a message publish-subscribe mechanism after the writing is completed, so as to trigger each execution end to retrieve a task from its corresponding dedicated task pool. If there is no task to be executed in the corresponding dedicated task pool, the task is retrieved from the global task pool.
[0147] In some embodiments, the first publishing module 330 is specifically used to publish a notification message carrying a task start identifier through a preset publish / subscribe message channel in the memory database, so that each execution end can respond to the notification message and enter the scheduling process after subscribing to the publish / subscribe message channel.
[0148] In some embodiments, the first receiving module 310 is specifically used to receive registration requests sent by each of the execution terminals at startup; The first publishing module is specifically used to register the execution end according to the registration request and return a registration confirmation to the execution end.
[0149] In some embodiments, the first writing module 320 is specifically used to concatenate the pool identifier of the dedicated task pool corresponding to each execution terminal according to the address information of each execution terminal; The first writing module 320 is specifically used to write the test task into the dedicated task pool indicated by the pool identifier.
[0150] In some embodiments, the first receiving module 310 is specifically configured to receive heartbeat information reported by each of the execution terminals based on a preset heartbeat period, the heartbeat information including the address information of the corresponding execution terminal and the current number of concurrent tasks; update the online status and current load of each of the execution terminals according to the heartbeat information; the current load is determined based on the current number of concurrent tasks and the maximum number of concurrent tasks of the execution terminal; when the target execution terminal has not reported heartbeat information for a period of time greater than or equal to a preset duration, mark the online status of the target execution terminal as offline, and stop writing test tasks to the dedicated task pool of the target execution terminal.
[0151] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0152] Based on the same inventive concept, this application also provides a task execution device corresponding to the task execution method. Since the principle of the device in this application is similar to the task execution method described above in this application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0153] Figure 9 This application provides a schematic diagram of the structure of a task execution device according to an embodiment of the present application. Figure 9 As shown, the device includes: a second receiving module 410, a judging module 420, a second writing module 430, and an execution module 440; wherein: The second receiving module 410 is used to receive the scheduling notification broadcast by the scheduling end through the message publish-subscribe mechanism; The judgment module 420 is used to determine, in response to the scheduling notification, whether there are any tasks to be executed in the dedicated task pool corresponding to the execution end; the tasks in the dedicated task pool are written by the scheduling end when specifying the execution end in the host field of the test task. The second writing module 430 is used to retrieve a task from the dedicated task pool corresponding to the execution terminal if there is a task to be executed; and to retrieve a task from the global task pool shared by all execution terminals if there is no task to be executed; the tasks in the global task pool are written by the scheduling terminal when the host field carried by the test task does not specify the execution terminal. The execution module 440 is used to execute the retrieved task.
[0154] In some embodiments, the execution module 440 is specifically used to run the retrieved task and update the current number of concurrent tasks at the execution end.
[0155] In some embodiments, the second receiving module 410 is specifically used to obtain the address information of the execution terminal when the execution terminal starts and send a registration request to the scheduling terminal. The registration request includes the address information of the execution terminal, and the address information is used to form the pool identifier of the execution terminal's dedicated task pool. After successful registration, it subscribes to the publish / subscribe message channel used by the scheduling terminal to receive the scheduling notification.
[0156] In some embodiments, the execution module 440 is specifically configured to register the execution start time of the retrieved task to the execution status record; read the execution start time of each task being executed in the execution status record according to a preset detection cycle; for any task, determine the execution duration of the task based on the execution start time of the task; when the execution duration of the task exceeds a preset duration threshold, determine that the task execution has timed out, and perform timeout recovery processing on the task execution.
[0157] In some embodiments, the execution module 440 is specifically configured to: delete the task information of the task from the execution status record; terminate the process corresponding to the task and all child processes of the process; according to the host field carried by the task, if the host field specifies an execution end, rewrite the task into the dedicated task pool corresponding to the specified execution end, and if the host field of the task does not specify an execution end, rewrite the task into the global task pool; and broadcast the scheduling notification through the message publish-subscribe mechanism to trigger each execution end to retrieve and execute the task again.
[0158] This application also provides a scheduling terminal. Figure 10 This application provides a schematic diagram of the structure of a scheduling terminal according to an embodiment of the present application. Figure 10 As shown, the scheduling terminal includes a processor 51 and a memory 52, and optionally, a bus 53. The memory 52 stores machine-readable instructions executable by the processor 51. When the scheduling terminal is running, the processor 51 and the memory 52 communicate via the bus 53. When the machine-readable instructions are executed by the processor 51, the aforementioned... Figures 4-6 The steps of any method.
[0159] This application also provides an execution terminal. Figure 11 This application provides a schematic diagram of the structure of an execution terminal according to an embodiment of the present application. Figure 11As shown, the execution end includes a processor 61 and a memory 62, and optionally, a bus 63. The memory 62 stores machine-readable instructions executable by the processor 61. When the execution end is running, the processor 61 and the memory 62 communicate via the bus 63. When the machine-readable instructions are executed by the processor 61, the aforementioned... Figures 1-3 The steps of any method.
[0160] This application also provides a computer-readable storage medium storing a computer program, which is executed by a processor. Figures 1-7 The steps of any method.
[0161] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0162] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0163] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A task scheduling method for automated testing, characterized in that, Applied to a scheduling terminal that communicates with multiple execution terminals, the method includes: Receive the test task and extract the host field from the test task; If the host field is not empty, then based on the value of the host field, a specified execution terminal is determined from among the multiple execution terminals, and the test task is written into the dedicated task pool corresponding to the specified execution terminal; the dedicated task pool is only used by the corresponding execution terminal. If the host field is empty, the test task is written to the global task pool; the global task pool is shared and used by all execution terminals. After the writing is completed, a scheduling notification is broadcast through a message publish-subscribe mechanism to trigger each execution end to retrieve a task from its corresponding dedicated task pool. If there is no task to be executed in the corresponding dedicated task pool, a task is retrieved from the global task pool.
2. The method according to claim 1, characterized in that, The broadcast scheduling notification via message publish-subscribe mechanism includes: A notification message carrying a task start identifier is published through a pre-defined publish / subscribe message channel in the memory database, so that each execution end can respond to the notification message and enter the scheduling process after subscribing to the publish / subscribe message channel.
3. The method according to claim 1, characterized in that, The method further includes: Receive the registration request sent by each of the aforementioned execution terminals at startup; Register the execution terminal according to the registration request, and return a registration confirmation to the execution terminal.
4. The method according to claim 3, characterized in that, The registration request includes the address information of the execution terminal; after receiving the registration request sent by each execution terminal at startup, the method further includes: Based on the address information of each execution terminal, the pool identifier of the dedicated task pool corresponding to each execution terminal is obtained by concatenation; The step of writing the test task into the dedicated task pool corresponding to the specified execution terminal includes: Write the test task into the dedicated task pool indicated by the pool identifier.
5. The method according to claim 1, characterized in that, The method further includes: Based on a preset heartbeat cycle, the heartbeat information reported by each of the execution terminals is received. The heartbeat information includes the address information of the corresponding execution terminal and the current number of concurrent tasks. The online status and current load of each execution terminal are updated based on the heartbeat information; the current load is determined based on the current number of concurrent tasks and the maximum number of concurrent tasks of the execution terminal. If the target execution terminal fails to report heartbeat information for a period of time greater than or equal to a preset duration, the online status of the target execution terminal will be marked as offline, and the writing of test tasks to the dedicated task pool of the target execution terminal will be stopped.
6. A task execution method, characterized in that, Applied to any execution terminal, wherein the execution terminal is communicatively connected to the scheduling terminal, the method includes: Receive scheduling notifications broadcast by the scheduling terminal through a message publish-subscribe mechanism; In response to the scheduling notification, it is determined whether there are any tasks to be executed in the dedicated task pool corresponding to the execution terminal; the tasks in the dedicated task pool are written by the scheduling terminal when specifying the execution terminal in the host field of the test task. If there are tasks to be executed, then the tasks are retrieved from the dedicated task pool corresponding to the execution terminal; If there are no tasks to be executed, a task is retrieved from the global task pool that is shared and accessible to all execution ends; the tasks in the global task pool are written by the scheduler when the host field carried by the test task does not specify the execution end. Execute the retrieved task.
7. The task execution method according to claim 6, characterized in that, The execution of the retrieved task includes: Run the retrieved task and update the current number of concurrent tasks on the execution end.
8. The task execution method according to claim 7, characterized in that, Before receiving the scheduling notification broadcast by the scheduling end through the message publish-subscribe mechanism, the method further includes: When the execution terminal starts, it obtains the address information of the execution terminal and sends a registration request to the scheduling terminal. The registration request includes the address information of the execution terminal, and the address information is used to form the pool identifier of the execution terminal's exclusive task pool. After successful registration, subscribe to the publish / subscribe message channel used by the scheduling terminal to receive the scheduling notification.
9. The task execution method according to claim 6, characterized in that, The method further includes: The start time of the extracted task is recorded in the execution status record; According to the preset detection cycle, the execution start time of each task currently being executed in the execution status record is read, and for any task, the execution duration of the task is determined based on the execution start time of the task. When the execution time of the task exceeds a preset time threshold, the task execution timeout is determined, and the task timeout recovery process is performed.
10. The task execution method according to claim 9, characterized in that, The timeout recovery process for the task includes: Delete the task information of this task from the execution status record; Terminate the process corresponding to the task and all its child processes. Based on the host field carried by the task, if the host field specifies an execution end, the task is rewritten into the dedicated task pool corresponding to the specified execution end; if the host field of the task does not specify an execution end, the task is rewritten into the global task pool. The scheduling notification is broadcast through the message publish-subscribe mechanism to trigger each execution end to retrieve and execute the task again.
