Test method, device, storage medium and product of service gateway

By recording and matching upstream and downstream data in the microservice system, test cases for the service gateway are generated, solving the problems of complexity and high manpower consumption in service gateway testing, and realizing efficient automated testing.

CN116418702BActive Publication Date: 2026-01-13DOUYIN VISION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111656627.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2026-01-13
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

In a microservice architecture, testing service gateways is complex and involves high traffic. Manually writing test cases is extremely costly, making automated testing impossible. Furthermore, service chain analysis is difficult, making it hard to comprehensively cover the testing of the entire service gateway.

Method used

By recording upstream and downstream data of the service gateway in the microservice system, link coloring is performed using the identifier of the microservice call request to obtain the interface link topology map, and upstream and downstream link data is matched to generate test cases for mock replay testing.

Benefits of technology

It greatly saves manpower in data construction and script writing, improves the testing efficiency and coverage of service gateways, and realizes automated testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116418702B_ABST
    Figure CN116418702B_ABST
Patent Text Reader

Abstract

The method comprises the following steps: recording a plurality of upstream data and a plurality of downstream data of a target interface of a service gateway; obtaining target upstream data and target downstream data belonging to a same microservice calling process; judging whether network nodes involved in the target upstream data and the target downstream data belong to the same microservice calling process match a network topology diagram of the target interface; if the network nodes match the network topology diagram, generating a test case of the service gateway to play back the target upstream data and the target downstream data when the service gateway is tested. The plurality of upstream data and the plurality of downstream data of the target interface of the service gateway are recorded by using a recording technology, and the upstream data and the downstream data belonging to the same microservice calling process are obtained to construct the test case, the service gateway can be tested according to the playback test initiated according to the test case, the manpower for data construction and script writing is saved, and the test efficiency of the service gateway is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The embodiment of the present disclosure relates to the technical field of computer and network communication, in particular to a service gateway testing method, device, storage medium and product. BACKGROUND

[0002] In the micro-service architecture, the application is designed to first divide the business function or process in advance, and each business function is independently implemented as a self-running micro-service, and then all the services required by the application are combined using the same protocol to form an application. The service gateway in the micro-service architecture is a key role in the micro-service architecture, which is used to protect, enhance and control access to micro-services. The service gateway is a system before the application or service, which is used to manage authorization, access control and traffic limitation, etc. In this way, the micro-service is protected by the service gateway, which is transparent to all callers.

[0003] Since the service gateway manages a large number of downstream services, the reliability of the gateway service itself is related to the stability of the entire micro-service system. An effective gateway service testing scheme is crucial to service protection. Currently, manual test case writing is usually used to test and accept the service gateway.

[0004] However, the gateway service scenario is very complex and has a large amount of traffic, and there are many non-idempotent interfaces. Purely human investment is huge, and automatic testing cannot be achieved. At the same time, since the service gateway aggregates all downstream micro-services, and requests are distributed to different micro-services according to different request parameters, service link analysis is difficult, and the number of services is large, so it is difficult for manual test case writing to comprehensively cover the testing of the entire service gateway. SUMMARY

[0005] The embodiment of the present disclosure provides a service gateway testing method, device, storage medium and product to save the human cost of writing test cases and improve the testing efficiency of the service gateway.

[0006] In a first aspect, the embodiment of the present disclosure provides a service gateway testing method, comprising:

[0007] recording a plurality of upstream data and a plurality of downstream data of a target interface of a service gateway in a micro-service system; wherein the upstream data is the interaction data between the service gateway and the upstream request node in the micro-service calling process, and the downstream data is the interaction data between the service gateway and the downstream micro-service node in the micro-service calling process;

[0008] from the plurality of upstream data and the plurality of downstream data, obtaining target upstream data and target downstream data belonging to the same micro-service calling process;

[0009] determine whether network nodes involved in the target upstream data and the target downstream data belonging to the same microservice invocation process match a network topology graph of the target interface, the network topology graph of the target interface including all request nodes and microservice nodes connected to the target interface;

[0010] If matched, generate test cases of the service gateway according to the target upstream data and the target downstream data belonging to the same microservice invocation process, for playing back the target upstream data and the target downstream data when testing the service gateway.

[0011] In a second aspect, the embodiments of the present disclosure provide a test device of a service gateway, comprising:

[0012] a recording unit configured to record a plurality of upstream data and a plurality of downstream data of a target interface of a service gateway in a microservice system, wherein the upstream data is interaction data between the service gateway and an upstream request node in a microservice invocation process, and the downstream data is interaction data between the service gateway and a downstream microservice node in the microservice invocation process;

[0013] a first matching unit configured to obtain target upstream data and target downstream data belonging to the same microservice invocation process from the plurality of upstream data and the plurality of downstream data;

[0014] a second matching unit configured to determine whether network nodes involved in the target upstream data and the target downstream data belonging to the same microservice invocation process match a network topology graph of the target interface, the network topology graph of the target interface including all request nodes and microservice nodes connected to the target interface;

[0015] a processing module configured to, when it is determined that the match is met, generate test cases of the service gateway according to the target upstream data and the target downstream data belonging to the same microservice invocation process, for playing back the target upstream data and the target downstream data when testing the service gateway.

[0016] In a third aspect, the embodiments of the present disclosure provide an electronic device, comprising at least one processor and a memory;

[0017] the memory stores computer-executable instructions;

[0018] the at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the test method of the service gateway as described in the above first aspect and various possible designs of the first aspect.

[0019] In a fourth aspect, the embodiments of the present disclosure provide a computer readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, a service gateway testing method is realized, as described in the first aspect and various possible designs of the first aspect.

[0020] In a fifth aspect, the embodiments of the present disclosure provide a computer program product, which includes computer execution instructions. When a processor executes the computer execution instructions, a service gateway testing method is realized, as described in the first aspect and various possible designs of the first aspect.

[0021] The service gateway testing method, device, storage medium, and product provided by the embodiments of the present disclosure record a plurality of upstream data and a plurality of downstream data of a target interface of a service gateway in a microservice system, obtain target upstream data and target downstream data belonging to a same microservice calling process from the plurality of upstream data and the plurality of downstream data, determine whether network nodes involved in the target upstream data and the target downstream data belonging to the same microservice calling process match a network topology diagram of the target interface, and if the network nodes match the network topology diagram, generate a test case of the service gateway according to the target upstream data and the target downstream data belonging to the same microservice calling process, so as to play back the target upstream data and the target downstream data when the service gateway is tested. The plurality of upstream data and the plurality of downstream data of the target interface of the service gateway are recorded by using a recording technology, and the upstream data and the downstream data belonging to the same microservice calling process are obtained to construct the test case. Then, the service gateway can be tested by initiating playback testing according to the test case, which greatly saves manpower for data construction and script writing and improves the testing efficiency of the service gateway. BRIEF DESCRIPTION OF DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present disclosure, and for those skilled in the art, other drawings can also be obtained without creative labor.

[0023] Figure 1 The application scenario of the service gateway testing method provided by an embodiment of the present disclosure is shown in the following figure.

[0024] Figure 2 The flowchart of the service gateway testing method provided by an embodiment of the present disclosure is shown in the following figure.

[0025] Figure 3 The schematic diagram of the target interface link topology diagram provided by an embodiment of the present disclosure is shown in the following figure.

[0026] Figure 4A flowchart of a test method of a service gateway according to another embodiment of the present disclosure is provided;

[0027] Figure 5 A flowchart of a test method of a service gateway according to another embodiment of the present disclosure is provided;

[0028] Figure 6 A schematic diagram of a complete network topology of a service gateway according to an embodiment of the present disclosure is provided;

[0029] Figure 7 A flowchart of a test method of a service gateway according to another embodiment of the present disclosure is provided;

[0030] Figure 8 A structural block diagram of a test device of a service gateway according to an embodiment of the present disclosure is provided;

[0031] Figure 9 A schematic diagram of a hardware structure of an electronic device according to an embodiment of the present disclosure is provided. DETAILED DESCRIPTION

[0032] In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only some of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present disclosure.

[0033] In the microservice architecture, the business functions or processes are designed to be divided in advance when the application is designed, and each business function is implemented as an individual service that can run independently. Then, all services required by the application are combined using the same protocol to form an application.

[0034] In a computer, a gateway is a server that forwards communication data of other servers. When receiving a request sent from a client, it processes the request as if it were a source server with resources. In the microservice architecture, the service gateway is a key role that protects, enhances and controls access to microservices. The service gateway is a system before the application or service, which is used to manage authorization, access control and traffic limitation, etc. In this way, the microservices are protected by the service gateway, which is transparent to all callers.

[0035] The microservice gateway is a middleware system that connects the consumer and the provider of services, and naturally isolates the evolution and development of each business system, so that the business system is more focused on the business service itself. The gateway service mainly has the following characteristics

[0036] 1) Manage all access requests as the request entry of all api interfaces;

[0037] 2) All microservice backends can be registered in the api gateway to expose services uniformly through the api gateway;

[0038] 3) A unified public security service component (such as security, risk control, traffic) can be provided.

[0039] Since the service gateway manages a large number of downstream services, the reliability of the gateway service itself is related to the stability of the entire microservice system. An effective gateway service test scheme is crucial to the service. At present, manual test case writing is usually used to test and accept the service gateway.

[0040] But the gateway service scenario is very complex and the traffic is large, and there are many non-idempotent interfaces, and the pure manpower consumption is huge, and it cannot be automatically tested; at the same time, since the service gateway aggregates all downstream microservices, and requests are distributed to different microservices according to different request parameters, service link analysis is difficult, and the number of services is large, so it is difficult for manual test case writing to comprehensively cover the test of the entire service gateway.

[0041] In order to solve the above technical problems, in the embodiment of the disclosure, the link is colored by using the identifier of the microservice calling request to obtain the interface link topology graph of the service gateway, the upstream and downstream link data in the topology graph is recorded by using the traffic recording technology, the upstream and downstream link data is matched by using the identifier of the microservice calling request, and then the matched upstream and downstream link data can be determined as the test case of the service gateway, which is used for Mock playback test of the microservice architecture, greatly saving the manpower of data construction and script writing.

[0042] Specifically, a plurality of upstream data and a plurality of downstream data of a target interface of a service gateway in a microservice system can be recorded; wherein the upstream data is interaction data between the service gateway and an upstream request node in a microservice calling process, and the downstream data is interaction data between the service gateway and a downstream microservice node in the microservice calling process; target upstream data and target downstream data belonging to the same microservice calling process are obtained from the plurality of upstream data and the plurality of downstream data; it is judged whether the network nodes involved in the target upstream data and the target downstream data belonging to the same microservice calling process match the network topology graph of the target interface; if matched, a test case of the service gateway is generated according to the target upstream data and the target downstream data belonging to the same microservice calling process, so as to play back the target upstream data and the target downstream data when testing the service gateway.

[0043] The test method of the service gateway provided by the embodiment of the disclosure is suitable forFigure 1 The application scenario shown includes a service gateway 101, a request node 102, and a microservice node 103. The request node 102 sends a first microservice call request to the service gateway 101 through a target interface. The service gateway 101 sends a second microservice call request to the microservice node 103 after processing the first microservice call request. The microservice node 103 sends second response data to the service gateway 101. The service gateway 101 processes the second response data and sends first response data to the request node 102 through the target interface. The upstream data of the service gateway 101 is the interaction data between the request node 102 and the service gateway 101. The upstream data includes at least one first microservice call request data sent by the request node 102 and received by the service gateway 101 through the target interface, and at least one first response data sent by the service gateway 101 to the request node 102 through the target interface. The downstream data of the service gateway 101 is the interaction data between the service gateway 101 and the microservice node 103. The downstream data includes at least one second microservice call request data sent by the service gateway 101 to the microservice node 103, and at least one second response data sent by the microservice node 103 and received by the service gateway 101. In the embodiment of the present disclosure, the target interface of the service gateway 101 or other recording nodes can record multiple upstream data and multiple downstream data of the target interface of the service gateway 101. From the multiple upstream data and the multiple downstream data, target upstream data and target downstream data belonging to the same microservice call process are obtained. It is determined whether the network nodes involved in the target upstream data and the target downstream data belonging to the same microservice call process match the network topology diagram of the target interface. If they match, test cases of the service gateway 101 are generated according to the target upstream data and the target downstream data belonging to the same microservice call process, so as to play back the target upstream data and the target downstream data when the service gateway is tested.

[0044] The service gateway testing method provided by the embodiment of the present disclosure will be described in detail below in combination with specific embodiments.

[0045] Reference Figure 2 , Figure 2 The service gateway testing method provided by the embodiment of the present disclosure will be described in detail below in combination with specific embodiments.

[0046] S201, record multiple upstream data and multiple downstream data of a target interface of a service gateway in a microservice system;

[0047] The upstream data is interaction data between the service gateway and an upstream request node in a microservice calling process, and the downstream data is interaction data between the service gateway and a downstream microservice node in the microservice calling process.

[0048] In this embodiment, the upstream data of the service gateway is interaction data between a request node and the service gateway, and the upstream data includes at least one first microservice calling request data sent by the request node to the service gateway through the target interface and at least one first response data sent by the service gateway to the request node through the target interface; and the downstream data of the service gateway is interaction data between the service gateway and a microservice node, and the downstream data includes at least one second microservice calling request data sent by the service gateway to the microservice node and at least one second response data sent by the microservice node to the service gateway.

[0049] That is, for a target interface, the complete process of calling a microservice by a request node is as follows: the request node sends a first microservice calling request to the service gateway through the target interface, the service gateway sends a second microservice calling request to a microservice node after processing the first microservice calling request, the microservice node sends second response data to the service gateway, and the service gateway sends first response data to the request node through the target interface after processing the second response data.

[0050] S202, from the plurality of upstream data and the plurality of downstream data, target upstream data and target downstream data belonging to the same microservice calling process are obtained.

[0051] In this embodiment, since the plurality of upstream data and the plurality of downstream data for the target interface are recorded, the upstream data and the downstream data need to be matched to find target first microservice calling request data, target second microservice calling request data, target first response data and target second response data which belong to the complete process of calling a microservice.

[0052] Optionally, each first microservice invocation request data and its corresponding second microservice invocation request data carries the same microservice invocation request identifier; each first response data and its corresponding second response data carries the identifier of the microservice invocation request responded to; that is, the request node sends a first microservice invocation request A1 to the service gateway, the service gateway sends a second microservice invocation request A2 to the microservice node after processing the first microservice invocation request A1, the microservice node sends a second response data B2 to the service gateway, and the service gateway sends a first response data B1 to the request node after processing the second response data B2. For each data in the complete process of the request node calling the microservice: the first microservice invocation request A1, the second microservice invocation request A2, the second response data B2, and the first response data B1, all carry the same microservice invocation request identifier. Different microservice invocation requests have different identifiers, and the identifier of the microservice invocation request can be a logID identifier.

[0053] Further, in the embodiment, target first microservice invocation request data, target second microservice invocation request data, target first response data, and target second response data carrying the same microservice invocation request identifier can be obtained according to the microservice invocation request identifier, and target upstream data and target downstream data belonging to the same microservice invocation process can be determined.

[0054] Of course, the matching process in the embodiment is not limited to the above, and other methods capable of tracing the request and response data can also be used.

[0055] S203, determining whether the network nodes involved in the target upstream data and the target downstream data belonging to the same microservice invocation process match the network topology graph of the target interface.

[0056] The network topology graph of the target interface includes all request nodes and microservice nodes connected by the target interface.

[0057] In the embodiment, the network topology graph of the target interface can be obtained in advance, and the network topology graph of the target interface includes all request nodes connected by the target interface and microservice nodes that can be invoked by the request nodes, as shown in Figure 3 The microservice nodes 1-8 are microservice nodes that can be invoked by the request nodes through the target interface of the service gateway.

[0058] Further, whether the network nodes involved in the target upstream data and the target downstream data belonging to the same microservice invocation process match the network topology graph of the target interface is determined, that is, whether the request nodes and the microservice nodes involved in the target upstream data and the target downstream data belonging to the same microservice invocation process match the network topology graph of the target interface.

[0059] Optionally, as shown in S203, determining whether the network nodes involved in the target upstream data and the target downstream data belonging to the same microservice calling process match the network topology graph of the target interface, can specifically include: Figure 4

[0060] S2031, determining, according to the target upstream data and the target downstream data belonging to the same microservice calling process, the target microservice nodes downstream of the target interface involved in the microservice calling process;

[0061] S2032, matching the target microservice nodes downstream of the target interface with the network topology graph of the target interface obtained in advance.

[0062] In this embodiment, according to the target upstream data and the target downstream data belonging to the same microservice calling process, it can be determined which target microservice nodes are called by the request node in this request, and whether the called target microservice nodes can match the network topology graph of the target interface. If it can match, it means that the target upstream data and the target downstream data belonging to the same microservice calling process cover the microservice nodes in the network topology graph of the target interface, and do not exceed the range of the microservice nodes in the network topology graph of the target interface, and can be used as a test case.

[0063] Optionally, if it is determined that the target microservice nodes are completely the same as the microservice nodes downstream of the target interface in the network topology graph of the target interface, it is determined as a matching success; or

[0064] If it is determined that the target microservice nodes are only part of the microservice nodes downstream of the target interface in the network topology graph of the target interface, it is determined whether the remaining nodes in the microservice nodes downstream of the target interface in the network topology graph of the target interface are optional microservice nodes.

[0065] If it is determined that the remaining nodes in the microservice nodes downstream of the target interface in the network topology graph of the target interface are optional microservice nodes, it is determined as a matching success; or

[0066] If it is determined that the remaining nodes in the microservice nodes downstream of the target interface in the network topology graph of the target interface are not optional microservice nodes, it is determined as a matching failure.

[0067] In this embodiment, the network topology graph of the target interface can include mandatory microservice nodes and optional microservice nodes, as shown in Figure 3 ​As shown in the figure, the microservice nodes 1, 2, 3, 4, and 8 are mandatory microservice nodes, and the microservice nodes 5, 6, and 7 are optional microservice nodes. The first case is that the target microservice nodes and the network topology of the target interface completely coincide with the mandatory microservice nodes and the optional microservice nodes, and it is determined that the matching is successful. The second case is that all the mandatory microservice nodes in the target microservice nodes and the network topology of the target interface coincide, and no other microservice nodes are included, or at least one other node is included and the at least one other node is an optional microservice node in the network topology of the target interface, and it is determined that the matching is successful. The third case is that the target microservice nodes include microservice nodes outside the network topology of the target interface, or the target microservice nodes completely cover all the mandatory microservice nodes in the network topology of the target interface, and it is determined that the matching fails and can be discarded.

[0068] Of course, in the embodiment, whether the target upstream data and the target downstream data belonging to the same microservice calling process are test cases of the service gateway can also be determined in other manners, so that a test case meets the scenario of covering all the mandatory microservice nodes in the network topology of the target interface.

[0069] S204, if the matching is successful, the target upstream data and the target downstream data belonging to the same microservice calling process are used to generate test cases of the service gateway, which are used to play back the target upstream data and the target downstream data when the service gateway is tested.

[0070] In the embodiment, a group of target upstream data and target downstream data belonging to the same microservice calling process are determined as a test case, and the target upstream data and the target downstream data in the test case can be played back in the form of Mock testing when the target interface of the service gateway needs to be tested subsequently. Through the recording and matching manner, a plurality of test cases can be automatically constructed, the manpower for data construction and script writing is greatly saved, and the test efficiency of the service gateway is improved.

[0071] Further, in the embodiment, the test cases of the service gateway can be stored in a database.

[0072] The service gateway testing method provided in this embodiment records multiple upstream and downstream data of the target interface of the service gateway in a microservice system; from the multiple upstream and downstream data, it obtains target upstream and target downstream data belonging to the same microservice call process; it determines whether the network nodes involved in the target upstream and target downstream data belonging to the same microservice call process match the network topology of the target interface; if they match, it generates test cases for the service gateway based on the target upstream and target downstream data belonging to the same microservice call process, so as to replay the target upstream and target downstream data when testing the service gateway. By using recording technology to record multiple upstream and downstream data of the target interface of the service gateway and obtaining upstream and downstream data belonging to the same microservice call process to construct test cases, and then initiating replay tests based on the test cases to test the service gateway, it greatly saves manpower in data construction and script writing, and improves the testing efficiency of the service gateway.

[0073] Based on any of the above embodiments, such as Figure 5 As shown, before matching the target microservice node downstream of the target interface with the pre-obtained network topology map of the target interface, the method further includes:

[0074] S301. Obtain the complete network topology diagram of the service gateway;

[0075] S302. Obtain the network topology diagram of the target interface based on the complete network topology diagram of the service gateway.

[0076] In this embodiment, a complete network topology diagram of the serving gateway can be obtained first, such as... Figure 6 As shown, the network topology diagram includes each interface. Therefore, when the network topology diagram of a specific target interface is needed, it can be directly obtained from the complete network topology diagram of the service gateway. By compiling the complete network topology diagram of the service gateway, testing of the entire service gateway can be facilitated, ensuring comprehensive testing and avoiding omissions.

[0077] In obtaining the complete network topology of the service gateway, multiple upstream and downstream data points from different interfaces of the service gateway can be recorded. These upstream and downstream data points are then matched to obtain upstream and downstream data belonging to the same microservice call process. The recording and matching process can be found in the above-described embodiment. Furthermore, based on the upstream and downstream data belonging to the same microservice call process, the link relationships between each request node and each microservice node are determined, thus obtaining the complete network topology of the service gateway. Specifically, when determining the link relationships between each request node and each microservice node based on the upstream and downstream data belonging to the same microservice call process, link analysis is performed. Interfaces are queried based on service names, links are supplemented based on the identifiers of microservice call requests, and call service links are queried. The complete network topology of the service gateway is obtained through link information analysis and stored.

[0078] It should be noted that, since there are mandatory and optional microservice nodes when some interfaces call microservice nodes, the mandatory and optional microservice nodes connected by each requesting node through the service gateway interface can be determined based on the upstream and downstream data belonging to the same microservice call process, and then aggregated to obtain the complete network topology of the service gateway.

[0079] Based on any of the above embodiments, the step of generating test cases for the service gateway based on the target upstream data and target downstream data belonging to the same microservice call process includes:

[0080] The upstream and downstream data belonging to the same microservice call process are anonymized, and the anonymized upstream and downstream data belonging to the same microservice call process are determined as test cases for the service gateway.

[0081] In this embodiment, sensitive or private data, such as user data, in the upstream and downstream target data belonging to the same microservice call process can be anonymized. The anonymized upstream and downstream target data belonging to the same microservice call process are then identified as a set of test cases for the service gateway, which can protect data security.

[0082] Based on any of the above embodiments, such as Figure 7 As shown, this embodiment also includes a process of performing mock testing based on the acquired test cases, specifically including:

[0083] S401. Receive the trigger command for the test task of the target interface, and perform a link status check according to the network topology diagram of the target interface;

[0084] S402. After confirming that the link status is normal, obtain the test cases and configuration data corresponding to the target interface;

[0085] S403. Test the target interface according to the test cases and configuration data corresponding to the target interface.

[0086] In this embodiment, when it is necessary to test the target interface of the service gateway, a Mock test task can be triggered. The trigger instruction of the Mock test task is received, and the link status is checked according to the network topology diagram of the target interface to ensure that the target interface is available and to determine the request nodes and microservice nodes involved in the target interface. After confirming that the link status is normal, the test cases and configuration data corresponding to the target interface are obtained, and the target interface is tested according to the test cases and configuration data corresponding to the target interface. The configuration data is the relevant data for controlling the Mock replay test of the test cases.

[0087] Based on the principle of mock testing, target test cases are replayed to simulate microservice nodes, avoiding impact on their operation. Assertions are performed on the execution results to determine whether the gateway node's execution results meet expectations. These assertions can include assertions on the value and type of the execution results, regular expression matching, and parameter range judgments.

[0088] In this embodiment, executing the target test case within the microservice architecture specifically includes: inputting a target first microservice call request from the target test case into the service gateway, where the service gateway processes the target first microservice call request and outputs a real second microservice call request; and inputting target second response data from the target test case into the service gateway, where the service gateway processes the target second response data and outputs real first response data. This process does not require the participation of request nodes and microservice nodes. The target test case can be loaded into a Mock engine, which then executes the above-mentioned input of the target first microservice call request and target second response data to the service gateway.

[0089] Furthermore, assertions can be made based on the actual second microservice call request and the target second microservice call request in the target test case to determine whether the service gateway processes the target first microservice call request normally; assertions can also be made based on the actual first response data and the target first response data in the target test case to determine whether the service gateway processes the target second response data normally.

[0090] The testing method for the service gateway corresponding to the above embodiment, Figure 8This is a structural block diagram of a test device for a service gateway provided in an embodiment of this disclosure. For ease of explanation, only the parts relevant to the embodiments of this disclosure are shown. (Refer to...) Figure 8 The test device 800 of the service gateway includes: a recording unit 801, a first matching unit 802, a second matching unit 803, and a processing unit 804.

[0091] The recording unit 801 is used to record multiple upstream data and multiple downstream data of the target interface of the service gateway in the microservice system; wherein, the upstream data is the interaction data between the service gateway and the upstream request node during the microservice call process, and the downstream data is the interaction data between the service gateway and the downstream microservice node during the microservice call process.

[0092] The first matching unit 802 is used to obtain target upstream data and target downstream data belonging to the same microservice call process from the plurality of upstream data and the plurality of downstream data;

[0093] The second matching unit 803 is used to determine whether the network nodes involved in the target upstream data and target downstream data belonging to the same microservice call process match the network topology map of the target interface. The network topology map of the target interface includes all request nodes and microservice nodes connected to the target interface.

[0094] The processing unit 804 is configured to generate test cases for the service gateway based on the target upstream data and target downstream data belonging to the same microservice call process when a match is determined, so as to replay the target upstream data and target downstream data when testing the service gateway.

[0095] In one or more embodiments of this disclosure, the plurality of upstream data includes at least one first microservice call request data received by the service gateway through the target interface from a requesting node, and at least one first response data sent by the service gateway to the requesting node through the target interface;

[0096] The multiple downstream data include at least one second microservice call request data sent by the service gateway to the microservice node, and at least one second response data sent by the microservice node and received by the service gateway.

[0097] In one or more embodiments of this disclosure, each first microservice call request data and its corresponding second microservice call request data carry the same microservice call request identifier; each first response data and its corresponding second response data carry the identifier of the microservice call request that has been responded to.

[0098] When the first matching unit 802 obtains target upstream data and target downstream data belonging to the same microservice call process from the plurality of upstream data and the plurality of downstream data, it is used to:

[0099] Based on the identifier of the microservice call request, obtain the target first microservice call request data, the target second microservice call request data, the target first response data, and the target second response data, which carry the same microservice call request identifier.

[0100] In one or more embodiments of this disclosure, the second matching unit 803, when determining whether the network nodes involved in the target upstream data and target downstream data belonging to the same microservice call process match the network topology map of the target interface, is configured to:

[0101] Based on the upstream and downstream data of the target that belong to the same microservice call process, determine the target microservice node downstream of the target interface involved in the microservice call process;

[0102] The target microservice nodes downstream of the target interface are matched with the network topology map of the pre-obtained target interface.

[0103] In one or more embodiments of this disclosure, the second matching unit 803, when matching the target microservice node downstream of the target interface with the pre-acquired network topology map of the target interface, is configured to:

[0104] If it is determined that the target microservice node is exactly the same as the downstream microservice node of the target interface in the network topology diagram of the target interface, then it is determined that the match is successful; or

[0105] If it is determined that the target microservice node is only a portion of the microservice nodes downstream of the target interface in the network topology diagram of the target interface, then it is determined whether the remaining nodes in the microservice nodes downstream of the target interface in the network topology diagram of the target interface are optional microservice nodes.

[0106] If it is determined that the remaining nodes among the microservice nodes downstream of the target interface in the network topology diagram of the target interface are optional microservice nodes, then the match is considered successful; or

[0107] If it is determined that the remaining nodes in the microservice nodes downstream of the target interface in the network topology diagram of the target interface are not selectable microservice nodes, then the matching is determined to be a failure.

[0108] In one or more embodiments of this disclosure, the device further includes: a topology map acquisition unit, configured to:

[0109] Obtain the complete network topology diagram of the service gateway;

[0110] Based on the complete network topology map of the service gateway, obtain the network topology map of the target interface.

[0111] In one or more embodiments of this disclosure, the topology map acquisition unit, when acquiring a complete network topology map of the serving gateway, is configured to:

[0112] Record multiple upstream and multiple downstream data from different interfaces of the service gateway;

[0113] Match multiple upstream and downstream data to obtain upstream and downstream data belonging to the same microservice call process;

[0114] Based on upstream and downstream data belonging to the same microservice call process, the link relationship between each request node and each microservice node is determined, and the complete network topology of the service gateway is obtained.

[0115] In one or more embodiments of this disclosure, when the topology map acquisition unit determines the link relationship between each request node and each microservice node based on upstream and downstream data belonging to the same microservice call process, and obtains the complete network topology map of the service gateway, it is used to:

[0116] Based on the upstream and downstream data belonging to the same microservice call process, the required and optional microservice nodes connected by each request node through the service gateway interface are determined and aggregated to obtain the complete network topology of the service gateway.

[0117] In one or more embodiments of this disclosure, when the processing unit 804 generates test cases for the service gateway based on target upstream data and target downstream data belonging to the same microservice call process, it is configured to:

[0118] The upstream and downstream data belonging to the same microservice call process are anonymized, and the anonymized upstream and downstream data belonging to the same microservice call process are determined as test cases for the service gateway.

[0119] In one or more embodiments of this disclosure, the processing unit 804 is further configured to:

[0120] Receive the trigger command for the test task of the target interface, and perform link status check according to the network topology diagram of the target interface;

[0121] After confirming that the link status is normal, obtain the test cases and configuration data corresponding to the target interface;

[0122] The target interface is tested based on the test cases and configuration data corresponding to the target interface.

[0123] In one or more embodiments of this disclosure, when the processing unit 804 tests the target interface according to the test cases and configuration data corresponding to the target interface, it is configured to:

[0124] The target first microservice call request data in the test case is input into the service gateway through the target interface. The actual second microservice call request data output by the service gateway is obtained. Assertions are made based on the actual second microservice call request data and the target second microservice call request data in the test case.

[0125] The target second response data in the test case is input into the service gateway to obtain the real first response data output by the service gateway through the target interface, and assertions are made based on the real first response data and the target first response data in the test case.

[0126] The device provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.

[0127] refer to Figure 9 The diagram illustrates a structural schematic of an electronic device 900 suitable for implementing embodiments of the present disclosure. The electronic device 900 can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, personal digital assistants (PDAs), portable Android devices (PADs), portable media players (PMPs), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 9 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0128] like Figure 9As shown, the electronic device 900 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the electronic device 900. The processing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0129] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic device 900 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 9 An electronic device 900 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0130] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by a processing device 901, it performs the functions defined in the methods of embodiments of this disclosure.

[0131] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0132] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0133] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.

[0134] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0135] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0136] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".

[0137] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0138] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0139] In a first aspect, according to one or more embodiments of this disclosure, a method for testing a service gateway is provided, comprising:

[0140] Record multiple upstream and multiple downstream data of the target interface of the service gateway in the microservice system; wherein, the upstream data is the interaction data between the service gateway and the upstream request node during the microservice call process, and the downstream data is the interaction data between the service gateway and the downstream microservice node during the microservice call process;

[0141] From the multiple upstream data and the multiple downstream data, obtain the target upstream data and target downstream data belonging to the same microservice call process;

[0142] Determine whether the network nodes involved in the target upstream data and target downstream data belonging to the same microservice call process match the network topology map of the target interface, wherein the network topology map of the target interface includes all request nodes and microservice nodes connected to the target interface;

[0143] If a match is found, test cases for the service gateway are generated based on the target upstream data and target downstream data belonging to the same microservice call process, so as to replay the target upstream data and target downstream data when testing the service gateway.

[0144] According to one or more embodiments of this disclosure, the plurality of upstream data includes at least one first microservice call request data received by the service gateway through the target interface from a requesting node, and at least one first response data sent by the service gateway to the requesting node through the target interface;

[0145] The multiple downstream data include at least one second microservice call request data sent by the service gateway to the microservice node, and at least one second response data sent by the microservice node and received by the service gateway.

[0146] According to one or more embodiments of this disclosure, each first microservice call request data and its corresponding second microservice call request data carry the same microservice call request identifier; each first response data and its corresponding second response data carry the identifier of the microservice call request that has been responded to.

[0147] The step of obtaining target upstream data and target downstream data belonging to the same microservice call process from the plurality of upstream data and the plurality of downstream data includes:

[0148] Based on the identifier of the microservice call request, obtain the target first microservice call request data, the target second microservice call request data, the target first response data, and the target second response data, which carry the same microservice call request identifier.

[0149] According to one or more embodiments of this disclosure, determining whether the network nodes involved in the target upstream data and target downstream data belonging to the same microservice call process match the network topology of the target interface includes:

[0150] Based on the upstream and downstream data of the target that belong to the same microservice call process, determine the target microservice node downstream of the target interface involved in the microservice call process;

[0151] The target microservice nodes downstream of the target interface are matched with the network topology map of the pre-obtained target interface.

[0152] According to one or more embodiments of this disclosure, matching the target microservice node downstream of the target interface with a pre-acquired network topology map of the target interface includes:

[0153] If it is determined that the target microservice node is exactly the same as the downstream microservice node of the target interface in the network topology diagram of the target interface, then it is determined that the match is successful; or

[0154] If it is determined that the target microservice node is only a portion of the microservice nodes downstream of the target interface in the network topology diagram of the target interface, then it is determined whether the remaining nodes in the microservice nodes downstream of the target interface in the network topology diagram of the target interface are optional microservice nodes.

[0155] If it is determined that the remaining nodes among the microservice nodes downstream of the target interface in the network topology diagram of the target interface are optional microservice nodes, then the match is considered successful; or

[0156] If it is determined that the remaining nodes in the microservice nodes downstream of the target interface in the network topology diagram of the target interface are not selectable microservice nodes, then the matching is determined to be a failure.

[0157] According to one or more embodiments of this disclosure, before matching the target microservice node downstream of the target interface with the pre-acquired network topology map of the target interface, the method further includes:

[0158] Obtain the complete network topology diagram of the service gateway;

[0159] Based on the complete network topology map of the service gateway, obtain the network topology map of the target interface.

[0160] According to one or more embodiments of this disclosure, obtaining a complete network topology map of the service gateway includes:

[0161] Record multiple upstream and multiple downstream data from different interfaces of the service gateway;

[0162] Match multiple upstream and downstream data to obtain upstream and downstream data belonging to the same microservice call process;

[0163] Based on upstream and downstream data belonging to the same microservice call process, the link relationship between each request node and each microservice node is determined, and the complete network topology of the service gateway is obtained.

[0164] According to one or more embodiments of this disclosure, determining the link relationship between each request node and each microservice node based on upstream and downstream data belonging to the same microservice call process, and obtaining a complete network topology map of the service gateway, includes:

[0165] Based on the upstream and downstream data belonging to the same microservice call process, the required and optional microservice nodes connected by each request node through the service gateway interface are determined and aggregated to obtain the complete network topology of the service gateway.

[0166] According to one or more embodiments of this disclosure, generating test cases for the service gateway based on target upstream data and target downstream data belonging to the same microservice call process includes:

[0167] The upstream and downstream data belonging to the same microservice call process are anonymized, and the anonymized upstream and downstream data belonging to the same microservice call process are determined as test cases for the service gateway.

[0168] According to one or more embodiments of this disclosure, the method further includes:

[0169] Receive the trigger command for the test task of the target interface, and perform link status check according to the network topology diagram of the target interface;

[0170] After confirming that the link status is normal, obtain the test cases and configuration data corresponding to the target interface;

[0171] The target interface is tested based on the test cases and configuration data corresponding to the target interface.

[0172] According to one or more embodiments of this disclosure, testing the target interface based on test cases and configuration data corresponding to the target interface includes:

[0173] The target first microservice call request data in the test case is input into the service gateway through the target interface. The actual second microservice call request data output by the service gateway is obtained. Assertions are made based on the actual second microservice call request data and the target second microservice call request data in the test case.

[0174] The target second response data in the test case is input into the service gateway to obtain the real first response data output by the service gateway through the target interface, and assertions are made based on the real first response data and the target first response data in the test case.

[0175] Secondly, according to one or more embodiments of this disclosure, a testing device for a service gateway is provided, comprising:

[0176] The recording unit is used to record multiple upstream data and multiple downstream data of the target interface of the service gateway in the microservice system; wherein, the upstream data is the interaction data between the service gateway and the upstream request node during the microservice call process, and the downstream data is the interaction data between the service gateway and the downstream microservice node during the microservice call process.

[0177] The first matching unit is used to obtain target upstream data and target downstream data belonging to the same microservice call process from the multiple upstream data and the multiple downstream data;

[0178] The second matching unit is used to determine whether the network nodes involved in the target upstream data and target downstream data belonging to the same microservice call process match the network topology map of the target interface. The network topology map of the target interface includes all request nodes and microservice nodes connected to the target interface.

[0179] The processing module is used to generate test cases for the service gateway based on the target upstream data and target downstream data belonging to the same microservice call process when determining a match, so as to replay the target upstream data and target downstream data when testing the service gateway.

[0180] According to one or more embodiments of this disclosure, the plurality of upstream data includes at least one first microservice call request data received by the service gateway through the target interface from a requesting node, and at least one first response data sent by the service gateway to the requesting node through the target interface;

[0181] The multiple downstream data include at least one second microservice call request data sent by the service gateway to the microservice node, and at least one second response data sent by the microservice node and received by the service gateway.

[0182] According to one or more embodiments of this disclosure, each first microservice call request data and its corresponding second microservice call request data carry the same microservice call request identifier; each first response data and its corresponding second response data carry the identifier of the microservice call request that has been responded to.

[0183] When the first matching unit obtains target upstream data and target downstream data belonging to the same microservice call process from the plurality of upstream data and the plurality of downstream data, it is used to:

[0184] Based on the identifier of the microservice call request, obtain the target first microservice call request data, the target second microservice call request data, the target first response data, and the target second response data, which carry the same microservice call request identifier.

[0185] According to one or more embodiments of this disclosure, when determining whether the network nodes involved in the target upstream data and target downstream data belonging to the same microservice call process match the network topology map of the target interface, the second matching unit is configured to:

[0186] Based on the upstream and downstream data of the target that belong to the same microservice call process, determine the target microservice node downstream of the target interface involved in the microservice call process;

[0187] The target microservice nodes downstream of the target interface are matched with the network topology map of the pre-obtained target interface.

[0188] According to one or more embodiments of this disclosure, when the second matching unit matches the target microservice node downstream of the target interface with the pre-acquired network topology map of the target interface, it is configured to:

[0189] If it is determined that the target microservice node is exactly the same as the downstream microservice node of the target interface in the network topology diagram of the target interface, then it is determined that the match is successful; or

[0190] If it is determined that the target microservice node is only a portion of the microservice nodes downstream of the target interface in the network topology diagram of the target interface, then it is determined whether the remaining nodes in the microservice nodes downstream of the target interface in the network topology diagram of the target interface are optional microservice nodes.

[0191] If it is determined that the remaining nodes among the microservice nodes downstream of the target interface in the network topology diagram of the target interface are optional microservice nodes, then the match is considered successful; or

[0192] If it is determined that the remaining nodes in the microservice nodes downstream of the target interface in the network topology diagram of the target interface are not selectable microservice nodes, then the matching is determined to be a failure.

[0193] According to one or more embodiments of this disclosure, the device further includes: a topology map acquisition unit, configured to:

[0194] Obtain the complete network topology diagram of the service gateway;

[0195] Based on the complete network topology map of the service gateway, obtain the network topology map of the target interface.

[0196] According to one or more embodiments of this disclosure, when the topology map acquisition unit acquires a complete network topology map of the serving gateway, it is configured to:

[0197] Record multiple upstream and multiple downstream data from different interfaces of the service gateway;

[0198] Match multiple upstream and downstream data to obtain upstream and downstream data belonging to the same microservice call process;

[0199] Based on upstream and downstream data belonging to the same microservice call process, the link relationship between each request node and each microservice node is determined, and the complete network topology of the service gateway is obtained.

[0200] According to one or more embodiments of this disclosure, when the topology map acquisition unit determines the link relationship between each request node and each microservice node based on upstream and downstream data belonging to the same microservice call process, and obtains the complete network topology map of the service gateway, it is used to:

[0201] Based on the upstream and downstream data belonging to the same microservice call process, the required and optional microservice nodes connected by each request node through the service gateway interface are determined and aggregated to obtain the complete network topology of the service gateway.

[0202] According to one or more embodiments of this disclosure, when the processing unit generates test cases for the service gateway based on target upstream data and target downstream data belonging to the same microservice call process, it is configured to:

[0203] The upstream and downstream data belonging to the same microservice call process are anonymized, and the anonymized upstream and downstream data belonging to the same microservice call process are determined as test cases for the service gateway.

[0204] According to one or more embodiments of this disclosure, the processing unit is further configured to:

[0205] Receive the trigger command for the test task of the target interface, and perform link status check according to the network topology diagram of the target interface;

[0206] After confirming that the link status is normal, obtain the test cases and configuration data corresponding to the target interface;

[0207] The target interface is tested based on the test cases and configuration data corresponding to the target interface.

[0208] According to one or more embodiments of this disclosure, when the processing unit tests the target interface based on test cases and configuration data corresponding to the target interface, it is configured to:

[0209] The target first microservice call request data in the test case is input into the service gateway through the target interface. The actual second microservice call request data output by the service gateway is obtained. Assertions are made based on the actual second microservice call request data and the target second microservice call request data in the test case.

[0210] The target second response data in the test case is input into the service gateway to obtain the real first response data output by the service gateway through the target interface, and assertions are made based on the real first response data and the target first response data in the test case.

[0211] Thirdly, according to one or more embodiments of the present disclosure, an electronic device is provided, comprising: at least one processor and a memory; said memory storing computer-executable instructions;

[0212] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the test method for the service gateway as described in the first aspect above and various possible designs of the first aspect.

[0213] Fourthly, according to one or more embodiments of this disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, and when a processor executes the computer-executable instructions, a test method for implementing the service gateway described in the first aspect and various possible designs of the first aspect is provided.

[0214] Fifthly, according to one or more embodiments of this disclosure, a computer program product is provided, including computer execution instructions, which, when executed by a processor, implement the testing method for the service gateway described in the first aspect and various possible designs of the first aspect.

[0215] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0216] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0217] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A testing method for a service gateway, characterized in that, include: Record multiple upstream and multiple downstream data of the target interface of the service gateway in the microservice system; wherein, the upstream data is the interaction data between the service gateway and the upstream request node during the microservice call process, and the downstream data is the interaction data between the service gateway and the downstream microservice node during the microservice call process; From the multiple upstream data and the multiple downstream data, obtain the target upstream data and target downstream data belonging to the same microservice call process; Determine whether the network nodes involved in the target upstream data and target downstream data belonging to the same microservice call process match the network topology map of the target interface in advance. The network topology map of the target interface includes all request nodes and microservice nodes connected to the target interface. The microservice nodes consist of mandatory microservice nodes and optional microservice nodes. The condition for a successful match is that the network nodes cover all mandatory microservice nodes in the network topology map and do not include microservice nodes outside the network topology map. If a match is found, test cases for the service gateway are generated based on the target upstream data and target downstream data belonging to the same microservice call process, so as to replay the target upstream data and target downstream data when testing the service gateway.

2. The method according to claim 1, characterized in that, The multiple upstream data include at least one first microservice call request data received by the service gateway through the target interface from the requesting node, and at least one first response data sent by the service gateway to the requesting node through the target interface; The multiple downstream data include at least one second microservice call request data sent by the service gateway to the microservice node, and at least one second response data sent by the microservice node and received by the service gateway.

3. The method according to claim 2, characterized in that, Each first microservice call request data and its corresponding second microservice call request data carry the same microservice call request identifier; each first response data and its corresponding second response data carry the identifier of the microservice call request that has responded. The step of obtaining target upstream data and target downstream data belonging to the same microservice call process from the plurality of upstream data and the plurality of downstream data includes: Based on the identifier of the microservice call request, obtain the target first microservice call request data, the target second microservice call request data, the target first response data, and the target second response data, which carry the same microservice call request identifier.

4. The method according to claim 2 or 3, characterized in that, The determination of whether the network nodes involved in the target upstream data and target downstream data belonging to the same microservice call process match the pre-obtained network topology map of the target interface includes: Based on the upstream and downstream data of the target that belong to the same microservice call process, determine the target microservice node downstream of the target interface involved in the microservice call process; The target microservice nodes downstream of the target interface are matched with the network topology map of the pre-obtained target interface.

5. The method according to claim 4, characterized in that, The step of matching the target microservice nodes downstream of the target interface with the pre-acquired network topology map of the target interface includes: If it is determined that the target microservice node is exactly the same as the downstream microservice node of the target interface in the network topology diagram of the target interface, then it is determined that the match is successful; or If it is determined that the target microservice node is only a portion of the microservice nodes downstream of the target interface in the network topology diagram of the target interface, then it is determined whether the remaining nodes in the microservice nodes downstream of the target interface in the network topology diagram of the target interface are optional microservice nodes. If it is determined that the remaining nodes among the microservice nodes downstream of the target interface in the network topology diagram of the target interface are optional microservice nodes, then the match is considered successful; or If it is determined that the remaining nodes in the microservice nodes downstream of the target interface in the network topology diagram of the target interface are not selectable microservice nodes, then the matching is determined to be a failure.

6. The method according to claim 4, characterized in that, Before matching the target microservice nodes downstream of the target interface with the pre-acquired network topology map of the target interface, the method further includes: Obtain the complete network topology diagram of the service gateway; Based on the complete network topology map of the service gateway, obtain the network topology map of the target interface.

7. The method according to claim 6, characterized in that, Obtaining the complete network topology map of the service gateway includes: Record multiple upstream and multiple downstream data from different interfaces of the service gateway; Match multiple upstream and downstream data to obtain upstream and downstream data belonging to the same microservice call process; Based on upstream and downstream data belonging to the same microservice call process, the link relationship between each request node and each microservice node is determined, and the complete network topology of the service gateway is obtained.

8. The method according to claim 7, characterized in that, The step of determining the link relationship between each request node and each microservice node based on upstream and downstream data belonging to the same microservice call process, and obtaining the complete network topology map of the service gateway, includes: Based on the upstream and downstream data belonging to the same microservice call process, the required and optional microservice nodes connected by each request node through the service gateway interface are determined and aggregated to obtain the complete network topology of the service gateway.

9. The method according to any one of claims 1-3, characterized in that, The process of generating test cases for the service gateway based on upstream and downstream data belonging to the same microservice call process includes: The upstream and downstream data belonging to the same microservice call process are anonymized, and the anonymized upstream and downstream data belonging to the same microservice call process are determined as test cases for the service gateway.

10. The method according to claim 2 or 3, characterized in that, The method further includes: Receive the trigger command for the test task of the target interface, and perform link status check according to the network topology diagram of the target interface; After confirming that the link status is normal, obtain the test cases and configuration data corresponding to the target interface; The target interface is tested based on the test cases and configuration data corresponding to the target interface.

11. The method according to claim 10, characterized in that, The step of testing the target interface based on the test cases and configuration data corresponding to the target interface includes: The target first microservice call request data in the test case is input into the service gateway through the target interface. The actual second microservice call request data output by the service gateway is obtained. Assertions are made based on the actual second microservice call request data and the target second microservice call request data in the test case. The target second response data in the test case is input into the service gateway to obtain the real first response data output by the service gateway through the target interface, and assertions are made based on the real first response data and the target first response data in the test case.

12. A testing device for a service gateway, characterized in that, include: The recording unit is used to record multiple upstream data and multiple downstream data of the target interface of the service gateway in the microservice system; wherein, the upstream data is the interaction data between the service gateway and the upstream request node during the microservice call process, and the downstream data is the interaction data between the service gateway and the downstream microservice node during the microservice call process. The first matching unit is used to obtain target upstream data and target downstream data belonging to the same microservice call process from the multiple upstream data and the multiple downstream data; The second matching unit is used to determine whether the network nodes involved in the target upstream data and target downstream data belonging to the same microservice call process match the network topology map of the target interface in advance. The network topology map of the target interface includes all request nodes and microservice nodes connected to the target interface. The microservice nodes consist of mandatory microservice nodes and optional microservice nodes. The condition for a successful match is that the network nodes cover all mandatory microservice nodes in the network topology map and do not include microservice nodes outside the network topology map. The processing module is used to generate test cases for the service gateway based on the target upstream data and target downstream data belonging to the same microservice call process when a match is determined, so as to replay the target upstream data and target downstream data when testing the service gateway.

13. An electronic device, characterized in that, include: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the test method for the service gateway as described in any one of claims 1-11.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the testing method for a service gateway as described in any one of claims 1-11.

15. A computer program product, characterized in that, Includes computer execution instructions, which, when executed by a processor, implement the testing method for a service gateway as described in any one of claims 1-11.

Citation Information

Patent Citations

  • Flow playback method and system

    CN111625452A

  • Regression testing system and method and electronic equipment

    CN112532490A