A test case execution method, device and readable storage medium
Patent Information
- Application Number
- CN202110583755.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-27
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2041-05-27
AI Technical Summary
[0004]然而由于测试机器是固定的,这样也就导致了在对测试用例执行测试时,可选择的测试机器有限,进而导致无法支持高并发的测试需求
[0045] In summary, it can be seen that in this embodiment, when testing test cases, the scaling evaluation result corresponding to the test node can be determined by the total set duration corresponding to N test cases, the number of test cases to be tested (including the N test cases changed in the code repository and the test cases associated with the N test cases), the number of test nodes, and the average processing speed; the test nodes are adjusted according to the scaling evaluation result; and finally, the test is executed according to the adjusted test nodes. In this application, the test nodes can be adjusted according to the set total duration, the number of test cases to be tested, the number of test nodes, and the average processing speed, that is, the test nodes are automatically scaled up, so that the test nodes are more compatible with the test cases to be tested and support high-concurrency testing requirements.
Smart Images

Figure CN115408255B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of testing, and more particularly to a method, apparatus, and readable storage medium for executing test cases. Background Technology
[0002] A test case is a description of a specific software product testing task, including test objectives, test environment, input data, test steps, expected results, and test scripts.
[0003] Currently, Jenkins is primarily used to test test cases. Jenkins is an open-source software project, a continuous integration tool developed based on Java, used to monitor repetitive tasks. The main process for executing test cases using Jenkins is as follows: developers create test cases, debug them locally, push the completed test cases to the test case code repository, manually create a Jenkins job, select the test cases to be tested from the test case code repository, and access the local or remote machine to execute the test cases.
[0004] However, since the testing machines are fixed, the number of available testing machines is limited when executing tests on test cases, which in turn makes it impossible to support high-concurrency testing requirements. Summary of the Invention
[0005] This application provides a method, apparatus, and readable storage medium for executing test cases, which can automatically expand the capacity of test nodes, thereby meeting the high-concurrency testing requirements and making the test nodes more compatible with the test cases to be tested.
[0006] One embodiment of this application provides a method for executing test cases, including:
[0007] Identify K test cases in the code repository that are associated with the first test case. The first test case is any one of the N modified test cases in the code repository, where K and N are both integers greater than or equal to 1.
[0008] The number of test cases to be tested is determined based on N test cases and K test cases associated with the first test case. The current test cases are N test cases and K test cases associated with the first test case.
[0009] Obtain the total set duration, number of test nodes, and average processing speed of the test nodes corresponding to N test cases. Test nodes are used to execute tests on the test cases.
[0010] The scaling evaluation results for each test node are determined based on the total set duration, the number of test cases to be tested, the number of test nodes, and the average processing speed.
[0011] The number of test nodes is adjusted based on the scaling assessment results;
[0012] Assign the test cases currently to be tested to the adjusted test nodes for testing.
[0013] This application also provides a test case execution apparatus, comprising:
[0014] The first determining unit is used to determine K test cases in the code repository that are associated with the first test case. The first test case is any one of the N modified test cases in the code repository, where K and N are both integers greater than or equal to 1.
[0015] The second determining unit is used to determine the number of test cases to be tested at present based on N test cases and K test cases associated with the first test case. The current test cases are N test cases and K test cases associated with the first test case.
[0016] The acquisition unit is used to acquire the total set duration, the number of test nodes, and the average processing speed of the test nodes corresponding to N test cases. The test nodes are used to execute tests on the test cases.
[0017] The third determining unit is used to determine the scaling evaluation result corresponding to the test node based on the set total duration, the number of test cases to be tested, the number of test nodes, and the average processing speed.
[0018] An adjustment unit is used to adjust the number of test nodes based on the scaling evaluation results;
[0019] The allocation unit is used to assign the test cases currently under test to the adjusted test nodes for execution.
[0020] In one possible design, the first determining unit is specifically used for:
[0021] Determine the calling relationships between modules in Service-Oriented Architecture (SOA) and the membership relationships between test cases in the code repository and modules in SOA.
[0022] Determine the first module to which the first test case belongs based on the affiliation relationship;
[0023] Determine the second module that has a calling relationship with the first module based on the calling relationship;
[0024] The test cases belonging to the second module are determined to be K test cases.
[0025] In one possible design, the third determining unit is specifically used for:
[0026] The number of tests for the current test cases to be tested is determined based on the number of test nodes, the total set duration, and the average processing speed.
[0027] Determine the difference between the number of test cases currently to be tested and the number of tests performed on the test cases currently to be tested;
[0028] The expansion / contraction assessment result is determined based on the difference.
[0029] In one possible design, the third determining unit is also specifically used for:
[0030] The first number of test nodes required to complete the current test case within the set total time is determined based on the average processing speed.
[0031] Determine the difference between the first quantity and the number of test nodes;
[0032] The scaling evaluation result corresponding to the test node is determined based on the difference.
[0033] In one possible design, the third determining unit determines the scaling evaluation result corresponding to the test node based on the difference, including:
[0034] The number of nodes to be added or deleted is determined based on the difference and the average processing speed.
[0035] The number of newly added nodes or the number of deleted nodes is determined as the scaling assessment result.
[0036] In one possible design, the adjustment unit is specifically used for:
[0037] If the scaling assessment result is the number of new nodes, then add new nodes to the current test nodes according to the number of new nodes;
[0038] If the scaling evaluation node is the number of nodes to be deleted, then the current test node will be deleted according to the number of nodes to be deleted.
[0039] In one possible design, the allocation unit is specifically used for:
[0040] Identify a second test case that contains a development identifier in the current test case to be tested;
[0041] The second test case is assigned to the first test node corresponding to the development identifier in the test node and executed.
[0042] Other test cases are assigned to other nodes for testing. Other test cases are the test cases other than the second test case in the current test cases to be tested. Other nodes are the nodes other than the first test node in the adjusted test nodes.
[0043] Another aspect of this application provides a computer device including at least one connected processor, memory, and transceiver, wherein the memory is used to store program code, and the processor is used to call the program code in the memory to execute the steps of the test case execution method described in the above aspects.
[0044] Another aspect of this application provides a computer storage medium including instructions that, when run on a computer, cause the computer to perform the steps of the test case execution method described in the above aspects.
[0045] In summary, it can be seen that in this embodiment, when testing test cases, the scaling evaluation result corresponding to the test node can be determined by the total set duration corresponding to N test cases, the number of test cases to be tested (including the N test cases changed in the code repository and the test cases associated with the N test cases), the number of test nodes, and the average processing speed; the test nodes are adjusted according to the scaling evaluation result; and finally, the test is executed according to the adjusted test nodes. In this application, the test nodes can be adjusted according to the set total duration, the number of test cases to be tested, the number of test nodes, and the average processing speed, that is, the test nodes are automatically scaled up, so that the test nodes are more compatible with the test cases to be tested and support high-concurrency testing requirements. Attached Figure Description
[0046] Figure 1 A schematic diagram of an embodiment of the test case execution method provided in this application:
[0047] Figure 2 A schematic diagram of another embodiment of the method for executing test cases provided in this application;
[0048] Figure 3 A schematic diagram of an optional structure of a distributed system applied to a blockchain system, as provided in an embodiment of this application;
[0049] Figure 4 An optional schematic diagram of the block structure provided in the embodiments of this application;
[0050] Figure 5 A flowchart illustrating the execution method of the test cases provided in the embodiments of this application;
[0051] Figure 6This is a virtual schematic diagram of the test case execution device provided in the embodiments of this application;
[0052] Figure 7 This is a schematic diagram of the hardware structure of the server provided in an embodiment of this application. Detailed Implementation
[0053] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0054] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or modules is not necessarily limited to those explicitly listed, but may include other steps or modules not explicitly listed or inherent to these processes, methods, products, or devices. The division of modules appearing in this application is merely a logical division; in practical applications, other division methods may be used. For example, multiple modules may be combined or integrated into another system, or some feature vectors may be ignored or not executed. Additionally, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interface, and the indirect coupling or communication connection between modules may be electrical or other similar forms, none of which are limited in this application. Furthermore, the modules or sub-modules described as separate components may or may not be physically separate, may or may not be physical modules, or may be distributed among multiple circuit modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this application.
[0055] The following is combined with Figure 1 For instructions on executing existing test cases, please refer to [link / reference]. Figure 1 This includes test case 101, test case code repository 102, Jenkins 103, test machine 104, application under test 105, and local machine 106.
[0056] Among them, test case 101 is developed and debugged on local machine 106. Test case 101 is a test case for the application under test 105. After the developers have completed the development and debugging of test case 101 for application under test 105, they can push test case 101 to test case code repository 102.
[0057] Developers can manually create Jenkins Jobs using Jenkins 103, selecting a subset of test cases from the test case code repository. Each Jenkins Job represents a task or project; in this case, it refers to a test task or project where the developer manually creates test cases for the application under test (305). Test machine 104 is accessed via Jenkins 103 to execute test case 101. Test machine 104 can be a local or remote test machine. This completes the testing of the application under test (105). Jenkins is a scalable continuous integration engine that can be used to automate various tasks related to building, testing, delivering, or deploying software.
[0058] However, since the number of test machines is fixed (105), the number of test machines available for execution of test cases is limited, which makes it impossible to support high-concurrency testing requirements.
[0059] In view of this, this application provides a method for executing test cases. When testing the application under test using test cases, the scaling evaluation result corresponding to the test node can be determined based on the total set duration corresponding to N test cases, the number of test cases currently to be tested (including the N test cases changed in the code repository and the test cases associated with the N test cases), the number of test nodes, and the average processing speed. The test nodes are then adjusted according to the scaling evaluation result. Finally, the test is executed based on the adjusted test nodes. Thus, in this application, determining the test nodes based on the total set duration, the number of test cases currently to be tested, the number of test nodes, and the average processing speed, and adjusting the test nodes accordingly, i.e., automatically scaling up the test nodes, makes the test nodes more compatible with the test cases to be tested, and supports high-concurrency testing requirements.
[0060] Please see Figure 2 , Figure 2 A schematic diagram of an embodiment of the test case execution method provided in this application includes:
[0061] Test case 201, code repository 202, devops 203, Jenkins Master 204, Jenkins Slave 205, automatic scaling up and down module 206, Docker-based Selenium Hub 207, system under test 208, local machine 209, and Docker image of Selenium Gride 210;
[0062] DevOps (a combination of Development and Operations) is a collective term for a set of processes, methods, and systems used to facilitate communication, collaboration, and integration between development (application / software engineering), technical operations, and quality assurance (QA) departments.
[0063] Jenkins Master provides a global wide area network (web) interface for users to manage projects (jobs) and slave devices (slaves). Jobs run on the master machine or are assigned to slaves. A master can be associated with multiple slaves to serve different jobs or different configurations of the same job.
[0064] Selenium Grid is a distributed structure consisting of a Hub node and several Node proxy nodes. The Hub node manages the registration and status information of each Node proxy node, accepts requests from remote client code, and then forwards the requested commands to the Node proxy nodes for execution.
[0065] The system under test refers to some binary services that need to be tested when the system is online. For example, the order placement interface corresponding to the commissioned sales needs to be tested for the correctness of these interfaces, the services they correspond to, and the logic.
[0066] Docker is an open-source application container engine that allows developers to package their applications and dependencies into a portable container and then deploy it to any popular Linux or Windows machine. It can also achieve virtualization. Containers use a sandbox mechanism and have no interface with each other.
[0067] A Docker image refers to a virtual container image, which can be viewed as a special file system. In addition to providing the programs, libraries, resources, configuration files required for the virtual container to run, it also contains some configuration parameters prepared for runtime (such as anonymous volumes, environment variables, and user parameters).
[0068] The following describes the specific process of executing the test cases provided in this application:
[0069] Developers develop and debug test cases corresponding to the system under test 208 on local machine 209 to obtain test case 201, and then push test case 201 to code repository 202.
[0070] When test cases in code repository 202 change, the DevOps webhook event in 203 can be triggered. These changes include, but are not limited to, updating, adding, and deleting test cases in the code repository. A webhook refers to a "user-defined HTTP" callback, typically triggered by events such as "pushing code to the repository" or "posting a comment to a blog." In this case, the webhook is triggered by a change in test cases in the code repository. It's understood that this webhook uses the Hypertext Transfer Protocol (HTTP).
[0071] When test cases in code repository 202 change, a webhook event is triggered in DevOps 203. This webhook event then triggers DevOps 203 to automatically launch the Jenkins Master 204 task, creating test requests for the changed test cases in code repository 202. Specifically, DevOps 203, based on the module call relationships of Service-Oriented Architecture (SOA), identifies the modules involved in the changed test cases in code repository 202, locates the relevant test scripts for those modules, creates a collection of test scripts, and initiates test requests for the changed test cases in code repository 202. SOA is a component model that breaks down different functional units (called services) of an application and connects them through well-defined interfaces and protocols.
[0072] Next, Jenkins Master 204 distributes the test request to Jenkins Slave 205, which creates a Jenkins Job. This Jenkins Job is the specific test project corresponding to the changed test cases in code repository 202. Then, Jenkins Slave 205 determines the scaling evaluation result corresponding to the test node based on the total number of changed test cases in code repository 202, the corresponding set total time (that is, the test of the changed test cases in the code repository must be completed within the set total time), the number of test nodes, and the average processing speed of the test nodes.
[0073] The automatic scaling up and scaling down module 206 can scale up or down according to the scaling up and scaling down evaluation results. That is, if the current number of Selenium Node proxy nodes is too small, it will automatically scale up through Docker to increase the number of Selenium Node proxy nodes. If the current number of Selenium Node proxy nodes is too large, it will automatically scale down through Docker to reduce the number of Selenium Node proxy nodes. Then, a test request is initiated based on Selenium Hub 207 using Docker.
[0074] Selenium Hub 207, based on Docker, distributes test requests to designated Selenium Node proxy nodes to execute tests for the changed test cases in code repository 202. Specifically, when executing tests, it can locate the corresponding Docker container based on the developer's identifier for the changed test cases in code repository 202. Since the developer's identifier is included when the Docker container is created, the corresponding Docker container can be found using the same developer's identifier. If the corresponding Docker container is found, the corresponding test case is routed to that Docker container for execution. If the corresponding Docker container is not found, the test case is routed to a Docker container in the base environment for execution.
[0075] It should be noted that, based on Docker container technology, different types of test nodes can be quickly created using Docker images, such as Chrome-type container images and Firefox-type container images. Figure 2 As shown in 210, you can configure a Chrome Docker image for Selenium Hub to test test cases using a Chrome-type Docker image, and you can configure a Firefox Docker image for Selenium Hub to test test cases using a Firefox-type container image. The specific configuration is not limited.
[0076] In summary, it can be seen that in the embodiments provided in this application, when executing tests on test cases that have changed in the code repository, the introduction of Docker containers and Selenium Grid makes the test machines no longer fixed, supports automatic scaling, supports high-concurrency testing requirements, and Jenkins does not need to pay attention to the status of the test machines, thus achieving decoupling between Jenkins and the test machines, which is flexible and efficient. In addition, the introduction of Jenkins Master and Jenkins Slave removes the bottleneck of Jenkins and supports high-concurrency testing requirements.
[0077] The system involved in the embodiments of this application can be a distributed system formed by connecting a client and multiple nodes (any form of computing device in the network, such as a server or user terminal) through network communication.
[0078] Taking a distributed system as an example, see blockchain system. Figure 3 , Figure 3 This is an optional structural diagram of the distributed system 100 provided in this application embodiment applied to a blockchain system. It consists of multiple nodes (any form of computing device in the network, such as servers or user terminals) and clients, forming a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In the distributed system, any machine, such as a server or terminal, can join and become a node. A node includes a hardware layer, a middleware layer, an operating system layer, and an application layer.
[0079] See Figure 3 The functions of each node in the blockchain system shown include:
[0080] 1) Routing: A basic function of nodes used to support communication between nodes.
[0081] In addition to routing capabilities, nodes can also have the following functions:
[0082] 2) Applications are deployed in the blockchain to implement specific business needs. They record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes successfully verify the source and integrity of the record data, they add the record data to a temporary block.
[0083] For example, the business logic implemented by the application includes:
[0084] 2.1) A wallet is used to provide the function of conducting electronic currency transactions, including initiating transactions (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system; after other nodes successfully verify the transaction, they store the transaction record data in the temporary block of the blockchain as a response to acknowledge the validity of the transaction; of course, the wallet also supports querying the remaining electronic currency in the electronic currency address;
[0085] 2.2) Shared ledger, used to provide functions such as storage, query and modification of ledger data. It sends the record data of the operation on the ledger data to other nodes in the blockchain system. After the other nodes verify the validity, as a response to acknowledge the validity of the ledger data, they store the record data in a temporary block. They can also send confirmation to the node that initiated the operation.
[0086] 2.3) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented through code deployed on a shared ledger that executes when certain conditions are met. Based on actual business needs, the code is used to complete automated transactions, such as querying the logistics status of goods purchased by a buyer and transferring the buyer's electronic money to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions; they can also execute contracts for processing received information.
[0087] 3) A blockchain consists of a series of blocks that are sequentially generated. Once a new block is added to the blockchain, it will not be removed. The blocks contain the data submitted by the nodes in the blockchain system.
[0088] See Figure 4 , Figure 4 This is an optional schematic diagram of the block structure provided in this application embodiment. Each block includes the hash value of the transaction records stored in this block (the hash value of this block) and the hash value of the previous block. The blocks are connected through their hash values to form a blockchain. Additionally, the block may include information such as a timestamp when it was generated. A blockchain is essentially a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains relevant information used to verify the validity of the information (anti-counterfeiting) and to generate the next block.
[0089] Based on the above introduction, the execution method of the test cases in this application will be described from the perspective of the test case execution device. Please refer to [link / reference]. Figure 5 One embodiment of the test case execution method in this application includes:
[0090] 501. Identify the K test cases in the code repository that are associated with the first test case.
[0091] In this embodiment, the test case execution device can determine K test cases associated with the first test case in the code repository. The first test case is any one of the N modified test cases in the code repository, where K and N are both integers greater than or equal to 1. That is, after developers complete the development and debugging of test cases for the application under test on their local machine, they can push the test cases to the code repository. This causes changes to the test cases in the code repository, triggering the test case execution device to determine the modified test cases in the code repository. These changes include at least one of updating, adding, and deleting test cases. When the test case execution device determines that N test cases in the code repository have been modified, it can determine the K test cases associated with those N test cases.
[0092] In one embodiment, the test case execution device determines K test cases in the code repository associated with the first test case, including:
[0093] Determine the calling relationships between modules in a Service-Oriented Architecture (SOA) and the membership relationships between test cases in the code repository and modules in the SOA.
[0094] Determine the first module to which the first test case belongs based on the affiliation relationship;
[0095] Determine the second module that has a calling relationship with the first module based on the calling relationship;
[0096] The test cases belonging to the second module are determined to be K test cases.
[0097] In this embodiment, SOA (Service-Oriented Architecture) is introduced when executing tests on test cases. Each test case in the code repository belongs to a module of SOA. SOA records the call relationships between modules. For example, a test case b in the code repository belongs to module B in SOA. In the call relationships recorded by SOA, the modules related to module B are module A and module C. If module A has test case a and module C has test case c, it can be determined that test cases a, b, and c are related. When test case a changes, it may cause test cases b and c associated with it to fail. Therefore, when testing test case a, test cases b and c should be tested together. Therefore, when determining the K test cases associated with the first test case, the test case execution device can first determine the calling relationship between SOA modules and the membership relationship between test cases in the code repository and modules in SOA. Then, based on the membership relationship, it can determine the first module to which the first test case belongs, and based on the calling relationship, it can determine the second module that has a calling relationship with the first module. The test cases in the second module are then used as the K test cases associated with the first test case.
[0098] It should be noted that the test case execution device, by introducing a DevOps pipeline and configuring webhook events, can trigger the configured webhook events when test cases in the code repository change, thereby triggering the execution of the test scripts corresponding to the changed test cases. It also incorporates SOA module call relationships, which record the call relationships between SOA modules. This allows for the automatic identification of all test cases associated with the changed test cases in the code repository, finding the corresponding set of test scripts, and initiating test requests based on this set of test scripts for the changed test cases in the code repository, as well as test requests associated with the changed test cases. This not only achieves proactive triggering of test execution but also improves the execution efficiency of test cases.
[0099] 502. Determine the number of test cases to be tested based on N test cases and K test cases associated with the first test case.
[0100] In this embodiment, after determining the K test cases associated with the first test case in the code repository, the test case execution device can add up the test cases associated with each of the N test cases, and then add N to obtain the number of test cases currently to be tested. For example, if there are three changed test cases A, B, and C in the code repository, test case D is associated with test case A, test cases E and F are associated with test case B, and test case G is associated with test case C. The number of test cases currently to be tested is 3 + 1 + 2 + 1 = 7. It is understood that if there are duplicate test cases associated with each test case in the current test cases to be tested, the duplicates are removed before determining the number of test cases to be tested.
[0101] 503. Obtain the total set duration, number of test nodes, and average processing speed of the test nodes for N test cases.
[0102] In this embodiment, the test case execution device can obtain the total set time, the number of test nodes, and the average processing speed of the test nodes corresponding to N test cases. The test nodes are used to execute tests on the test cases. The total set time indicates the time required to complete the testing of N test cases that have changed in the code repository. The number of test nodes indicates the number of nodes assigned to execute tests on the changed test cases in the code repository. For example, if the number of test nodes is A, B, and C, and test node A takes 1 minute to process one test case, node B takes 2 minutes, and node C takes 2 minutes, the average processing speed can be calculated as (1+2+2) / 3 = 1.67. Therefore, the average processing speed of this test node is 1.67 minutes per test case, meaning it takes 1.67 minutes to execute one test case.
[0103] It should be noted that steps 501 to 502 can determine the number of test cases to be tested, and step 503 can obtain the total set duration, the number of test nodes, and the average processing speed of the test nodes. However, there is no restriction on the execution order of steps 501 to 502 and step 503. Steps 501 to 502 can be executed first, or step 503 can be executed first, or they can be executed simultaneously. There is no specific limitation.
[0104] 504. Determine the scaling evaluation result corresponding to the test node based on the set total duration, the number of test cases to be tested, the number of test nodes, and the average processing speed.
[0105] In this embodiment, after obtaining the set total duration, the number of test cases to be tested, the number of test nodes, and the average processing speed, the test case execution device can determine the scaling evaluation result corresponding to the test node based on the set total duration, the number of test cases to be tested, the number of test nodes, and the average processing speed.
[0106] In one embodiment, the test case execution device determines the scaling evaluation result corresponding to the test node based on the set total duration, the number of test cases currently to be tested, the number of test nodes, and the average processing speed, including:
[0107] The number of tests for the current test cases to be tested is determined based on the number of test nodes, the total set duration, and the average processing speed.
[0108] Determine the difference between the number of test cases currently to be tested and the number of tests performed on the test cases currently to be tested;
[0109] The expansion / contraction assessment result is determined based on the difference.
[0110] In this embodiment, when determining the scaling evaluation result corresponding to a test node, the test case execution device can first determine the number of test cases to be tested based on the number of test nodes, the set total time, and the average processing speed. Then, it determines the difference between the current number of test cases and the current number of tests performed, and uses this difference to determine the scaling evaluation result. That is, it can first determine how many test cases the current test node can complete within the set total time, and then determine how many test cases remain untested within the set total time if processed according to the current number of test nodes and the average processing speed. Finally, it can determine the scaling evaluation result based on the number of remaining test cases within the set total time. Specifically, it can determine the number of new nodes or the number of nodes to be deleted based on the difference and the average processing speed, and use this number as the scaling evaluation result. For example, if the number of test cases to be tested is 1000, the number of test nodes is 2, and the average processing speed of the test nodes is 1 minute per test case, then 2 test nodes can process 2 test cases per minute. Therefore, after testing the test cases to be tested for 1 hour with 2 test nodes, there will be 1000 - (2 * 1 * 60) = 880 test cases remaining. With 880 test cases, each test node can process 60 test cases per hour. If the test cases are to be completed within the set total time of 1 hour, 880 / 60 = 14.67 test cases are needed. Thus, it can be determined that 15 new test nodes need to be added. The number of new test nodes is the scaling evaluation result.
[0111] It should be noted that the above only illustrates the example of the number of newly added test nodes as the result of the scaling assessment. Of course, the scaling assessment result can also be the number of nodes deleted, and there is no specific limitation. Furthermore, the scaling evaluation result determined by the difference between the number of test cases currently under test and the remaining number of test cases under test can also be determined in other ways, without any specific limitation. For example, the number of test nodes required to complete the test cases under test within the set total time can be determined first based on the average processing speed, the set total time, and the number of test cases under test. Then, the difference between the required number of test nodes and the number of existing test nodes is determined as the scaling evaluation result. As in the example above, to complete 1000 test cases within the set total time of 1 hour, 1000 / 60 = 16.67, or 17 test nodes, are required. However, the current number of test nodes is 2. Therefore, 15 additional test nodes are needed to ensure that the test cases under test are completed within the set total time. These 15 additional test nodes are the scaling evaluation result.
[0112] 505. Adjust the number of test nodes based on the expansion / contraction assessment results.
[0113] In this embodiment, after determining the scaling evaluation result, the test case execution device can adjust the number of test nodes according to the scaling evaluation result. Specifically, if the scaling evaluation result is the number of new nodes, then test nodes are added according to the number of new nodes; if the scaling evaluation result is the number of deleted nodes, then current test nodes are deleted according to the number of deleted nodes. The test node is a Selenium Node. If the current number of Selenium Nodes is too small, it is automatically scaled up using Docker, increasing the number of Selenium Nodes by the number of new nodes corresponding to the scaling evaluation result. If the current number of Selenium Nodes is too large, it is automatically scaled down using Docker, reducing the number of Selenium Nodes by the number of deleted nodes corresponding to the scaling evaluation result. This ensures that the high concurrency processing requirements of test cases can be supported while preventing resource waste when the number of test cases is small.
[0114] 506. Assign the currently tested test cases to the adjusted test nodes for testing.
[0115] In this embodiment, after adjusting the number of test nodes based on the scaling evaluation results, the test case execution device can assign the currently tested test cases to the adjusted test nodes for execution.
[0116] In one embodiment, the test case execution device assigns the currently tested test case to the adjusted test node for execution, including:
[0117] Identify a second test case that contains a development identifier in the current test case to be tested;
[0118] The second test case is assigned to the first test node corresponding to the development identifier in the test node and executed.
[0119] Other test cases are assigned to other nodes for testing. Other test cases are the test cases other than the second test case in the current test cases to be tested. Other nodes are the nodes other than the first test node in the adjusted test nodes.
[0120] In this embodiment, developers may include their own identifiers in the code they develop. Here, the first test case containing this identifier can be identified among the test cases to be tested. The corresponding Docker container is then located based on the identifier of the first test case. Since the Docker container carries the developer's identifier when it is created, the corresponding Docker container can be found using the same developer's identifier. If a corresponding Docker container is found, the corresponding test case is routed to that Docker container for execution. If no corresponding Docker container is found, the test case is routed to a Docker container in the base environment for execution. This allows for automatic identification of the environment under test (determining whether the current test is being performed in the development environment or the base environment) based on the developer's identifier, improving testing efficiency.
[0121] It should be noted that after assigning the test case to the adjusted test node, the test case execution device can also determine the test report corresponding to the test case and output the test report, making it easier for users to view it more intuitively.
[0122] In summary, it can be seen that in the embodiments provided in this application, when testing the changed test cases in the code repository, the test nodes are adjusted according to the total set duration of the changed test cases, the number of test cases to be tested, the number of test nodes, and the average processing speed. That is, the test nodes are automatically expanded to make the test nodes more compatible with the test cases to be tested and support high-concurrency testing requirements.
[0123] The embodiments of this application have been described above from the perspective of test case execution methods. The embodiments of this application will now be described below from the perspective of test case execution devices.
[0124] Please see Figure 6This application provides a test case execution device 600, which includes:
[0125] The first determining unit 601 is used to determine K test cases in the code repository that are associated with the first test case. The first test case is any one of the N modified test cases in the code repository, where K and N are both integers greater than or equal to 1.
[0126] The second determining unit 602 is used to determine the number of test cases to be tested at present based on N test cases and K test cases associated with the first test case. The current test cases are N test cases and K test cases associated with the first test case.
[0127] The acquisition unit 603 is used to acquire the total set duration, the number of test nodes, and the average processing speed of the test nodes corresponding to N test cases. The test nodes are used to execute tests on the test cases.
[0128] The third determining unit 604 is used to determine the scaling evaluation result corresponding to the test node based on the set total duration, the number of test cases to be tested, the number of test nodes, and the average processing speed.
[0129] Adjustment unit 605 is used to adjust the number of test nodes according to the expansion / shrinkage evaluation results;
[0130] The allocation unit 606 is used to allocate the test cases to be tested to the adjusted test nodes for execution.
[0131] In one possible design, the first determining unit 601 is specifically used for:
[0132] Determine the calling relationships between modules in Service-Oriented Architecture (SOA) and the membership relationships between test cases in the code repository and modules in SOA.
[0133] Determine the first module to which the first test case belongs based on the affiliation relationship;
[0134] Determine the second module that has a calling relationship with the first module based on the calling relationship;
[0135] The test cases belonging to the second module are determined to be K test cases.
[0136] In one possible design, the third determining unit 604 is specifically used for:
[0137] The number of tests for the current test cases to be tested is determined based on the number of test nodes, the total set duration, and the average processing speed.
[0138] Determine the difference between the number of test cases currently to be tested and the number of tests performed on the test cases currently to be tested;
[0139] The expansion / contraction assessment result is determined based on the difference.
[0140] In one possible design, the third determining unit 604 is also specifically used for:
[0141] The first number of test nodes required to complete the current test case within the set total time is determined based on the average processing speed.
[0142] Determine the difference between the first quantity and the number of test nodes;
[0143] The scaling evaluation result corresponding to the test node is determined based on the difference.
[0144] In one possible design, the third determining unit 604 determines the scaling evaluation result corresponding to the test node based on the difference, including:
[0145] The number of nodes to be added or deleted is determined based on the difference and the average processing speed.
[0146] The number of newly added nodes or the number of deleted nodes is determined as the scaling evaluation result.
[0147] In one possible design, the adjustment unit 605 is specifically used for:
[0148] If the scaling assessment result is the number of new nodes, then add new nodes to the current test nodes according to the number of new nodes;
[0149] If the scaling evaluation node is the number of nodes to be deleted, then the current test node will be deleted according to the number of nodes to be deleted.
[0150] In one possible design, the allocation unit 606 is specifically used for:
[0151] Identify a second test case that contains a development identifier in the current test case to be tested;
[0152] The second test case is assigned to the first test node corresponding to the development identifier in the test node and executed.
[0153] Other test cases are assigned to other nodes for testing. Other test cases are the test cases other than the second test case in the current test cases to be tested. Other nodes are the nodes other than the first test node in the adjusted test nodes.
[0154] In summary, it can be seen that in the embodiments provided in this application, when testing the changed test cases in the code repository, the test nodes are adjusted according to the total set duration of the changed test cases, the number of test cases to be tested, the number of test nodes, and the average processing speed. That is, the test nodes are automatically expanded to make the test nodes more compatible with the test cases to be tested and support high-concurrency testing requirements.
[0155] This application also provides another test case execution device, which is deployed on a server. For easier understanding, please refer to... Figure 7 , Figure 7 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 700 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 722 (e.g., one or more processors) and memory 732, and one or more storage media 730 (e.g., one or more mass storage devices) for storing application programs 742 or data 744. The memory 732 and storage media 730 can be temporary or persistent storage. The program stored in the storage media 730 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the server. Furthermore, the CPU 722 may be configured to communicate with the storage media 730 and execute the series of instruction operations in the storage media 730 on the server 700.
[0156] Server 700 may also include one or more power supplies 726, one or more wired or wireless network interfaces 750, one or more input / output interfaces 758, and / or one or more operating systems 741, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM etc.
[0157] The steps performed by the test case execution device in the above embodiments can be based on this Figure 7 The server structure shown.
[0158] This application also provides a computer-readable storage medium storing a computer program thereon. When executed by a computer, the computer program implements the method flow related to the test case execution device in any of the above method embodiments. Correspondingly, the computer can be the aforementioned test case execution device.
[0159] This application also provides a computer program or a computer program product including a computer program, which, when executed on a computer, causes the computer to implement the method flow related to the test case execution device in any of the above method embodiments. Correspondingly, the computer can be the aforementioned test case execution device.
[0160] In the above Figure 5 In the corresponding embodiments, it can be implemented entirely or partially through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented entirely or partially in the form of a computer program product.
[0161] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state disk (SSD)).
[0162] It should be understood that the processor mentioned in this application can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0163] It should also be understood that the number of processors in this application can be one or more, and can be adjusted according to the actual application scenario. This is merely an illustrative example and is not intended to limit the application. The number of memory in the embodiments of this application can be one or more, and can be adjusted according to the actual application scenario. This is merely an illustrative example and is not intended to limit the application.
[0164] It should also be noted that when the test case execution device includes a processor (or processing unit) and a memory, the processor in this application may be integrated with the memory, or the processor and the memory may be connected through an interface. The specific configuration can be adjusted according to the actual application scenario and is not limited.
[0165] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0166] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0167] 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 units can be selected to achieve the purpose of this embodiment according to actual needs.
[0168] 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. The integrated unit can be implemented in hardware or as a software functional unit.
[0169] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or 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, a server, or other device, etc.) to execute this application. Figure 5 The embodiments of the method may include all or part of the steps described.
[0170] It should be understood that the storage medium or memory mentioned in this application may include volatile memory or non-volatile memory, or both. Non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
[0171] It should be noted that the memories described herein are intended to include, but are not limited to, these and any other suitable types of memories.
[0172] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application 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. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for executing test cases, characterized in that, include: Identify K test cases in the code repository that are associated with the first test case, where the first test case is any one of the N modified test cases in the code repository, and K and N are both integers greater than or equal to 1; The number of test cases to be tested is determined based on the N test cases and the K test cases associated with the first test case. The test cases to be tested currently are the N test cases and the K test cases associated with the first test case. Obtain the total set duration, the number of test nodes, and the average processing speed of the test nodes corresponding to the N test cases. The test nodes are used to execute tests on the test cases. The total set duration indicates that the tests for the N test cases that have changed in the code repository should be completed within the set total duration. The number of test nodes indicates the number of nodes allocated to execute tests on the test cases that have changed in the code repository. The scaling evaluation result corresponding to the test node is determined based on the set total duration, the number of test cases to be tested, the number of test nodes, and the average processing speed. The number of test nodes is adjusted based on the scaling evaluation results. The test cases currently to be tested are assigned to the adjusted test nodes for execution. The process of determining the scaling evaluation result corresponding to the test node based on the set total duration, the number of test cases currently to be tested, the number of test nodes, and the average processing speed includes: The number of tests for the current test cases to be tested is determined based on the number of test nodes, the set total duration, and the average processing speed. Determine the difference between the number of test cases currently to be tested and the number of tests performed on the test cases currently to be tested; The expansion / shrinkage assessment result is determined based on the difference. or, Based on the average processing speed, determine the first number of test nodes required to complete the current test case to be tested within the set total time. Determine the difference between the first quantity and the number of test nodes; The scaling evaluation result corresponding to the test node is determined based on the difference.
2. The execution method according to claim 1, characterized in that, The K test cases in the code repository associated with the first test case include: Determine the calling relationships between modules in the Service-Oriented Architecture (SOA) and the membership relationships between test cases in the code repository and modules in the SOA. The first module to which the first test case belongs is determined based on the aforementioned affiliation; Based on the calling relationship, determine the second module that has a calling relationship with the first module; The test cases belonging to the second module are determined as the K test cases.
3. The execution method according to claim 1, characterized in that, The step of determining the scaling evaluation result corresponding to the test node based on the difference includes: The number of new nodes or the number of deleted nodes are determined based on the difference and the average processing speed. The number of newly added nodes or the number of deleted nodes is determined as the scaling evaluation result.
4. The execution method according to claim 3, characterized in that, The adjustment of the test node based on the scaling evaluation results includes: If the scaling assessment result is the number of newly added nodes, then the test nodes are added according to the number of newly added nodes; If the scaling evaluation result is the number of nodes to be deleted, then the current test node is deleted according to the number of nodes to be deleted.
5. The execution method according to any one of claims 1 to 2 and 4, characterized in that, The step of assigning the currently tested test cases to the adjusted test nodes for testing includes: Identify a second test case that contains a development identifier in the currently tested test case; The second test case is assigned to the first test node corresponding to the development identifier in the test node for test execution; Other test cases are assigned to other nodes for testing. The other test cases are the test cases other than the second test case in the current test cases to be tested. The other nodes are the nodes other than the first test node in the adjusted test nodes.
6. A test case execution device, characterized in that, include: The first determining unit is used to determine K test cases in the code repository that are associated with the first test case, wherein the first test case is any one of the N modified test cases in the code repository, and K and N are both integers greater than or equal to 1; The second determining unit is used to determine the number of test cases to be tested currently based on the N test cases and the K test cases associated with the first test case, wherein the test cases to be tested currently are the N test cases and the K test cases associated with the first test case. The acquisition unit is used to acquire the total set duration, the number of test nodes, and the average processing speed of the test nodes corresponding to the N test cases. The test nodes are used to execute tests on the test cases. The total set duration indicates that the tests for the N test cases must be completed within the set total duration. The number of test nodes indicates the number of nodes required to test the N test cases. The third determining unit is used to determine the scaling evaluation result corresponding to the test node based on the set total duration, the number of test cases to be tested, the number of test nodes, and the average processing speed. An adjustment unit is used to adjust the number of test nodes based on the scaling evaluation results. The allocation unit is used to allocate the currently tested test cases to the adjusted test nodes for test execution; The third determining unit is specifically used for: The number of tests for the current test cases to be tested is determined based on the number of test nodes, the set total duration, and the average processing speed. Determine the difference between the number of test cases currently to be tested and the number of tests performed on the test cases currently to be tested; The expansion / shrinkage assessment result is determined based on the difference. The third determining unit is also specifically used for: Based on the average processing speed, determine the first number of test nodes required to complete the current test case to be tested within the set total time. Determine the difference between the first quantity and the number of test nodes; The scaling evaluation result corresponding to the test node is determined based on the difference.
7. The apparatus according to claim 6, characterized in that, The first determining unit is specifically used for: Determine the calling relationships between modules in the Service-Oriented Architecture (SOA) and the membership relationships between test cases in the code repository and modules in the SOA. The first module to which the first test case belongs is determined based on the aforementioned affiliation; Based on the calling relationship, determine the second module that has a calling relationship with the first module; The test cases belonging to the second module are determined as the K test cases.
8. The apparatus according to claim 6, characterized in that, The third determining unit determines the scaling evaluation result corresponding to the test node based on the difference, including: The number of new nodes or the number of deleted nodes are determined based on the difference and the average processing speed. The number of newly added nodes or the number of deleted nodes is determined as the scaling evaluation result.
9. The apparatus according to claim 8, characterized in that, The adjustment unit is specifically used for: If the scaling assessment result is the number of newly added nodes, then the test nodes are added according to the number of newly added nodes; If the scaling evaluation result is the number of nodes to be deleted, then the current test node is deleted according to the number of nodes to be deleted.
10. The apparatus according to any one of claims 6 to 7 and 9, characterized in that, The allocation unit is specifically used for: Identify a second test case that contains a development identifier in the currently tested test case; The second test case is assigned to the first test node corresponding to the development identifier in the test node for test execution; Other test cases are assigned to other nodes for testing. The other test cases are the test cases other than the second test case in the current test cases to be tested. The other nodes are the nodes other than the first test node in the adjusted test nodes.
11. A computer device, characterized in that, include: Memory, processor, and bus system; The memory is used to store programs, and the bus system is used to connect the memory and the processor so that the memory and the processor can communicate. The processor is used to execute the program in the memory, and the processor is used to execute the execution method according to any one of claims 1 to 5 according to the instructions in the program code.
12. A computer storage medium, characterized in that, It includes instructions that, when executed on a computer, cause the computer to perform the execution method according to any one of claims 1-5.
13. A computer program product, characterized in that, The computer program product includes instructions that, when executed on a computer device, cause the computer device to perform the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Test method and device
CN105786696A