Test method, device, electronic device and computer storage medium
The test request forwarding is solved by marking the service node and the baffle middle platform through the baffle pointer, and the problem of inflexible and invasive baffle program in microservice test is solved, achieving a flexible and stable test environment and the effect of quickly troubleshooting link problems.
Patent Information
- Application Number
- CN202110088917.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-22
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2041-01-22
AI Technical Summary
In the existing microservice testing technology, the baffle program is not flexible enough, needs to be written separately, takes up a large amount of hardware resources, frequent interface changes, and strong invasiveness, so it is impossible to flexibly adjust and quickly respond to the problem of inconsistent microservice development progress.
Marking service nodes through the baffle pointer, zero-invasion, pluggable baffle service is achieved, and the baffle middle platform is used to flexibly forward test requests to real or baffle services, and return results through assertions, supporting free adjustment of baffle pointer and link segmentation testing.
It realizes a flexible and stable testing environment for microservice links, supports fast-developed services to test first without affecting each other, quickly troubleshoot link problems, and improves testing efficiency and accuracy.
Smart Images

Figure CN112765029B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of testing technology. Specifically, the present application relates to a testing method, device, electronic device and computer storage medium. Background Art
[0002] In the field of distributed internet technology, the microservices architecture has gradually become mainstream. After splitting application modules into microservices, the dependencies and collaboration networks between services become complex. Improving the testability of microservices with external dependencies directly impacts the software delivery cycle and quality.
[0003] In existing microservice testing technologies, developing interface shields is often used to address external dependencies. For example, when testing interfaces, mock testing is often used to simulate the actual working environment. Mock testing involves creating virtual objects for testing purposes that are difficult to construct or obtain. A mock shield is set to enable or disable mock testing. When the mock test function is enabled, the shield is turned on; otherwise, it is turned off.
[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 separate baffle written, 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 requires hardware resources. Fourth, the implantation of the baffle may require modifying the call address in the code configuration file, which intrudes into 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 deficiencies, 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. The real service is a service that includes the target service node pointed to by the baffle pointer in the test link and the service node located before the target service node pointed to by the baffle pointer. The baffle service is a service that includes the service node located after the target service node pointed to by the baffle pointer in the test link. The test link includes multiple service nodes.
[0008] Send a test request to the baffle middle platform, so that the baffle middle platform can determine whether to forward the test request to the real service or baffle service according to the pre-set parameters, and assert the test request through the real service or baffle service and return the corresponding assertion result.
[0009] In one possible implementation, the baffle service asserts the test request and returns the corresponding assertion results, including:
[0010] The baffle assertion in the baffle service determines whether the test request meets expectations and returns the corresponding assertion result.
[0011] In a possible implementation, the service gateway is located in a test system, the test system includes a front-end module, and the front-end module includes a baffle pointer management page, a baffle logic extension page, an assertion management page, and a service node management page;
[0012] Before the client sends a test request to any microservice, it also includes:
[0013] Add a bezel pointer through the bezel pointer management page;
[0014] Add baffle logic through the baffle logic extension page and generate baffle services based on the baffle logic;
[0015] Add baffle assertions through the assertion management page;
[0016] Through the service node management page, the baffle pointer is pointed to the target service node in the test link, and the target service node pointed to by the baffle pointer and the service node located before the target service node pointed to by the baffle pointer are determined as real services, and the service node located after the target service node pointed to by the baffle pointer is determined as baffle service.
[0017] In one possible implementation, the baffle pointer management page is also used to display and control the status of the baffle pointer; the baffle logic extension page is also used to display and edit the baffle extension logic or customize the baffle extension logic; the assertion management page is also used to display all current assertions and edit the assertion logic; the service node management page is also used to display the status of each service node in the current microservice registration center and the dependency relationship between each service node, wherein the microservice registration center is used to register the service gateway, service node, baffle middle platform and baffle service;
[0018] In a possible implementation, the testing system further includes a presentation module, which is used to support page presentation and is developed using the Vue.js programming language.
[0019] In one possible implementation, the test system further includes a data module, which is used to control data storage logic, including at least one of service node information, baffle logic, baffle assertion, user account information, and service routing information.
[0020] In one possible implementation, the test system further includes a database module, which includes a relational database MySQL, a cache database Redis, and a distributed document database Elasticsearch;
[0021] Among them, the relational database MySQL is used to store relational data, the cache database Redis is used to store hot data; the distributed document database Elasticsearch is used to retrieve text information such as baffle services, baffle assertions and service nodes.
[0022] In one possible implementation, the test system also includes a baffle middle platform, which includes a service node link management module corresponding to the service node management page, a baffle management module corresponding to the baffle pointer management page, a baffle management module corresponding to the baffle logic extension page, and an assertion management module corresponding to the assertion management page.
[0023] In one aspect, a testing device is provided, comprising:
[0024] A receiving module is configured to receive a test request for any microservice sent by a client, where any microservice is a real service and / or a baffle service. A real service is a service that includes a target service node pointed to by a baffle pointer in a test link and a service node located before the target service node pointed to by the baffle pointer. A baffle service is a service that includes a service node located after the target service node pointed to by the baffle pointer in a test link. The test link includes multiple service nodes.
[0025] The processing module is used to send a test request to the baffle middle platform, so that the baffle middle platform can determine whether to forward the test request to the real service or the baffle service according to the pre-set parameters, and assert the test request through the real service or the baffle service and return the corresponding assertion result.
[0026] In one possible implementation, when the processing module asserts the test request through the baffle service and returns the corresponding assertion result, it is configured to:
[0027] The baffle assertion in the baffle service determines whether the test request meets expectations and returns the corresponding assertion result.
[0028] In a possible implementation, the service gateway is located in a test system, the test system includes a front-end module, and the front-end module includes a baffle pointer management page, a baffle logic extension page, an assertion management page, and a service node management page;
[0029] The device also includes an adding module, which is used to:
[0030] Add a bezel pointer through the bezel pointer management page;
[0031] Add baffle logic through the baffle logic extension page and generate baffle services based on the baffle logic;
[0032] Add baffle assertions through the assertion management page;
[0033] Through the service node management page, the baffle pointer is pointed to the target service node in the test link, and the target service node pointed to by the baffle pointer and the service node located before the target service node pointed to by the baffle pointer are determined as real services, and the service node located after the target service node pointed to by the baffle pointer is determined as baffle service.
[0034] In one possible implementation, the baffle pointer management page is also used to display and control the status of the baffle pointer; the baffle logic extension page is also used to display and edit the baffle extension logic or customize the baffle extension logic; the assertion management page is also used to display all current assertions and edit the assertion logic; the service node management page is also used to display the status of each service node in the current microservice registration center and the dependency relationship between each service node, wherein the microservice registration center is used to register the service gateway, service node, baffle middle platform and baffle service;
[0035] In a possible implementation, the testing system further includes a presentation module, which is used to support page presentation and is developed using the Vue.js programming language.
[0036] In one possible implementation, the test system further includes a data module, which is used to control data storage logic, including at least one of service node information, baffle logic, baffle assertion, user account information, and service routing information.
[0037] In one possible implementation, the test system further includes a database module, which includes a relational database MySQL, a cache database Redis, and a distributed document database Elasticsearch;
[0038] Among them, the relational database MySQL is used to store relational data, the cache database Redis is used to store hot data; the distributed document database Elasticsearch is used to retrieve text information such as baffle services, baffle assertions and service nodes.
[0039] In one possible implementation, the test system also includes a baffle middle platform, which includes a service node link management module corresponding to the service node management page, a baffle management module corresponding to the baffle pointer management page, a baffle management module corresponding to the baffle logic extension page, and an assertion management module corresponding to the assertion management page.
[0040] On the one hand, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned testing method when executing the program.
[0041] In one aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the above-mentioned testing method is implemented.
[0042] The test method provided in the embodiment of the present application, on the one hand, can accurately determine the service nodes that need to be combined into real services in the test link by marking the service nodes by means of baffle pointers, and determine the service nodes other than the service nodes marked by the baffle pointers as 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 to the outside world; on the other hand, a zero-intrusion, pluggable baffle service is realized through the baffle pointer, and the baffle is plug-and-play, 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, thereby realizing segmented troubleshooting of link development.
[0043] Additional aspects and advantages of the embodiments of the present application will be partially given in the description below, which will become apparent from the description below or be understood through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The above and / or additional aspects and advantages of the embodiments of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0045] Figure 1 A flow chart of the testing method according to an embodiment of the present application;
[0046] Figure 2 A schematic diagram of the architecture of a test system according to an embodiment of the present application;
[0047] Figure 3 A schematic diagram of the basic structure of the testing device according to an embodiment of the present application;
[0048] Figure 4 This is a schematic structural diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0049] The following describes in detail embodiments of the present application, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and are not to be construed as limiting the present application.
[0050] It will be understood by those skilled in the art that, unless expressly stated otherwise, the singular forms "a", "an", "said" and "the" 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 refers to the presence of the 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 refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, "connected" or "coupled" as used herein may include wireless connections or wireless couplings. The term "and / or" used herein includes all or any units and all combinations of one or more associated listed items.
[0051] The main purpose of the embodiment of the present application is to provide a test method for segmenting the link in a pointer manner and testing the segmented links separately in a long link automation test scenario. The main problems solved are as follows: 1. There are multiple service nodes in a long link, and the development progress is inconsistent, making it impossible to conduct unified testing; 2. In a long link system, if there is a problem in production, then troubleshooting the problem will be a very tedious process. The embodiment of the present application can be used to implement segmented rapid troubleshooting and accurately locate online fault problems; 3. Service link management can clearly analyze the call chain path.
[0052] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0053] The following specific embodiments describe in detail 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-mentioned technical problems. The following 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 in conjunction with the accompanying drawings.
[0054] One embodiment of the present application provides a testing method, which is executed by a computer device, which may be a terminal or a server. The terminal may be a desktop device or a mobile terminal. The server may be an independent physical server, a physical server cluster, or a virtual server. Figure 1 As shown, the method includes:
[0055] Step S110: Receive a test request for any microservice sent by a client, where any microservice is a real service and / or a baffle service. A real service is a service that includes a target service node pointed to by a baffle pointer in a test link and a service node located before the target service node pointed to by the baffle pointer. A baffle service is a service that includes a service node located after the target service node pointed to by the baffle pointer in the test link. The test link includes multiple service nodes.
[0056] Step S120, sending a test request to the baffle middle platform, so that the baffle middle platform determines to forward the test request to the real service or baffle service according to pre-set parameters, and asserts the test request through the real service or baffle service and returns the corresponding assertion result.
[0057] Mock testing (also known as baffle testing) involves creating virtual objects to facilitate testing of difficult-to-construct or difficult-to-access objects during the testing process. For example, in some cross-system performance testing projects, objective limitations (such as limited testing hardware resources and coordination between multiple systems) often make it impossible to build a complete test environment to complete the test. In such cases, a software program can be used to simulate the functionality of other related systems using the system under test. This software program is generally called a baffle.
[0058] In mock testing, the mock tool or platform determines the expected result based on the call parameters specified by the caller (the party that needs to obtain the mock object). The expected result is a pre-defined, clear definition of what will happen when the mock object is executed, such as returning a specific value, throwing an exception, or triggering an event.
[0059] In one example, a user can control the baffle pointer to mark the service nodes in the test link through a user terminal or a client installed in the user terminal. There are multiple service nodes in the 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 baffle pointer in the test link can be recorded as a real service, and the service composed of the service nodes other than the service nodes marked by the baffle pointer in the test link can be recorded as a baffle service. This is equivalent to marking the service nodes in the form of pointers to determine which service nodes in the long link (i.e., the test link) need to be combined, and the service nodes outside the pointer mark are the services that need to be mocked, thereby realizing the segmentation of the link in the form of pointers and the ability to test the segmented links separately.
[0060] Among them, in the process of marking the service node through the bezel pointer, the service node pointed to by the bezel pointer can be flexibly determined according to the test requirements. The bezel pointer points to a service node (for example, service node A1), and the service node (for example, service node A1) is the service node marked by the bezel pointer. Therefore, the bezel pointer can be freely adjusted left and right like a cursor to mark the service node, realizing free switching between real service and bezel service.
[0061] The method of the embodiment of the present application assumes that the system under test is located in the same microservice cluster, wherein the microservice cluster includes a service gateway, a service node, a baffle central control, and a baffle. In the actual testing process, first, the service gateway receives a test request for a real service and / or a baffle service sent by a user through a client, wherein the real service is a service including a target service node pointed to by a baffle pointer in a test link and a service node located before the target service node pointed to by the baffle pointer, and the baffle service is a service including a service node located after the target service node pointed to by the baffle pointer in the test link, and the test link includes multiple service nodes. Then, the service gateway forwards the received test request to the baffle middle station; then, the baffle middle station determines whether to forward the test request to the real service or the baffle service based on the pre-set parameters. For example, the baffle middle station determines whether to forward the test request to the real service or the baffle service based on the pre-set parameters. If it is determined to be forwarded to the real service, the baffle middle station forwards the test request to the real service. If it is determined to be forwarded to the baffle service, the baffle middle station forwards the test request to the baffle service; then, when the real service receives the test request, the real service asserts the test request and returns the assertion result to the baffle middle station, and the baffle middle station displays the received assertion result. Similarly, when the baffle service receives the test request, the baffle service asserts the test request and returns the assertion result to the baffle middle station, and the baffle middle station displays the received assertion result.
[0062] Assertions are programming terms that represent Boolean expressions. When writing code, we always make assumptions, and assertions are used to capture these assumptions in the code. Programmers can trust that an expression will be true at a specific point in the program. Assertions can be enabled and disabled at any time, allowing them to be enabled during testing and disabled during deployment. Similarly, after the program is operational, end users can re-enable assertions if they encounter problems. Using assertions can create more stable, higher-quality, and less error-prone code.
[0063] The test method provided in the embodiment of the present application, on the one hand, can accurately determine the service nodes that need to be combined into real services in the test link by marking the service nodes by means of baffle pointers, and determine the service nodes other than the service nodes marked by the baffle pointers as 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 to the outside world; on the other hand, a zero-intrusion, pluggable baffle service is realized through the baffle pointer, and the baffle is plug-and-play, 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, thereby realizing segmented troubleshooting of link development.
[0064] The following is a detailed introduction to the embodiments of the present application:
[0065] In one possible implementation, the baffle service asserts the test request and returns the corresponding assertion results, including:
[0066] The baffle assertion in the baffle service determines whether the test request meets expectations and returns the corresponding assertion result.
[0067] In one example, a baffle assertion can be set in the baffle (i.e., the baffle service) so that the baffle has an assertion function and can perform assertion processing. In actual applications, when asserting a test request through the baffle service, the baffle assertion in the baffle service is actually used to determine whether the test request meets expectations. If the test request meets expectations, an assertion result that meets expectations is returned, such as true (indicating true) or 1 (indicating true). If the test request does not meet expectations, an assertion result that does not meet expectations is returned, such as false (indicating false) or 0 (indicating false).
[0068] In a possible implementation, the service gateway is located in a test system, the test system includes a front-end module, and the front-end module includes a baffle pointer management page, a baffle logic extension page, an assertion management page, and a service node management page;
[0069] Before the client sends a test request to any microservice, it also includes:
[0070] Add a bezel pointer through the bezel pointer management page;
[0071] Add baffle logic through the baffle logic extension page and generate baffle services based on the baffle logic;
[0072] Add baffle assertions through the assertion management page;
[0073] Through the service node management page, the baffle pointer is pointed to the target service node in the test link, and the target service node pointed to by the baffle pointer and the service node located before the target service node pointed to by the baffle pointer are determined as real services, and the service node located after the target service node pointed to by the baffle pointer is determined as baffle service.
[0074] In one possible implementation, the baffle pointer management page is also used to display and control the status of the baffle pointer; the baffle logic extension page is also used to display and edit the baffle extension logic or customize the baffle extension logic; the assertion management page is also used to display all current assertions and edit the assertion logic; the service node management page is also used to display the status of each service node in the current microservice registration center and the dependency relationship between each service node, wherein the microservice registration center is used to register the service gateway, service node, baffle middle platform and baffle service;
[0075] In a possible implementation, the testing system further includes a presentation module, which is used to support page presentation and is developed using the Vue.js programming language.
[0076] In one possible implementation, the test system further includes a data module, which is used to control data storage logic, including at least one of service node information, baffle logic, baffle assertion, user account information, and service routing information.
[0077] In one possible implementation, the test system further includes a database module, which includes a relational database MySQL, a cache database Redis, and a distributed document database Elasticsearch;
[0078] Among them, the relational database MySQL is used to store relational data, the cache database Redis is used to store hot data; the distributed document database Elasticsearch is used to retrieve text information such as baffle services, baffle assertions and service nodes.
[0079] In one possible implementation, the test system also includes a baffle middle platform, which includes a service node link management module corresponding to the service node management page, a baffle management module corresponding to the baffle pointer management page, a baffle management module corresponding to the baffle logic extension page, and an assertion management module corresponding to the assertion management page.
[0080] In actual applications, the baffle acts on each service node in the form of a pointer, separating the link in the interval marked by the pointer for separate testing.
[0081] The following is a detailed introduction to the front-end module, display module, baffle middle platform, data module, and database module included in the embodiment of the present application:
[0082] 1. The front-end module, or the page side, primarily consists of four pages: service node management, baffle pointer management, assertion management, and baffle extension logic. Service node management: This page displays the status of each service node in the current microservice registry, as well as the dependencies between them. Baffle pointer management: This page displays and controls the status of baffle pointers. Baffle pointers point to each service node in the service node call chain. The node where the pointer resides marks the demarcation point between the real service and the baffle service. The pointer can be moved, started, and deleted. Assertion management: This page displays all current assertions and edits assertion logic. Assertions are provided for baffles, including assertions on input parameters before the baffle and output parameters after the baffle, to ensure the correctness of service input and output before and after the baffle. Baffle extension logic: This page displays and edits baffle extension logic. Baffles for some complex businesses require custom logic, such as calculation logic and conversion logic.
[0083] 2. The display module (also called the display layer) is developed using the Vue.js language. It mainly supports page display and connects to the backend interface to transmit data.
[0084] 3. The baffle middle platform is the core of all baffle functions. Its main modules include service node link management module, service node routing relationship management module, baffle management module, assertion management module, etc. Its main functions correspond to the front-end page end.
[0085] 4. The data module (also called the data layer) is the data storage logic, including service node information, baffle logic, baffle assertions, user account information, service routing information, etc.
[0086] 5. The database module (also known as the database layer) uses three databases: the relational database MySQL, the cache database Redis, and the distributed document database Elasticsearch. All relational data is stored in MySQL, while hot data such as service routing information is cached in the Redis database. The Elasticsearch database is used to retrieve text information such as baffles, assertions, and service nodes.
[0087] 6. The baffle pointer acts on the microservice environment. The specific logic is as follows:
[0088] (1) Add a baffle pointer to the entrance from the baffle pointer management page on the front end of the baffle tool;
[0089] (2) Using the baffle logic extension page as the entry point, add baffle logic, generate baffle services, and register them with the microservice registration center;
[0090] (3) Add a baffle assertion on the assertion management page to determine whether the output of the upstream node meets expectations;
[0091] (4) On the service node management page, point the baffle pointer to a service node. In this way, the nodes after the current service node will be mocked and replaced by the baffle service.
[0092] (5) The service user initiates a request to the backend service using the gateway as the entry point;
[0093] (6) The service gateway forwards the request to the baffle middle station;
[0094] (7) The baffle middleware decides whether to forward the request to the real service or the baffle service based on the configured parameters;
[0095] (8) The baffle makes an assertion and returns it to the baffle middle platform for display;
[0096] (9) If you want to change the position of the bezel pointer, you can adjust the pointer to the position of any service node on the page end.
[0097] The embodiments of the present application have been applied to the testing of multiple systems in banks, allowing them to test any area in the long transaction chain of complex banking business, and also making a qualitative leap in automated testing.
[0098] Figure 3 A structural diagram of a testing device provided in another embodiment of the present application is shown in FIG. Figure 3 As shown, the apparatus 300 may include a receiving module 301 and a processing module 302, wherein:
[0099] Receiving module 301 is used to receive a test request for any microservice sent by a client. Any microservice is a real service and / or a baffle service. A real service is a service that includes a target service node pointed to by a baffle pointer in a test link and a service node located before the target service node pointed to by the baffle pointer. A baffle service is a service that includes a service node located after the target service node pointed to by the baffle pointer in the test link. The test link includes multiple service nodes.
[0100] Processing module 302 is used to send a test request to the baffle middle platform, so that the baffle middle platform determines to forward the test request to the real service or baffle service according to pre-set parameters, and assert the test request through the real service or baffle service and return the corresponding assertion result.
[0101] In one possible implementation, when the processing module asserts the test request through the baffle service and returns the corresponding assertion result, it is configured to:
[0102] The baffle assertion in the baffle service determines whether the test request meets expectations and returns the corresponding assertion result.
[0103] In a possible implementation, the service gateway is located in a test system, the test system includes a front-end module, and the front-end module includes a baffle pointer management page, a baffle logic extension page, an assertion management page, and a service node management page;
[0104] The device also includes an adding module, which is used to:
[0105] Add a bezel pointer through the bezel pointer management page;
[0106] Add baffle logic through the baffle logic extension page and generate baffle services based on the baffle logic;
[0107] Add baffle assertions through the assertion management page;
[0108] Through the service node management page, the baffle pointer is pointed to the target service node in the test link, and the target service node pointed to by the baffle pointer and the service node located before the target service node pointed to by the baffle pointer are determined as real services, and the service node located after the target service node pointed to by the baffle pointer is determined as baffle service.
[0109] In one possible implementation, the baffle pointer management page is also used to display and control the status of the baffle pointer; the baffle logic extension page is also used to display and edit the baffle extension logic or customize the baffle extension logic; the assertion management page is also used to display all current assertions and edit the assertion logic; the service node management page is also used to display the status of each service node in the current microservice registration center and the dependency relationship between each service node, wherein the microservice registration center is used to register the service gateway, service node, baffle middle platform and baffle service;
[0110] In a possible implementation, the testing system further includes a presentation module, which is used to support page presentation and is developed using the Vue.js programming language.
[0111] In one possible implementation, the test system further includes a data module, which is used to control data storage logic, including at least one of service node information, baffle logic, baffle assertion, user account information, and service routing information.
[0112] In one possible implementation, the test system further includes a database module, which includes a relational database MySQL, a cache database Redis, and a distributed document database Elasticsearch;
[0113] Among them, the relational database MySQL is used to store relational data, the cache database Redis is used to store hot data; the distributed document database Elasticsearch is used to retrieve text information such as baffle services, baffle assertions and service nodes.
[0114] In one possible implementation, the test system also includes a baffle middle platform, which includes a service node link management module corresponding to the service node management page, a baffle management module corresponding to the baffle pointer management page, a baffle management module corresponding to the baffle logic extension page, and an assertion management module corresponding to the assertion management page.
[0115] The device provided by the embodiment of the present application, on the one hand, can accurately determine the service nodes that need to be combined into real services in the test link by marking the service nodes by means of baffle pointers, and determine the service nodes other than the service nodes marked by the baffle pointers as 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 to the outside world; on the other hand, a zero-intrusion, pluggable baffle service is realized through the baffle pointer, and the baffle is plug-and-play, 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, thereby realizing segmented troubleshooting of link development.
[0116] It should be noted that this embodiment is an apparatus embodiment corresponding to the aforementioned method embodiment, and this embodiment can be implemented in conjunction with the aforementioned method embodiment. The relevant technical details mentioned in the aforementioned method embodiment are still valid in this embodiment and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the aforementioned method embodiment.
[0117] Another embodiment of the present application provides an electronic device, such as Figure 4 As shown, Figure 4 The electronic device 400 shown includes a processor 401 and a memory 403. The processor 401 and the memory 403 are connected, for example, via a bus 402. Furthermore, the electronic device 400 may also include a transceiver 404. It should be noted that in actual applications, the number of transceivers 404 is not limited to one, and the structure of the electronic device 400 does not constitute a limitation on the embodiments of the present application.
[0118] The processor 401 is used in the embodiment of the present application to implement Figure 3 The functions of the receiving module and the processing module are shown. The transceiver 404 includes a receiver and a transmitter.
[0119] Processor 401 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA, or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 401 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0120] 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 ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0121] The memory 403 may 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 an EEPROM, a CD-ROM or other optical disk storage, an optical disc storage (including a compact disc, a laser disc, an optical disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.
[0122] The memory 403 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 401. The processor 401 is used to execute the application code stored in the memory 403 to implement Figure 3 The illustrated embodiment provides for the operation of the test device.
[0123] The electronic device provided by the embodiment of the present application includes a memory, a processor and a computer program stored in the memory and capable of running on the processor. When the processor executes the program, it can achieve: receiving 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 target service node pointed to by a baffle pointer in a test link and a service node located before the target service node pointed to by the baffle pointer, and the baffle service is a service including a service node located after the target service node pointed to by the baffle pointer in the test link, and the test link includes multiple service nodes; then, sending a test request to the baffle middle station, so that the baffle middle station determines to forward the test request to the real service or the baffle service according to pre-set parameters, and asserts the test request through the real service or the baffle service and returns the corresponding assertion result.
[0124] The embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the method shown in the above embodiment when executed by a processor. On the one hand, by marking the service nodes in the form of a 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 the service nodes marked by the baffle pointer can be determined as 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 a stable test environment is provided to the outside world; on the other hand, a zero-intrusion, pluggable baffle service is realized through the baffle pointer, and the baffle is plug-and-play, 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, thereby realizing segmented troubleshooting of link development.
[0125] The computer-readable storage medium provided in the embodiments of the present application is applicable to any embodiment of the above method.
[0126] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and 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 in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0127] The above description is only part of the implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A testing method, characterized in that: Applied to service gateways, including: Receive a test request for any microservice sent by a client, where any microservice is a real service or a baffle service. The real service is a service that includes a target service node pointed to by a baffle pointer in a test link and a service node located before the target service node pointed to by the baffle pointer. The baffle service is a service that includes a service node located after the target service node pointed to by the baffle pointer in the test link, where the test link includes multiple service nodes. The test request is sent to the baffle middle platform, so that the baffle middle platform determines to forward the test request to the real service or the baffle service according to pre-set parameters, and asserts the test request through the real service or baffle service and returns the corresponding assertion result.
2. The method according to claim 1, characterized in that Asserting the test request through the baffle service and returning a corresponding assertion result, including: The baffle assertion in the baffle service is used to determine whether the test request meets expectations and return a corresponding assertion result.
3. The method according to claim 1 or 2, characterized in that The service gateway is located in a test system, and the test system includes a front-end module, and the front-end module includes a baffle pointer management page, a baffle logic extension page, an assertion management page, and a service node management page; Before the client sends a test request to any microservice, it also includes: Add the paddle pointer through the paddle pointer management page; Adding baffle logic through the baffle logic extension page and generating baffle services according to the baffle logic; Add baffle assertions through the assertion management page; Through the service node management page, the baffle pointer is pointed to the target service node in the test link, and the target service node pointed to by the baffle pointer and the service node located before the target service node pointed to by the baffle pointer are determined as real services, and the service node located after the target service node pointed to by the baffle pointer is determined as a baffle service.
4. The method according to claim 3, characterized in that The baffle pointer management page is also used to display and control the status of the baffle pointer; the baffle logic extension page is also used to display and edit the extended logic of the baffle; the assertion management page is also used to display all current assertions and edit the assertion logic; the service node management page is also used to display the status of each service node in the current microservice registration center and the dependency relationship between each service node, wherein the microservice registration center is used to register the service gateway, the service node, the baffle middle platform and the baffle service.
5. The method according to claim 3, characterized in that The testing system also includes a display module, which is used to support page display and is developed using the Vue.js programming language.
6. The method according to claim 3, characterized in that The test system further includes a data module, which is used to control data storage logic, wherein the storage logic includes at least one of service node information, baffle logic, baffle assertion, user account information, and service routing information.
7. The method according to claim 3, characterized in that The test system also includes a database module, which includes a relational database MySQL, a cache database Redis, and a distributed document database Elasticsearch; Among them, the relational database MySQL is used to store relational data, the cache database Redis is used to store hot spot data; the distributed document database Elasticsearch is used to retrieve baffle service text information, baffle assertion text information and service node text information.
8. The method according to claim 3, characterized in that The test system also includes a baffle middle platform, which includes a service node link management module corresponding to the service node management page, a baffle management module corresponding to the baffle pointer management page, a baffle management module corresponding to the baffle logic extension page, and an assertion management module corresponding to the assertion management page.
9. A testing device, characterized in that: include: a receiving module, configured to receive a test request for any microservice sent by a client, wherein the microservice is a real service or a baffle service, wherein the real service is a service including a target service node pointed to by a baffle pointer in a test link and a service node located before the target service node pointed to by the baffle pointer, and the baffle service is a service including a service node located after the target service node pointed to by the baffle pointer in the test link, wherein the test link includes multiple service nodes; A processing module is used to send the test request to the baffle middle platform, so that the baffle middle platform determines to forward the test request to the real service or the baffle service according to pre-set parameters, and assert the test request through the real service or baffle service and return the corresponding assertion result.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Service calling method and device based on micro-service and storage medium
CN112134922A