Test processing method, electronic device and storage medium
By dynamically determining the target test environment and obtaining changed applications, the problems of low accuracy of smoke test results and low resource utilization in the prior art are solved, and high-accuracy testing and efficient utilization of resources are achieved.
Patent Information
- Application Number
- CN202411846498.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-12-16
AI Technical Summary
The accuracy of the smoke test results in the prior art is not high because it cannot be guaranteed that the version of the test application is the latest version, and the resource utilization rate is low because the CI/CD process and the smoke environment are a fixed one-to-one correspondence.
By receiving the test environment deployment request sent by the pipeline, dynamically determine the target test environment, and obtain the changed applications in the target test environment through the pipeline for testing environment deployment and testing.
Ensure the accuracy of the test results, because the test is conducted for the latest version of the application, and the target testing environment is dynamically determined, which greatly improves resource utilization.
Smart Images

Figure CN119292959B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software testing technology, and in particular to a test processing method, an electronic device and a storage medium. Background Art
[0002] Continuous Integration / Continuous Delivery (CI / CD) is an important method in the field of software engineering. CI / CD can achieve fast and reliable delivery of high-quality software through automated building, testing, and deployment. Smoke testing is a testing method that can be applied in the CI / CD process to quickly verify whether there are major problems with new code. In the CI / CD process, automated building and testing are usually triggered after code integration. If the building and testing are successful, deployment is automatically performed. During the deployment process, smoke testing can be performed.
[0003] In the prior art, before smoke testing, the pipeline applies for a smoke environment, and then uses the smoke environment to perform smoke testing, wherein the smoke environment includes the application to be tested that needs to be smoke tested and the resources required for the smoke test.
[0004] However, the existing methods cannot guarantee that the version of the application under test in the smoke environment is the latest version, and thus it is difficult to guarantee the accuracy of the smoke test results. At the same time, the CI / CD process and the smoke environment in the existing technology are usually fixed one-to-one correspondence, which also leads to low resource utilization. Summary of the invention
[0005] The purpose of this application is to provide a test processing method, an electronic device and a storage medium to address the deficiencies in the above-mentioned prior art, so as to solve the problems of low accuracy of test results and low resource utilization in the prior art.
[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0007] In a first aspect, an embodiment of the present application provides a test processing method, including:
[0008] Receive a test environment deployment request sent by the pipeline, wherein the test environment deployment request includes at least: an identifier of the test environment type;
[0009] Determine the target test environment to be used according to the identification of the test environment type and the environment template corresponding to the test environment type, and obtain each change application of the target test environment through the pipeline, wherein the environment template is used to record the information of the application corresponding to the test environment type and the information of the environment resources, and the change application includes: changing the current application and changing the dependent application;
[0010] Based on each of the changed applications, deploy and start the target test environment;
[0011] Based on the target test environment, the test is executed.
[0012] In a second aspect, an embodiment of the present application provides a test processing device, including:
[0013] A receiving module, configured to receive a test environment deployment request sent by the pipeline, wherein the test environment deployment request at least includes: an identifier of a test environment type;
[0014] A determination module, configured to determine a target test environment to be used according to an identifier of the test environment type and an environment template corresponding to the test environment type, and obtain various changed applications of the target test environment through the pipeline, wherein the environment template is used to record information of the application corresponding to the test environment type and information of the environment resources, and the changed application includes: changing the current application and changing the dependent application;
[0015] A deployment module, used to deploy and start the target test environment based on each of the changed applications;
[0016] The test module is used to execute the test based on the target test environment.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the steps of the test processing method described in the first aspect above.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the test processing method described in the first aspect are executed.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program code. When the computer program code is executed by a computing device, the computing device executes the steps of the test processing method described in the first aspect above.
[0020] The test processing method, electronic device and storage medium provided by the present application, when the environment management engine receives the test environment deployment request sent by the pipeline, does not use a fixed test environment, but uses the identifier of the requested test environment type and the environment template corresponding to the test environment type to dynamically determine the target test environment to be used, and then obtains the changed application in the target test environment through the pipeline, and performs test environment deployment and testing. This ensures that subsequent tests are performed on the latest version of the application, thereby ensuring the accuracy of the test results. In addition, by dynamically determining the target test environment, each test environment in the cluster can be used by different pipelines, thereby greatly improving resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 This is an example diagram of an application of a smoke environment in the prior art;
[0023] Figure 2 A schematic diagram of the system architecture of the test processing method provided in the embodiment of the present application;
[0024] Figure 3 A flow chart of a test processing method provided in an embodiment of the present application;
[0025] Figure 4 Another schematic diagram of a test processing method provided in an embodiment of the present application;
[0026] Figure 5 Another schematic diagram of a test processing method provided in an embodiment of the present application;
[0027] Figure 6 A schematic diagram of a process for obtaining and changing an application of a test processing method provided in an embodiment of the present application;
[0028] Figure 7 A flow chart of the deployment and start-up of the target test environment of the test processing method provided in the embodiment of the present application;
[0029] Figure 8 A schematic diagram of a test execution flow of a test processing method provided in an embodiment of the present application;
[0030] Fig. 9 A schematic diagram of deploying a test environment and executing a test based on the method of an embodiment of the present application;
[0031] Fig.10 A module structure diagram of a test processing device provided in an embodiment of the present application;
[0032] Fig.11 A schematic diagram of the structure of an electronic device 110 provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0034] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0035] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0036] In the prior art, before the smoke test, the pipeline applies for a smoke environment, and then uses the smoke environment to perform the smoke test. Specifically, the image warehouse stores all applications involved in each software project, wherein the application involved in the software project refers to the executable application package obtained after compiling and building the source code of the software project. The image warehouse regularly updates the applications of each software project according to a certain update strategy. On this basis, the pipeline can be triggered to pull the application of the image warehouse into the smoke environment, or the application of the image warehouse can be pulled into the smoke environment regularly. Taking the pipeline triggering method as an example, when the pipeline applies for a smoke environment for a software project, the application of the software project is pulled from the image warehouse, and the smoke environment is updated or created in the cluster for subsequent smoke testing. In addition, in the prior art, the CI / CD process and the smoke environment are usually fixed one-to-one correspondence, and a smoke environment is only used by the pipeline of the CI / CD process corresponding to the smoke environment. Figure 1 This is an example diagram of an application of a smoke environment in the prior art, such as Figure 1 As shown, CI pipeline A can request the smoke environment of software project 1, and deployment pipeline A can regularly upgrade the smoke environment of software project 1. Pipeline B can request the smoke environment of software project 2. Pipeline C can request the smoke environment of software project 3. That is, there is a fixed one-to-one correspondence between the smoke environment and the CI / CD process.
[0037] However, the above method has the following problems:
[0038] First, the image warehouse regularly updates the application of the software project according to a certain update strategy. If the application of the software project changes between the time when the image warehouse updates the application of the software project and the time when the smoke environment is applied, the application in the image warehouse is no longer the latest version of the application. Correspondingly, the application in the smoke environment applied by the pipeline is not the latest version of the application. This will cause the subsequent smoke test to not be performed on the latest version of the application, and it is difficult to ensure the accuracy of the smoke test results. For example, for software project A, the image warehouse updates the application of software project A at 1 am every day. If an application of software project A changes at 12 noon on the same day, and the pipeline applies for the smoke environment at 3 pm on the same day, the version of the application in the smoke environment applied at this time is the version updated by the image warehouse at 1 am on that day, rather than the latest version after the change at 12 noon.
[0039] Second, a smoking environment is only used by the pipeline of the CI / CD process corresponding to the smoking environment. When the corresponding pipeline does not use the smoking environment, the smoking environment is idle and cannot be used by other pipelines, which will result in low resource utilization.
[0040] Based on the above problems, the embodiment of the present application proposes a test processing method. After receiving the test environment deployment request sent by the pipeline, the fixed smoking environment is no longer used. Instead, the identifier of the requested test environment type and the environment template corresponding to the test environment type are used to dynamically determine the target test environment to be used, and then the changed application in the target test environment can be obtained through the pipeline, and then the test environment can be deployed and the test can be executed. This ensures that the subsequent tests are performed on the latest version of the application, thereby ensuring the accuracy of the test results. In addition, by dynamically determining the target test environment, resource utilization can be greatly improved.
[0041] The embodiments of the present application can be applied to test scenarios such as smoke testing, interface testing, integration testing, system testing, user acceptance testing (User Acceptance Test, referred to as UAT), regression testing, and performance testing. To facilitate the description of the technical solution of the present application, the following embodiments of the present application are described by taking the application in the smoke test scenario as an example. However, it should be understood that this is not a limitation of the technical solution of the present application.
[0042] Figure 2 A schematic diagram of the system architecture of the test processing method provided in the embodiment of the present application, such as Figure 2 As shown, the method involves a pipeline, an environment management engine, a cluster, and an image repository. Among them, the pipeline can be a service that runs to implement the CI / CD process, and a pipeline can implement one or more functions in the CI / CD process. In an embodiment of the present application, the pipeline sends various requests to the environment management engine to trigger the deployment and startup of the test environment, as well as to trigger subsequent tests. The environment management engine communicates with the cluster and the pipeline respectively. The environment management engine uses the method of the embodiment of the present application to communicate with the cluster and the pipeline to complete the deployment and startup of the test environment and subsequent tests. Various resources are deployed in the cluster, such as a central processing unit (CPU for short), etc. Using these resources, the environment management engine can create, deploy, and start the test environment in the cluster. The image warehouse includes images, and the images include the applications of software projects. The image warehouse regularly updates the applications of software projects in the images according to a certain update strategy. The cluster can accordingly regularly update the images in the image warehouse to the corresponding test environment in the cluster according to a certain update strategy, or, after the environment management engine receives the test environment deployment request sent by the pipeline, the environment management engine pulls the image from the image warehouse to create a test environment. By updating or pulling the image to the test environment, the application of the software project in the image is correspondingly updated or pulled to the test environment.
[0043] Figure 3The flowchart of the test processing method provided in the embodiment of the present application is shown in FIG. 1 , which can be applied in the above-mentioned environment management engine. Figure 3 As shown, the method includes:
[0044] S301: Receive a test environment deployment request sent by a pipeline, where the test environment deployment request at least includes: an identifier of a test environment type.
[0045] Exemplarily, the test environment deployment request may be a smoking environment deployment request, which is used to request the deployment of a smoking environment in a cluster. The test environment type may indicate a software project applied by the test environment. The test environment type may be, for example, a smoking environment type.
[0046] Exemplarily, before performing a smoke test, a pipeline involved in the CI / CD process sends the above-mentioned smoking environment deployment request to the environment management engine. The smoking environment deployment request includes at least an identifier of the smoking environment type, wherein the smoking environment type may indicate a software project to which the smoking environment is applied. The identifier of the smoking environment type may be, for example, the name of the software project.
[0047] Optionally, in addition to the identification of the smoking environment type, the above-mentioned smoking environment deployment request may also include the pipeline number, build number, node number, sequence number, and status. This information can be used as a label for the target smoking environment to be used. Based on this information, the environment management engine can obtain relevant build information of the CI / CD process and use this build information for subsequent smoke testing and other links.
[0048] S302: Determine the target test environment to be used according to the identification of the test environment type and the environment template corresponding to the test environment type, and obtain each changed application of the target test environment through the pipeline.
[0049] The environment template is used to record the application information and environment resource information corresponding to the test environment type. The application change includes: changing the current application and changing the dependent application.
[0050] Exemplarily, for each type of smoking environment, an environment template corresponding to the smoking environment type can be pre-configured. Since the smoking environment type is used to indicate the software project applied to the smoking environment, the environment template corresponding to the smoking environment type is the environment template of the software project indicated by the smoking environment type. Accordingly, the environment template can record the application information of the software project indicated by the smoking environment and the information of the environmental resources required for the software project to perform the smoke test. Among them, the application information may include, for example: the names of all applications contained in the software project itself and the names and sources of other applications that the software project needs to rely on when performing the test. The application contained in the software project is called the present application, and the application that the software project needs to rely on when performing the test is called the dependent application. The information of the environmental resources may include, for example: CPU, memory, storage quota, etc. The environment template can be pre-configured by the user. By configuring the environment template, the environment management engine can be informed of which references are contained in the software project, which applications are relied on, and which or which resources need to be used during the test.
[0051] Based on the identification of the test environment type and the environment template, the environment management engine can determine the target test environment to be used, such as the target smoke environment. The target test environment can be determined by finding an existing test environment in the cluster or creating a new test environment. The determined target test environment can meet the requirements for the test environment in the environment template.
[0052] On the basis of determining the target test environment, the environment management engine can obtain the changed application of the test environment through the pipeline. It should be understood that after determining the target test environment, the target test environment already contains the application and dependent applications, but these applications and dependent applications may not be the latest versions of the applications. Therefore, by analyzing the change files of the configuration library through the pipeline, the changed application and the changed dependent applications can be obtained, that is, the changed application and the changed dependent applications mentioned above.
[0053] S303: Based on each changed application, deploy and start the target test environment.
[0054] For example, after acquiring each changed application, each changed application can be updated to the smoking environment to replace the original old version of the application. The target smoking environment can be started by deploying and starting the application according to the changes and the pre-set startup sequence.
[0055] S304: Execute the test based on the above target test environment.
[0056] Optionally, the test can be triggered to start by the pipeline, and the environment management engine cooperates with the pipeline to complete the test using the above-mentioned target test environment.
[0057] In this embodiment, after receiving the test environment deployment request sent by the pipeline, the environment management engine does not use a fixed test environment, but uses the identifier of the requested test environment type and the environment template corresponding to the test environment type to dynamically determine the target test environment to be used, and then obtains the changed application in the target test environment through the pipeline, and performs test environment deployment and testing. This ensures that subsequent tests are performed on the latest version of the application, thereby ensuring the accuracy of the test results. In addition, by dynamically determining the target test environment, each test environment in the cluster can be used by different pipelines, thereby greatly improving resource utilization.
[0058] Figure 4 Another flow chart of the test processing method provided in the embodiment of the present application is as follows: Figure 4 As shown, an optional manner of the above step S302 includes:
[0059] S401. Determine whether there is a test environment that meets a deployment condition according to an identifier of the test environment type. The deployment condition includes: the type of the test environment is the above test environment type, and the test environment is currently available.
[0060] Exemplarily, the environment management engine can create one or more test environments for each software project in the cluster in advance according to the environment template corresponding to each software project to form a test environment resource pool corresponding to the software project. The test environment quota corresponding to each software project can be flexibly set as needed, and the number of test environments created by the environment management engine for each software project does not exceed the test environment quota corresponding to the software project.
[0061] When the environment management engine receives the test environment deployment request from the pipeline, it can first determine whether there is a test environment that meets the above deployment conditions in the cluster. If so, the following step S402 is executed to directly use the test environment that meets the deployment conditions as the target test environment. If not, the following step S403 is executed to create the target test environment according to the environment template.
[0062] Optionally, the above deployment conditions include: the type of the test environment is the above test environment type, and the test environment is currently available. The type of the test environment is the above test environment type, indicating that a test environment of the type requested by the pipeline has been created in the cluster; the test environment is currently available, indicating that the test environment is not currently used by other pipelines, and is not in an unavailable state such as being created or deleted. When a test environment in the cluster meets the above deployment conditions, it indicates that the test environment is currently available for use by the pipeline.
[0063] It is worth noting that the environment management engine will dynamically maintain the status of the test environment in real time from the moment a test environment is created. Once the status of the test environment changes, the environment management engine will update the status in a timely manner to ensure that the test environment is used correctly. For example, a test environment can include states such as being created, idle, being deleted, and being tested throughout its life cycle. When the environment management engine receives a test environment deployment request from the pipeline, it can only select a test environment in the "idle" state as the target test environment.
[0064] S402: If yes, the test environment that meets the deployment conditions is used as the target test environment.
[0065] S403: If not, create a target test environment according to the environment template.
[0066] If there is no test environment that meets the deployment conditions in the cluster, indicating that there is currently no available test environment, the environment management engine can use the environment template to create a target test environment.
[0067] S404: Obtain information about the changed source code through the above pipeline, and obtain each changed application of the target test environment according to the information about the changed source code.
[0068] As mentioned above, an application refers to an executable application package obtained after compiling and building the source code of a software project. Based on the analysis in the previous article, it can be seen that since the application is updated regularly in the image warehouse, it does not mean that the image warehouse will update the application accordingly when the source code changes. Therefore, the application in the test environment cannot be guaranteed to be the latest version of the application. In this step, the information of the changed source code is obtained through the pipeline, so that it is judged from the source location whether to update the application in the test environment. Specifically, if the source code has changed, the environment management engine obtains the information of the changed source code through the pipeline. The above-mentioned changed source code refers to the changed source code. The information of the changed source code can be, for example, the name of the changed source code. It is worth noting that the changed source code can include the changed source code of the application and the changed source code of the dependent application.
[0069] After obtaining the information of the changed source code, the environment management engine may obtain each changed application of the target test environment according to the information of the changed source code.
[0070] In this embodiment, on the one hand, by determining whether there is a test environment that meets the deployment conditions in the cluster, if it exists, the test environment is directly used, so that the same test environment can be used by different pipelines, thereby improving resource utilization. On the other hand, by obtaining information about the changed source code through the pipeline and obtaining the changed application based on it, the changed application is learned from the source, ensuring that all applications in the test environment are the latest versions.
[0071] Figure 5 Another flow chart of the test processing method provided in the embodiment of the present application is as follows: Figure 5 As shown, an optional manner of the above step S401 includes:
[0072] S501. According to an identifier of a test environment type, obtain the status of each test environment in a cluster that belongs to the test environment type.
[0073] Exemplarily, the environment management engine will dynamically maintain the state of the smoking environment in real time from the moment a smoking environment is created. Once the state of the smoking environment changes, the environment management engine will update the state in a timely manner to ensure that the smoking environment is used correctly. Exemplarily, a smoking environment may include states such as being created, idle, being deleted, and being tested during its entire life cycle.
[0074] The environment management engine can create one or more smoking environments for each smoking environment type in the cluster, and the type of each smoking environment is the smoking environment type. Accordingly, the environment management engine can obtain each smoking environment belonging to the smoking environment type in the cluster according to the identifier of the smoking environment type, and then obtain the status of each smoking environment. Exemplarily, a smoking environment type is software project A, and three smoking environments corresponding to software project A are pre-created in the cluster, namely environment 1, environment 2, and environment 3. And the types of environment 1, environment 2, and environment 3 are all software project A. Then the environment management engine can filter environment 1, environment 2, and environment 3 from the cluster according to the identifier of "software project A", and obtain the status of environment 1, environment 2, and environment 3 in real time respectively.
[0075] S502: If the status of the current test environment indicates that the current test environment is currently available, it is determined that there is a test environment that meets the above deployment conditions, and the current test environment is a test environment that meets the deployment conditions.
[0076] The current test environment is any test environment of the above test environment types.
[0077] For example, a test environment may include the states of being created, idle, being deleted, and being tested in the entire life cycle. If the state of the current test environment is idle, it indicates that the current test environment is currently available. If the state of the current test environment is other than idle, it indicates that the current test environment is currently unavailable.
[0078] If the current test environment is currently available and belongs to the test environment type requested by the pipeline, the current test environment can be used as the test environment that meets the above deployment conditions.
[0079] In this embodiment, by utilizing the status of each test environment belonging to the test environment type in the cluster, available test environments that meet the deployment conditions can be accurately screened out to ensure normal execution of subsequent tests.
[0080] As an optional implementation, the above step S403 may include:
[0081] According to the above environment template, the application corresponding to the target test environment is pulled from the image repository; according to the environment template, the environment resources of the target test environment are obtained and enabled.
[0082] As mentioned above, the environment template includes application information, which may include, for example: the names of all applications contained in the software project itself and the names and sources of other applications that the software project needs to rely on when performing tests. At the same time, the environment template also includes information about environmental resources, such as CPU, memory, storage quotas, etc. When the environment management engine needs to create a target test environment, it can first pull the application corresponding to the target test environment from the mirror environment according to the application information recorded in the environment template. For example, the environment management engine pulls the corresponding images from the mirror repository in sequence according to the name of the application and the names of the dependent applications recorded in the environment template. Secondly, the environment management engine obtains and enables the target environment resources based on the information about the environmental resources recorded in the environment template.
[0083] In this embodiment, by pre-building an environment template, the application information and environmental resource requirements of each test environment type can be recorded in the environment template, so that when creating a test environment, a test environment that meets the requirements can be created according to the environment template, thereby improving creation efficiency.
[0084] Figure 6 A flow chart of obtaining and changing the application of the test processing method provided in the embodiment of the present application is as follows: Figure 6 As shown, an optional manner of the above step S404 includes:
[0085] S601, receiving source code change information sent by the pipeline.
[0086] Optionally, the pipeline defines the source code directory of the application and the dependent applications, and the pipeline can obtain the source code file changes in the source code repository according to the source code directory, and send the source code file changes to the environment management engine. Specifically, the pipeline sends the above-mentioned source code change information to the environment management engine, and the source code change information may include, for example, the name of the source code that has changed.
[0087] S602: Determine at least one changed application according to the information of the changed source code.
[0088] The environment management engine can analyze which applications will be changed based on the information of the changed source code. For example, a source code M is changed, and an application A is compiled from the source code M and some other source codes. Therefore, it can be determined that the application A is a changed application.
[0089] S603: Acquire each changed application according to the type of each changed application.
[0090] The changed application may include two types: the current application and the dependent application. Different methods may be used to obtain the changed application for different types.
[0091] In this embodiment, the pipeline obtains information about the changed source code, based on which the environment management engine can analyze the changed applications and obtain the changed applications according to the types of applications, thereby ensuring that the changed applications are not missed.
[0092] As an optional implementation, the above step S603 may include:
[0093] If the changed application is to change the current application, the changed current application is obtained through the pipeline; if the changed application is to change the dependent application, the artifact library directory corresponding to the changed dependent application is obtained, and according to the artifact library directory, the version information of the latest application corresponding to the changed dependent application is obtained from the artifact library corresponding to the changed dependent application, and the version information of the latest application is compared with the version information of the changed dependent application in the target test environment. If the comparison result is that the versions are inconsistent, the latest application is obtained.
[0094] Specifically, this application can be obtained directly from the pipeline, so no additional processing is required to obtain it from the pipeline. The change-dependent application cannot be obtained directly from the pipeline, so it is necessary to obtain the latest application of the change-dependent application from the artifact library of the change-dependent application. The latest application refers to the latest version of the change-dependent application. After the environment management engine obtains the latest application, it reads the version number of the latest application from the file name of the latest application, and compares it with the version number of the change-dependent application that already exists in the test environment. If the two version numbers are the same, it indicates that the change-dependent application in the test environment is the latest version and does not need to be obtained; if the two version numbers are different, the latest application needs to be obtained.
[0095] In this embodiment, for this application, the latest version of this application is directly obtained with the help of the pipeline, and for dependent applications, the latest version of dependent applications is obtained through the artifact library of the dependent applications, thereby ensuring that the latest versions of this application and dependent applications are obtained.
[0096] The above is a description of the process of determining the target test environment and obtaining the changed application. Next, the process of deploying and starting the target test environment in the aforementioned step S303 is described.
[0097] Figure 7 A flow chart of the deployment and startup of the target test environment of the test processing method provided in the embodiment of the present application is as follows: Figure 7 As shown, the above step S303 may include:
[0098] S701. Deploy each changed application to a container in a target test environment.
[0099] Optionally, the embodiment of the present application performs containerization transformation on the test environment and deploys a container in the target test environment. Accordingly, after obtaining the changed application, the changed application can be deployed to the container of the target test environment.
[0100] It is worth noting that when the test environment is created for the first time, the environment management engine pulls the image corresponding to the target test type from the image repository, and then deploys the application in the image to the container. In the subsequent process, only the changed application needs to be obtained and deployed to the container pulled up by the image. The unchanged application does not need to be obtained and deployed to the container, thereby improving processing efficiency.
[0101] S702: Start each changed application in the container in sequence according to the startup sequence relationship between each changed application to start the target test environment.
[0102] Optionally, the startup sequence relationship between the changed applications can be configured in advance by the user according to the needs. The environment management engine starts the changed applications in sequence according to the startup sequence relationship between the changed applications.
[0103] It is worth noting that applications that have not changed do not need to be restarted, thereby reducing resource usage.
[0104] In this embodiment, the test environment is containerized, a container is deployed in the target test environment, the changed application is deployed in the container, and each changed application is started in sequence according to a preconfigured startup sequence, thereby greatly reducing resource usage while meeting test requirements.
[0105] The following describes the process of executing the test in the aforementioned step S304.
[0106] Figure 8 A schematic diagram of a test execution flow of a test processing method provided in an embodiment of the present application, such as Figure 8 As shown, the above step S304 may include:
[0107] S801. Receive a test request sent by a pipeline, where the test request includes a label of a target test environment.
[0108] The label of the target test environment may include: an identifier of the test environment type, a pipeline number, a build number, a node number, a sequence number, and a status, etc.
[0109] S802: Determine the test version corresponding to the target test environment according to the label of the target test environment.
[0110] Different test versions have different test requirements, so different tests can be performed for different test versions. Test versions can be, for example, patch versions, incremental versions, baseline versions, etc. For baseline versions, full test cases can be used for testing; for incremental versions, incremental test cases can be used for testing.
[0111] S803. Determine the target test case according to the above test version.
[0112] Test cases applicable to various test versions may be configured in advance for the test versions. In this step, target test cases corresponding to the test versions may be found.
[0113] S804: Based on the target test environment, run the target test case.
[0114] In this embodiment, the test cases are graded and different test cases are used to test different test versions, thereby further improving the pertinence and efficiency of the test.
[0115] Fig. 9 A schematic diagram of deploying a test environment and executing a test based on the method of an embodiment of the present application, referring to Fig. 9 , various pipelines can dynamically deploy test environments and execute tests through the environment management engine. In the test environment deployment phase, after taking over the environment management engine, the test environment deployment and startup can be completed by obtaining the changed application, deploying the changed application, and starting the container. In the testing phase, the test is completed by grading the use cases and executing the use cases. Fig. 9 The specific implementation process of each step in each link has been described in detail in the aforementioned embodiments, and can be referred to in the aforementioned embodiments, and will not be repeated here.
[0116] As an optional implementation, after the test is completed, the embodiment of the present application can also delete the target test environment in time to reduce maintenance costs.
[0117] Specifically, the environment management engine receives a test environment deletion request sent by the pipeline, where the test environment deletion request includes a tag of a target test environment; the environment management engine then deletes the target test environment according to the tag of the target test environment.
[0118] After receiving the test environment deletion request, the environment management engine first determines whether there is a test environment with a tag matching the target test environment, and if so, deletes the test environment.
[0119] As an optional implementation, while deleting the test environment, a new test environment can also be created asynchronously so that the test environment can be directly used in the next test, thereby improving processing efficiency.
[0120] Specifically, the environment management engine creates a new test environment according to the label of the target test environment and the identifier of the test environment type, and the type of the new test environment is the same as the type of the target test environment.
[0121] Based on the same inventive concept, a test processing device corresponding to the test processing method is also provided in the embodiment of the present application. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the above-mentioned test processing method in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0122] Fig.10 The module structure diagram of the test processing device provided in the embodiment of the present application is as follows: Fig.10 As shown, the device comprises:
[0123] The receiving module 1001 is used to receive a test environment deployment request sent by the pipeline, wherein the test environment deployment request at least includes: an identifier of the test environment type.
[0124] Determination module 1002 is used to determine the target test environment to be used according to the identification of the test environment type and the environment template corresponding to the test environment type, and obtain various change applications of the target test environment through the pipeline, wherein the environment template is used to record the information of the application corresponding to the test environment type and the information of the environmental resources, and the change application includes: changing the current application and changing the dependent application.
[0125] The deployment module 1003 is used to deploy and start the target test environment based on each of the changed applications.
[0126] The testing module 1004 is used to execute a test based on the target testing environment.
[0127] As a possible implementation manner, the determining module 1002 is specifically configured to:
[0128] Determining whether there is a test environment that meets a deployment condition according to the identifier of the test environment type, wherein the deployment condition includes: the type of the test environment is the test environment type, and the test environment is currently available;
[0129] If yes, the test environment that meets the deployment conditions is used as the target test environment;
[0130] If not, creating the target test environment according to the environment template;
[0131] The information of the changed source code is obtained through the pipeline, and each changed application of the target test environment is obtained according to the information of the changed source code.
[0132] As a possible implementation manner, the determining module 1002 is specifically configured to:
[0133] According to the identifier of the test environment type, obtaining the status of each test environment in the cluster belonging to the test environment type;
[0134] If the status of the current test environment indicates that the current test environment is currently available, it is determined that there is a test environment that meets the deployment condition, and the current test environment is a test environment that meets the deployment condition, wherein the current test environment is any test environment belonging to the test environment type.
[0135] As a possible implementation manner, the determining module 1002 is specifically configured to:
[0136] Pull the application corresponding to the target test environment from the image repository according to the environment template;
[0137] According to the environment template, the environment resources of the target test environment are acquired and enabled.
[0138] As a possible implementation manner, the determining module 1002 is specifically configured to:
[0139] Receiving source code change information sent by the pipeline;
[0140] Determining at least one of the changed applications according to the information of the changed source code;
[0141] According to the type of each of the changed applications, each of the changed applications is acquired.
[0142] As a possible implementation manner, the determining module 1002 is specifically configured to:
[0143] If the changed application is the changed original application, obtaining the changed original application through the pipeline;
[0144] If the changed application is the changed dependent application, obtain the artifact library directory corresponding to the changed dependent application, and obtain the version information of the latest application corresponding to the changed dependent application from the artifact library corresponding to the changed dependent application based on the artifact library directory, and compare the version information of the latest application with the version information of the changed dependent application in the target test environment. If the comparison result is that the versions are inconsistent, obtain the latest application.
[0145] As a possible implementation, the deployment module 1003 is specifically used for:
[0146] Deploy each of the changed applications into a container of the target test environment;
[0147] According to the startup sequence relationship between the changed applications, the changed applications are started in the container in sequence to start the target test environment.
[0148] As a possible implementation, the testing module 1004 is specifically used for:
[0149] receiving a test request sent by the pipeline, wherein the test request includes a label of the target test environment;
[0150] Determining a test version corresponding to the target test environment according to the label of the target test environment;
[0151] Determine target test cases according to the test version;
[0152] Based on the target test environment, the target test case is run.
[0153] As a possible implementation manner, the receiving module 1001 is further used for:
[0154] receiving a test environment deletion request sent by the pipeline, wherein the test environment deletion request includes a label of the target test environment;
[0155] The target test environment is deleted according to the tag of the target test environment.
[0156] As a possible implementation manner, the determining module 1002 is further configured to:
[0157] A new test environment is created according to the label of the target test environment and the identifier of the test environment type, wherein the type of the new test environment is the same as the type of the target test environment.
[0158] The present application embodiment also provides an electronic device 110, such as Fig.11As shown, it is a schematic diagram of the structure of the electronic device 110 provided in the embodiment of the present application, including: a processor 111, a memory 112, and optionally, a bus 113. The memory 112 stores machine-readable instructions executable by the processor 111 (for example, Fig.10 The receiving module, determining module, deploying module and executing instructions corresponding to the testing module in the device, etc.), when the electronic device 110 is running, the processor 111 communicates with the memory 112 through the bus 113, and when the machine-readable instructions are executed by the processor 111, the method steps in the aforementioned method embodiment are executed.
[0159] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned test processing method are executed.
[0160] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0161] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or part of the technical solution that contributes to the prior art or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.
[0162] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.
Claims
1. A test processing method, characterized in that: include: Receive a test environment deployment request sent by the pipeline, wherein the test environment deployment request includes at least: an identifier of the test environment type; According to the identification of the test environment type and the environment template corresponding to the test environment type, the target test environment to be used is determined, and after the target test environment is determined, each change application of the target test environment is obtained through the pipeline, wherein the environment template is used to record the information of the application corresponding to the test environment type and the information of the environment resources, and the change application includes: changing the current application and changing the dependent application, wherein the test environment type is used to indicate the software project applied by the test environment; the application information includes: the names of all applications contained in the software project itself and the names and sources of other applications that the software project needs to rely on when executing; The changed application obtained through the pipeline is the application that has been changed in the target test environment, the changed dependent application is the dependent application that has been changed in the target test environment, the application is the application included in the software project, the dependent application is the application that the software project needs to rely on when executing the test, and each changed application obtained is used to update to the target test environment to replace the old version of the application; Based on each of the changed applications, deploy and start the target test environment; Based on the target test environment, execute the test; Determining the target test environment to be used includes searching for an existing test environment in the cluster or creating a new test environment.
2. The method according to claim 1, characterized in that The determining the target test environment to be used according to the identifier of the test environment type and the environment template corresponding to the test environment type, and obtaining each change application of the target test environment through the pipeline, includes: Determining whether there is a test environment that meets a deployment condition according to the identifier of the test environment type, wherein the deployment condition includes: the type of the test environment is the test environment type, and the test environment is currently available; If yes, the test environment that meets the deployment conditions is used as the target test environment; If not, creating the target test environment according to the environment template; The information of the changed source code is obtained through the pipeline, and each changed application of the target test environment is obtained according to the information of the changed source code.
3. The method according to claim 2, characterized in that The determining, according to the identifier of the test environment type, whether there is a test environment that meets the deployment condition includes: According to the identifier of the test environment type, obtaining the status of each test environment in the cluster belonging to the test environment type; If the status of the current test environment indicates that the current test environment is currently available, it is determined that there is a test environment that meets the deployment condition, and the current test environment is a test environment that meets the deployment condition, wherein the current test environment is any test environment belonging to the test environment type.
4. The method according to claim 2, characterized in that: The step of creating the target test environment according to the environment template includes: Pull the application corresponding to the target test environment from the image repository according to the environment template; According to the environment template, the environment resources of the target test environment are acquired and enabled.
5. The method according to claim 2, characterized in that: The obtaining of information about the changed source code through the pipeline, and obtaining each changed application of the target test environment according to the information about the changed source code, includes: Receiving source code change information sent by the pipeline; Determining at least one of the changed applications according to the information of the changed source code; According to the type of each of the changed applications, each of the changed applications is acquired.
6. The method according to claim 5, characterized in that The acquiring each of the changed applications according to the type of each of the changed applications includes: If the changed application is the changed original application, obtaining the changed original application through the pipeline; If the changed application is the changed dependent application, obtain the artifact library directory corresponding to the changed dependent application, and obtain the version information of the latest application corresponding to the changed dependent application from the artifact library corresponding to the changed dependent application based on the artifact library directory, and compare the version information of the latest application with the version information of the changed dependent application in the target test environment. If the comparison result is that the versions are inconsistent, obtain the latest application.
7. The method according to claim 1, characterized in that The deploying and starting the target test environment based on each of the changed applications includes: Deploy each of the changed applications into a container of the target test environment; According to the startup sequence relationship between the changed applications, the changed applications are started in the container in sequence to start the target test environment.
8. The method according to any one of claims 1 to 7, characterized in that: The performing of the test based on the target test environment includes: receiving a test request sent by the pipeline, wherein the test request includes a label of the target test environment; Determining a test version corresponding to the target test environment according to the label of the target test environment; Determine target test cases according to the test version; Based on the target test environment, the target test case is run.
9. The method according to any one of claims 1 to 7, characterized in that: After executing the test based on the target test environment, the method further includes: receiving a test environment deletion request sent by the pipeline, wherein the test environment deletion request includes a label of the target test environment; The target test environment is deleted according to the tag of the target test environment.
10. The method according to claim 9, characterized in that The method further comprises: A new test environment is created according to the label of the target test environment and the identifier of the test environment type, wherein the type of the new test environment is the same as the type of the target test environment.
11. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the steps of the test processing method according to any one of claims 1 to 10.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the test processing method according to any one of claims 1 to 10 are executed.
13. A computer program product, characterized in that The computer program product comprises computer program codes. When the computer program codes are executed by a computing device, the computing device executes the steps of the test processing method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Development and test environment deployment method and system, electronic equipment and medium
CN113448837A
Test environment deployment method and device, storage medium and program product
CN115757135A
Deployment method of application program
CN118626138A