Method and apparatus for performing test tasks
By executing test tasks on blockchain nodes and selecting leader nodes, the problems of high testing costs and low efficiency in existing technologies are solved, achieving lower cost and more efficient test execution.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE GROUP JIANGSU
- Filing Date
- 2021-09-30
- Publication Date
- 2026-06-16
AI Technical Summary
Existing blockchain-based automated testing systems require the deployment of dedicated execution machines and recording systems, resulting in high testing costs and low efficiency.
The target test task is sent to each blockchain node, and the target blockchain node is determined to execute the test task based on the node status information, including selecting the leader node and the execution node, and using the consensus mechanism to ensure the consistency and stability of the test results.
It reduces the cost of automated testing, improves testing efficiency and stability, avoids the execution of abnormal state nodes, and ensures the reliability and consistency of test tasks.
Smart Images

Figure CN115878450B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automated testing technology, and in particular to a method and apparatus for performing testing tasks. Background Technology
[0002] Existing blockchain-based automated testing systems typically consist of a blockchain system and test case execution nodes. Deploying such a system requires not only deploying dedicated execution machines for running test cases but also deploying a blockchain system to record system data, resulting in significant investment in automated testing costs. Furthermore, the blockchain system deploys automated test scripts and scheduling algorithms within smart contracts. Based on this deployment structure, the blockchain system assigns an execution machine to complete the test task according to the scheduling algorithm, leading to very low testing efficiency. Summary of the Invention
[0003] This invention provides a method and apparatus for performing testing tasks, in order to solve the technical problems of high testing costs and low testing efficiency in the prior art.
[0004] In a first aspect, the present invention provides a method for performing a test task, comprising:
[0005] Send the target test task to each blockchain node;
[0006] Based on the node status information of each blockchain node, one or more target blockchain nodes are identified, and the target test task is executed in the target blockchain node;
[0007] The blockchain node is used to execute the target test task and record test-related data.
[0008] In one embodiment, determining one or more target blockchain nodes based on the node state information of each blockchain node includes:
[0009] Given a target blockchain node, the target blockchain node is determined from the idle nodes based on the node status information of each blockchain node.
[0010] When multiple target blockchain nodes are identified, the first leader node is determined from the idle nodes based on the node status information of each blockchain node.
[0011] Based on the first leader node, determine a preset number of execution nodes from the remaining idle nodes;
[0012] The first leader node and the execution node are designated as the target blockchain nodes.
[0013] In one embodiment, determining the first leader node among idle nodes based on the node state information of each blockchain node includes:
[0014] If the idle node has not executed the target test task, the first leader node is determined based on the node status information and consensus mechanism of each idle node.
[0015] In one embodiment, determining the first leader node among idle nodes based on the node state information of each blockchain node includes:
[0016] If the target test task has been executed on the idle node, the idle node with the shortest estimated execution time of the target test task is determined as the first leader node based on the node status information and consensus mechanism of each idle node.
[0017] In one embodiment, determining the idle node with the shortest estimated execution time of the target test task as the first leader node based on the node state information of each idle node and the consensus mechanism includes:
[0018] Based on the current CPU utilization of each idle node, the historical execution time of each idle node in executing the target test task, and the corresponding historical CPU utilization, the estimated execution time of each idle node in executing the target test task is determined.
[0019] Based on the consensus mechanism, the idle node with the shortest estimated execution time is determined as the first leader node;
[0020] The node status information includes: the current CPU utilization rate, the historical execution time, and the historical CPU utilization rate.
[0021] In one embodiment, the method for performing the test task further includes:
[0022] Based on the consensus mechanism, the test results corresponding to the target test task are determined and sent to each blockchain node.
[0023] In one embodiment, determining the test result corresponding to the target test task based on the consensus mechanism and sending the test result to each blockchain node includes:
[0024] When the first leader node performs the target test task, the leadership state of the first leader node is switched to the candidate state;
[0025] Given the test results, a second leader node is determined from the candidate blockchain nodes based on the node state information of each blockchain node and the consensus mechanism.
[0026] The test results are sent to each blockchain node through the second leader node.
[0027] In a second aspect, the present invention provides an apparatus for performing a test task, comprising:
[0028] The sending module is used to send the target test task to each blockchain node;
[0029] The execution module is used to determine one or more target blockchain nodes based on the node status information of each blockchain node, and to execute the target test task in the target blockchain node;
[0030] The blockchain node is used to execute the target test task and record test-related data.
[0031] Thirdly, the present invention provides an electronic device, including a memory and a memory storing a computer program, wherein the processor executes the program to implement the steps of the method for performing a test task as described in the first aspect.
[0032] Fourthly, the present invention provides a processor-readable storage medium storing a computer program for causing the processor to perform the steps of the method for performing the test task described in the first aspect.
[0033] The method and apparatus for executing test tasks provided by this invention send the target test task to each blockchain node, enabling each blockchain node to receive the test task and execute the target test task in the target blockchain node based on the node status information. This eliminates the need to set up a separate test task execution node, reducing the cost of automated testing. In addition, the target blockchain node for executing the test task is determined based on the node status information, avoiding the situation where abnormal nodes execute test tasks, ensuring the stability of test task execution, and improving testing efficiency. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0035] Figure 1 This is a flowchart illustrating the method for performing test tasks provided by the present invention;
[0036] Figure 2 This is an interactive schematic diagram of the method for performing test tasks provided by the present invention;
[0037] Figure 3 This is a schematic diagram of the structure of the device for performing test tasks provided by the present invention;
[0038] Figure 4 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0039] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0040] Figure 1 This is a flowchart illustrating the method for performing a test task provided by the present invention. (Refer to...) Figure 1 The method for performing test tasks provided by this invention includes:
[0041] Step 110: Send the target test task to each blockchain node;
[0042] Step 120: Based on the node status information of each blockchain node, determine one or more target blockchain nodes, and execute the target test task in the target blockchain node;
[0043] The blockchain node is used to execute the target test task and record test-related data.
[0044] The execution subject of the method for performing test tasks provided by the present invention can be an automated test system, which can be a computer device or a server, etc.
[0045] The automated testing system may include a smart contract system, a client, and a blockchain system.
[0046] Optionally, in step 110, smart contracts are deployed in the automated testing system. This involves writing automated test scripts, test data, and trigger scenarios within the smart contract system. Trigger scenarios can include pre-set test cycles, manual triggering, or code update triggering. For example, submitting updated code can trigger sanity testing, tagging code can trigger regression testing, and test sets can be manually triggered or regression tests can be periodically triggered. When each smart contract meets the trigger scenario conditions, the blockchain system automatically executes the smart contract. When the smart contract system meets the conditions for executing tests, it can select the set of automated test cases to be executed based on the test type, and determine whether the test cases in the test case set can be executed in parallel according to the smart contract definition, thus splitting the test task into multiple subtasks or a single subtask. If the test case set is defined for parallel processing, the test task can be split into multiple subtasks; if the test case set is defined for serial processing, it will only be split into a single subtask. After determining the test tasks, the smart contract system sends one or more target test tasks to each blockchain node of the blockchain system.
[0047] Smart contracts are computer contracts that can be automatically executed based on defined triggering rules; they can also be seen as digital versions of traditional contracts. Because blockchain technology uses a block-chain ledger, the data generated cannot be tampered with or deleted, and the entire ledger is constantly updated, ensuring the traceability of historical data. At the same time, the decentralized operating mechanism avoids the influence of centralized factors. Smart contracts based on blockchain technology not only leverage the advantages of smart contracts in terms of cost and efficiency but also prevent malicious interference with the normal execution of contracts. By writing smart contracts into the blockchain in digital form, the characteristics of blockchain technology ensure that the entire process of storage, retrieval, and execution is transparent, traceable, and tamper-proof.
[0048] Optionally, in step 120, after each blockchain node receives the target test task, it can determine one or more target blockchain nodes to execute the target test task based on its own node status information, such as whether the node is idle, the CPU usage status, or historical execution data.
[0049] Optionally, the blockchain node in this invention, in addition to its original functions, can also function as an automated test executor, meaning it can not only execute automated tests but also record test-related data. This test-related data can include automated test data, scripts, triggering conditions, test results, and node status information.
[0050] The method for executing test tasks provided by this invention sends the target test task to each blockchain node, enabling each blockchain node to receive the target test task and execute the target test task in the target blockchain node based on the node status information. This eliminates the need to set up a separate test task execution node, reducing the cost of automated testing. In addition, the target blockchain node for executing the target test task is determined based on the node status information, avoiding the situation where nodes in abnormal states execute the target test task, ensuring the stability of test task execution, and improving testing efficiency.
[0051] In one embodiment, determining one or more target blockchain nodes based on the node state information of each blockchain node includes:
[0052] Given a target blockchain node, the target blockchain node is determined from the idle nodes based on the node status information of each blockchain node.
[0053] When multiple target blockchain nodes are identified, the first leader node is determined from the idle nodes based on the node status information of each blockchain node.
[0054] Based on the first leader node, determine a preset number of execution nodes from the remaining idle nodes;
[0055] The first leader node and the execution node are designated as the target blockchain nodes.
[0056] Optionally, after the smart contract system sends the target test task to each blockchain node, the automated testing system determines all nodes that are not executing test tasks as idle nodes based on the execution status of the test tasks by each blockchain node in the system.
[0057] Optionally, based on the node status information of each blockchain node, a target blockchain node can be selected from all idle nodes to execute the target test task.
[0058] Optionally, based on the node status information of each blockchain node, multiple target blockchain nodes can be identified from the idle nodes to execute the target test task. First, it is determined whether a leader node exists in the current system. If not, the leader node is determined based on node status information such as CPU usage, current network conditions, IO load, or historical execution data of each idle node, to lead the execution of the target test task. The leader node can randomly select a preset number of execution nodes from the remaining idle nodes to jointly execute the test task. The preset number can be a number that meets preset conditions, such as a minimum integer greater than 3 representing more than 50% of the idle nodes.
[0059] Optionally, the leader node and the selected execution node are determined as the target blockchain nodes. All target blockchain nodes can form an execution group, which will execute the target test task simultaneously. When the execution group begins executing the target test task, the leadership privileges of the leader node within the system are released, but the leadership privileges of the leader node within the execution group are retained. This ensures that the execution group's execution of the target test task is unaffected and allows the automated testing system to continuously and dynamically select the leader node.
[0060] The method for executing test tasks provided by this invention can determine the leader node through the node status information of each node to ensure the stability of the execution of the target test task; furthermore, by having all target blockchain nodes jointly execute the target test task, it can ensure that the node with the better status executes the target test task, thereby improving testing efficiency.
[0061] In one embodiment, determining the first leader node among idle nodes based on the node state information of each blockchain node includes:
[0062] If the idle node has not executed the target test task, the first leader node is determined based on the node status information and consensus mechanism of each idle node.
[0063] Optionally, when the smart contract system sends a target test task to each blockchain node, it will confirm whether the target test task has been executed on the blockchain node. If the currently idle node has not executed the test task, the currently idle node initiates a vote, and all idle nodes confirm, based on the consensus mechanism, that the currently idle node has not executed the test task. Then, based on the node status information such as the CPU usage, current network status, and IO load of each idle node, and the consensus mechanism, after all idle nodes reach a consensus, the idle node with the best performance and stable operation is determined as the leader node.
[0064] The consensus mechanism is a process in which nodes participating in the consensus of a blockchain network reach a consensus state in a very short time through voting by special nodes. This process means that multiple nodes agree on the order of occurrence, legality, and updates to the ledger state of a certain batch of transactions.
[0065] The method for executing test tasks provided by this invention can quickly determine the leader node by using the node status information of idle nodes that have not executed the target test task and the consensus mechanism, and can avoid leader nodes with abnormal status from executing the target test task, thus ensuring the stability of test task execution.
[0066] In one embodiment, determining the first leader node among idle nodes based on the node state information of each blockchain node includes:
[0067] If the target test task has been executed on the idle node, the idle node with the shortest estimated execution time of the target test task is determined as the first leader node based on the node status information and consensus mechanism of each idle node.
[0068] Optionally, when the smart contract system sends a target test task to each blockchain node, it confirms whether the target test task has been executed on the blockchain node. If all idle nodes in the automated testing system have executed the test task, the estimated execution time for each idle node to execute the target test task is calculated based on the node status information of all idle nodes. If the current idle node calculates that it is the idle node with the shortest estimated execution time, based on the consensus mechanism, the current idle node initiates a vote to ensure that all idle nodes confirm whether the current idle node's estimated execution time is the shortest. When all idle nodes' calculation results are consistent, i.e., when the current idle node is determined to be the node with the shortest estimated execution time, it is designated as the leader node.
[0069] The method for executing test tasks provided by this invention improves the accuracy of the leader node by determining the leader node based on the estimated execution time of idle nodes that have executed the target test task, and improves the testing efficiency by determining the node with the shortest estimated execution time as the leader node.
[0070] In one embodiment, determining the idle node with the shortest estimated execution time of the target test task as the first leader node based on the node state information of each idle node and the consensus mechanism includes:
[0071] Based on the current CPU utilization of each idle node, the historical execution time of each idle node in executing the target test task, and the corresponding historical CPU utilization, the estimated execution time of each idle node in executing the target test task is determined.
[0072] Based on the consensus mechanism, the idle node with the shortest estimated execution time is determined as the first leader node;
[0073] The node status information includes: the current CPU utilization rate, the historical execution time, and the historical CPU utilization rate.
[0074] Optionally, the node status information may include CPU usage and historical execution data. CPU usage may include the node's current CPU utilization rate, and historical execution data may include the node's historical execution time for the target test task and the historical CPU utilization rate for executing the test task. The historical CPU utilization rate may be the historical average CPU utilization rate for executing the target test task within the historical execution time.
[0075] Optionally, if all historical CPU utilization rates are greater than or less than the current CPU utilization rate, then the set of historical CPU utilization rate data closest to the current CPU utilization rate is selected for calculating the estimated execution time. Assume the historical CPU utilization rate is C1, the historical execution time is T1, and the current CPU utilization rate is C... C Therefore, the estimated execution time for this operation is:
[0076]
[0077] Optionally, if the current CPU utilization rate falls between the maximum and minimum historical CPU utilization rates, select one set of historical CPU utilization rate data closest to the current CPU utilization rate on each side for calculating the estimated execution time. Assume the historical CPU utilization rate is C1, the historical execution time is T1, the historical CPU utilization rate is C2, the historical execution time is T2, and the current CPU utilization rate is C... C Among them, C2 is greater than C1, C C If it is greater than C1, then the estimated execution time for this operation is:
[0078]
[0079] The method for executing test tasks provided by this invention determines the estimated execution time of the target test task based on CPU usage and historical execution data, thereby identifying the leader node and improving the accuracy of the leader node. At the same time, it identifies the node with the shortest estimated execution time as the leader node, thus improving testing efficiency.
[0080] In one embodiment, the method for performing the test task further includes:
[0081] Based on the consensus mechanism, the test results corresponding to the target test task are determined and sent to each blockchain node.
[0082] Optionally, after all target blockchain nodes have completed the target test task and generated test results, the target blockchain nodes, based on a consensus mechanism, reach a consensus on the test results and store them in memory to update the test-related data in the blockchain nodes. The test results may include: a test report, the average CPU utilization of each target blockchain node during the execution of the target test task, and the execution time of the target test task. Thus, all blockchain nodes in the network reach a consensus on the test results and record the results, which will serve as the basis for selecting target blockchain nodes for the next test task.
[0083] Optionally, if the leader node fails to send test results to all blockchain nodes within a preset time threshold, the smart contract system will reissue the test task and automatically re-elect an execution group to execute the test task again. The method used to execute the test task again is the same as the method provided in the above embodiments, and will not be described again here.
[0084] Optionally, if the leader node publishes the test results after a preset time threshold, it will cause the blockchain nodes to fail to reach a consensus, and thus the test results cannot be recorded and stored by the blockchain nodes.
[0085] The method for executing test tasks provided by this invention improves the reliability of test results by determining the test results corresponding to the target test task based on a consensus mechanism; and ensures the consistency of test results by sending the test results to each blockchain node.
[0086] In one embodiment, determining the test result corresponding to the target test task based on the consensus mechanism and sending the test result to each blockchain node includes:
[0087] When the first leader node performs the target test task, the leadership state of the first leader node is switched to the candidate state;
[0088] Given the test results, a second leader node is determined from the candidate blockchain nodes based on the node state information of each blockchain node and the consensus mechanism.
[0089] The test results are sent to each blockchain node through the second leader node.
[0090] Optionally, since the leader node's leadership privileges are released within the system when the execution group begins executing the target test task, the automated testing system can periodically check whether a leader node exists in the system by setting a timer. If no leader node exists, a new leader node is elected based on the node status messages and consensus mechanism of each blockchain node. After the leader node is determined, it sends the test results of the target test task to each blockchain node in the system, and then decides whether to start the next test task. Thus, all blockchain nodes in the network reach a consensus on the test results and record them as the basis for selecting the target blockchain node for the next test task. After the next test task is released, the target blockchain node will be determined again based on the test-related data recorded in each node.
[0091] The method for executing test tasks provided by this invention ensures the stability of executing the target test task and improves the reliability of the system by periodically querying whether there is a leader node in the system and promptly electing a leader node when there is no leader node.
[0092] In one embodiment, the automated testing system also provides a front-end client page for users to manually trigger tests and view test reports. The automated testing system also provides notification functionality, such as notifying the code version control system of automated test results to initiate further actions.
[0093] Figure 2 This is an interactive diagram illustrating the method for performing test tasks provided by the present invention. (Refer to...) Figure 2 The method for performing test tasks provided by this invention includes:
[0094] Step 201: After the automated testing system receives a new code submission event from the code version control system, the smart contract system determines that the triggering conditions for smart contract 1 have been met. It then determines the test case set to execute smart contract 1. According to the smart contract definition, test task 1 can be split into two parallel sub-test tasks: test task 1.1 and test task 1.2. These tasks are then added to the pending list.
[0095] It should be noted that the automated testing system includes a code version control system, a smart contract system, a front-end client, blockchain A node, and blockchain B node. The blockchain A node and blockchain B node mentioned above are merely examples of idle nodes; this invention does not impose a specific limit on the number of blockchain nodes.
[0096] The smart contract system deploys four smart contracts, including:
[0097] Smart Contract 1: Sanity tests are triggered when code is committed;
[0098] Smart Contract 2: Regression tests are triggered when the code is tagged;
[0099] Smart Contract 3: Manually Triggered Test Set;
[0100] Smart Contract 4: Periodically Triggered Regression Test.
[0101] Step 202: The smart contract system publishes test tasks to each blockchain node. 1.1 The smart contract system publishes the first task in the list of tasks to be processed each time, and each blockchain node jointly selects an appropriate number of idle nodes in the current system to complete the test.
[0102] Step 203: Based on the historical execution of test task 1.1 by each blockchain node, select node A as the current system leader node and also as the leader node for test task 1.1. Node A selects nodes with more than 50% of the available nodes in the current system to form an execution group, which simultaneously executes the test task. After node A completes the selection, it broadcasts the selection to all nodes. Once all nodes reach a consensus, the smart contract updates the pending list, marking the execution group with node A as the leader node as currently executing test task 1.1. Node A releases its system leader node privileges but retains its leader privileges within the execution group. After test task 1.1 is completed and a consensus is reached within the execution group, node A publishes the test results.
[0103] Step 204: The user triggers a test case set on the front-end client page. The system determines that the requirements of smart contract 3 are met and executes the smart contract. According to the smart contract definition, test task 3 needs to be executed sequentially and cannot be split into multiple subtasks for parallel processing. Therefore, it can only be split into one sub-test task 3.1.
[0104] Step 205: Currently, there is no leader node in the automated testing system. The smart contract system issues sub-test task 1.2 of test task 1 to each blockchain node.
[0105] Step 206: Since the execution group led by node A is currently executing sub-test task 1.1 of test task 1, the system will select an execution node from other idle nodes. Each node elects node B as the leader node for this round. Node B selects an execution group and reaches a consensus with all nodes. Node B, representing the execution group, receives test task 1.2. After reaching a consensus with other nodes in the network, the smart contract updates the pending list, and test task 1.2 is marked as being executed.
[0106] Step 207: After reaching a consensus on the test results of Test Task 1.1, the execution group led by Node A stores the test report, test time, and CPU utilization during the execution of the test task in memory. Simultaneously, it starts a timer and participates in the next round of election. Once elected as the leader node, it synchronizes the test report, test time, and average CPU utilization during execution to all other blockchain nodes. After all blockchain nodes reach a consensus, the smart contract removes Test Task 1.1 from the pending list.
[0107] Step 208: Smart Contract 3 releases test task 3.1.
[0108] Step 209: The number of idle nodes in the system does not meet the minimum threshold. Add the test task to the system waiting list.
[0109] Step 210: Test task 1.2 is completed, and node B publishes the test results. Smart contract 1 removes test task 1.2 from the pending list.
[0110] Step 211: Now that all sub-test tasks of smart contract 1 have been completed, smart contract 1 notifies the code version management system that it can proceed with the next steps.
[0111] Step 212: In the above process, the front-end client can query the execution status of all use cases through any blockchain node, because all information is stored on all blockchain nodes.
[0112] In one embodiment, when a blockchain node is elected as the leader, it executes the triggered smart contract or submits information stored in its memory. The hash value of the previous blockchain node, the hash value of the Merkle root of the information to be submitted, the current timestamp, and the information to be submitted are encapsulated together into a block, which is then published to all blockchain nodes in the network. After receiving confirmation from a majority of blockchain nodes, the block is saved to the blockchain. All follower nodes refresh their local data based on the leader node's information to achieve network-wide consistency.
[0113] The apparatus for performing test tasks provided by the present invention will be described below. The apparatus for performing test tasks described below can be referred to in correspondence with the method for performing test tasks described above.
[0114] Figure 3 This is a schematic diagram of the device for performing test tasks provided by the present invention. (Refer to...) Figure 3 The apparatus for performing test tasks provided by the present invention includes:
[0115] The sending module 310 is used to send the target test task to each blockchain node;
[0116] The execution module 320 is used to determine one or more target blockchain nodes based on the node status information of each blockchain node, and to execute the target test task in the target blockchain node;
[0117] The blockchain node is used to execute the target test task and record test-related data.
[0118] The apparatus for executing test tasks provided by this invention sends the target test task to each blockchain node, enabling each blockchain node to receive the test task and execute the target test task in the target blockchain node based on the node status information. This eliminates the need to set up a separate test task execution node, reducing the cost of automated testing. In addition, the target blockchain node for executing the test task is determined based on the node status information, avoiding the situation where abnormal nodes execute test tasks, ensuring the stability of test task execution, and improving testing efficiency.
[0119] In one embodiment, the execution module 320 further includes:
[0120] A determining unit (not shown in the figure) is used to determine the target blockchain node from among the idle nodes based on the node status information of each blockchain node when a target blockchain node is determined.
[0121] When multiple target blockchain nodes are identified, the first leader node is determined from the idle nodes based on the node status information of each blockchain node.
[0122] Based on the first leader node, determine a preset number of execution nodes from the remaining idle nodes;
[0123] The first leader node and the execution node are designated as the target blockchain nodes.
[0124] In one embodiment, the determining unit is further configured to:
[0125] If the idle node has not executed the target test task, the first leader node is determined based on the node status information and consensus mechanism of each idle node.
[0126] In one embodiment, the determining unit is further configured to:
[0127] If the target test task has been executed on the idle node, the idle node with the shortest estimated execution time of the target test task is determined as the first leader node based on the node status information and consensus mechanism of each idle node.
[0128] In one embodiment, the determining unit is further configured to:
[0129] Based on the current CPU utilization of each idle node, the historical execution time of each idle node in executing the target test task, and the corresponding historical CPU utilization, the estimated execution time of each idle node in executing the target test task is determined.
[0130] Based on the consensus mechanism, the idle node with the shortest estimated execution time is determined as the first leader node;
[0131] The node status information includes: the current CPU utilization rate, the historical execution time, and the historical CPU utilization rate.
[0132] In one embodiment, the apparatus for performing the test task further includes:
[0133] The test result sending module (not shown in the figure) is used to determine the test result corresponding to the target test task based on the consensus mechanism, and send the test result to each blockchain node.
[0134] In one embodiment, the test result sending module is further configured to:
[0135] When the first leader node performs the target test task, the leadership state of the first leader node is switched to the candidate state;
[0136] Given the test results, a second leader node is determined from the candidate blockchain nodes based on the node state information of each blockchain node and the consensus mechanism.
[0137] The test results are sent to each blockchain node through the second leader node.
[0138] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 can call a computer program in the memory 430 to execute the steps of the method for performing the test task, such as including:
[0139] Send the target test task to each blockchain node;
[0140] Based on the node status information of each blockchain node, one or more target blockchain nodes are identified, and the target test task is executed in the target blockchain node;
[0141] The blockchain node is used to execute the target test task and record test-related data.
[0142] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, 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 the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0143] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is capable of performing the method for performing the test task provided by the above methods, the method comprising:
[0144] Send the target test task to each blockchain node;
[0145] Based on the node status information of each blockchain node, one or more target blockchain nodes are identified, and the target test task is executed in the target blockchain node;
[0146] The blockchain node is used to execute the target test task and record test-related data.
[0147] On the other hand, embodiments of this application also provide a processor-readable storage medium storing a computer program for causing the processor to execute the methods provided in the above embodiments, such as including:
[0148] Send the target test task to each blockchain node;
[0149] Based on the node status information of each blockchain node, one or more target blockchain nodes are identified, and the target test task is executed in the target blockchain node;
[0150] The blockchain node is used to execute the target test task and record test-related data.
[0151] The processor-readable storage medium can be any available medium or data storage device that the processor can access, including but not limited to magnetic memory (e.g., floppy disk, hard disk, magnetic tape, magneto-optical disk (MO)), optical memory (e.g., CD, DVD, BD, HVD), and semiconductor memory (e.g., ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)).
[0152] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0153] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0154] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for performing a test task, characterized in that, include: Send the target test task to each blockchain node; Based on the node status information of each blockchain node, one or more target blockchain nodes are identified, and the target test task is executed in the target blockchain node; The blockchain node is used to execute the target test task and record test-related data. The process of determining one or more target blockchain nodes based on the node status information of each blockchain node includes: Given a target blockchain node, the target blockchain node is determined from the idle nodes based on the node status information of each blockchain node. When multiple target blockchain nodes are identified, the first leader node is determined from the idle nodes based on the node status information of each blockchain node. Based on the first leader node, determine a preset number of execution nodes from the remaining idle nodes; The first leader node and the execution node are designated as the target blockchain nodes; The target blockchain nodes form an execution group, which simultaneously executes the target test task. When the execution group begins to execute the target test task, the leadership authority of the first leader node in the system is released, while the leadership authority of the first leader node within the execution group is maintained.
2. The method for performing a test task according to claim 1, characterized in that, The process of determining the first leader node among idle nodes based on the node status information of each blockchain node includes: If the idle node has not executed the target test task, the first leader node is determined based on the node status information and consensus mechanism of each idle node.
3. The method for performing a test task according to claim 1, characterized in that, The process of determining the first leader node among idle nodes based on the node status information of each blockchain node includes: If the target test task has been executed on the idle node, the idle node with the shortest estimated execution time of the target test task is determined as the first leader node based on the node status information and consensus mechanism of each idle node.
4. The method for performing a test task according to claim 3, characterized in that, The method of determining the idle node with the shortest estimated execution time of the target test task as the first leader node based on the node state information and consensus mechanism of each idle node includes: Based on the current CPU utilization of each idle node, the historical execution time of each idle node in executing the target test task, and the corresponding historical CPU utilization, the estimated execution time of each idle node in executing the target test task is determined. Based on the consensus mechanism, the idle node with the shortest estimated execution time is determined as the first leader node; The node status information includes: the current CPU utilization rate, the historical execution time, and the historical CPU utilization rate.
5. The method for performing a test task according to any one of claims 1-4, characterized in that, Also includes: Based on the consensus mechanism, the test results corresponding to the target test task are determined and sent to each blockchain node.
6. The method for performing a test task according to claim 5, characterized in that, The process of determining the test results corresponding to the target test task based on the consensus mechanism and sending the test results to each blockchain node includes: When the first leader node performs the target test task, the leadership state of the first leader node is switched to the candidate state; Given the test results, a second leader node is determined from the candidate blockchain nodes based on the node state information of each blockchain node and the consensus mechanism. The test results are sent to each blockchain node through the second leader node.
7. An apparatus for performing a test task, characterized in that, include: The sending module is used to send the target test task to each blockchain node; The execution module is used to determine one or more target blockchain nodes based on the node status information of each blockchain node, and to execute the target test task in the target blockchain node; The blockchain node is used to execute the target test task and record test-related data. The execution module further includes: The determining unit is used to determine the target blockchain node from among the idle nodes based on the node status information of each blockchain node when a target blockchain node is determined. When multiple target blockchain nodes are identified, the first leader node is determined from the idle nodes based on the node status information of each blockchain node. Based on the first leader node, determine a preset number of execution nodes from the remaining idle nodes; The first leader node and the execution node are designated as the target blockchain nodes; The target blockchain nodes form an execution group, which simultaneously executes the target test task. When the execution group begins to execute the target test task, the leadership authority of the first leader node in the system is released, while the leadership authority of the first leader node within the execution group is maintained.
8. An electronic device comprising a processor and a memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method for performing a test task as described in any one of claims 1 to 6.
9. A processor-readable storage medium, characterized in that, The processor-readable storage medium stores a computer program for causing the processor to perform the steps of the method for performing a test task as described in any one of claims 1 to 6.