A method and apparatus for automated test resource management
By dynamically adjusting resource allocation strategies in automated hardware testing, and allocating resources according to task weight and priority, the imbalance caused by scarce testing resources is solved, achieving efficient resource utilization and timely task execution.
Patent Information
- Application Number
- CN201910672201.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-24
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2039-07-24
AI Technical Summary
In automated testing of hardware devices, the scarcity of testing resources leads to an uneven distribution of task resources. Long tasks occupy resources, causing other tasks to wait. This results in resource waste, especially during unattended periods, and important tasks may be delayed or even fail.
By periodically checking idle resources, sorting them according to task weight, and matching the highest priority subtask of the highest weight task to allocate resources, the resource allocation strategy is dynamically adjusted to achieve fine-grained resource management and scheduling.
It enables dynamic resource allocation for automated tasks, avoiding long-term resource occupation, improving resource utilization efficiency, preventing delays in important tasks, and ensuring fair resource allocation and timely task execution.
Smart Images

Figure CN112286651B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The embodiments of the present application relate to, but are not limited to, automation testing technology, and more particularly to a method and device for automation testing resource management. BACKGROUND
[0002] Automation testing plays an increasingly important role in hardware device testing, but the scarcity of testing resources, especially large hardware devices and instrument resources, leads to the problem of resource occupation by automation testing tasks, and therefore how to fairly allocate resources to tasks becomes a problem to be solved.
[0003] Most of the current testing resource allocation is manually occupied according to the task level, and the first come first served strategy, which will not cause imbalance in the case of short task execution time, but now the execution of a task may take 10 to 20 hours or more, and in this process, the resources cannot be released, and other tasks can only be in a long waiting process.
[0004] In addition, if the task execution completion time is at night when no one is on duty, the resources will not be released until the next day when the test personnel are on duty, which will cause waste. On the other hand, this first come first served strategy will also cause important tasks to be delayed or even starved. SUMMARY
[0005] Therefore, the embodiments of the present application provide a method for automation testing resource management, comprising:
[0006] checking whether there is idle resource at regular intervals;
[0007] when there is idle resource, sorting tasks to be allocated resources according to weight;
[0008] calculating whether the idle resource matches the task with the highest weight;
[0009] when matching, allocating resources to the subtask with the highest priority in the task with the highest weight.
[0010] The embodiments of the present application also provide a device for automation testing resource management, comprising:
[0011] a checking unit for checking whether there is idle resource at regular intervals;
[0012] a sorting unit for sorting tasks to be allocated resources according to weight when there is idle resource;
[0013] a calculating unit for calculating whether the idle resource matches the task with the highest weight;
[0014] an allocation unit configured to allocate resources to a highest priority subtask in the highest weight task when a match is found.
[0015] The embodiment of the present application also provides a device for automatic test resource management, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, and the computer program is executed by the processor to realize the method for resource management.
[0016] The embodiment of the present application also provides a computer readable storage medium, and the computer readable storage medium stores an information processing program, and the information processing program is executed by a processor to realize the steps of the method for resource management.
[0017] The technical scheme provided by the embodiment of the present application can realize automatic dynamic resource allocation of tasks.
[0018] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent to those skilled in the art upon examination of the following or can be learned by practice of the present application. The objects and other advantages of the present application can be realized and attained by the structure particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF DRAWINGS
[0019] The accompanying drawings are included to provide a further understanding of the technical scheme of the present application, and constitute a part of the specification, and are used together with the embodiments of the present application to explain the technical scheme of the present application, and do not constitute a limitation on the technical scheme of the present application.
[0020] Figure 1 A flowchart of a method for automatic test resource management provided by an embodiment of the present application is shown in the figure;
[0021] Figure 2 A flowchart of a method for automatic test resource management provided by another embodiment of the present application is shown in the figure;
[0022] Figure 3 An architecture diagram of a system for automatic test resource management provided by another embodiment of the present application is shown in the figure;
[0023] Figure 4 A structure diagram of a device for automatic test resource management provided by an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical scheme and advantages of the present application more clear, the embodiments of the present application will be described in detail below with reference to the drawings. It should be noted that, in the case of no conflict, the embodiments and features in the embodiments in the present application can be combined with each other at will.
[0025] The steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0026] Figure 1 A flowchart of a method for automatic test resource management is provided for an embodiment of the present application, as shown in Figure 1 The method comprises:
[0027] Step 101, periodically check whether there is an idle resource;
[0028] Step 102, when there is an idle resource, sort the tasks to be allocated resources according to the weight;
[0029] Step 103, calculate whether the idle resource matches the task with the highest weight;
[0030] Step 104, when matching, allocate resources for the highest priority subtask in the task with the highest weight.
[0031] Wherein, after allocating resources for the highest priority subtask in the task with the highest weight, the method further comprises:
[0032] According to a preset proportion, reduce the weight of the task with the highest weight;
[0033] If there is still a remaining idle resource, sort the tasks to be allocated resources according to the weight again;
[0034] Calculate whether the remaining idle resource matches the task with the highest weight;
[0035] When matching, allocate resources for the highest priority subtask in the task with the highest weight;
[0036] And so on, until there is no idle resource.
[0037] Wherein, the method further comprises:
[0038] According to the allocated resources, execute the highest priority subtask;
[0039] When the highest priority subtask is executed or fails, release the allocated resources.
[0040] Wherein, the method further comprises:
[0041] When not matching, allocate resources for the highest priority subtask in the task with the second highest weight.
[0042] Wherein, the method further comprises:
[0043] When there is no subtask requiring resource allocation in any task requiring resource allocation, the any task requiring resource allocation is deleted.
[0044] The method further comprises:
[0045] When the subtask with the highest priority is executed, the execution result is saved;
[0046] and whether the task in which the subtask with the highest priority is located is completed is checked;
[0047] When the task is completed, the execution results of all subtasks in the task are collected.
[0048] The method further comprises:
[0049] A task requiring resource allocation is received;
[0050] Each task requiring resource allocation is split into one or more subtasks according to a business attribute.
[0051] Figure 2 A flowchart of a method for automatic test resource management according to another embodiment of the present application is provided.
[0052] The embodiment is applied to Figure 3 the system shown in the figure. As Figure 3 shown, the system comprises:
[0053] a task module, a resource module and an MQ message queue; further comprising a database DB (database) and a resource pool.
[0054] MQ is used between entities of each module to complete message transmission, and multiple MQ channels are required in the system, and a Queue mode is used.
[0055] Specifically, the MQ message queue comprises:
[0056] 1. A task queue task.queue, which transmits a task requiring resource allocation;
[0057] 2. A subtask queue subTask.queue, which is used to transmit resource messages for a subtask execution module, and after the subtask execution module listens to the messages, corresponding resources are extracted and test operations are performed on the resources;
[0058] 3. A resource release queue release.resource.queue, which is used to transmit resource information requiring release to a resource management module through the message queue after subtask execution is completed;
[0059] 4. A subtask failed queue is executed, which is used to inform the resource management module that a subtask fails to be executed and needs to release resources.
[0060] The task module comprises:
[0061] A task management module is configured to receive a task to be allocated with resources, and split each task to be allocated with resources into one or more subtasks according to a service attribute.
[0062] The resource module comprises a task to be allocated acquisition unit and a resource management module.
[0063] The resource management module listens to the MQ message, and if a task to be allocated with resources is received, the task is put into a local task list TL to be allocated with resources.
[0064] Specifically, the task management module determines all subtasks according to user requirements, and the priority order of the subtasks in the task, and assigns an initial weight W to the task, and needs to specify the environmental conditions (for example, a frame, a master control, a line card, a number of single boards, etc.) required to complete the test task, and the subtasks need to be split according to the specific service attribute, and the principle is that the subtask must be an executable entity, such as a testable module or a testable group.
[0065] The task management module is further configured to trigger task execution and generate a task queue message.
[0066] Specifically, the task management module issues the task to the task acquisition unit to be allocated with resources (which can also be referred to as a resource allocation unit) to apply for appropriate resources. The resource allocation unit manages a task queue to be allocated with resources, and after listening to the task queue message, the task is added to the task queue to be allocated with resources.
[0067] The allocation engine maintained in the background is a timing worker (for example, generally processed once every 1 minute, which can be modified as appropriate), when the timing time window arrives, the allocation engine first sorts the task queue according to the weight, and the task with high weight is arranged in the front, and vice versa, and then the resource allocation service is accepted according to the weight. And after the subtask is matched to the resource, the subtask resource message is released to the subtask queue.
[0068] Specifically, when the time window of the resource management module allocation worker arrives, the resource module first checks whether there is a free resource in the current resource pool, and if there is, the free resource is processed in turn, and the processing process is as follows:
[0069] 1. The tasks in the task list TL to be allocated with resources are sorted according to the weight weight;
[0070] 2, get the task T1 with the highest weight, calculate whether the idle resource matches the task, if matches, assign the resource to the highest priority subtask ST1 of the task, if not matches, get the task T2 with the second highest weight, do the same calculation, and so on; there is another case, if the task has no subtask to be assigned, then the task needs to be deleted from the local to-be-assigned resource task list TL.
[0071] Repeat steps 1 and 2 until the idle resources in the resource pool are processed.
[0072] The matching work can be completed by an entity of a matching module (not shown in the figure, provided in the resource module). The entity obtains the task resource requirement, i.e., the requirement of the task for the resource. For example, the resource requirement of a task is: at least one device, a line card of a VLD (visual leak detector), a master control of a T1042, and other attributes are not concerned. According to the task requirement, the resource of the resource pool is matched according to the requirement of each attribute, if matched, the subtask assigned to the resource is returned to the subtask execution module, and if not matched, the next resource is replaced.
[0073] The task module further includes:
[0074] The subtask execution module is configured to occupy the resource to perform testing, and the execution process is performed in the granularity of the subtask, so that different test resources are occupied by each subtask, and the result of the execution is written into the database.
[0075] When the subtask is completed, the task module checks whether the parent task in which the subtask is located is completed, and if completed, collects the results of all the subtasks and sends an email to inform the relevant parties. Figure 2 When the subtask is completed, the task module checks whether the parent task in which the subtask is located is completed, and if completed, collects the results of all the subtasks and sends an email to inform the relevant parties.
[0076] When the subtask is completed, the task module checks whether the parent task in which the subtask is located is completed, and if completed, collects the results of all the subtasks and sends an email to inform the relevant parties.
[0077] Task generation, resource allocation, task execution, and task result
[0078] As shown in the figure, the method includes: Figure 2
[0079] 1, task generation;
[0080] Specifically, a system user creates a task with a version number in a task module, and then executes 1.1 to write into a database.
[0081] 2, query task;
[0082] Specifically, it includes: executing 2.1 query database; 2.2, the database returns the query result (with execution); 2.3, return the result.
[0083] 3, start task;
[0084] 4, task module adds task to task queue;
[0085] The resource management module executes step 0, that is, listens to the task queue message, and then executes 4.1 to add the task to the task list. For example, the priority (weight) of a task is 100 by default, and decreases by 1 for each subtask.
[0086] 5, find the task after matching to the resource;
[0087] The resource management module executes step 0, that is, starts work every 1 min, judges whether there is an idle resource, matches to the resource (that is, there is an idle resource), and then sorts the tasks to be allocated resources according to the weight; calculates whether the idle resource matches the task with the highest weight; when matching, allocates resources to the subtask with the highest priority in the task with the highest weight.
[0088] 6, add the subtask to the subtask queue when the resource meets the subtask execution condition;
[0089] That is, execute step 6.1 to modify the subtask state.
[0090] The execution module performs step 0 listening;
[0091] That is, after listening to the subtask queue message, step 7 is performed
[0092] 7, execute step.
[0093] Among them, Figure 2 0 in the above steps represents that the step is the worker task thread behind, similar to a daemon thread, which always exists, and is triggered to execute every 1 min, and has no sequence relationship with other steps.
[0094] In addition, the resource management module is a large module name, which is used to manage all resources. The local Q resource management module records the current task resource and resource information in the resource management module. It can be said that the local resource management module is the most important part of the resource management module.
[0095] The technical scheme provided by the embodiment can realize fine-grained execution and scheduling of task execution, overcome the extensive scheduling dimension of using a task as a scheduling unit when scheduling resources in the prior art, and can complete dynamic intelligent allocation and management of resources, solve the problem of low resource occupation efficiency caused by manual occupation by using an intelligent resource occupation and release scheme.
[0096] Figure 4 A structural schematic diagram of an apparatus for automatic test resource management is provided for an embodiment of the present application. Figure 4 As shown in the figure, the apparatus comprises:
[0097] A checking unit for checking whether there is idle resource at regular intervals;
[0098] A sorting unit for sorting tasks to be allocated resources according to weights when there is idle resource;
[0099] A calculating unit for calculating whether the idle resource matches a task with the highest weight;
[0100] An allocating unit for allocating resources to a sub-task with the highest priority in the task with the highest weight when the matching is successful.
[0101] The apparatus further comprises a weight management unit for reducing the weight of the task with the highest weight according to a preset proportion after the resources are allocated to the sub-task with the highest priority in the task with the highest weight.
[0102] The sorting unit is further configured to sort the tasks to be allocated resources according to weights again if there is remaining idle resource;
[0103] The calculating unit is further configured to calculate whether the remaining idle resource matches a task with the highest weight;
[0104] The allocating unit is further configured to allocate resources to a sub-task with the highest priority in the task with the highest weight when the matching is successful.
[0105] The process is repeated until there is no idle resource.
[0106] The apparatus further comprises:
[0107] An executing unit for executing the sub-task with the highest priority according to the allocated resources.
[0108] A releasing unit is configured to release the allocated resource when the highest-priority subtask fails to execute or the execution of the highest-priority subtask is completed.
[0109] The matching unit is further configured to allocate a resource to a highest-priority subtask in the second-highest-weight task when the matching fails.
[0110] The matching unit is further configured to delete any task to be allocated with a resource when there is no subtask in the any task to be allocated with a resource that needs to be allocated with a resource.
[0111] The device further comprises:
[0112] A saving unit is configured to save an execution result when the highest-priority subtask is completed.
[0113] A checking unit is configured to check whether all tasks in which the highest-priority subtask is located are completed.
[0114] A collecting unit is configured to collect execution results of all subtasks in the tasks when all the tasks are completed.
[0115] The device further comprises:
[0116] A task management unit is configured to receive tasks to be allocated with a resource.
[0117] Each task to be allocated with a resource is split into one or more subtasks according to a business attribute.
[0118] The checking unit, the sorting unit, the calculating unit, the allocating unit, the releasing unit, the checking unit and the collecting unit in the embodiment can be arranged in the resource module shown in Figure 3 .
[0119] The weight management unit, the executing unit and the task management unit in the embodiment can be arranged in the task module shown in Figure 3 .
[0120] The embodiment of the application further provides a device for automatically managing test resources, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the computer program is executed by the processor to implement the method for managing resources according to any one of the above.
[0121] The embodiment of the application further provides a computer readable storage medium, which stores an information processing program, and the information processing program is executed by a processor to implement the steps of the method for managing resources according to any one of the above.
[0122] Those of ordinary skill in the art will realize and understand that all or some of the steps in the methods disclosed above and the functional modules / units in the systems and devices can be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component can have multiple functions, or one function or step can be performed by several physical components in cooperation. Some or all of the components can be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on computer-readable media, which can include computer storage media (or non-transitory media) and communication media (or transitory media). As is well known to those of ordinary skill in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, it is common and well understood by those of ordinary skill in the art that communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and can include any information delivery media.
Claims
1. A method for automatic test resource management, comprising: checking whether there is a free resource at a regular interval; the free resource is an environmental condition required for completing a task of a resource to be allocated, and the environmental condition comprises at least one of a chassis, a master control, a line card, and a number of single boards; when there is a free resource, sorting test tasks of the resource to be allocated according to weights; the test tasks comprise a plurality of subtasks; calculating whether the free resource matches a subtask with the highest priority in a test task with the highest weight; when the free resource matches the subtask with the highest priority, allocating the resource to the subtask with the highest priority; decreasing the weight of the test task with the highest weight by a preset ratio; if there is still a free resource, sorting test tasks of the resource to be allocated according to weights again; calculating whether the free resource matches a subtask with the highest priority in a test task with the highest weight; when the free resource matches the subtask with the highest priority, allocating the resource to the subtask with the highest priority; and so on until there is no free resource.
2. The method of claim 1, wherein, The method further comprises: executing the subtask with the highest priority according to the allocated resource; when the subtask with the highest priority is executed successfully or fails, releasing the allocated resource.
3. The method of claim 1, wherein, The method further comprises: when the free resource does not match the subtask with the highest priority, allocating a resource to a subtask with the highest priority in a test task with the second highest weight.
4. The method of claim 1, wherein, The method further comprises: when there is no subtask requiring resource allocation in any test task of the resource to be allocated, deleting the any test task of the resource to be allocated.
5. The method of claim 2, wherein, The method further comprises: when the subtask with the highest priority is executed successfully, saving an execution result; checking whether all tasks in which the subtask with the highest priority is located are completed; when all the tasks are completed, collecting execution results of all the subtasks in the tasks.
6. The method of claim 1, wherein, The method further comprises: receiving test tasks of the resource to be allocated; according to a business attribute, splitting each test task of the resource to be allocated into a plurality of subtasks.
7. An apparatus for automated test resource management, the apparatus comprising: The method comprises: a checking unit configured to check whether there is a free resource at a regular interval; the free resource is an environmental condition required for completing a task of a resource to be allocated, and the environmental condition comprises at least one of a chassis, a master control, a line card, and a number of single boards; a sorting unit configured to, when there is a free resource, sort test tasks of the resource to be allocated according to weights; the test tasks comprise a plurality of subtasks; a calculating unit configured to calculate whether the free resource matches a subtask with the highest priority in a test task with the highest weight; an allocating unit configured to, when the free resource matches the subtask with the highest priority, allocate the resource to the subtask with the highest priority, and decrease the weight of the test task with the highest weight by a preset ratio; if there is still a free resource, the sorting unit is further configured to sort test tasks of the resource to be allocated according to weights again; the calculating unit is further configured to calculate whether the free resource matches a subtask with the highest priority in a test task with the highest weight; when the free resource matches the subtask with the highest priority, the allocating unit is further configured to allocate the resource to the subtask with the highest priority; and so on until there is no free resource.
8. An apparatus for automated test resource management, the apparatus comprising: A computer program product comprising a memory, a processor, and a computer program stored on the memory and loadable on the processor, the computer program implementing the method of resource management of any of claims 1-6 when executed by the processor.
9. A computer-readable storage medium, characterized in that, An information processing program is stored on the computer readable storage medium, and the information processing program implements the steps of the method of resource management of any of claims 1-6 when executed by the processor.
Citation Information
Patent Citations
Scheduling service end, scheduling device, robot system and scheduling method
CN108227654A