Source code processing method and device and storage medium
By adding private variables to unexecuted methods in the code testing platform and automatically recording the execution status, the cost and complexity of manually obtaining code coverage in the existing technology is solved, automatic acquisition of code coverage is achieved, and maintenance costs are reduced. and improved test platform flexibility.
Patent Information
- Application Number
- CN202310752997.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-03-17
- Filing Date
- 2023-06-25
- Publication Date
- 2024-09-20
AI Technical Summary
Obtaining code coverage in the existing technology requires manual participation by technical personnel, which increases cost and complexity, and is difficult to automate.
By adding private variables to unexecuted methods in the code testing platform, recording the execution status, and automatically obtaining code coverage information after testing, automatic acquisition of code coverage is achieved.
It reduces the maintenance cost of the code testing platform, improves the flexibility of the automated testing platform, and reduces the user's perception of the process of obtaining code coverage information.
Smart Images

Figure CN118672891A
Abstract
Description
[0001] This application claims priority to Chinese patent application No. 202310264708.7, filed on March 17, 2023, and entitled “A code coverage integration method and device based on dynamic instrumentation”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computers, and in particular to a method, device and storage medium for processing source code. Background Art
[0003] Code coverage is the ratio of executed code to all code during the service operation. It is an objective and effective indicator to measure the quality of the service source code. After the service source code is developed, the service source code can be tested, and the code coverage can be obtained during the testing of the source code.
[0004] In the related art, the code coverage of the source code can only be obtained by manual participation of technicians. The manual participation of technicians requires the technicians to perceive the process of obtaining the code coverage, which increases the cost. Summary of the invention
[0005] The present application provides a method, device and storage medium for processing source code to achieve automatic acquisition of code coverage and reduce costs. The technical solution is as follows:
[0006] In a first aspect, the present application provides a method for processing source code, the method being applied to a code testing platform, the code testing platform being used to test a first source code using a first test case. In the method, an instruction for starting a code test is received, the instruction for starting a code test being used to instruct the code testing platform to start testing the first source code. A private variable is added to at least one first method included in the first source code, the at least one first method being a method that is not executed in the first source code, the private variable in the first method being used to record the execution status of each code statement in the first method when the first method is executed. After the first source code is tested using the first test case, first code coverage information is obtained based on the private variables in the at least one first method, the first code coverage information being used to describe the execution status of the code statements in the at least one first method. Based on the first code coverage information, a first code coverage result is displayed, the first code coverage result including the code coverage rate of the first source code.
[0007] The test of the first source code is started upon receiving the instruction to start the code test. After starting the test of the first source code, a private variable is added to at least one first method that is not executed in the first source code, so that when each of the at least one first method is executed, the private variable in the first method is used to record the execution of each code statement in the first method. After the first source code is tested using the first test case, the first code coverage information is obtained based on the private variables in the at least one first method. The first code coverage information is used to describe the execution of the code statements in the at least one first method, and the code coverage rate of the first source code is displayed based on the first code coverage information. Since the private variable is added to the at least one first method that is not executed after starting the test of the first source code, the modification of the instruction to start the code test required in the scenario of plugging at startup is avoided. After starting the test of the first source code, the private variable is automatically added to the unexecuted method in the first source code, and the user does not perceive the entire process of obtaining the first code coverage information. Thereby, the code coverage rate is automatically obtained, the cost is saved, the cost of maintaining the code testing platform is reduced, and the flexibility of the user to use the automated code testing platform is increased.
[0008] In a possible implementation, the first source code also includes a second method, and the second method is the method being executed when the private variable is added in the at least one first method. The thread stack frame information of the second method is obtained, and the thread stack frame information is used to record the execution status of each code statement in the second method. The executed code statement in the second method is determined based on the thread stack frame information, and the first code coverage information is also used to describe the execution status of the code statement in the second method. In this way, the first code coverage information is enriched to avoid missing the code execution status of the second method.
[0009] In another possible implementation, the first code coverage information is also used to describe the execution status of each code statement in the first static code block, where the first static code block is a static code block that has been executed in the first source code before the private variable is added in the at least one first method, and each code statement in the first static code block is executed. This enriches the first code coverage information and avoids missing the code execution status of the first static code block.
[0010] In another possible implementation, the first code coverage information is also used to describe the execution status of each code statement in the constructor of the target class, where the target class is a class including a constructor that has been executed in the first source code before the private variable is added to the at least one first method, and each code statement in the constructor of the target class is executed. This enriches the first code coverage information and avoids missing the code execution status of the constructor of the target class.
[0011] In another possible implementation, the private variable of the first method includes an element corresponding to each code statement in the first method. An assignment statement corresponding to the i-th code statement in the first method is added, i=1, 2, 3, ..., and the assignment statement is used to set the value of the element corresponding to the i-th code statement to a target value when the i-th code statement is executed, and the target value is used to indicate that the i-th code statement is executed. In this way, the private variable records the execution status of the code statements in the first method through the assignment statement in the first method.
[0012] In another possible implementation, the first code coverage information includes identification information of the code statements executed in the at least one first method. The order of each first method in the first source code and the identification information of the start code statement and the identification information of the end code statement in each first method are obtained. The values of each element included in the private variable of each first method are obtained. Based on the values of each element included in the private variable of each first method, the order of each first method, the identification information of the start code statement and the identification information of the end code statement in each first method, the first code coverage information is obtained.
[0013] Since the at least one method is stored in disorder in the code testing platform, based on the order of each first method, the identification information of the starting code statement and the identification information of the ending code statement in each first method, the order of the at least one first method in the first source code can be restored, thereby improving the accuracy of the obtained first code coverage information.
[0014] In another possible implementation, the code testing platform includes a first test device and a second test device, the first source code includes a first part and a second part, the first test device is used to test the first part using a first test case, the second test device is used to test the second part using the first test case, and the first code coverage information is used to describe the execution of the code statements in the first part. A second private variable is added to at least one third method included in the first source code in the second test device, and the at least one third method is a method that is not executed in the first source code in the second test device. When the second test device completes testing the first source code using the first test case, the second code coverage information is obtained based on the private variables in the third method included in the second part, and the second code coverage information is used to describe the execution of the code statements in the second part. The overall code coverage information corresponding to the first source code is obtained based on the first code coverage information and the second code coverage information. Based on the overall code coverage information, the first code coverage result is displayed.
[0015] In this way, multiple test devices can be used to test different parts of the first source code, and then the code coverage information corresponding to the part of the source code tested by each test device can be obtained, and the overall code coverage information corresponding to the first source code can be obtained based on the code coverage information corresponding to each part of the source code. This ensures that the first source code is tested in parallel using multiple test devices, thereby improving the test efficiency.
[0016] In another possible implementation, a private variable is added to a method other than the at least one first method in the first source code, so as to ensure that a private variable is added to each method of the first source code, and the execution status of the code statements in each method is collected through the private variables in each method.
[0017] In another possible implementation, the code coverage rate included in the first code coverage result is the code coverage rate when the first source code executes the first test case, and the code testing platform is also used to test the first source code using the second test case after the first source code is tested using the first test case. When the first source code is tested using the second test case, third code coverage information is obtained based on the private variables in each method included in the first source code, and the third code coverage information is used to describe the execution status of the code statements in the first source code. Based on the first code coverage information and the third code coverage information, the second code coverage result is displayed, and the second code coverage result includes the code coverage rate when the first source code executes the first test case and the second test case.
[0018] Since one test case may not be able to execute every code statement of the first source code, code coverage information corresponding to each test case is obtained, and the code coverage rate of the first source code can be accurately obtained based on the code coverage information corresponding to each test case.
[0019] In another possible implementation, change information is obtained, and the change information is used to describe the difference between the second source code and the first source code. The first source code and the second source code are two versions of the source code for the same service, and the version of the second source code is earlier than the version of the first source code. Code coverage information corresponding to the difference is obtained based on the change information and the first code coverage information, and the code coverage information corresponding to the difference is used to describe the execution of the code statements in the difference. The code coverage result of the difference is displayed based on the code coverage information corresponding to the difference, and the code coverage result of the difference includes the code coverage rate of the difference.
[0020] The difference part is the new content in the first source code. The execution status of the code statements in the difference part may be the content that the user is interested in. Displaying the code coverage results of the difference part can meet the user's needs and enable the user to know the code coverage information of the new part in the new version of the source code.
[0021] In another possible implementation, at least one component included in the difference part is obtained. For each component, the code coverage information corresponding to the component is obtained based on the code coverage information corresponding to the difference part, and the code coverage information corresponding to the component is used to describe the execution status of the code statements in the component. The code coverage result of the component is displayed based on the code coverage information corresponding to the component, and the code coverage result of the component includes the code coverage rate of the component. Each component of the difference part may be content of interest to the user, and displaying the code coverage result of each component can meet the user's needs.
[0022] In another possible implementation, at least one component includes one or more of the following: at least one branch in the difference portion, at least one method in the difference portion, or at least one class in the difference portion.
[0023] In a second aspect, the present application provides a device for processing source code, which is used to execute the method in the first aspect or any possible implementation of the first aspect. Specifically, the device includes a unit for executing the method in the first aspect or any possible implementation of the first aspect.
[0024] In a third aspect, the present application provides a computing device cluster, the cluster comprising at least one computing device, each device in the at least one computing device comprising at least one processor and at least one memory, the at least one memory storing computer-readable instructions; the at least one processor executes the computer-readable instructions so that the cluster implements the method in the first aspect or any possible implementation manner of the first aspect.
[0025] In a fourth aspect, the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium, and the computer program is loaded by a processor to implement the method in the first aspect or any possible implementation manner of the first aspect.
[0026] In a fifth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program is loaded by a processor to execute the method in the first aspect or any possible implementation manner of the first aspect.
[0027] In a sixth aspect, the present application provides a chip comprising a memory and a processor, wherein the memory is used to store computer instructions, and the processor is used to call and run the computer instructions from the memory to execute the method in the first aspect or any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a structural diagram of a code testing platform provided in an embodiment of the present application;
[0029] Figure 2 It is a structural diagram of another code testing platform provided in an embodiment of the present application;
[0030] Figure 3 is a flow chart of a method for processing source code provided by an embodiment of the present application;
[0031] Figure 4 is a schematic diagram of a source code provided in an embodiment of the present application;
[0032] Figure 5 is a schematic diagram of another source code provided in an embodiment of the present application;
[0033] Figure 6 is a schematic diagram of the source code after adding private variables provided in an embodiment of the present application;
[0034] Figure 7 This is a schematic diagram of an interface provided by an embodiment of the present application;
[0035] Figure 8 It is a schematic diagram of the structure of a device for processing source code provided in an embodiment of the present application;
[0036] Fig. 9 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0037] Fig.10 It is a schematic diagram of the structure of a cluster for processing source code provided in an embodiment of the present application;
[0038] Fig.11 It is a schematic diagram of the structure of another cluster for processing source code provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] The implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0040] Source code is a series of computer language instructions. The source code here may be source code written in Java language or source code written in Python language, etc. After the source code is written, it is necessary to test the source code to obtain at least one test indicator, and the at least one test indicator can be used to measure the quality of the source code.
[0041] The at least one test indicator includes code coverage, which refers to the ratio of executed code statements in the source code to the total code statements in the source code when the source code is executed. When testing the source code, the code coverage information of the source code can be obtained, and the code coverage information is used to describe the executed code statements in the source code. In this way, the number of executed code statements in the source code can be obtained through the code coverage information, and the code coverage of the source code can be calculated based on the number of code statements and the total number of code statements included in the source code.
[0042] For example, the code coverage information may include identification information of executed code statements in the source code, and the number of executed code statements in the source code may be obtained by counting the identification information of the executed code statements in the source code. The total number of code statements included in the source code may be counted, and the ratio between the number of executed code statements and the total number of code statements may be calculated to obtain the code coverage rate.
[0043] Before testing the source code, the technician needs to manually modify the startup command used to start the test, so that the startup command includes the storage path of the source code, the storage path of the code coverage tool and the configuration parameters, and then send the startup command to the test device. The test device loads the code coverage tool based on the storage path of the code coverage tool included in the startup command, and configures the code coverage tool based on the configuration parameters; then the source code is loaded into the memory of the test device based on the storage path of the source code. In the process of loading the source code, the code coverage tool adds a global static variable to the source code, and the static variable includes an element corresponding to each code statement in the source code. When each code statement is loaded into the memory of the test device, an assignment statement corresponding to the code statement is added to the memory of the test device. For each code statement in the source code, the static variable includes an element corresponding to the code statement. If the code statement is executed, the assignment statement corresponding to the code statement uses the element to record that the code statement is executed. In this way, after the source code is tested, the code coverage information of the source code can be obtained based on the elements included in the static variable.
[0044] Although this method can obtain code coverage information of the source code, it requires technicians to invasively modify the startup command, which is not easy to maintain. The technicians need to be aware of the access process of the code coverage tool to a great extent, and need to download and rely on the parameters added to the startup command. In addition, the code of the production environment and the test environment needs to be distinguished, which brings some additional overhead.
[0045] See also Figure 1An embodiment of the present application provides a code testing platform 100, which includes a pipeline device 101, a code coverage device 102, a code warehouse 103 and a test environment 104, and the test environment 104 includes at least one test device 1041.
[0046] The pipeline device 101 communicates with the code coverage device 102 , the code warehouse 103 , and each test device 1041 in the test environment 104 , respectively.
[0047] The code repository 103 is used to store at least one source code, and the at least one source code is the source code of at least one service. Optionally, the source code stored in the code repository 103 may be bytecode, etc. The at least one service may be a microservice, etc.
[0048] In some embodiments, the test device 1041 included in the test environment 105 may be a physical device (such as a server or terminal device, etc.), a virtual machine and / or a container, etc. The pipeline device 101 may be a single device or a cluster, the code coverage device 102 may be a single device or a cluster, and the code warehouse 103 may be a storage device or a storage cluster.
[0049] For each source code in the at least one source code, for ease of description, the source code is referred to as a first source code, and the pipeline device 101 includes a test service, and the test service is used to test the first source code. The code coverage device 102 subscribes to the test service on the pipeline device 101, so that when the pipeline device 101 tests the first source code through the test service, it will notify the code coverage device 102.
[0050] In some embodiments, the pipeline device 101 receives an instruction for starting a code test, the instruction for starting a code test is used to instruct the code testing platform 100 to start a test on the first source code, obtains the first source code from the code warehouse 103 based on the instruction for starting a code test, and loads the first source code into at least one test device 1041 in the test environment 105. Wherein, when the at least one test device 1041 includes one test device 1041, the test device 1041 tests the entire first source code, and when the at least one test device 1041 includes multiple test devices 1041, each test device 1041 tests part of the first source code.
[0051] Optionally, the pipeline device 101 loads the first source code into the memory of the at least one test device 1041. For each test device 1041 in the at least one test device 1041, when the first source code is loaded into the memory of the test device 1041, the test device 1041 executes the first source code.
[0052] Among them, after the first source code is loaded into the memory of the test device 1041, it is not allowed to add static variables and static methods, etc. to the first source code stored in the memory of the test device 1041. Usually, the static variable is located in the main function of the first source code and is a global variable. Each function in the first source code can access the global variable. In other words, after the first source code is loaded into the memory of the test device 1041, it is not allowed to add global variables to the first source code stored in the memory of the test device 1041.
[0053] When initiating the test on the first source code, the pipeline device 101 will also send a test notification message to the code coverage device 102 , where the test notification message is used to instruct to start testing the first source code on the at least one test device 1041 .
[0054] The code coverage device 102 receives the test notification message, and sends a code coverage request to the at least one test device, where the code coverage request is used to request to obtain code coverage information of the first source code.
[0055] For each test device 1041 in the at least one test device 1041, for ease of explanation, the test device 1041 is referred to as a first test device. The first test device 1041 receives a code coverage request, and based on the triggering of the code coverage request, adds a private variable to at least one first method included in a first source code stored in a memory of the first test device 1041, the at least one first method being a method that is not executed in the first source code, and the private variable in the first method is used to record the execution status of each code statement in the first method when executing the first method.
[0056] After the first source code is loaded into the memory of the at least one test device 1041, the first test device 1041 may receive the first test case and test the first source code based on the first test case. After the first source code is tested using the first test case, first code coverage information is obtained based on the private variables in the at least one first method, and the first code coverage information is used to describe the executed code statements in the at least one first method; and the first code coverage information is sent to the code coverage device 102. The code coverage device 102 displays a first code coverage result based on the first code coverage information, and the first code coverage result includes the code coverage rate of the first source code.
[0057] In some embodiments, a technician may configure at least one test case on the pipeline device 101, and the at least one test case includes a first test case. The pipeline device 101 may send the first test case to the at least one test device 1041, so that the at least one test device 1041 tests the first source code using the first test case. After the first source code is tested using the first test case, the pipeline device 101 may also send a second test case to the at least one test device 1041, so that the at least one test device 1041 tests the first source code using the second test case, and the second test case is a test case other than the first test case in the at least one test case.
[0058] In some embodiments, see Figure 2 The code testing platform 100 also includes a test management device 105 , which communicates with the pipeline device 101 and each test device 1041 in the test environment 104 .
[0059] After loading the first source code into at least one test device 1041 included in the test environment 104, the pipeline device 101 sends the at least one test case to the test management device 105. After receiving the at least one test case, the test management device 105 sends the first test case to the at least one test device 1041, so that the at least one test device 1041 tests the first source code using the first test case. After testing the first source code using the first test case, the test management device 105 may also send a second test case to the at least one test device 1041, so that the at least one test device 1041 tests the first source code using the second test case.
[0060] Among them, after the pipeline device 101 starts testing the first source code on the at least one test device 1041, the code coverage device 102 sends a code coverage request to the at least one test device 1041, requesting the at least one test device 1041 to obtain code coverage information of the first source code. In this way, the code coverage information is requested to be obtained after the process of testing the first source code starts, so there is no need to modify the start command for starting the test, and the technician does not perceive the process of obtaining the code coverage information, so that the code coverage information can be automatically obtained, reducing labor costs.
[0061] See also Figure 3 The present application embodiment provides a method 300 for processing source code, wherein the method 300 is applied to Figure 1 or Figure 2 The code testing platform 100 shown, the method 300 includes the following process.
[0062] Step 301: A pipeline device receives an instruction to start a test code, and loads a first source code into at least one test device in a test environment, wherein the at least one test device includes a first test device.
[0063] The code repository stores source code of at least one service. When a user needs to test the source code of at least one service in the code repository, an instruction to start the test code is triggered to the pipeline device.
[0064] In some embodiments, the pipeline device may display a test start interface to the user, the interface including a start button, and the user may click the start button to trigger the start test code instruction to the pipeline device. Alternatively, the user inputs the start test code instruction on the corresponding terminal device, and the terminal device triggers the start test code instruction to the pipeline device.
[0065] The pipeline device receives the instruction to start the test code, obtains the source code of a service from the code warehouse, for the sake of convenience, the service is called the first service, the source code of the service is called the first source code, and the first source code is loaded into at least one test device included in the test environment.
[0066] For each of the at least one test device, when the first source code is loaded into the memory of each test device, each test device starts to execute the first source code.
[0067] In some embodiments, after testing the first source code, the pipeline device obtains a second source code from the code repository, where the second source code is the source code of a second service, which is a service other than the first service, and then tests the second source code according to the process of testing the first source code.
[0068] In some embodiments, when the first source code is loaded into the memory of the first test device, the first test device also obtains an index file of the first source code, the index file including a first correspondence relationship and a second correspondence relationship, the first correspondence relationship being used to save the correspondence between the identification information of each class in the first source code and the identification information of each method included in each class. The second correspondence relationship is used to save the correspondence between the order of each method, the identification information of the starting code statement of each method, and the identification information of the ending code statement. Optionally, the identification information of the code statement may be the line number of the code statement in the first source code, etc. For any class in the first source code, the identification information of the class may include the fully qualified class name of the class, etc.
[0069] In some embodiments, each method included in any class in the first source code may be stored in a disordered order in the memory of the first test device. That is, for each method included in any class in the first source code, the order of each method stored in the memory of the first test device may be different from or the same as the actual order of each method in the class.
[0070] For example, see Figure 4 A class in the first source code shown includes method 1, method 2 and method 3. After the first source code is loaded into the memory of the first test device, the storage order of method 1, method 2 and method 3 in the memory of the first test device may be disordered or not. That is, the storage order of the three methods in the memory of the first test device may be method 3, method 2, method 1; or method 2, method 3, method 1; or method 1, method 3, method 2; or method 1, method 2, method 3, etc.
[0071] For example, Figure 5 As shown, assuming that Figure 4 After the first source code is loaded into the memory of the first test device, the storage order of the three methods in the memory of the first test device is method 2, method 3, and method 1.
[0072] In some embodiments, when the pipeline device starts testing the first source code, it also assigns a pipeline identifier to the first source code, obtains pipeline detail information of the first source code, and stores the pipeline identifier of the first source code and the pipeline detail information of the first source code in correspondence between the pipeline identifier and the pipeline detailed information.
[0073] The pipeline details information of the first source code includes one or more of the following information:
[0074] The environment type of the test environment, the address of the at least one test device, the storage address of the first source code in the code repository, change information, or identification information of at least one test case, wherein the change information is used to indicate the difference between the second source code and the first source code. The second source code and the first source code are source codes of two different versions of the first service, and the version of the second source code is earlier than the version of the first source code.
[0075] In some embodiments, in addition to the test environment, there is also a production environment. The test environment is used to test the first source code, and the production environment is used to run the first source code to provide the first service to the user.
[0076] In some embodiments, the at least one test case may be configured by a technician on a pipeline device.
[0077] In some embodiments, the second source code is changed to obtain the first source code, and the change information includes a first commit point and a second commit point, the first commit point is used to record the change start operation and the operation content of the change start operation, and the second commit point is used to record the change end operation and the operation content of the change end operation. The difference part can be obtained based on the first commit point and the second commit point. Alternatively, the change information includes the starting position and the ending position of the difference part in the first source code.
[0078] In some embodiments, the pipeline device may also send the at least one test case to the test management device.
[0079] Step 302: The pipeline device sends a test notification message to the code coverage device, where the test notification message is used to instruct to start testing the first source code on the at least one test device.
[0080] The code coverage device has subscribed to the test service on the pipeline device in advance. When the pipeline device starts testing the first source code using the test service, it sends a test notification message to the code coverage device.
[0081] In some embodiments, the test notification message also includes a pipeline identifier corresponding to the first source code.
[0082] Step 303: The code coverage device receives the test notification message and sends a code coverage request to the at least one test device, where the code coverage request is used to request to obtain code coverage information of the first source code.
[0083] In step 303, the code coverage device receives the test notification message, and based on the pipeline identifier corresponding to the first source code included in the test notification message, obtains the pipeline detail information of the first source code from the correspondence between the pipeline identifier and the pipeline detail information included in the pipeline device.
[0084] The pipeline detail information of the first source code includes the address of at least one test device in the test environment where the first source code is deployed. The code coverage device sends a code coverage request to the at least one test device based on the address of the at least one test device.
[0085] In some embodiments, the pipeline detail information of the first source code includes identification information of at least one test case, and the code coverage request may also include identification information of the at least one test case. The code coverage request is used to request code coverage information corresponding to each test case in the at least one test case.
[0086] In some embodiments, the code coverage request also includes a code coverage unit, which is used to obtain code coverage information of the first source code. Optionally, the code coverage unit can automatically add private variables to each method of the first source code, and for each method, an assignment statement corresponding to each code statement included in the method can be added to the method. For an assignment statement corresponding to any code statement in the method, the assignment statement is used to record the execution status of the code statement in the private variable of the method when the code statement is executed.
[0087] In some embodiments, the code coverage unit may be a plug-in or program for obtaining code coverage information, etc. For example, the code coverage unit may be a local probe array strategy, etc.
[0088] In some embodiments, the pipeline details information of the first source code also includes the environment type of the test environment, and the code coverage device determines whether the environment corresponding to the environment type is a test environment. If it is a test environment, it means that the pipeline platform tests the first source code and sends a code coverage request to the at least one test device. If it is a production environment, it means that the pipeline platform uses the first source code to provide the first service to the user, and the code coverage platform does not need to send a code coverage request.
[0089] Since the code coverage platform can automatically identify whether the current environment is a test environment or a production environment, the production environment can be isolated from the test environment, and the user does not need to be aware of the test environment and the production environment when starting the test. When the test is needed, the pipeline platform sends an instruction to start the test code. After receiving the instruction, the pipeline platform loads the first source code to the test device in the test environment.
[0090] In some embodiments, the code coverage unit corresponding to the environment type may be pre-deployed in the at least one test device, so that in step 303, the code coverage request may not include the code coverage unit corresponding to the environment type.
[0091] For example, the type of the at least one test device may be a physical device, a virtual machine, a container, or the like.
[0092] Step 304: The first test device receives the code coverage request, and based on the code coverage request, adds private variables in at least one first method included in the first source code, where the at least one first method is a method that is not executed in the first source code, and the private variables in the first method are used to record the execution status of each code statement in the first method when executing the first method.
[0093] In step 304, after the pipeline device loads the first source code into the memory of the first test device, the first test device starts to execute the first source code. After the pipeline device starts testing the first source code, the pipeline device sends a test notification message to the code coverage device, and the code coverage device sends a code coverage request to the at least one test device. Therefore, when the first test device receives the code coverage request, it has already executed part of the first source code.
[0094] In step 304, the first test device may add private variables to at least one first method that is not executed and included in the first source code, and may also add private variables to methods other than the at least one first method in the first source code. That is, the first test device adds private variables to each method included in the first source code.
[0095] In some embodiments, for each method included in the first source code, in addition to adding a private variable in the method, an assignment statement corresponding to each code statement included in the method is also added in the method. For each code statement, the assignment statement corresponding to the code statement is used to record the execution status of the code statement in the private variable of the method.
[0096] In step 304, for each method in the first source code stored in the memory of the first test device, for the sake of convenience, the method is referred to as a target method. The private variables of the target method and the assignment statements corresponding to each code statement included in the target method can be added to the target method through the following steps 3041-3042. Optionally, the first test device performs the following operations 3041-3042 through a code coverage unit.
[0097] 3041: Declare the private variables of the target method before the first code statement of the target method. The private variables of the target method include elements corresponding to each code statement in the target method.
[0098] For each code statement in the target method, the element corresponding to the code statement in the private variable is used to record the execution status of the code statement, that is, the element corresponding to the code statement is used to record whether the code statement is executed.
[0099] In some embodiments, the declared private variables include each element having a default value, and the element corresponding to the code statement having a default value indicates that the code statement has not been executed.
[0100] In some embodiments, the number of elements included in the declared private variables is equal to the number of code statements included in the target method; or, the number of elements included in the declared private variables is equal to the number of code statements included in the first target class to which the target method belongs.
[0101] The data type of the target method's private variable can be an integer, a character, a Boolean, etc. The target method's private variable can be an array, a linked list, or a graph, etc.
[0102] for Figure 5 The class in the first source code shown includes method 1, method 2 and method 3, and includes nine code statements in total. For method 2 in the first source code, a private variable of method 2 is added in method 2, which is a Boolean array Array. Figure 6 As shown, the length of the private variable Array is 9, that is, the private variable Array includes nine elements. Method 2 includes two code statements, and two of the nine elements included in the private variable Array are elements corresponding to the two code statements.
[0103] For method 3 in the first source code, the private variable added to method 3 is also a Boolean array Array. Figure 6 As shown, the length of the private variable Array is 9, method 3 includes two code statements, and two of the nine elements included in the private variable Array are elements corresponding to the two code statements.
[0104] For method 1 in the first source code, the private variable added to method 1 is also a Boolean array Array. Figure 6 As shown, the length of the private variable Array is 9, method 1 includes five code statements, and five of the nine elements included in the private variable Array are elements corresponding to the five code statements.
[0105] 3042: Add an assignment statement corresponding to the i-th code statement in the target method, i=1, 2, 3, ..., the assignment statement is used to set the value of the element corresponding to the i-th code statement to the target value when the i-th code statement is executed, and the target value is used to indicate that the i-th code statement is executed.
[0106] In some embodiments, an assignment statement is added after the i-th code statement in the target method, and the assignment statement is located between the i-th code statement and the (i+1)-th code statement.
[0107] In some embodiments, when the data type of the private variable of the target method is an integer, the default value and the target value are two integer values, for example, the default value is 0 and the target value is 1; or, the default value is 1 and the target value is 0, etc. Or,
[0108] When the data type of the private variable of the target method is character type, the default value and the target value are two characters, for example, the default value is a and the target value is b; or, the default value is c and the target value is d, etc. Or,
[0109] When the data type of the private variable of the target method is Boolean, the default value and the target value are two Boolean values, for example, the default value is false and the target value is true; or, the default value is true and the target value is false, etc.
[0110] In some embodiments, the assignment statement is used to set the value of the j-th element of the private variable of the target method to the target value, where j is obtained based on the ith code statement, and the j-th element is the element corresponding to the ith code statement.
[0111] In some embodiments, the number of elements included in the private variables of the target method is equal to the number of code statements included in the target method, i=j, that is, the element corresponding to the i-th code statement in the target method is the i-th element of the private variable in the target method.
[0112] In some embodiments, the number of elements included in the private variables of the target method is equal to the number of code statements included in the first target class to which the target method belongs. j is determined based on i, the order of the target method in the first target class, the identification information of the start code statement and the identification information of the end code statement of the target method, where j is the actual serial number of the i-th code statement in the target method in the first target class, that is, the i-th code statement in the target method is actually the j-th code statement in the first target class, and the element corresponding to the i-th code statement in the target method is the j-th element of the private variable in the target method.
[0113] In some embodiments, each method included in the first target class is stored in the same storage area in the memory of the first test device, but the methods included in the first target class are stored in a disordered order in the storage area. The i-th code statement in the target method is actually the j-th code statement stored in the storage area, and the element corresponding to the i-th code statement in the target method is the j-th element of the private variable in the target method.
[0114] For example, see Figure 5 , the three methods included in the first target class are stored in the same storage area in the memory of the first test device, and the storage order of the three methods in the storage area is method 2, method 3 and method 1. Method 2 includes two code statements, see Figure 6 , the first code statement is the first code statement saved in the storage area, assignment statement 1 is added after the first code statement, and assignment statement 1 is used to set the value of the first element included in the private variable of method 2 to the target value "true". The second code statement is the second code statement saved in the storage area, assignment statement 2 is added after the second code statement, and assignment statement 2 is used to set the value of the second element included in the private variable of method 2 to the target value "true".
[0115] Still see Figure 6 , method 3 includes two code statements. The first code statement is the third code statement stored in the storage area. After the first code statement, assignment statement 3 is added. Assignment statement 3 is used to set the value of the third element included in the private variable of method 3 to the target value "true". The second code statement is the fourth code statement stored in the storage area. After the second code statement, assignment statement 4 is added. Assignment statement 4 is used to set the value of the fourth element included in the private variable of method 3 to the target value "true".
[0116] See also Figure 6 Method 1 includes five code statements. The i-th code statement is the i+4-th code statement saved in the storage area, that is, j=i+4, i=1, 2, 3, 4, 5. An assignment statement is added after the i-th code statement. The assignment statement is used to set the value of the i+4-th element included in the private variable of Method 1 to the target value "true".
[0117] For any code statement in the first source code, when the code statement is executed, the assignment statement following the code statement will also be executed.
[0118] In some embodiments, since the first test device immediately adds private variables to the at least one first method upon receiving the code coverage request, the time when the code coverage request is received is substantially the same as the time when private variables are started to be added to the at least one first method.
[0119] In some embodiments, when the first test device receives a code coverage request (or adds a private variable to the at least one first method), the first test device is executing the second method in the first source code, and obtains thread stack frame information of the second method, the thread stack frame information is used to record the execution status of each code statement in the second method, and determines the executed code statement in the second method based on the thread stack frame information.
[0120] When the first test device executes the second method, it records the thread stack frame information of the second method. Optionally, the thread stack frame information includes identification information of the code statements executed in the second method and / or identification information of the code statements not executed in the second method. After the first test device executes the second method, the first test device obtains the thread stack frame information of the second method, and determines the code statements executed in the second method based on the thread stack frame information.
[0121] In some embodiments, when the first test device receives a code coverage request (or adds a private variable to the at least one first method), the first test device has executed one or more static code blocks in the first source code. For ease of explanation, the static code block that has been executed by the first test device is referred to as the first static code block. When the first test device executes the first static code block, it executes each code statement in the first static code block. In this way, when the first test device receives a code coverage request, it determines that each code statement in the first static code block is executed.
[0122] In some embodiments, when the first test device receives a code coverage request (or adds a private variable to the at least one first method), the first test device has executed one or more classes in the first source code, some of which may include a constructor, and some of which may include multiple constructors. For ease of explanation, the class including a constructor is referred to as the second target class, and when the first test device executes the second target class, it executes each code statement in the constructor included in the second target class. In this way, when the first test device receives a code coverage request, it determines that each code statement included in the constructor in the second target class is executed.
[0123] For a class including multiple constructors, the first test device may execute some of the constructors in the class when executing the class. Therefore, for the executed class including multiple constructors, the first test device cannot determine which constructors in the class are executed.
[0124] In some embodiments, after loading the first source code into the at least one test device, the pipeline device further sends the at least one test case to the test management device, and the test management device receives the at least one test case. Then, the test management device can schedule the at least one test device, send the first test case to the at least one test device, and the at least one test device uses the first test case to test the first source code, and the at least one test case includes the first test case.
[0125] In some embodiments, after the pipeline device loads the first source code into the at least one test device, it sends a first test case to the at least one test device, and the at least one test device tests the first source code using the first test case, and the at least one test case includes the first test case.
[0126] Among them, for the process of the above steps 301-304, in this process, the code coverage device subscribes to the test service on the pipeline device, and the pipeline device notifies the code coverage device when starting the test of the first source code using the test service, and the code coverage device sends a code coverage request to the at least one test device. The first test device adds a private variable to the method included in the first source code when receiving the code coverage request. Optionally, the time required for this process is relatively short, and the process may be completed before the first test device receives the first test case, that is, the first test device has completed step 304 when receiving the first test case and using the first test case to test the first source code. Alternatively, the process may be completed after the first test device receives the first test case, but because the time required for this process is relatively short, the first test device has completed step 304 in a very short time when it starts to use the first test case to test the first source code.
[0127] Step 305: After the first test device completes testing the first source code using the first test case, the first test device obtains first code coverage information based on the private variables in the at least one first method, where the first code coverage information is used to describe the code statements executed in the at least one first method.
[0128] In step 305, the first test device determines the executed code statements and / or unexecuted code statements in each first method based on the values of each element included in the private variable in each first method, and obtains first code coverage information based on the executed code statements and / or unexecuted code statements in each first method.
[0129] For each first method, and for each code statement in the first method, the value of the element corresponding to the code statement is obtained from the private variable of the first method. If the value of the element corresponding to the code statement is the target value, it indicates that the code statement is executed; or, if the value of the element corresponding to the code statement is the default value, it indicates that the code statement is not executed.
[0130] In some embodiments, the first code coverage information includes identification information of code statements that are executed in the first source code and / or identification information of code statements that are not executed in the first source code.
[0131] In some embodiments, the number of elements included in the private variable of the first method is equal to the number of code statements included in the first method, and the element corresponding to the i-th code statement in the first method is the i-th element of the private variable in the first method.
[0132] In some embodiments, the number of elements included in the private variables of the first method is equal to the number of code statements included in the first target class to which the first method belongs, the actual serial number of the ith code statement in the first method in the first target class is j, the ith code statement in the first method is actually the jth code statement in the first target class, and the element corresponding to the ith code statement in the first method is the jth element of the private variable in the first method. At this time, the values of each element included in the private variables of each first method are obtained; based on the values of each element included in the private variables of each first method, the first code coverage information is obtained. Optionally, during implementation:
[0133] Based on the first correspondence in the index file and the identification information of the first target class, each first method in the first target class is obtained. Based on the values of each element included in the private variable of each first method in the first target class, the code coverage information corresponding to the first target class is obtained. In the above manner, the code coverage information corresponding to each category in the first source code is obtained, and the code coverage information corresponding to each category in the first source code is combined into the first code coverage information.
[0134] In some embodiments, the number of elements included in the private variables of the first method is equal to the number of code statements included in the first target class to which the first method belongs. For the storage area in the memory of the first test device used to store each method included in the first target class, the i-th code statement of the first method is the j-th code statement stored in the storage area, and the element corresponding to the i-th code statement in the first method is the j-th element of the private variable in the first method. At this time, the values of each element included in the private variables of each first method are obtained; based on the values of each element included in the private variables of each first method, the order of each first method, the identification information of the starting code statement and the identification information of the ending code statement in each first method, the first code coverage information is obtained. Optionally, during implementation:
[0135] Based on the first correspondence in the index file and the identification information of the first target class, the identification information of each first method in the first target class is obtained. Based on the second correspondence in the index file and the identification information of each first method in the first target class, the order of each first method in the first target class and the identification information of the start code statement and the identification information of the end code statement of each first method in the first target class are obtained. Based on the values of each element included in the private variable of each first method in the first target class, the order of each first method in the first target class, the identification information of the start code statement and the identification information of the end code statement in each first method in the first target class, the code coverage information corresponding to the first target class is obtained. In the above manner, the code coverage information corresponding to each category in the first source code is obtained, and the code coverage information corresponding to each category in the first source code is combined into the first code coverage information.
[0136] In some embodiments, the first code coverage information is also used to describe the code statements executed in the second method. And / or, the first code coverage information is also used to describe each code statement in the first static code block. And / or, the first code coverage information is also used to describe each code statement in the construction method of the second target class.
[0137] Step 306: The first test device sends first code coverage information to the code coverage device.
[0138] In some embodiments, the at least one test device includes a test device, which is a first test device. The first test device uses a first test case to test the entire first source code. The first code coverage information is the overall code coverage information corresponding to the first source code. The first code coverage information is also the overall code coverage information corresponding to the first test case.
[0139] In some embodiments, the at least one test device includes multiple test devices, each of the multiple test devices tests a portion of the content in the first source code, that is, the first test device tests a portion of the content in the first source code, and the first code coverage information is used to describe the code statements executed in the portion of the content. Other test devices also obtain code coverage information corresponding to the portion of the content they test, just like the first test device. For example, the second test device obtains second code coverage information, and the second code coverage information is used to describe the code statements executed in the portion of the content tested by the second test device, and sends the second code coverage information to the code coverage device. The first code coverage information and the second code coverage information are also code coverage information corresponding to the first test case.
[0140] In some embodiments, after testing the first source code using the first test case, the pipeline device may also send a second test case to the at least one test device, or the test management device may also send a second test case to the at least one test device, and the second test case is a test case in the at least one test case other than the first test case.
[0141] That is, when the first test device receives the second test case, it uses the second test case to test the first source code, that is, it uses the second test case to execute the first source code. When the first source code is tested using the second test case, the third code coverage information is obtained based on the private variables in each method included in the first source code, and the third code coverage information is used to describe the executed code statements in the first source code; and the third code coverage information is sent to the code coverage device.
[0142] Step 307: The code coverage device receives the first code coverage information, and displays a first code coverage result based on the first code coverage information, where the first code coverage result includes a code coverage rate of the first source code.
[0143] If the at least one test device includes multiple test devices, the first test device tests part of the first source code, and the first code coverage information is used to describe the code statements executed in the part. The code coverage device receives the code coverage information sent by the multiple test devices, and obtains the overall code coverage information corresponding to the first source code based on the code coverage information sent by the multiple test devices. If the at least one test device includes one test device, and the one test device is the first test device, the first test device tests the entire first source code, and the first code coverage information sent by the first test device is the overall code coverage information corresponding to the first source code.
[0144] The code coverage device displays a first code coverage result based on the overall code coverage information, where the first code coverage result includes a code coverage rate of the first source code.
[0145] See also Figure 7 For other source codes in the code warehouse, after the pipeline platform uses the at least one test device to test the first source code, it obtains the second source code from the other source codes in the code warehouse, loads the second source code into the at least one test device, and uses the at least one test device to test the second source code. In this way, the source codes in the code warehouse can be tested one by one, forming a pipeline test mode.
[0146] In some embodiments, the code coverage device further obtains code coverage information corresponding to the difference between the second source code and the first source code based on the change information and the overall code coverage information, the first source code and the second source code are source codes of two versions of the first service, and the version of the second source code is earlier than the version of the first source code. Based on the code coverage information corresponding to the difference, the code coverage result of the difference includes the code coverage rate of the difference.
[0147] The change information is the change information included in the pipeline details information of the first source code. The pipeline details information of the first source code also includes the storage address of the first source code in the code warehouse. In this way, the code coverage device obtains the first source code from the code warehouse based on the storage address of the first source code. Based on the change information and the first source code, the identification information of the start code statement and the identification information of the end code statement of the difference part are obtained.
[0148] Based on the overall code coverage information corresponding to the first source code, the identification information of the start code statement and the identification information of the end code statement of the difference part, the code coverage information corresponding to the difference part between the second source code and the first source code is obtained. Based on the code coverage information corresponding to the difference part, the code coverage result of the difference part is displayed, and the code coverage result of the difference part includes the code coverage rate of the difference part.
[0149] In some embodiments, the code coverage device may display code coverage information corresponding to the difference between the second source code and the first source code, and / or the entire code coverage information corresponding to the first source code.
[0150] In some embodiments, the code coverage device obtains the difference part based on the change information and the first source code. Obtain at least one component included in the difference part. Obtain code coverage information corresponding to each component based on the code coverage information corresponding to the difference part, and the code coverage information corresponding to the component is used to describe the code statements executed in the component. Display the code coverage result of each component based on the code coverage information corresponding to each component, and the code coverage result of the component includes the code coverage rate of the component.
[0151] Optionally, an abstract syntax tree (AST) of the difference part is generated based on the difference part. At least one component included in the difference part is obtained based on the AST of the difference part.
[0152] The at least one component includes one or more of the following: at least one branch in the difference portion, at least one method in the difference portion, or at least one class in the difference portion.
[0153] In some embodiments, the code coverage device may display the code coverage information corresponding to each component.
[0154] In some embodiments, the code coverage device obtains at least one component included in the first source code, obtains code coverage information corresponding to each component included in the first source code based on the overall code coverage information, and displays code coverage results for each component included in the first source code based on the code coverage information corresponding to each component included in the first source code.
[0155] In some embodiments, the overall code coverage information corresponding to the first source code is the overall code coverage information corresponding to the first test case. The at least one test device also sends the code coverage information corresponding to the second test case to the code coverage device, that is, the code coverage device will continue to obtain the overall code coverage information corresponding to the second test case. The code coverage device can obtain the overall code coverage information corresponding to different test cases.
[0156] In some embodiments, when the code coverage information includes identification information of at least one test case, the at least one test device sends the code coverage information corresponding to each test case in the at least one test case to the code coverage device. Based on the code coverage information corresponding to each test case, a second code coverage result is displayed, and the second code coverage result includes the code coverage rate when the first source code executes each test case.
[0157] In some embodiments, the code coverage information may be displayed at the granularity of test cases, that is, the overall code coverage information corresponding to different test cases may be displayed.
[0158] The first source code is the source code of the first service. The overall code coverage information corresponding to the first source code can also be referred to as the overall code coverage information corresponding to the first service.
[0159] The code repository may also include source code of other services, and the overall code coverage information corresponding to other services can be obtained through the process of steps 301-307 above.
[0160] Multiple services in the code warehouse can be divided into at least one service group, each service group includes one or more services. For each service group, after obtaining the overall code coverage information corresponding to each service in the service group, the overall code coverage information corresponding to the service group is obtained based on the overall code coverage information corresponding to each service in the service group. The code coverage rate corresponding to the service group is displayed based on the overall code coverage information corresponding to the service group. Optionally, the overall code coverage information corresponding to the service group can be displayed.
[0161] The services in the at least one service group may belong to a cloud service. Optionally, each service in the at least one service group is a microservice in the cloud service. Based on the overall code coverage information corresponding to each service group in the cloud service, the overall code coverage information corresponding to the cloud service is obtained. Based on the overall code coverage information corresponding to the cloud service, the code coverage rate corresponding to the cloud service is displayed. Optionally, the overall code coverage information corresponding to the cloud service can be displayed.
[0162] The code coverage device uses different granularities to display code coverage or code coverage information, which can meet the user's display needs for different granularities.
[0163] In an embodiment of the present application, after the pipeline device loads the first source code into the memory of the first test device, the first test device receives a code coverage request sent by the code coverage device. Based on the code coverage request, a private variable is added to the method included in the first source code, and the private variable includes an element corresponding to each code statement in the method. For each code statement in the method, an assignment statement is added after the code statement, and the assignment statement is used to set the value of the element corresponding to the code statement to a target value when the code statement is executed, and the target value is used to indicate that the code statement is executed. After the first source code is tested, the first code coverage information can be obtained based on the private variables of each method in the first source code. In this way, after the first source code has been started on the first test device, variables and assignment statements can be added to the first source code, and there is no need to add variables and assignment statements while loading the first source code to the first test device. In this way, there is no need to modify the command to start testing the first source code, and the user can not perceive the acquisition process of the code coverage information, and the code coverage information can be automatically acquired, thereby reducing labor costs, reducing the cost of maintaining the code testing platform, and increasing the flexibility of users using the automated code testing platform.
[0164] See also Figure 8 The embodiment of the present application provides a device 800 for processing source code, wherein the device 800 is deployed in Figure 1 or Figure 2 The code testing platform 100 shown, or the device 800 is deployed in Figure 3 The code testing platform of the method 300 is shown. The device 800 is used to test the first source code using the first test case, and the device 800 includes:
[0165] The receiving unit 801 is used to receive an instruction for starting a code test, where the instruction for starting a code test is used to instruct the apparatus 800 to start a test on a first source code;
[0166] A processing unit 802 is configured to add a private variable to at least one first method included in the first source code, where the at least one first method is a method that is not executed in the first source code, and the private variable in the first method is used to record the execution status of each code statement in the first method when the first method is executed;
[0167] The processing unit 802 is further configured to obtain first code coverage information based on the private variables in the at least one first method after testing the first source code using the first test case, where the first code coverage information is used to describe the execution status of the code statements in the at least one first method;
[0168] The processing unit 802 is further configured to display a first code coverage result based on the first code coverage information, where the first code coverage result includes a code coverage rate of the first source code.
[0169] Optionally, the detailed implementation process of the receiving unit 801 receiving the instruction for the boot code test is shown in Figure 3 The relevant contents of step 301 of the method 300 are not described in detail here.
[0170] Optionally, the detailed implementation process of the processing unit 802 adding a private variable to at least one first method included in the first source code is shown in Figure 3 The relevant contents of step 304 of the method 300 are not described in detail here.
[0171] Optionally, the detailed implementation process of the processing unit 802 obtaining the first code coverage information based on the private variable in the at least one first method can be found in Figure 3 The relevant contents of step 305 of the method 300 are not described in detail here.
[0172] Optionally, the detailed implementation process of the processing unit 802 obtaining the first code coverage information based on the private variable in the at least one first method can be found in Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0173] Optionally, the first source code further includes a second method, and the second method is a method being executed when a private variable is added to the at least one first method. The processing unit 802 is further configured to:
[0174] Obtaining thread stack frame information of the second method, where the thread stack frame information is used to record the execution status of each code statement in the second method;
[0175] The code statements executed in the second method are determined based on the thread stack frame information, and the first code coverage information is also used to describe the execution status of the code statements in the second method.
[0176] Optionally, the detailed implementation process of the processing unit 802 obtaining the thread stack frame information of the second method can be found in Figure 3 The relevant contents of step 3042 of the method 300 are not described in detail here.
[0177] Optionally, the processing unit 802 determines the detailed implementation process of the code statement executed in the second method based on the thread stack frame information. Figure 3 The relevant contents of step 3042 of the method 300 are not described in detail here.
[0178] Optionally, the first code coverage information is also used to describe the execution status of each code statement in the first static code block, where the first static code block is a static code block that has been executed in the first source code before private variables are added in the at least one first method, and each code statement in the first static code block is executed.
[0179] Optionally, the first code coverage information is also used to describe the execution status of each code statement in the constructor of the target class, the target class being a class including a constructor that has been executed in the first source code before private variables are added to the at least one first method, and each code statement in the constructor of the target class is executed.
[0180] Optionally, the private variable of the first method includes an element corresponding to each code statement in the first method, and the processing unit 802 is further configured to:
[0181] Add an assignment statement corresponding to the i-th code statement in the first method, i=1, 2, 3, ..., the assignment statement is used to set the value of the element corresponding to the i-th code statement to the target value when the i-th code statement is executed, and the target value is used to indicate that the i-th code statement is executed.
[0182] Optionally, the processing unit 802 adds an assignment statement corresponding to the i-th code statement in the first method. Figure 3 The relevant contents of step 3042 of the method 300 are not described in detail here.
[0183] Optionally, the first code coverage information includes identification information of a code statement executed in at least one first method, and the processing unit 802 is configured to:
[0184] Acquire the order of each first method in the first source code and identification information of a start code statement and identification information of an end code statement in each first method;
[0185] Get the value of each element included in the private variable of each first method;
[0186] Based on the values of each element included in the private variable of each first method, the order of each first method, and the identification information of the start code statement and the identification information of the end code statement in each first method, the first code coverage information is obtained.
[0187] Optionally, the detailed implementation process of the processing unit 802 obtaining the order of each first method in the first source code and the identification information of the start code statement and the end code statement in each first method can be found in Figure 3 The relevant contents of step 305 of the method 300 are not described in detail here.
[0188] Optionally, the detailed implementation process of the processing unit 802 obtaining the value of each element included in the private variable of each first method can be found in Figure 3 The relevant contents of step 305 of the method 300 are not described in detail here.
[0189] Optionally, the detailed implementation process of the processing unit 802 obtaining the first code coverage information is shown in Figure 3 The relevant contents of step 305 of the method 300 are not described in detail here.
[0190] Optionally, the apparatus 800 further includes a first test device and a second test device, the first source code includes a first part and a second part, the first test device is used to test the first part using a first test case, the second test device is used to test the second part using the first test case, the first code coverage information is used to describe the execution status of the code statements in the first part, and the processing unit 802 is further used to:
[0191] adding a second private variable in at least one third method included in the first source code in the second test device, where the at least one third method is a method that is not executed in the first source code in the second test device;
[0192] When the second test device completes testing the first source code using the first test case, second code coverage information is obtained based on the private variables in the third method included in the second part, where the second code coverage information is used to describe the execution status of the code statements in the second part;
[0193] Acquire overall code coverage information corresponding to the first source code based on the first code coverage information and the second code coverage information;
[0194] Based on the overall code coverage information, a first code coverage result is displayed.
[0195] Optionally, the processing unit 802 adds a second private variable to at least one third method included in the first source code in the second test device. Figure 3The relevant contents of step 304 of the method 300 are not described in detail here.
[0196] Optionally, the detailed implementation process of the processing unit 802 obtaining the second code coverage information is shown in Figure 3 The relevant contents of step 306 of the method 300 are not described in detail here.
[0197] Optionally, the detailed implementation process of the processing unit 802 obtaining the overall code coverage information corresponding to the first source code can be found in Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0198] Optionally, the detailed implementation process of the processing unit 802 displaying the first code coverage result is shown in Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0199] Optionally, the processing unit 802 is further configured to add a private variable to a method other than the at least one first method in the first source code.
[0200] Optionally, the code coverage rate included in the first code coverage result is the code coverage rate when the first source code executes the first test case, the apparatus 800 is further configured to test the first source code using the second test case after testing the first source code using the first test case, and the processing unit 802 is further configured to:
[0201] After the first source code is tested using the second test case, third code coverage information is obtained based on private variables in each method included in the first source code, where the third code coverage information is used to describe the execution status of code statements in the first source code;
[0202] Based on the first code coverage information and the third code coverage information, a second code coverage result is displayed, where the second code coverage result includes code coverage when the first source code executes the first test case and the second test case.
[0203] Optionally, the detailed implementation process of the processing unit 802 obtaining the third code coverage information is shown in Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0204] Optionally, the detailed implementation process of the processing unit 802 displaying the second code coverage result is shown in Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0205] Optionally, the processing unit 802 is further configured to:
[0206] Obtaining change information, where the change information is used to describe a difference between a second source code and a first source code, where the first source code and the second source code are two versions of source code for the same service, and the version of the second source code is earlier than the version of the first source code;
[0207] Acquire code coverage information corresponding to the difference part based on the change information and the first code coverage information, where the code coverage information corresponding to the difference part is used to describe the execution status of the code statements in the difference part;
[0208] The code coverage result of the difference part is displayed based on the code coverage information corresponding to the difference part, and the code coverage result of the difference part includes the code coverage rate of the difference part.
[0209] Optionally, the detailed implementation process of the processing unit 802 obtaining the change information can be found in Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0210] Optionally, the detailed implementation process of the processing unit 802 obtaining the code coverage information corresponding to the difference part can be found in Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0211] Optionally, the processing unit 802 displays the code coverage result of the difference part for a detailed implementation process. Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0212] Optionally, the processing unit 802 is further configured to:
[0213] Acquire at least one component included in the difference portion;
[0214] For each component, based on the code coverage information corresponding to the difference part, the code coverage information corresponding to the component is obtained, where the code coverage information corresponding to the component is used to describe the execution status of the code statements in the component;
[0215] The code coverage result of the component is displayed based on the code coverage information corresponding to the component, and the code coverage result of the component includes the code coverage rate of the component.
[0216] Optionally, the detailed implementation process of the processing unit 802 obtaining at least one component included in the difference part is as follows: Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0217] Optionally, the detailed implementation process of the processing unit 802 obtaining the code coverage information corresponding to the component can be found in Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0218] Optionally, the detailed implementation process of the processing unit 802 displaying the code coverage result of the component is shown in Figure 3 The relevant contents of step 307 of the method 300 are not described in detail here.
[0219] Optionally, the at least one component includes one or more of the following: at least one branch in the difference portion, at least one method in the difference portion, or at least one class in the difference portion.
[0220] The processing unit 802 and the receiving unit 801 may be implemented by software or hardware. For example, the implementation of the processing unit 802 is described below by taking the processing unit 802 as an example. Similarly, the implementation of the receiving unit 801 may refer to the implementation of the processing unit 802.
[0221] As an example of a software functional unit, the processing unit 802 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the processing unit 802 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple data centers with similar geographical locations. Among them, usually a region may include multiple AZs.
[0222] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0223] As an example of a hardware functional unit, the processing unit 802 may include at least one computing device, such as a server, etc. Alternatively, the processing unit 802 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0224] The multiple computing devices included in the processing unit 802 can be distributed in the same region or in different regions. The multiple computing devices included in the processing unit 802 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the processing unit 802 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0225] It should be noted that, in other embodiments, the processing unit 802 may be used to execute any step in the method provided in any of the above embodiments, and the receiving unit 801 may be used to execute any receiving step in the method provided in any of the above embodiments. The steps that the processing unit 802 and the receiving unit 801 are responsible for implementing may be specified as needed, and the processing unit 802 and the receiving unit 801 respectively implement different steps in the method provided in any of the above embodiments to implement all functions of the device 800 for processing source code.
[0226] In an embodiment of the present application, when the receiving unit receives an instruction to start code testing, the processing unit starts testing the first source code. After starting the test of the first source code, the processing unit adds a private variable to at least one first method that is not executed in the first source code. When the first source code is tested using the first test case, the processing unit obtains first code coverage information based on the private variables in the at least one first method, and displays the code coverage of the first source code based on the first code coverage information. Since the processing unit adds private variables to the at least one first method that is not executed after starting the test of the first source code, there is no need to modify the instruction to start code testing. After starting the test of the first source code, private variables are automatically added to the unexecuted method in the first source code, and the user does not perceive the entire process of obtaining the first code coverage information. Thereby, the code coverage rate is automatically obtained, the cost is saved, the cost of maintaining the code testing platform is reduced, and the flexibility of users using the automated code testing platform is increased.
[0227] See also Fig. 9 , the present application embodiment provides a computing device 900. For example, the computing device 900 may be Figure 1 or Figure 2 The code shown in the test platform 100 is either Figure 3 The illustrated method 300 is applied to a computing device in a code testing platform.
[0228] like Fig. 9 As shown, the computing device 900 includes: a bus 902, a processor 904, a memory 906, and a communication interface 908. The processor 904, the memory 906, and the communication interface 908 communicate through the bus 902. The computing device 900 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 900.
[0229] The bus 902 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 The bus 904 is represented by only one line, but does not mean that there is only one bus or one type of bus. The bus 904 may include a path for transmitting information between various components of the computing device 900 (eg, the memory 906, the processor 904, and the communication interface 908).
[0230] The processor 904 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0231] The memory 906 may include a volatile memory, such as a random access memory (RAM). The processor 904 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0232] See also Fig. 9 , the memory 906 stores executable program codes, and the processor 904 executes the executable program codes to respectively implement Figure 8 The functions of the receiving unit 801 and the processing unit 802 in the device 800 shown in the figure are implemented to realize the method provided by any of the above embodiments. That is, the memory 906 stores instructions for executing the method provided by any of the above embodiments. Or,
[0233] The communication interface 908 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 900 and other devices or communication networks.
[0234] The embodiment of the present application also provides a cluster for processing source code. The cluster for processing source code includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0235] like Fig.10 As shown, the cluster for processing source code includes at least one computing device 900. The memory 906 in one or more computing devices 900 in the cluster for processing source code may store the same instructions for executing the method provided by any of the above embodiments.
[0236] In some possible implementations, the memory 906 of one or more computing devices 900 in the source code processing cluster may also store partial instructions for executing the above-mentioned method for processing source code. In other words, the combination of one or more computing devices 900 can jointly execute instructions for executing the method provided in any of the above-mentioned embodiments.
[0237] In some possible implementations, one or more computing devices in a cluster processing source code may be connected via a network, which may be a wide area network or a local area network. Fig.11 A possible implementation is shown. Fig.11 As shown, two computing devices 900A and 900B are connected via a network. Specifically, they are connected to the network via a communication interface in each computing device.
[0238] In this type of possible implementation, the memory 906 in the computing device 900A stores the execution Figure 8 Instructions for the functions of the processing unit 802 in the illustrated embodiment. Meanwhile, the memory 906 in the computing device 900B stores instructions for executing the functions of the processing unit 802 in the illustrated embodiment. Figure 8 Instructions for the functionality of the receiving unit 801 in the illustrated embodiment.
[0239] It should be understood that Fig.11 The functions of the computing device 900A shown in FIG. 9A may also be completed by multiple computing devices 900. Similarly, the functions of the computing device 900B may also be completed by multiple computing devices 900.
[0240] The present application embodiment also provides another cluster for processing source code. The connection relationship between the computing devices in the cluster for processing data can be similarly referred to as Fig.11 The connection mode of the cluster for processing source code is different in that the memory 906 in one or more computing devices 900 in the cluster for processing source code may store the same instructions for executing the method provided in any of the above embodiments.
[0241] In some possible implementations, the memory 906 of one or more computing devices 900 in the cluster processing source code may also store partial instructions for executing the method provided in any of the above embodiments. In other words, a combination of one or more computing devices 900 may jointly execute instructions for executing the method provided in any of the above embodiments.
[0242] The present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the method provided in any of the above embodiments.
[0243] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the method provided in any of the above embodiments.
[0244] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0245] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for processing source code, It is characterized in that The method is applied to a code testing platform, the code testing platform is used to test a first source code using a first test case, and the method includes: receiving an instruction for starting a code test, wherein the instruction for starting a code test is used to instruct the code testing platform to start a test on the first source code; adding a private variable to at least one first method included in the first source code, wherein the at least one first method is a method that is not executed in the first source code, and the private variable in the first method is used to record the execution status of each code statement in the first method when the first method is executed; After testing the first source code using the first test case, first code coverage information is obtained based on the private variables in the at least one first method, where the first code coverage information is used to describe the execution status of code statements in the at least one first method; Based on the first code coverage information, a first code coverage result is displayed, where the first code coverage result includes a code coverage rate of the first source code.
2. The method according to claim 1, It is characterized in that The first source code further includes a second method, which is a method being executed when the private variable is added in the at least one first method, and the method further includes: Obtaining thread stack frame information of the second method, where the thread stack frame information is used to record the execution status of each code statement in the second method; The code statements executed in the second method are determined based on the thread stack frame information, and the first code coverage information is also used to describe the execution status of the code statements in the second method.
3. The method according to claim 1 or 2, It is characterized in that The first code coverage information is also used to describe the execution status of each code statement in the first static code block, where the first static code block is a static code block that has been executed in the first source code before the private variable is added in the at least one first method, and each code statement in the first static code block is executed.
4. The method according to any one of claims 1 to 3, It is characterized in that The first code coverage information is also used to describe the execution status of each code statement in the constructor of the target class, where the target class is a class including a constructor that has been executed in the first source code before the private variable is added to the at least one first method, and each code statement in the constructor of the target class is executed.
5. The method according to any one of claims 1 to 4, It is characterized in that The private variables of the first method include elements corresponding to each code statement in the first method, and after adding private variables to at least one first method included in the first source code, the method further includes: Add an assignment statement corresponding to the i-th code statement in the first method, i=1, 2, 3, ..., the assignment statement is used to set the value of the element corresponding to the i-th code statement to a target value when the i-th code statement is executed, and the target value is used to indicate that the i-th code statement is executed.
6. The method according to any one of claims 1 to 5, It is characterized in that The first code coverage information includes identification information of code statements executed in the at least one first method, and the method further includes: Acquire the order of each first method in the first source code and identification information of a start code statement and identification information of an end code statement in each first method; The obtaining first code coverage information based on the private variables in the at least one first method includes: Obtaining the value of each element included in the private variable of each first method; The first code coverage information is obtained based on the values of each element included in the private variable of each first method, the order of each first method, and the identification information of the start code statement and the identification information of the end code statement in each first method.
7. The method according to any one of claims 1 to 6, It is characterized in that The code testing platform includes a first testing device and a second testing device, the first source code includes a first part and a second part, the first testing device is used to test the first part using the first test case, the second testing device is used to test the second part using the first test case, the first code coverage information is used to describe the execution status of the code statements in the first part, and the method further includes: adding a second private variable in at least one third method included in the first source code in the second test device, wherein the at least one third method is a method that is not executed in the first source code in the second test device; When the second test device completes testing the first source code using the first test case, obtaining second code coverage information based on private variables in a third method included in the second part, wherein the second code coverage information is used to describe execution conditions of code statements in the second part; The displaying of the first code coverage result based on the first code coverage information includes: Acquire overall code coverage information corresponding to the first source code based on the first code coverage information and the second code coverage information; Based on the overall code coverage information, the first code coverage result is displayed.
8. The method according to any one of claims 1 to 7, It is characterized in that The method further comprises: A private variable is added to a method other than the at least one first method in the first source code.
9. The method according to claim 8, It is characterized in that The code coverage rate included in the first code coverage result is the code coverage rate when the first source code executes the first test case, the code testing platform is further used to test the first source code using a second test case after the first source code is tested using the first test case, and the method further includes: When the first source code is tested using the second test case, third code coverage information is obtained based on private variables in each method included in the first source code, where the third code coverage information is used to describe execution status of code statements in the first source code; Based on the first code coverage information and the third code coverage information, a second code coverage result is displayed, where the second code coverage result includes the code coverage rate when the first source code executes the first test case and the second test case.
10. The method according to any one of claims 1 to 9, It is characterized in that The method further comprises: Acquire change information, where the change information is used to describe a difference between a second source code and the first source code, where the first source code and the second source code are two versions of source code for the same service, and a version of the second source code is earlier than a version of the first source code; Acquire code coverage information corresponding to the difference part based on the change information and the first code coverage information, where the code coverage information corresponding to the difference part is used to describe the execution status of the code statements in the difference part; The code coverage result of the difference part is displayed based on the code coverage information corresponding to the difference part, and the code coverage result of the difference part includes the code coverage rate of the difference part.
11. The method according to claim 10, It is characterized in that The method further comprises: Acquire at least one component included in the difference portion; For each component, based on the code coverage information corresponding to the difference part, the code coverage information corresponding to the component is obtained, where the code coverage information corresponding to the component is used to describe the execution status of the code statements in the component; The code coverage result of the component is displayed based on the code coverage information corresponding to the component, and the code coverage result of the component includes the code coverage rate of the component.
12. The method according to claim 11, It is characterized in that The at least one component includes one or more of the following: at least one branch in the difference portion, at least one method in the difference portion, or at least one class in the difference portion.
13. A device for processing source code, It is characterized in that The device is used to test a first source code using a first test case, and the device includes: a receiving unit, configured to receive an instruction for starting a code test, wherein the instruction for starting a code test is used to instruct the device to start a test on the first source code; a processing unit, configured to add a private variable in at least one first method included in the first source code, wherein the at least one first method is a method that is not executed in the first source code, and the private variable in the first method is used to record the execution status of each code statement in the first method when the first method is executed; The processing unit is further configured to obtain first code coverage information based on the private variables in the at least one first method when the first source code is tested using the first test case, wherein the first code coverage information is used to describe the execution status of code statements in the at least one first method; The processing unit is further configured to display a first code coverage result based on the first code coverage information, where the first code coverage result includes a code coverage rate of the first source code.
14. The device according to claim 13, It is characterized in that The first source code further includes a second method, which is a method being executed when the private variable is added in the at least one first method, and the processing unit is further configured to: Obtaining thread stack frame information of the second method, where the thread stack frame information is used to record the execution status of each code statement in the second method; The code statements executed in the second method are determined based on the thread stack frame information, and the first code coverage information is also used to describe the execution status of the code statements in the second method.
15. The device according to claim 13 or 14, It is characterized in that The first code coverage information is also used to describe the execution status of each code statement in the first static code block, where the first static code block is a static code block that has been executed in the first source code before the private variable is added in the at least one first method, and each code statement in the first static code block is executed.
16. The device according to any one of claims 13 to 15, It is characterized in that The first code coverage information is also used to describe the execution status of each code statement in the constructor of the target class, where the target class is a class including a constructor that has been executed in the first source code before the private variable is added to the at least one first method, and each code statement in the constructor of the target class is executed.
17. The device according to any one of claims 13 to 16, It is characterized in that The private variables of the first method include elements corresponding to each code statement in the first method, and the processing unit is further used for: Add an assignment statement corresponding to the i-th code statement in the first method, i=1, 2, 3, ..., the assignment statement is used to set the value of the element corresponding to the i-th code statement to a target value when the i-th code statement is executed, and the target value is used to indicate that the i-th code statement is executed.
18. The device according to any one of claims 13 to 17, It is characterized in that The first code coverage information includes identification information of code statements executed in the at least one first method, and the processing unit is configured to: Acquire the order of each first method in the first source code and identification information of a start code statement and identification information of an end code statement in each first method; Obtaining the value of each element included in the private variable of each first method; The first code coverage information is obtained based on the values of each element included in the private variable of each first method, the order of each first method, and the identification information of the start code statement and the identification information of the end code statement in each first method.
19. The device according to any one of claims 13 to 18, It is characterized in that The apparatus further includes a first test device and a second test device, the first source code includes a first part and a second part, the first test device is used to test the first part using the first test case, the second test device is used to test the second part using the first test case, the first code coverage information is used to describe the execution status of the code statements in the first part, and the processing unit is further used to: adding a second private variable in at least one third method included in the first source code in the second test device, wherein the at least one third method is a method that is not executed in the first source code in the second test device; When the second test device completes testing the first source code using the first test case, obtaining second code coverage information based on private variables in a third method included in the second part, wherein the second code coverage information is used to describe execution conditions of code statements in the second part; Acquire overall code coverage information corresponding to the first source code based on the first code coverage information and the second code coverage information; Based on the overall code coverage information, the first code coverage result is displayed.
20. The device according to any one of claims 13 to 19, It is characterized in that The processing unit is further configured to add private variables to methods other than the at least one first method in the first source code.
21. The device according to claim 20, It is characterized in that The code coverage rate included in the first code coverage result is the code coverage rate when the first source code executes the first test case, the device is further used to test the first source code using a second test case after testing the first source code using the first test case, and the processing unit is further used to: When the first source code is tested using the second test case, third code coverage information is obtained based on private variables in each method included in the first source code, where the third code coverage information is used to describe execution status of code statements in the first source code; Based on the first code coverage information and the third code coverage information, a second code coverage result is displayed, where the second code coverage result includes the code coverage rate when the first source code executes the first test case and the second test case.
22. The device according to any one of claims 13 to 21, It is characterized in that The processing unit is further used for: Acquire change information, where the change information is used to describe a difference between a second source code and the first source code, where the first source code and the second source code are two versions of source code for the same service, and a version of the second source code is earlier than a version of the first source code; Acquire code coverage information corresponding to the difference part based on the change information and the first code coverage information, where the code coverage information corresponding to the difference part is used to describe the execution status of the code statements in the difference part; The code coverage result of the difference part is displayed based on the code coverage information corresponding to the difference part, and the code coverage result of the difference part includes the code coverage rate of the difference part.
23. The device according to claim 22, It is characterized in that The processing unit is further used for: Acquire at least one component included in the difference portion; For each component, based on the code coverage information corresponding to the difference part, the code coverage information corresponding to the component is obtained, where the code coverage information corresponding to the component is used to describe the execution status of the code statements in the component; The code coverage result of the component is displayed based on the code coverage information corresponding to the component, and the code coverage result of the component includes the code coverage rate of the component.
24. The device according to claim 23, It is characterized in that The at least one component includes one or more of the following: at least one branch in the difference portion, at least one method in the difference portion, or at least one class in the difference portion.
25. A computing device cluster, It is characterized in that The cluster includes at least one computing device, each of the at least one computing device includes at least one processor and at least one memory, and the at least one memory stores computer-readable instructions; the at least one processor executes the computer-readable instructions so that the cluster executes the method according to any one of claims 1 to 12.
26. A computer storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
27. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
