Testing Method, Device, Electronic Device and Computer Storage Medium

The service nodes are marked through the baffle pointer, routing information is obtained, and the zero-invasion and pluggable baffle service is realized, which solves the problem of inflexible baffle programs in existing microservice tests, and realizes the segmented inspection and stable testing environment for link development.

CN112765030BActive Publication Date: 2025-07-22CHINA CITIC BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110090370.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-22
Publication Date
2025-07-22
Estimated Expiration
2041-01-22

AI Technical Summary

Technical Problem

In the existing microservice testing technology, the baffle program is not flexible enough, and needs to be written separately and occupy hardware resources. The implantation and removal are invasive to the code and cannot return specific responses based on different inputs. The interface changes at the beginning of the development stage are high, which affects the software delivery cycle and quality.

Method used

The service node is marked with a bezel pointer, and routing information is obtained through the microservice registration center to achieve zero-invasion, pluggable bezel service, support assertion and judgment, and flexibly switch between real services and bezel services.

Benefits of technology

It realizes segmented inspection of link development. Service nodes with fast development progress are tested first, so that nodes with slow development progress are not affected. They provide a stable testing environment and support automated testing and rapid development progress.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112765030B_ABST
    Figure CN112765030B_ABST
Patent Text Reader

Abstract

The embodiments of the present application relate to the field of testing technologies, and disclose a testing method, apparatus, electronic device, and computer storage medium. The testing method includes: receiving a testing request sent by a client for any microservice, where any microservice is a real service and / or a stub service. A real service is a service including service nodes marked by a stub pointer in a testing link, and a stub service is a service including service nodes other than the service nodes marked by the stub pointer in the testing link. The testing link includes multiple service nodes; then, obtaining the routing information of each service node included in any microservice; then, based on the routing information of each service node included in any microservice, testing the testing request and returning a corresponding testing result. The method of the embodiments of the present application marks service nodes by means of pointers, realizes a non-invasive and pluggable stub, and can be freely adjusted left and right like a cursor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of testing. Specifically, the present application relates to a testing method, device, electronic device and computer storage medium. Background Art

[0002] In the field of Internet distributed technology, the microservice architecture model has gradually become mainstream. After splitting application modules into microservices, the dependencies and collaboration networks between services become complicated. How to improve the testability of microservices with external dependencies will directly affect the cycle and quality of software delivery.

[0003] In the existing microservice testing technology, the development of interface baffle programs is often used to solve external dependency problems. For example, when testing interfaces, mock testing is often used to simulate the actual working environment. Mock testing is a test method that uses a virtual object to create some objects that are not easy to construct or obtain during the test process for testing. Set a mock baffle to implement the switch of mock testing. When the mock test function needs to be turned on, turn on the mock baffle, otherwise, turn off the baffle.

[0004] However, the inventors of the present application discovered during the specific examples that the use of the baffle program itself has great limitations. First, the baffle program itself is not flexible enough. Each service that needs to be mocked needs to have a baffle written separately, and the result returned by calling the baffle program is a static result, which cannot return a specific response based on different inputs. Second, when the interface of the microservice under test changes, the baffle program needs to be modified and upgraded in a targeted manner. In the early stages of development, the frequency of interface changes is very high. Third, the baffle program needs to be deployed separately and takes up hardware resources. Fourth, the implantation of the baffle may require modifying the calling address in the code configuration file, which intrudes on the service code. The removal of the baffle also requires manual removal. Summary of the invention

[0005] The purpose of the embodiments of the present application is to solve at least one of the above technical defects, and the following technical solutions are proposed:

[0006] In one aspect, a testing method is provided, comprising:

[0007] Receive a test request for any microservice sent by a client, where any microservice is a real service and / or a baffle service, where the real service is a service including a service node marked by a baffle pointer in the test link, and the baffle service includes a service of a service node in the test link other than the service node marked by the baffle pointer, and the test link includes multiple service nodes;

[0008] Obtain the routing information of each service node included in any microservice;

[0009] Based on the routing information of each service node included in any microservice, test the test request and return the corresponding test result.

[0010] In a possible implementation manner, obtaining the routing information of each service node included in any microservice includes:

[0011] Send a query request to the microservice registry to query the routing information of each service node included in any microservice. The microservice registry is used to register service gateways, service nodes, baffle central controls, and baffle services. The baffle central control is used to control the transfer of test requests to real services or baffle services;

[0012] Receive the routing information of each service node included in any microservice returned by the microservice registry.

[0013] In a possible implementation manner, before receiving a test request sent by a customer for any microservice, it further includes:

[0014] Register the service gateway, service node, baffle central control, and baffle service to the microservice registry.

[0015] In a possible implementation manner, based on the routing information of each service node included in any microservice, testing the test request and returning the corresponding test result includes:

[0016] Send the routing information of each service node included in any microservice to the baffle central control, so that the baffle central control forwards the test request to the corresponding real service or baffle service based on the preset situation according to the routing information of each service node included in any microservice, and the real service or baffle service tests the test request and returns the corresponding test result.

[0017] In a possible implementation manner, the baffle service acts on each service node in the form of a pointer, and the baffle service supports setting assertions. The assertions are used to judge whether the input parameters and / or output parameters meet the expectations and obtain the corresponding assertion results.

[0018] In a possible implementation manner, before receiving a test request sent by a customer for any microservice, it further includes:

[0019] Register and uniformly manage the baffle pointers through the master control, and generate baffle services according to the baffle logic.

[0020] On the one hand, a testing device is provided, including:

[0021] A receiving module, configured to receive a test request sent by a client for any microservice, where any microservice is a real service and / or a stub service. The real service is a service including service nodes marked by a stub pointer in a test link, and the stub service is a service including service nodes other than those marked by the stub pointer in the test link. The test link includes multiple service nodes.

[0022] An obtaining module, configured to obtain the routing information of each service node included in any microservice.

[0023] A testing module, configured to test the test request based on the routing information of each service node included in any microservice and return a corresponding test result.

[0024] In a possible implementation, the obtaining module is specifically configured to:

[0025] Send a query request to the microservice registry to query the routing information of each service node included in any microservice. The microservice registry is used to register service gateways, service nodes, stub controls, and stub services. The stub control is used to control the transfer of the test request to the real service or the stub service.

[0026] Receive the routing information of each service node included in any microservice returned by the microservice registry.

[0027] In a possible implementation, the apparatus further includes a registration module;

[0028] The registration module is configured to register service gateways, service nodes, stub controls, and stub services to the microservice registry.

[0029] In a possible implementation, the testing module is specifically configured to:

[0030] Send the routing information of each service node included in any microservice to the stub control, so that the stub control, based on the preset situation and according to the routing information of each service node included in any microservice, forwards the test request to the corresponding real service or stub service, and the real service or stub service tests the test request and returns a corresponding test result.

[0031] In a possible implementation, the stub service acts on each service node in a pointer manner, and the stub service supports setting assertions. The assertions are used to determine whether input parameters and / or output parameters meet the expectations and obtain corresponding assertion results.

[0032] In a possible implementation, the apparatus further includes a processing module;

[0033] A processing module is used to register and uniformly manage baffle pointers through a master control, and generate baffle services according to baffle logic.

[0034] On the one hand, an electronic device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the above-mentioned test method is implemented.

[0035] On the one hand, a computer-readable storage medium is provided. A computer program is stored on the computer-readable storage medium, and when the program is executed by a processor, the above-mentioned test method is implemented.

[0036] For the test method provided in the embodiments of the present application, on the one hand, by marking service nodes in the form of baffle pointers, the service nodes that need to be combined into real services in the test link can be accurately determined, and the service nodes other than the service nodes marked by the baffle pointers are determined as baffle services that need to be mocked, so that any number of adjacent service nodes in the test link can be combined without relying on other service nodes and provide a stable test environment externally; on the other hand, a zero-intrusion and pluggable baffle service is realized through baffle pointers. The baffle can be plugged and used immediately, and can be freely adjusted left and right like a cursor, so that in the process of link development, the service nodes with fast development progress are tested first, and the service nodes with slow development progress are tested later, without affecting each other, realizing segmented troubleshooting of link development.

[0037] Additional aspects and advantages of the embodiments of the present application will be given in part in the following description, and these will become obvious from the following description, or will be understood through the practice of the present application. Description of the Drawings

[0038] The above-mentioned and / or additional aspects and advantages of the embodiments of the present application will become obvious and easy to understand from the following description of the embodiments in conjunction with the drawings, where:

[0039] Figure 1 It is a schematic flowchart of the test method of the embodiments of the present application;

[0040] Figure 2 It is a schematic diagram of the process of the test method of the embodiments of the present application;

[0041] Figure 3 It is a schematic diagram of the basic structure of the test device of the embodiments of the present application;

[0042] Figure 4 It is a schematic diagram of the structure of the electronic device of the embodiments of the present application. Detailed Embodiments

[0043] Embodiments of the present application will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and are only used to explain the present application and should not be construed as a limitation to the present application.

[0044] Those skilled in the art of the present technology can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the", and "said" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present application means the presence of the described features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The phrase "and / or" used herein includes all or any unit and all combinations of one or more related listed items.

[0045] The main purpose of the embodiments of the present application is to provide a test method for splitting a link in the form of a pointer and separately testing the split links in a long-link automated test scenario. The main problems to be solved are as follows: 1. There are multiple service nodes in the long link, and the development progress is inconsistent, so unified testing cannot be carried out; 2. In a long-link system, if a problem occurs in production, then troubleshooting will be a very cumbersome process, and the embodiments of the present application can be used to troubleshoot line faults in segments; 3. The master control configuration realizes unified control of the baffle and can be plugged and unplugged at any time.

[0046] To make the purpose, technical solutions, and advantages of the embodiments of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0047] The technical solutions of the embodiments of the present application and how the technical solutions of the embodiments of the present application solve the above technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.

[0048] An embodiment of the present application provides a test method, which is executed by a computer device. The computer device can be a terminal or a server. The terminal can be a desktop device or a mobile terminal. The server can be an independent physical server, a physical server cluster, or a virtual server. As Figure 1 shown, the method includes:

[0049] Step S110: Receive a test request sent by a client for any microservice. Any microservice is a real service and / or a stub service. A real service is a service that includes service nodes marked by a stub pointer in a test link. A stub service includes services of service nodes other than those marked by the stub pointer in the test link. The test link includes multiple service nodes. Step S120: Obtain the routing information of each service node included in any microservice. Step S130: Based on the routing information of each service node included in any microservice, test the test request and return a corresponding test result.

[0050] Mock testing (stub testing) is a testing method in which, during the testing process, for some objects that are not easy to construct or obtain, a virtual object is created for testing. For example, in some cross-system performance testing projects, due to objective factors (such as limited test hardware resources and coordination between multiple systems), it is often impossible to build a complete test environment to complete the testing work. At this time, the system under test can be built, and then a software program can be used to simulate the functions of other related systems. This software program is generally called a stub.

[0051] In mock testing, a mock tool or mock platform will determine the expected return result based on the specific call parameters of the caller (i.e., the party that needs to obtain the mock object). The expected result is what will happen when the predefined explicit mock object is executed, such as returning a specific value, throwing an exception, or triggering an event.

[0052] In an example, a user can control the service nodes marked by the stub pointer in the test link through a user terminal or a client installed in the user terminal. There are multiple service nodes in this test link, that is, the test link is composed of multiple service nodes. Among them, the service composed of the service nodes marked by the stub pointer in the test link can be recorded as a real service, and the service composed of the service nodes other than those marked by the stub pointer in the test link can be recorded as a stub service. Equivalently, by marking the service nodes in the form of pointers, it is determined which service nodes in the long link (i.e., the test link) need to be combined, and the service nodes outside the pointer marking are the services that need to be mocked, thus realizing the segmentation of the link in the form of pointers and enabling separate testing of the segmented links.

[0053] Among them, during the process of marking service nodes through the baffle pointer, according to the test requirements, the service node pointed to by the baffle pointer can be flexibly determined. The baffle pointer points to a service node (such as service node A1), and this service node (such as service node A1) is the service node marked by the baffle pointer. Thus, the baffle pointer can be freely adjusted left and right like a cursor to mark service nodes, realizing the free switching between real services and baffle services.

[0054] The method of the embodiment of this application assumes that the system under test is in the same microservice cluster. Among them, the microservice cluster includes a service gateway, service nodes, a baffle control center, and baffles. During the actual test process, first, the service gateway receives a test request for real services and / or baffle services sent by the user through the client. Among them, the real service is a service that includes the service nodes marked by the baffle pointer in the test link, and the baffle service includes the services of the service nodes other than those marked by the baffle pointer in the test link. The test link includes multiple service nodes. Then, after receiving the test request, the service gateway obtains the routing information of each service node included in the real service and / or baffle service. Then, based on the routing information of each service node included in the obtained real service and / or baffle service, the test request is tested and the corresponding test result is returned.

[0055] For the test method provided by the embodiment of this application, on the one hand, by marking service nodes through the baffle pointer, the service nodes that need to be combined into real services in the test link can be accurately determined, and the service nodes other than those marked by the baffle pointer are determined as the baffle services that need to be mocked, so that any multiple adjacent service nodes in the test link can be combined without relying on other service nodes and provide a stable test environment externally. On the other hand, through the baffle pointer, a non-invasive and pluggable baffle service is realized. The baffle can be plugged in and used immediately, and at the same time, it can be freely adjusted left and right like a cursor, so that in the process of link development, the service nodes with faster development progress are tested first, and the service nodes with slower development progress are tested later, without affecting each other, realizing the segmented troubleshooting of link development.

[0056] Next, the embodiments of this application will be specifically introduced:

[0057] In a possible implementation manner, obtaining the routing information of each service node included in any microservice includes:

[0058] Sending a query request to the microservice registry to query the routing information of each service node included in any microservice. The microservice registry is used to register the service gateway, service nodes, baffle control center, and baffle services. The baffle control center is used to control the transfer of test requests to real services or baffle services;

[0059] Receive the routing information of each service node included in any microservice returned by the microservice registration center.

[0060] Before receiving a test request from a customer for any microservice, the following steps are also included:

[0061] Register the service gateway, service node, baffle central control and baffle service to the microservice registration center.

[0062] Specifically, when a user initiates a test request for any backend microservice through a client, in the microservice architecture, the test request for any backend microservice is forwarded through the service gateway. After the service gateway receives the test request from the client for any backend microservice, it needs to query the routing information of each service node in the microservice from the microservice registration center, where the microservice registration center stores the routing information of each service node in the test link. In one example, the service gateway can obtain the routing information of each service node in any microservice from the microservice registration center by sending a query request to the microservice registration center to query the routing information of each service node included in any microservice.

[0063] After receiving the query request, the microservice registration center searches for the corresponding routing information and returns it to the service gateway, that is, the service gateway receives the routing information of each service node included in any microservice returned by the microservice registration center.

[0064] It should be noted that the premise of using the method of the embodiment of the present application is that the system under test needs to be located in the same microservice cluster, so the service gateway, service node, baffle central control and baffle service used by the microservice need to be registered in advance to the microservice registration center.

[0065] In a possible implementation, based on the routing information of each service node included in any microservice, the test request is tested and the corresponding test result is returned, including:

[0066] The routing information of each service node included in any microservice is sent to the baffle central control, so that the baffle central control forwards the test request to the corresponding real service or baffle service based on the preset situation and the routing information of each service node included in any microservice, and tests the test request through the real service or baffle service and returns the corresponding test result.

[0067] Specifically, after the service gateway obtains the routing information of each service node included in any one microservice from the microservice registry, it forwards the routing information of each service node included in the any one microservice to the baffle control center, and the baffle control center controls the forwarding direction, that is, the baffle control center determines whether to forward the test request for the any one microservice to the real service or the baffle service according to the pre-set situation, so as to test the test request for the any one microservice through the real service or the baffle service and return the corresponding test result.

[0068] In practical applications, the baffle service acts on each service node in the form of a pointer, and the baffle service supports setting assertions, which can judge input parameters, output parameters, input parameters and output parameters, etc., to determine whether they meet the expectations. Subsequently, the assertion result can be returned to the baffle control center for unified analysis and display.

[0069] The embodiment of the present application also introduces the concept of a general controller. The general controller can realize the registration of pointers, unified management, and generation of baffle logic. At the same time, the general controller can also automatically generate a baffle service according to the baffle logic according to the page configuration of the user on the client side, realizing the automatic switching between the real service and the baffle service. In addition, assertions, complex logics, etc. can be implanted into the baffle pointer, so as to accurately assert the input and output of the baffle service.

[0070] It should be noted that the embodiment of the present application is mainly aimed at the scenario in the automated testing of long links, where any number of adjacent service nodes in the link can be combined and can provide a stable test environment externally without relying on other nodes.

[0071] Figure 2 A process schematic diagram of the test method of the embodiment of the present application is given. In Figure 2 , the baffle acts on each service node in the form of a pointer, and the link is separated and tested separately for the marked interval. Figure 2 The specific steps in

[0072] 1. Register the service gateway, service nodes, baffle control center, and baffle used by the microservice to the microservice registry. Since the premise of using the method of the embodiment of the present application is that the system to be tested needs to be in the same microservice cluster, it is necessary to register the service gateway, service nodes, baffle control center, and baffle used by the microservice to the microservice registry.

[0073] 2. The client initiates a request (test request) for any one microservice in the backend. In the microservice architecture, the request for any one service in the backend is forwarded through the service gateway;

[0074] 3. If the service gateway wants to forward requests to the corresponding service nodes according to the client's requirements, it needs to query the routing information of each service node from the microservice registry. This step is to query the routing information of the service nodes from the registry;

[0075] 4. The microservice registry responds to the query request of the service gateway and returns the service routing information;

[0076] 5. The service gateway forwards the routing information to the baffle control center, and the baffle control center controls the forwarding direction;

[0077] 6. The baffle control center determines whether to forward the request to the real service or the baffle service according to the settings;

[0078] 7. The baffle service supports setting assertions, which can be used to assert the input and output parameters to determine whether they meet the expectations, and then return the assertion results to the baffle control center for unified analysis and display;

[0079] 8. The real service node or the baffle service processes the client's request and returns the request response.

[0080] In summary, the difference between the embodiment of the present application and the traditional baffle technology lies in the introduction of the concepts of pointer and total control. Among them, the pointer can implement a zero-intrusion and pluggable baffle, and can be freely adjusted left and right like a cursor. The total control can implement the registration, unified management of the pointer and the baffle logic. The total control can automatically generate the baffle service according to the page configuration to realize the automatic switching between the real service and the mock service (i.e., the baffle service). In addition, assertions, complex logics, etc. can be implanted in the pointer, so as to accurately assert the input and output of the baffle.

[0081] In addition, the method of the embodiment of the present application realizes that the one with a faster development progress is tested first and the one with a slower development progress is tested later during the development process of the long-link system, without affecting each other. Moreover, during the testing process of the long-link system, a pluggable and automated baffle is realized, and the baffle can be plugged in and used immediately.

[0082] Figure 3 FIG. is a schematic structural diagram of a testing device provided in another embodiment of the present application. As Figure 3 shown, the device 300 may include a receiving module 301, an obtaining module 302 and a testing module 303, where:

[0083] The receiving module 301 is configured to receive a test request sent by a client for any microservice. Any microservice is a real service and / or a baffle service. The real service is a service including service nodes marked by baffle pointers in the test link, and the baffle service includes services of service nodes other than those marked by baffle pointers in the test link. The test link includes multiple service nodes;

[0084] An acquisition module 302, configured to acquire the routing information of each service node included in any microservice;

[0085] A test module 303, configured to test a test request based on the routing information of each service node included in any microservice and return a corresponding test result.

[0086] In a possible implementation manner, the acquisition module is specifically configured to:

[0087] Send a query request for querying the routing information of each service node included in any microservice to a microservice registry, where the microservice registry is used to register service gateways, service nodes, baffle central controls, and baffle services, and the baffle central control is used to control the transfer of a test request to a real service or a baffle service;

[0088] Receive the routing information of each service node included in any microservice returned by the microservice registry.

[0089] In a possible implementation manner, the apparatus further includes a registration module;

[0090] The registration module is configured to register service gateways, service nodes, baffle central controls, and baffle services to the microservice registry.

[0091] In a possible implementation manner, the test module is specifically configured to:

[0092] Send the routing information of each service node included in any microservice to the baffle central control, so that the baffle central control forwards the test request to the corresponding real service or baffle service based on the preset situation according to the routing information of each service node included in any microservice, and the real service or baffle service tests the test request and returns a corresponding test result.

[0093] In a possible implementation manner, the baffle service acts on each service node in a pointer manner, and the baffle service supports setting assertions, where the assertions are used to determine whether input parameters and / or output parameters meet expectations and obtain corresponding assertion results.

[0094] In a possible implementation manner, the apparatus further includes a processing module;

[0095] The processing module is configured to register and uniformly manage baffle pointers through a master control, and generate a baffle service according to baffle logic.

[0096] On one hand, the device provided by the embodiment of the present application marks service nodes through the baffle pointer, which can accurately determine the service nodes that need to be combined into real services in the test link, and determine the baffle services that need to be mocked for the service nodes other than those marked by the baffle pointer, so that any multiple adjacent service nodes in the test link can be combined without relying on other service nodes and provide a stable test environment externally; on the other hand, a zero-intrusion and pluggable baffle service is realized through the baffle pointer. The baffle is plug-and-play, and at the same time, it can be freely adjusted left and right like a cursor, so that during the link development process, the service nodes with faster development progress are tested first, and the service nodes with slower development progress are tested later, without affecting each other, realizing segmented troubleshooting of link development.

[0097] It should be noted that this embodiment is a device embodiment corresponding to the above method embodiment, and this embodiment can be implemented in cooperation with the above method embodiment. The relevant technical details mentioned in the above method embodiment are still valid in this embodiment. To avoid repetition, they will not be elaborated here. Correspondingly, the relevant technical details mentioned in this embodiment can also be applied to the above method embodiment.

[0098] Another embodiment of the present application provides an electronic device, as Figure 4 shown, Figure 4 The electronic device 400 shown includes: a processor 401 and a memory 403. Among them, the processor 401 and the memory 403 are connected, such as connected through a bus 402. Further, the electronic device 400 may further include a transceiver 404. It should be noted that in practical applications, the transceiver 404 is not limited to one, and the structure of the electronic device 400 does not constitute a limitation to the embodiment of the present application.

[0099] Among them, the processor 401 is applied in the embodiment of the present application and is used to implement Figure 3 the functions of the receiving module, the obtaining module and the testing module shown. The transceiver 404 includes a receiver and a transmitter.

[0100] The processor 401 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in combination with the disclosure of the present application. The processor 401 may also be a combination for implementing computing functions, such as a combination including one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0101] The bus 402 may include a path for transmitting information between the above components. The bus 402 may be a PCI bus or an EISA bus, etc. The bus 402 may be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation,Figure 4 It is represented by only one thick line, but it does not mean that there is only one bus or one type of bus.

[0102] The memory 403 can be a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, or it can also be an EEPROM, a CD-ROM or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.

[0103] The memory 403 is used to store the application program code for executing the solution of this application and is controlled by the processor 401 to execute. The processor 401 is used to execute the application program code stored in the memory 403 to implement Figure 3 the actions of the test device provided by the illustrated embodiment.

[0104] The electronic device provided by the embodiment of this application includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it can: receive a test request for any microservice sent by a client, where any microservice is a real service and / or a mock service, the real service is a service including service nodes marked by a mock pointer in a test link, the mock service includes services of service nodes other than the service nodes marked by the mock pointer in the test link, and the test link includes multiple service nodes; then, obtain the routing information of each service node included in any microservice; then, based on the routing information of each service node included in any microservice, test the test request and return the corresponding test result.

[0105] The embodiment of this application provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the method shown in the above embodiment. On the one hand, by marking service nodes in the way of a mock pointer, it is possible to accurately determine the service nodes that need to be combined into a real service in the test link, and determine the service nodes other than the service nodes marked by the mock pointer as mock services that need to be mocked, so that any multiple adjacent service nodes in the test link can be combined without depending on other service nodes and provide a stable test environment externally; on the other hand, a zero-intrusion and pluggable mock service is realized through the mock pointer. The mock can be plugged in and used immediately, and at the same time, it can be freely adjusted left and right like a cursor, so that in the process of link development, service nodes with a faster development progress are tested first, and service nodes with a slower development progress are tested later, without affecting each other, realizing segmented troubleshooting of link development.

[0106] The computer-readable storage medium provided by the embodiments of the present application is applicable to any of the embodiments of the above method.

[0107] It should be understood that although the steps in the flowchart of the accompanying drawings are shown in sequence according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this article, there is no strict order limit for the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.

[0108] The above are only some embodiments of the present application. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.

Claims

1. A testing method, characterized in that, Applied to a service gateway, including: Register the service gateway, service nodes, baffle central control, and baffle service to the microservice registry; Receive a test request for any microservice sent by the client, where the any microservice is a real service and / or a baffle service, the real service is a service including service nodes marked by baffle pointers in the test link, the baffle service includes services of service nodes other than the service nodes marked by baffle pointers in the test link, and the test link includes multiple service nodes; Obtain the routing information of each service node included in the any microservice; Based on the routing information of each service node included in the any microservice, test the test request and return the corresponding test result; The baffle service acts on each service node in the form of a pointer, and the baffle service supports setting assertions, which are used to determine whether the input parameters and / or output parameters meet the expectations and obtain the corresponding assertion results; Before receiving the test request for any microservice sent by the client, it further includes: Register and uniformly manage the baffle pointers through the master control, and generate the baffle service according to the baffle logic; Among them, the master control automatically generates the baffle service according to the page configuration of the user on the client and the baffle logic.

2. The method according to claim 1, characterized in that, The obtaining the routing information of each service node included in the any microservice includes: Send a query request to the microservice registry to query the routing information of each service node included in the any microservice. The microservice registry is used to register the service gateway, the service nodes, the baffle central control, and the baffle service. The baffle central control is used to control the transfer of the test request to the real service or the baffle service; Receive the routing information of each service node included in the any microservice returned by the microservice registry.

3. The method according to claim 1, characterized in that, The based on the routing information of each service node included in the any microservice, testing the test request and returning the corresponding test result includes: Send the routing information of each service node included in the any microservice to the baffle central control, so that the baffle central control forwards the test request to the corresponding real service or baffle service based on the preset situation according to the routing information of each service node included in the any microservice, and the real service or baffle service tests the test request and returns the corresponding test result.

4. A testing device, characterized in that, Including: Register the service gateway, service nodes, baffle central control, and baffle service to the microservice registry; A receiving module, configured to receive a test request for any microservice sent by the client, where the any microservice is a real service and / or a baffle service, the real service is a service including service nodes marked by baffle pointers in the test link, the baffle service includes services of service nodes other than the service nodes marked by baffle pointers in the test link, and the test link includes multiple service nodes; An obtaining module, configured to obtain the routing information of each service node included in the any microservice; A test module, configured to test the test request based on the routing information of each service node included in any one of the microservices and return a corresponding test result; A processing module, configured to register and uniformly manage the baffle pointer through a master controller, and generate a baffle service according to the baffle logic; The baffle service acts on each service node in the form of a pointer, and the baffle service supports setting assertions, where the assertions are used to determine whether input parameters and / or output parameters meet expectations and obtain corresponding assertion results; Among them, the master controller automatically generates a baffle service according to the baffle logic based on the page configuration of the user at the client.

5. The device according to claim 4, characterized in that, The obtaining module is specifically configured to: Send a query request to the microservice registry to query the routing information of each service node included in any one of the microservices, where the microservice registry is used to register the service gateway, the service node, the baffle master controller, and the baffle service; Receive the routing information of each service node included in any one of the microservices returned by the microservice registry.

6. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, the method according to any one of claims 1-3 is implemented.

7. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the program is executed by the processor, the method according to any one of claims 1-3 is implemented.

Citation Information

Patent Citations

  • Micro-service automatic testing method based on Redis database

    CN110147326A

  • Service calling method and device based on micro-service and storage medium

    CN112134922A