Parallel testing method, device and equipment based on kubernetes

Through the parallel testing method based on kubernetes, the test parameters of preset gateway services and microservices are used to realize parallel testing of multiple parallel microservices to be tested, solving the problem of inefficient testing in the existing technology and improving the testing efficiency.

CN114385318BActive Publication Date: 2025-03-21BEIJING HUITONG TIANXIA LOGISTIC CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210043693.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-14
Publication Date
2025-03-21
Estimated Expiration
2042-01-14

AI Technical Summary

Technical Problem

In the prior art, parallel testing of microservices is inefficient, and it is impossible to avoid conflicts of modifications between versions when multiple requirements of the same microservice are developed in parallel, resulting in a slow test process.

Method used

Using a parallel testing method based on kubernetes, by obtaining the test parameters of multiple parallel microservices to be tested, including target access link identification and target access interface identification, the preset gateway service and these test parameters are used to access the target microservices corresponding to each microservice to be tested, and parallel testing of multiple parallel microservices to be tested is realized.

Benefits of technology

By isolating the service resources of each microservice to be tested, parallel access to the target microservices is achieved, testing efficiency is improved, and the problem of inefficient testing in the existing technology is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114385318B_ABST
    Figure CN114385318B_ABST
Patent Text Reader

Abstract

The present application provides a parallel testing method, device and equipment based on kubernetes, and relates to the field of computer technology. The method includes: obtaining test parameters of multiple parallel microservices to be tested, and the test parameters of each microservice to be tested include: a target access link identifier and a target access interface identifier, the target access interface identifier is the interface identifier corresponding to the target microservice, and the target microservice is any microservice other than the microservice to be tested in the link indicated by the target access link identifier; by presetting the gateway service and the test parameters of each microservice to be tested, the target microservice corresponding to each microservice to be tested is accessed, and the service resources of each microservice to be tested can be isolated through the namespace corresponding to each target access link, and then the parallel access to each target microservice can be realized according to the address information of each target microservice, and the parallel testing of multiple parallel microservices to be tested is realized, and the test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of smart home technology, and in particular to a parallel testing method, device and equipment based on Kubernetes. Background Art

[0002] In the Java language, many microservice frameworks such as Spring Cloud and Dubbo have been born. They have gradually become one of the preferred frameworks for quickly building microservices. Coupled with the development of container technology and the fact that microservices are generally composed of many services, the container service orchestration framework Kubernetes is often used to orchestrate the built microservices.

[0003] Currently, each microservice needs to be tested and verified before it goes online. However, in actual business development, multiple requirements of the same microservice are often developed in parallel. Therefore, in order to avoid conflicts in modifications between versions of the same microservice during testing, the prior art often only allows the next round of testing to be performed after the testing of a certain requirement is completed.

[0004] It can be seen that the existing testing methods are relatively simple, but they are very slow in the development mode that requires rapid iteration, and there is a problem of low testing efficiency. Summary of the invention

[0005] The purpose of this application is to provide a Kubernetes-based parallel testing method, device and equipment to improve testing efficiency in response to the above-mentioned deficiencies 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, the present invention provides a parallel testing method based on Kubernetes, comprising:

[0008] Obtain test parameters of multiple parallel microservices to be tested, where the test parameters of each microservice to be tested include: a target access link identifier and a target access interface identifier, where the target access interface identifier is an interface identifier corresponding to the target microservice, and the target access interface identifier includes: a service name of the target microservice, where the target microservice is any microservice other than the microservice to be tested in the link indicated by the target access link identifier, and each target access link identifier corresponds to a namespace identifier, and the namespace identifiers corresponding to the target access link identifiers are different;

[0009] The target microservice corresponding to each microservice to be tested is accessed through the preset gateway service and the test parameters of each microservice to be tested. The preset gateway service includes a first mapping relationship between a link identifier and a namespace identifier, and a second mapping relationship between a namespace identifier, address information of the microservice, and a service name.

[0010] In an optional implementation manner, accessing a target microservice corresponding to each microservice to be tested by presetting a gateway service and test parameters of each microservice to be tested includes:

[0011] Extract the target access link identifier and target access interface identifier corresponding to each microservice to be tested through the preset gateway service;

[0012] Determine the target namespace identifier corresponding to each target access link identifier according to the target access link identifier corresponding to each microservice to be tested and the first mapping relationship;

[0013] According to the target namespace identifier corresponding to each target access link identifier, each target access interface identifier, and the second mapping relationship, the target microservice corresponding to each microservice to be tested is accessed.

[0014] In an optional implementation manner, before accessing the target microservice corresponding to each microservice to be tested by presetting the gateway service and the test parameters of each microservice to be tested, the method further includes:

[0015] Obtain service information of the namespace corresponding to each link identifier, wherein the service information of each namespace includes: the service name of each microservice in the namespace and the address information of the resource object component corresponding to each microservice;

[0016] The second mapping relationship is constructed according to the service information of the namespace corresponding to each link identifier, wherein the address information of the resource object component corresponding to each microservice is used to indicate the address information of each microservice.

[0017] In an optional implementation, accessing the target microservice corresponding to each microservice to be tested according to the target namespace identifier corresponding to each target access link identifier, each target access interface identifier, and the second mapping relationship includes:

[0018] According to each target access interface identifier, extract the service name of the target microservice corresponding to each target access interface identifier;

[0019] Determine the address information of each target microservice according to the target namespace identifier corresponding to each target access link identifier, the service name of each target microservice, and the second mapping relationship;

[0020] According to the address information of each target microservice, access the target microservice corresponding to each microservice to be tested.

[0021] In an optional implementation manner, accessing the target microservices corresponding to the microservices to be tested according to the address information of the target microservices includes:

[0022] Determine whether there is an associated Pod under the target resource object component indicated by the address information of each target microservice;

[0023] If it exists and the Pod is alive, the target microservice corresponding to the microservice to be tested is accessed through the Pod.

[0024] In an optional implementation manner, the preset gateway service further includes: a primary namespace identifier, and the method further includes:

[0025] If it is determined that there is no associated Pod under the target resource object component indicated by the address information of each target microservice, the target microservice corresponding to the microservice to be tested is accessed according to the main namespace identifier, the service name of each target microservice and the second mapping relationship.

[0026] In an optional implementation, before obtaining the test parameters of multiple parallel microservices to be tested, the method further includes:

[0027] Obtain multiple microservice codes to be released and the service name and namespace identifier corresponding to each microservice code to be released;

[0028] According to the service name and namespace identifier corresponding to each microservice code, each microservice code to be published is published to the corresponding namespace through a preset publishing script.

[0029] In a second aspect, the present invention provides a parallel testing device based on Kubernetes, comprising:

[0030] An acquisition module is used to acquire test parameters of multiple parallel microservices to be tested, where the test parameters of each microservice to be tested include: a target access link identifier and a target access interface identifier, where the target access interface identifier is an interface identifier corresponding to the target microservice, and the target access interface identifier includes: a service name of the target microservice, where the target microservice is any microservice other than the microservice to be tested in the link indicated by the target access link identifier, and each target access link identifier corresponds to a namespace identifier, and the namespace identifiers corresponding to the target access link identifiers are different;

[0031] An access module is used to access the target microservice corresponding to each microservice to be tested through a preset gateway service and test parameters of each microservice to be tested, wherein the preset gateway service includes a first mapping relationship between a link identifier and a namespace identifier, and a second mapping relationship between a namespace identifier, address information of a microservice, and a service name.

[0032] In an optional implementation, the access module is specifically used to extract the target access link identifier and the target access interface identifier corresponding to each microservice to be tested through a preset gateway service;

[0033] Determine the target namespace identifier corresponding to each target access link identifier according to the target access link identifier corresponding to each microservice to be tested and the first mapping relationship;

[0034] According to the target namespace identifier corresponding to each target access link identifier, each target access interface identifier, and the second mapping relationship, the target microservice corresponding to each microservice to be tested is accessed.

[0035] In an optional implementation, the access module is further used to obtain service information of the namespace corresponding to each link identifier, and the service information of each namespace includes: the service name of each microservice in the namespace and the address information of the resource object component corresponding to each microservice;

[0036] The second mapping relationship is constructed according to the service information of the namespace corresponding to each link identifier, wherein the address information of the resource object component corresponding to each microservice is used to indicate the address information of each microservice.

[0037] In an optional implementation, the access module is specifically used to access the target microservice corresponding to each microservice to be tested according to the target namespace identifier corresponding to each target access link identifier, each target access interface identifier and the second mapping relationship, including:

[0038] According to each target access interface identifier, extract the service name of the target microservice corresponding to each target access interface identifier;

[0039] Determine the address information of each target microservice according to the target namespace identifier corresponding to each target access link identifier, the service name of each target microservice, and the second mapping relationship;

[0040] According to the address information of each target microservice, access the target microservice corresponding to each microservice to be tested.

[0041] In an optional implementation, the access module is specifically used to determine whether there is an associated Pod under the target resource object component indicated by the address information of each target microservice;

[0042] If it exists and the Pod is alive, the target microservice corresponding to the microservice to be tested is accessed through the Pod.

[0043] In an optional implementation manner, the preset gateway service further includes: a primary namespace identifier, and the access module is further used in the method further including:

[0044] If it is determined that there is no associated Pod under the target resource object component indicated by the address information of each target microservice, the target microservice corresponding to the microservice to be tested is accessed according to the main namespace identifier, the service name of each target microservice and the second mapping relationship.

[0045] In an optional implementation, the acquisition module is further used to acquire multiple microservice codes to be released and service names and namespace identifiers corresponding to each microservice code to be released;

[0046] According to the service name and namespace identifier corresponding to each microservice code, each microservice code to be published is published to the corresponding namespace through a preset publishing script.

[0047] In a third aspect, the present invention provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the Kubernetes-based parallel testing method as described in any of the aforementioned implementations.

[0048] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the Kubernetes-based parallel testing method as described in any of the aforementioned implementations are executed.

[0049] The beneficial effects of this application are:

[0050] In the Kubernetes-based parallel testing method, apparatus and device provided in the embodiments of the present application, by obtaining test parameters of multiple parallel microservices to be tested, the test parameters of each microservice to be tested include: a target access link identifier and a target access interface identifier, the target access interface identifier is the interface identifier corresponding to the target microservice, the target access interface identifier includes: the service name of the target microservice, the target microservice is any microservice other than the microservice to be tested in the link indicated by the target access link identifier, each target access link identifier corresponds to a namespace identifier, and the namespace identifiers corresponding to each target access link identifier are different; by presetting the gateway service and the test parameters of each microservice to be tested, the target microservice corresponding to each microservice to be tested is accessed, and by applying this method, the service resources of each microservice to be tested can be isolated through the namespace corresponding to each target access link, and then parallel access to each target microservice can be achieved according to the address information of each target microservice, and parallel testing of multiple parallel microservices to be tested is achieved, thereby improving testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] 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.

[0052] Figure 1 A flowchart of a Kubernetes-based parallel testing method provided in an embodiment of the present application;

[0053] Figure 2 A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application;

[0054] Figure 3 A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application;

[0055] Figure 4 A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application;

[0056] Figure 5 A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application;

[0057] Figure 6 A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application;

[0058] Figure 7 A schematic diagram of functional modules of a Kubernetes-based parallel testing device provided in an embodiment of the present application;

[0059] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution 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. Obviously, the described embodiments are 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 different configurations.

[0061] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0062] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0063] Before introducing the present application, the relevant terms used in the embodiments of the present application are first explained.

[0064] Kubernetes: is an open source containerized application for managing multiple hosts in a cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and powerful. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance.

[0065] Namespace: An abstract collection of resources and objects. For example, it can be used to divide objects within the system into different project groups or user groups. Common pods, services, replication controllers, deployments, etc. all belong to a namespace (default is the default). Namespaces are often used to isolate different users. For example, Kubernetes' built-in services generally run in the kube-system namespace.

[0066] In the prior art, when multiple requirements of the same microservice are developed in parallel, in order to avoid conflicts between the revisions of the same microservice during testing, the next round of testing can usually only be performed after the test of a certain requirement is completed. Therefore, the existing testing method cannot achieve parallel testing and has the problem of low testing efficiency.

[0067] In addition, although there are other solutions in the prior art, for example, multiple test environments can be used to solve the problem, but the solution of multiple test environments will cause waste of resources. In addition, since there are many microservice projects and the calling relationship between each microservice is very close, each time a microservice is tested and launched, it is easy to miss it when it is synchronized to all test environments, which brings many inconveniences to subsequent maintenance and management.

[0068] In view of this, an embodiment of the present application provides a parallel testing method based on Kubernetes, which can support parallel testing of multiple versions of multiple microservices to be tested and improve testing efficiency.

[0069] Figure 1 The flowchart of a parallel testing method based on kubernetes provided in the embodiment of the present application is provided. The execution subject of the method can be a computer, server, etc. running a kubernetes engine, which is not limited here. Figure 1 As shown, the method may include:

[0070] S101. Acquire test parameters of multiple parallel microservices to be tested, where the test parameters of each microservice to be tested include: a target access link identifier and a target access interface identifier.

[0071] Among them, the target access interface identifier is the interface identifier corresponding to the target microservice, and the target access interface identifier includes: the service name of the target microservice, the target microservice is any microservice in the link indicated by the target access link identifier except the microservice to be tested, each target access link identifier corresponds to a namespace identifier, and the namespace identifiers corresponding to each target access link identifier are different. Based on this description, it can be seen that the link indicated by each target access link identifier can include at least two microservices, one of which is the microservice to be tested, and the other microservice is the target microservice that the microservice to be tested needs to access. Of course, the present application does not limit the number of microservices in the link indicated by each target access link identifier, which may be different according to the actual application scenario.

[0072] Optionally, the multiple parallel microservices to be tested may be multiple versions of microservices to be tested corresponding to multiple requirements. In some embodiments, the test parameters of the multiple parallel microservices to be tested may be obtained according to the user's input operation, or may be obtained according to the relevant parameters sent by other devices, which is not limited here.

[0073] The link indicated by the target access link identifier corresponding to each microservice to be tested may include the microservice to be tested and the target microservice corresponding to the microservice to be tested, wherein the target microservice is also the microservice to be accessed by the microservice to be tested; the target access interface identifier corresponding to each microservice to be tested is the interface identifier of the target microservice corresponding to the microservice to be tested, which may include the service name of the target microservice. Based on this description, it can be understood that the target access link corresponding to the microservice to be tested can be determined according to the target access link identifier corresponding to each microservice to be tested, and the target microservice corresponding to the microservice to be tested can be determined according to the target access link and the target access interface identifier corresponding to the microservice to be tested. By applying the embodiments of the present application, it is realized that the service resources of each microservice to be tested can be isolated through the namespace corresponding to each target access link, which can improve the security and stability of the method of the present application.

[0074] In addition, it should be noted that each microservice to be tested can correspond to a separate link, and multiple parallel microservices to be tested can correspond to multiple separate links. When a link is set as an independent link, it will be completely isolated from any other link resources. When a microservice to be tested needs to be updated, only the changed service needs to be deployed in the link, which can realize flexible changes in the relationship between links and greatly improve the test efficiency of multiple parallel microservices to be tested under Kubernetes.

[0075] S102: Access the target microservices corresponding to the microservices to be tested by presetting the gateway service and the test parameters of the microservices to be tested.

[0076] Among them, the preset gateway service includes a first mapping relationship between a link identifier and a namespace identifier, and a second mapping relationship between a namespace identifier, address information of a microservice, and a service name.

[0077] Based on the above description, it can be seen that according to the first mapping relationship and the second mapping relationship in the preset gateway service, the address information of the target microservice corresponding to each microservice to be tested can be determined, and then according to the address information of each target microservice, parallel access to each target microservice can be achieved, and parallel testing of multiple parallel microservices to be tested can be achieved, thereby improving testing efficiency.

[0078] In summary, an embodiment of the present application provides a parallel testing method based on Kubernetes, the method comprising: obtaining test parameters of multiple parallel microservices to be tested, the test parameters of each microservice to be tested comprising: a target access link identifier and a target access interface identifier, the target access interface identifier being the interface identifier corresponding to the target microservice, the target access interface identifier comprising: the service name of the target microservice, the target microservice being any microservice other than the microservice to be tested in the link indicated by the target access link identifier, each target access link identifier corresponding to a namespace identifier, and the namespace identifiers corresponding to each target access link identifier are different; through a preset gateway service and the test parameters of each microservice to be tested, access the target microservice corresponding to each microservice to be tested, the preset gateway service comprising a first mapping relationship between a link identifier and a namespace identifier, and a second mapping relationship between a namespace identifier, an address information of a microservice, and a service name, by applying this method, it is possible to isolate the service resources of each microservice to be tested through the namespace corresponding to each target access link, and then according to the address information of each target microservice, parallel access to each target microservice can be achieved, and parallel testing of multiple parallel microservices to be tested is achieved, thereby improving testing efficiency.

[0079] In addition, based on the above embodiments, it can be seen that when performing parallel testing, the embodiments of the present application can dynamically adjust the test path according to the test parameters of the microservice to be tested, which can improve the flexibility of the parallel testing method of the present application; and the testing process is simple and quick to operate.

[0080] Figure 2 A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application. Optionally, Figure 2 As shown, the above step of accessing the target microservice corresponding to each microservice to be tested by presetting the gateway service and the test parameters of each microservice to be tested may include:

[0081] S201. Extract the target access link identifier and the target access interface identifier corresponding to each microservice to be tested through a preset gateway service.

[0082] S202: Determine a target namespace identifier corresponding to each target access link identifier according to the target access link identifier corresponding to each microservice to be tested and the first mapping relationship.

[0083] S203: Access the target microservices corresponding to the microservices to be tested according to the target namespace identifiers corresponding to the target access link identifiers, the target access interface identifiers, and the second mapping relationship.

[0084] Among them, the preset gateway service can be configured to extract the corresponding target access link identifier and target access interface identifier for each microservice to be tested; according to the above-mentioned first mapping relationship, the target namespace identifier corresponding to each extracted target access link identifier can be determined; further, according to each target namespace identifier, the extracted target access interface identifier and the second mapping relationship, the address information of the target microservice corresponding to each microservice to be tested can be determined, and according to the address information of each target microservice, parallel access to each target microservice can be achieved, and parallel testing of multiple parallel microservices to be tested can be achieved, thereby improving testing efficiency.

[0085] Figure 3 A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application. Optionally, Figure 3 As shown, by presetting the test parameters of the gateway service and each microservice to be tested, before accessing the target microservice corresponding to each microservice to be tested, the method further includes:

[0086] S301. Obtain service information of the namespace corresponding to each link identifier, where the service information of each namespace includes: the service name of each microservice in the namespace and the address information of the resource object component corresponding to each microservice.

[0087] S302. Construct a second mapping relationship according to the service information of the namespace corresponding to each link identifier, wherein the address information of the resource object component corresponding to each microservice is used to indicate the address information of each microservice.

[0088] In some embodiments, the service information of each namespace can be obtained through the resource object (Service) corresponding to each namespace, wherein the service information of each namespace may include: the service name of each microservice in the namespace and the address information of the resource object component (i.e., Service component) corresponding to each microservice. After obtaining the service information of each namespace, a second mapping relationship between the namespace identifier, the address information of the microservice, and the service name of the microservice can be constructed, wherein the address information of each microservice can be identified by the address information of the resource object component corresponding to each microservice.

[0089] Among them, the Service component is a resource object component built on a group of Pod objects in Kubernetes. It can select a group of Pod objects through a label selector and define a unified fixed access entry (usually an IP address) for this group of Pod objects. The fixed access entry can be understood as the address information of the Service component.

[0090] Figure 4A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application. Optionally, Figure 4 As shown, the target microservices corresponding to the microservices to be tested are accessed according to the target namespace identifiers corresponding to the target access link identifiers, the target access interface identifiers and the second mapping relationship, including:

[0091] S401. Extract the service name of the target microservice corresponding to each target access interface identifier according to each target access interface identifier.

[0092] S402: Determine address information of each target microservice according to the target namespace identifier corresponding to each target access link identifier, the service name of each target microservice, and the second mapping relationship.

[0093] S403: Access the target microservices corresponding to the microservices to be tested according to the address information of the target microservices.

[0094] Referring to the above description, it can be seen that after extracting the service name of the target microservice corresponding to each target access interface identifier according to each target access interface identifier, the address information of each target microservice can be determined according to the service name of each target microservice, the corresponding target namespace identifier, and the second mapping relationship, and then according to the address information of each target microservice, the target microservice corresponding to each microservice to be tested can be accessed.

[0095] Of course, it should be noted that if in some embodiments, the address information of each target microservice is identified by the address information of the resource object component corresponding to each microservice, then the target microservice corresponding to each microservice to be tested can be accessed according to the address information of the resource object component corresponding to each microservice. It can be seen that by applying the embodiments of the present application, each microservice can be discovered and managed through the resource object component that comes with Kubernetes, so that there is no need to introduce third-party management components in the Kubernetes engine, such as: euraka, nacos, zookeeper, consul, etc. Therefore, the maintenance and management costs of third-party components can be saved, and the applicability of the parallel testing method can be improved.

[0096] Figure 5 A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application. Optionally, Figure 5 As shown, the above step of accessing the target microservices corresponding to each microservice to be tested according to the address information of each target microservice may include:

[0097] S501. Determine whether there is an associated Pod under the target resource object component indicated by the address information of each target microservice.

[0098] S502: If it exists and the Pod is alive, access the target microservice corresponding to the microservice to be tested through the Pod.

[0099] Among them, Pod is the smallest scheduling unit in the kubernetes cluster, which can be composed of one or more containers; the resource object (Service) component is a resource object component in kubernetes built on a group of Pod objects, and each Pod belonging to the same group can have the same function. Therefore, there can be an associated Pod under the resource object component. Then, when accessing the target microservice corresponding to each microservice to be tested, it can be determined whether there is an associated Pod under the target resource object component indicated by the address information of each target microservice. If it exists and the Pod is in a live state, then the target microservice corresponding to the microservice to be tested can be accessed through the Pod. Among them, the Pod is in a live state, which means that the Pod is in a running state.

[0100] Optionally, to determine whether the Pod is in a survival state, a survival probe may be used to detect the survival probe. Of course, the present application does not limit the detection frequency of the survival probe, and the detection frequency may be flexibly set according to the actual application scenario.

[0101] Optionally, the preset gateway service further includes: a primary namespace identifier, and the above method further includes:

[0102] If it is determined that there is no associated Pod under the target resource object component indicated by the address information of each target microservice, the target microservice corresponding to the microservice to be tested is accessed according to the main namespace identifier, the service name of each target microservice and the second mapping relationship.

[0103] Of course, in some embodiments, there may not be an associated Pod under the target resource object component. Optionally, in this case, it can be determined whether the service name of the microservice corresponding to the primary namespace identifier includes the service name of the target microservice based on the second mapping relationship. If it does, the address information of the target microservice can be further obtained, and the target microservice corresponding to the microservice to be tested can be accessed based on the address information of the target microservice. For the description of this part, please refer to the description of the above steps S402 and S403, which will not be repeated here.

[0104] Figure 6 A flowchart of another Kubernetes-based parallel testing method provided in an embodiment of the present application. Optionally, Figure 6 As shown, before obtaining the test parameters of multiple parallel microservices to be tested, the method further includes:

[0105] S601. Obtain multiple microservice codes to be released and the service name and namespace identifier corresponding to each microservice code to be released.

[0106] S602: According to the service name and namespace identifier corresponding to each microservice code, each microservice code to be published is published to the corresponding namespace through a preset publishing script.

[0107] Among them, multiple microservice codes to be released can be obtained by writing, or can be obtained through other devices, which is not limited here. Optionally, the namespace identifier corresponding to each microservice code to be released can be obtained according to the generation rule of the preset namespace, which is not limited.

[0108] The preset release script may have the function of publishing the microservice code to be released to the namespace indicated by the corresponding namespace identifier. Optionally, each microservice code in the namespace may be identified by the service name. It is understood that if the release is successful, then the published microservice codes can be tested in parallel with the above steps. Optionally, the service name may include a version identifier, etc., which is not limited here.

[0109] Optionally, in some embodiments, the preset release script may also include: compiling and packaging, image building, uploading the built image to a specified image repository, marking the image version number, and other functions, which are not limited here.

[0110] Figure 7 This is a functional module diagram of a Kubernetes-based parallel testing device provided in an embodiment of the present application. The basic principle and technical effects of the device are the same as those of the corresponding method embodiment described above. For the sake of brief description, the parts not mentioned in this embodiment can be referred to the corresponding contents in the method embodiment. Figure 7 As shown, the parallel testing device 100 includes:

[0111] The acquisition module 110 is used to obtain test parameters of multiple parallel microservices to be tested, and the test parameters of each microservice to be tested include: a target access link identifier and a target access interface identifier, the target access interface identifier is an interface identifier corresponding to the target microservice, and the target access interface identifier includes: a service name of the target microservice, and the target microservice is any microservice other than the microservice to be tested in the link indicated by the target access link identifier. Each of the target access link identifiers corresponds to a namespace identifier, and the namespace identifiers corresponding to the target access link identifiers are different;

[0112] The access module 120 is used to access the target microservice corresponding to each microservice to be tested through a preset gateway service and the test parameters of each microservice to be tested. The preset gateway service includes a first mapping relationship between a link identifier and a namespace identifier, and a second mapping relationship between a namespace identifier, address information of a microservice, and a service name.

[0113] In an optional implementation, the access module 120 is specifically used to extract the target access link identifier and the target access interface identifier corresponding to each microservice to be tested through a preset gateway service;

[0114] Determine the target namespace identifier corresponding to each target access link identifier according to the target access link identifier corresponding to each microservice to be tested and the first mapping relationship;

[0115] According to the target namespace identifier corresponding to each target access link identifier, each target access interface identifier, and the second mapping relationship, the target microservice corresponding to each microservice to be tested is accessed.

[0116] In an optional implementation, the access module 120 is further used to obtain service information of the namespace corresponding to each link identifier, and the service information of each namespace includes: the service name of each microservice in the namespace and the address information of the resource object component corresponding to each microservice;

[0117] The second mapping relationship is constructed according to the service information of the namespace corresponding to each link identifier, wherein the address information of the resource object component corresponding to each microservice is used to indicate the address information of each microservice.

[0118] In an optional implementation, the access module 120 is specifically used to access the target microservice corresponding to each microservice to be tested according to the target namespace identifier corresponding to each target access link identifier, each target access interface identifier and the second mapping relationship, including:

[0119] According to each target access interface identifier, extract the service name of the target microservice corresponding to each target access interface identifier;

[0120] Determine the address information of each target microservice according to the target namespace identifier corresponding to each target access link identifier, the service name of each target microservice, and the second mapping relationship;

[0121] According to the address information of each target microservice, access the target microservice corresponding to each microservice to be tested.

[0122] In an optional implementation, the access module 120 is specifically used to determine whether there is an associated Pod under the target resource object component indicated by the address information of each target microservice;

[0123] If it exists and the Pod is alive, the target microservice corresponding to the microservice to be tested is accessed through the Pod.

[0124] In an optional implementation manner, the preset gateway service further includes: a primary namespace identifier, and the access module is further used in the method further including:

[0125] If it is determined that there is no associated Pod under the target resource object component indicated by the address information of each target microservice, the target microservice corresponding to the microservice to be tested is accessed according to the main namespace identifier, the service name of each target microservice and the second mapping relationship.

[0126] In an optional implementation, the acquisition module 110 is further used to acquire multiple microservice codes to be released and service names and namespace identifiers corresponding to each microservice code to be released;

[0127] According to the service name and namespace identifier corresponding to each microservice code, each microservice code to be published is published to the corresponding namespace through a preset publishing script.

[0128] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0129] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), or one or more microprocessors, or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0130] Figure 8 The following is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device can be integrated into the above-mentioned parallel testing device. Figure 8 As shown, the electronic device may include: a processor 210, a storage medium 220 and a bus 230, the storage medium 220 stores machine-readable instructions executable by the processor 210, when the electronic device is running, the processor 210 and the storage medium 220 communicate through the bus 230, and the processor 210 executes the machine-readable instructions to perform the steps of the above method embodiment. The specific implementation method and technical effect are similar and will not be repeated here.

[0131] Optionally, the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method embodiment are executed. The specific implementation method and technical effect are similar and will not be repeated here.

[0132] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as multiple units 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 interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0133] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0134] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0135] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.

[0136] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0137] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A parallel testing method based on kubernetes, characterized in that: include: Obtain test parameters of multiple parallel microservices to be tested, where the test parameters of each microservice to be tested include: a target access link identifier and a target access interface identifier, where the target access interface identifier is an interface identifier corresponding to the target microservice, and the target access interface identifier includes: a service name of the target microservice, where the target microservice is any microservice other than the microservice to be tested in the link indicated by the target access link identifier, and each target access link identifier corresponds to a namespace identifier, and the namespace identifiers corresponding to the target access link identifiers are different; The target microservice corresponding to each microservice to be tested is accessed through the preset gateway service and the test parameters of each microservice to be tested. The preset gateway service includes a first mapping relationship between a link identifier and a namespace identifier, and a second mapping relationship between a namespace identifier, address information of the microservice, and a service name.

2. The method according to claim 1, characterized in that It is characterized in that The method of accessing the target microservice corresponding to each microservice to be tested by presetting the gateway service and the test parameters of each microservice to be tested includes: Extract the target access link identifier and target access interface identifier corresponding to each microservice to be tested through the preset gateway service; Determine the target namespace identifier corresponding to each target access link identifier according to the target access link identifier corresponding to each microservice to be tested and the first mapping relationship; According to the target namespace identifier corresponding to each target access link identifier, each target access interface identifier, and the second mapping relationship, the target microservice corresponding to each microservice to be tested is accessed.

3. The method according to claim 1, characterized in that: Before accessing the target microservices corresponding to the microservices to be tested by presetting the gateway service and the test parameters of the microservices to be tested, the method further includes: Obtain service information of the namespace corresponding to each link identifier, wherein the service information of each namespace includes: the service name of each microservice in the namespace and the address information of the resource object component corresponding to each microservice; The second mapping relationship is constructed according to the service information of the namespace corresponding to each link identifier, wherein the address information of the resource object component corresponding to each microservice is used to indicate the address information of each microservice.

4. The method according to claim 2, characterized in that: The step of accessing the target microservices corresponding to the microservices to be tested according to the target namespace identifiers corresponding to the target access link identifiers, the target access interface identifiers, and the second mapping relationship includes: According to each target access interface identifier, extract the service name of the target microservice corresponding to each target access interface identifier; Determine the address information of each target microservice according to the target namespace identifier corresponding to each target access link identifier, the service name of each target microservice, and the second mapping relationship; According to the address information of each target microservice, access the target microservice corresponding to each microservice to be tested.

5. The method according to claim 4, characterized in that It is characterized in that The step of accessing the target microservices corresponding to the microservices to be tested according to the address information of the target microservices includes: Determine whether there is an associated Pod under the target resource object component indicated by the address information of each target microservice; If it exists and the Pod is alive, the target microservice corresponding to the microservice to be tested is accessed through the Pod.

6. The method according to claim 5, characterized in that It is characterized in that The preset gateway service also includes: a primary namespace identifier, and the method also includes: If it is determined that there is no associated Pod under the target resource object component indicated by the address information of each target microservice, the target microservice corresponding to the microservice to be tested is accessed according to the main namespace identifier, the service name of each target microservice and the second mapping relationship.

7. The method according to any one of claims 1 to 6, characterized in that: It is characterized in that Before obtaining the test parameters of the multiple parallel microservices to be tested, the method further includes: Obtain multiple microservice codes to be released and the service name and namespace identifier corresponding to each microservice code to be released; According to the service name and namespace identifier corresponding to each microservice code, each microservice code to be published is published to the corresponding namespace through a preset publishing script.

8. A parallel testing device based on kubernetes, characterized in that: include: An acquisition module is used to acquire test parameters of multiple parallel microservices to be tested, where the test parameters of each microservice to be tested include: a target access link identifier and a target access interface identifier, where the target access interface identifier is an interface identifier corresponding to the target microservice, and the target access interface identifier includes: a service name of the target microservice, where the target microservice is any microservice other than the microservice to be tested in the link indicated by the target access link identifier, and each target access link identifier corresponds to a namespace identifier, and the namespace identifiers corresponding to the target access link identifiers are different; An access module is used to access the target microservice corresponding to each microservice to be tested through a preset gateway service and test parameters of each microservice to be tested, wherein the preset gateway service includes a first mapping relationship between a link identifier and a namespace identifier, and a second mapping relationship between a namespace identifier, address information of a microservice, and a service name.

9. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the Kubernetes-based parallel testing method as described in any one of claims 1-7.

10. 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 Kubernetes-based parallel testing method according to any one of claims 1 to 7 are executed.

Citation Information

Patent Citations

  • Sandbox-based micro-service test method, apparatus and device, and storage medium

    CN113535571A

  • Automatic interface testing method and device

    CN113626333A