A test method and device for gateway interface and a readable storage medium
Patent Information
- Application Number
- CN202110592732.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-28
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2041-05-28
AI Technical Summary
这个过程比较繁琐和低效,不但基于proto协议的CGI测试效率过低,浪费人工成本
[0045] In summary, it can be seen that in this embodiment, when testing a gateway interface, a mapping table can be constructed between all gateway interfaces and their request and return data structure identifiers. Then, the request and return data structure identifiers corresponding to the gateway interface currently under test are retrieved from the mapping table, along with the corresponding request and return field information. Finally, the gateway interface under test is tested based on these request and return field information. This eliminates the need for manual searching of the corresponding structure data for the request and return field information of each gateway interface, improving the efficiency of gateway testing and reducing the waste of manual labor.
Smart Images

Figure CN115408260B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computing, and more particularly to a method, apparatus, and readable storage medium for testing a gateway interface. Background Technology
[0002] Protocol Buffers is a lightweight and efficient structured data storage format defined by Google. It can be used for structured data serialization and is used as a data storage, remote procedure call (RPC) and persistent data exchange format. It can be used in communication protocols, data storage and other fields as a language-independent, platform-independent and scalable serialized structured data format.
[0003] For Common Gateway Interface (CGI) testing based on the proto protocol, each gateway test request requires assembling the data structure of the request according to the corresponding proto structure declaration, then serializing it into binary data before sending. The returned content is also in binary data form, which needs to be deserialized into the corresponding proto structure and then parsed to extract the specific field data. After completing one network request test, the results are verified to determine the gateway test results.
[0004] However, in practical applications, due to the large number of backend CGI interfaces (such as thousands of gateway interfaces), it is necessary to test each backend request interface individually to ensure the quality and stability of the backend CGI. For each request test, it is necessary to manually look up the request's proto structure and the response's proto structure from the proto protocol to successfully assemble and parse the data. This process is tedious and inefficient, not only making proto protocol-based CGI testing too inefficient but also wasting manual labor costs. Summary of the Invention
[0005] This application provides a testing method and related equipment for gateway interfaces, which can improve the testing efficiency of gateway interfaces and reduce the waste of labor costs.
[0006] One embodiment of this application provides a method for testing a gateway interface, including:
[0007] Determine the N gateway interfaces to be tested, where N is an integer greater than or equal to 1;
[0008] Obtain the first request data structure identifier and the first return data structure identifier corresponding to the target gateway interface from the gateway interface mapping table. The target gateway interface is any one of the N gateway interfaces. The gateway interface mapping table is used to represent the association between the gateway interface and the request data structure identifier and the return data structure identifier. The gateway interface includes N gateway interfaces.
[0009] Obtain the first request field information corresponding to the first request data structure identifier and the first return field information corresponding to the first return data structure identifier;
[0010] The test results of N gateway interfaces are determined based on the information in the first request field and the information in the first return field.
[0011] Another aspect of this application provides a gateway interface testing device, characterized in that it includes:
[0012] The first determining unit is used to determine the N gateway interfaces to be tested, where N is an integer greater than or equal to 1;
[0013] The first acquisition unit is used to acquire the first request data structure identifier and the first return data structure identifier corresponding to the target gateway interface from the gateway interface mapping table. The target gateway interface is any one of the N gateway interfaces. The gateway interface mapping table is used to represent the association between the gateway interface and the request data structure identifier and the return data structure identifier. The gateway interface includes N gateway interfaces.
[0014] The second acquisition unit is used to acquire the first request field information corresponding to the first request data structure identifier and the first return field information corresponding to the first return data structure identifier;
[0015] The second determining unit is used to determine the test results of N gateway interfaces based on the first request field information and the first return field information.
[0016] In one possible design, the first determining unit is also used for:
[0017] Retrieve the identifier of each gateway interface in the gateway interface list;
[0018] Find the request data structure identifier and return data structure identifier corresponding to the identifier of each gateway interface from the full code of the target protocol;
[0019] Map the identifier of each gateway interface, the request data structure identifier corresponding to each gateway interface identifier, and the return data structure identifier corresponding to each gateway interface identifier to obtain the gateway interface mapping table.
[0020] In one possible design, the second acquisition unit is specifically used for:
[0021] Import the field information of the target protocol into the protocol file to generate the full code corresponding to the target protocol;
[0022] The first request field information is obtained from the full code based on the first request data structure identifier;
[0023] The first returned field information is obtained from the full code based on the first returned data structure identifier.
[0024] In one possible design, the gateway interface testing device also includes:
[0025] Update unit, update unit is used for:
[0026] Monitor project code change information;
[0027] If the project code change information includes change information for the target code, then obtain the change information corresponding to the target code from the project code change information. The target code is the code associated with the gateway interface in the full code.
[0028] Update the gateway interface mapping table and the entire code based on the change information corresponding to the target code in the project code change information.
[0029] In one possible design,
[0030] The second acquisition unit is further configured to, if the project code change information includes change code for the target gateway interface, obtain the second request data structure identifier and the second return data structure identifier corresponding to the target gateway interface from the updated gateway interface mapping table;
[0031] The second acquisition unit is further configured to acquire the second request field information corresponding to the second request data structure identifier and the second return field information corresponding to the second return data structure identifier;
[0032] The second determining unit is also used to determine the test results of N gateway interfaces based on the second request field information and the second return field information.
[0033] In one possible design, the second determining unit is specifically used for:
[0034] The first request field information is parsed to obtain the first sending information and the first receiving information included in the first request field information;
[0035] The first returned field information is parsed to obtain the second sent information and the second received information included in the first returned field information;
[0036] If the first sent information matches the second received information, and the first received information matches the second sent information, then it is determined that N gateway interfaces have passed the test.
[0037] If the first sent information does not match the second received information, or if the first received information does not match the second sent information, then it is determined that N gateway interface tests have failed.
[0038] In one possible design, the second determining unit is also specifically used for:
[0039] The first request field information is parsed to obtain the request content included in the first request field information;
[0040] The first returned field information is parsed to obtain the returned content included in the first returned field information;
[0041] If the requested content matches the returned content, then N gateway interfaces are confirmed to have passed the test.
[0042] If the requested content and the returned content do not match, then N gateway interface tests are determined to have failed.
[0043] Another aspect of this application provides a computer device including at least one connected processor, memory, and transceiver, wherein the memory is used to store program code, and the processor is used to call the program code in the memory to execute the steps of the gateway interface testing method described in the above aspects.
[0044] Another aspect of this application provides a computer storage medium including instructions that, when executed on a computer, cause the computer to perform the steps of the gateway interface testing method described in the above aspects.
[0045] In summary, it can be seen that in this embodiment, when testing a gateway interface, a mapping table can be constructed between all gateway interfaces and their request and return data structure identifiers. Then, the request and return data structure identifiers corresponding to the gateway interface currently under test are retrieved from the mapping table, along with the corresponding request and return field information. Finally, the gateway interface under test is tested based on these request and return field information. This eliminates the need for manual searching of the corresponding structure data for the request and return field information of each gateway interface, improving the efficiency of gateway testing and reducing the waste of manual labor. Attached Figure Description
[0046] Figure 1 A schematic diagram of the architecture of the gateway interface testing system provided in this application embodiment:
[0047] Figure 2 A flowchart illustrating a testing method for a gateway interface provided in an embodiment of this application;
[0048] Figure 3 A virtual structure diagram of the gateway interface testing device provided in the embodiments of this application;
[0049] Figure 4 This is a schematic diagram of the hardware structure of the server provided in an embodiment of this application. Detailed Implementation
[0050] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0051] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or modules is not necessarily limited to those explicitly listed, but may include other steps or modules not explicitly listed or inherent to these processes, methods, products, or devices. The division of modules appearing in this application is merely a logical division; in practical applications, other division methods may be used. For example, multiple modules may be combined or integrated into another system, or some feature vectors may be ignored or not performed. Additionally, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interface, and the indirect coupling or communication connection between modules may be electrical or other similar forms, none of which are limited in this application. Furthermore, the modules or sub-modules described as separate components may or may not be physically separate, may or may not be physical modules, or may be distributed among multiple circuit modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this application.
[0052] This application provides a testing method for gateway interfaces based on cloud computing technology, enabling automated testing of gateway interfaces. Cloud computing refers to the delivery and usage model of Internet Technology (IT) infrastructure, meaning obtaining required resources through the network in an on-demand and easily scalable manner; broadly speaking, cloud computing also refers to the delivery and usage model of services, meaning obtaining required services through the network in an on-demand and easily scalable manner. These services can be IT and software, Internet-related, or other services. Cloud computing is a product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing. With the development of the Internet, real-time data streams, and the diversification of connected devices, as well as the driving force of demands for search services, social networks, mobile commerce, and open collaboration, cloud computing has developed rapidly. Unlike previous parallel and distributed computing, the emergence of cloud computing will, conceptually, drive a revolutionary change in the entire Internet model and enterprise management model.
[0053] The realization of cloud computing relies on cloud technology, which refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. Cloud technology is a general term encompassing network technology, information technology, integration technology, management platform technology, and application technology applied to the cloud computing business model. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will all require robust system support, which can only be achieved through cloud computing.
[0054] Please see Figure 1 , Figure 1 This is a schematic diagram of the architecture of the gateway interface testing system in an embodiment of this application, as shown below. Figure 1As shown, the gateway interface testing system includes a terminal device 101, a network 102, and a server 103. The terminal device 101 communicates with the server 103 through the network 102. The server 103 obtains the request data structure identifier and return data structure identifier corresponding to the gateway interface to be tested through the association relationship between the gateway interface and the request data structure identifier and the return data structure identifier. It then obtains the request field information based on the request data structure identifier and the return field information based on the return data structure identifier. Finally, it determines the test result of the gateway interface to be tested based on the request field information and the return field information. In addition, if code change information is detected, it can determine whether the code change information includes change information for the target code. The target code is the code associated with the gateway interface in the full code corresponding to the target protocol. If the code change information includes change information for the target code, the gateway interface mapping table and the full code corresponding to the protocol are updated according to the change information corresponding to the target code in the code change information. In this way, testing the gateway interface eliminates the need for manual searching of the request and return field information for each gateway interface from the full code of the protocol. Furthermore, when the code in the protocol is updated, the mapping table and the full code of the protocol can be updated directly without manual intervention. This not only improves the efficiency of gateway testing but also reduces the waste of labor costs.
[0055] It is understood that the server involved in this application can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. This application will use a cloud gaming server as an example. Terminal devices can be smartphones, tablets, laptops, PDAs, personal computers, smart TVs, smartwatches, etc., but are not limited to these. Terminal devices and servers can be directly or indirectly connected via wired or wireless communication, which is not limited in this application. The number of servers and terminal devices is also not limited.
[0056] It should be noted that the gateway interface mentioned above can be CGI, Fast Common Gateway Interface (FastCGI), Web Server Gateway Interface (WSGI), or Application Programming Interface (API), etc., without any specific limitation. Furthermore, the protocol mentioned above can be the proto protocol, or other protocols such as JavaScript Object Notation (JSON) and Extensible Markup Language (XML). For simplicity, the following description uses the proto protocol as an example to illustrate the testing method of the gateway interface provided in this application.
[0057] Based on the above introduction, the following section will describe the testing method for the gateway interface in this application from the server's perspective. Please refer to [link / reference needed]. Figure 2 One embodiment of the testing method for the gateway interface in this application includes:
[0058] 201. Determine the N gateway interfaces to be tested.
[0059] In this embodiment, the server can determine N gateway interfaces to be tested, where N is an integer greater than or equal to 1. These N gateway interfaces are the gateway interfaces among gateway interfaces. It is understood that the proto data structures required for each interface, request, and return in the gateway interface are predefined in the proto protocol code (using the proto protocol as an example here; if the protocol is XML, then the data structure is the data structure corresponding to XML). To test the gateway interface, the identifier of the interface to be tested needs to be found in the code. Then, the contents of the request proto data structure and the returned proto data structure corresponding to that identifier are read out, and then compiled into an executable code file using the protoc command. Thus, the request proto data structure and the returned proto data structure become executable code objects, and values are assigned to the fields of the request proto object and the returned proto object. Here, the proto structure is defined field by field; assignment refers to the process of assigning values to each field of the proto data structure according to the actual situation, filling the proto data structure.
[0060] 202. Obtain the first request data structure identifier and the first return data structure identifier corresponding to the target gateway interface from the gateway interface mapping table.
[0061] In this embodiment, the server can obtain the first request data structure identifier and the first return data structure representation corresponding to the target gateway interface from the gateway interface mapping table. The target gateway interface is any one of N gateway interfaces. The gateway interface mapping table represents the association between the gateway interface and the request data structure identifier and the return data structure identifier. That is, the server can first construct the gateway interface mapping table, and then obtain the request data structure identifier and the return data structure identifier corresponding to the target gateway interface from the gateway interface mapping table. The construction of the gateway interface mapping table is described in detail below:
[0062] Retrieve the identifier of each gateway interface in the gateway interface list;
[0063] Find the request data structure identifier and return data structure identifier corresponding to the identifier of each gateway interface from the full code of the target protocol;
[0064] Map the identifier of each gateway interface, the request data structure identifier corresponding to each gateway interface identifier, and the return data structure identifier corresponding to each gateway interface identifier to obtain the gateway interface mapping table.
[0065] In this embodiment, the server can define the function definition of each gateway interface through the full code corresponding to the target protocol. Taking the proto protocol as an example, the specific format is: "Function interface name (request, return)". When constructing the gateway interface mapping table, the server first obtains the identifier of each gateway interface. Then, based on the identifier of each gateway interface, it searches for the request data structure identifier and return data structure identifier corresponding to each gateway interface from the proto protocol that defines the function definition of each gateway interface. Finally, it maps the identifier of each gateway interface, the request data structure identifier corresponding to each gateway interface, and the return data structure identifier corresponding to each gateway interface to obtain the gateway interface mapping table. In other words, for each gateway interface in the gateway interface, since the function definition of each gateway interface has already been defined in the full code corresponding to the proto, the proto data structure name of the request and response of each gateway interface can be found in the full code corresponding to the proto protocol by searching the code. In this way, all the function definitions of all gateway interfaces in the gateway interface can be extracted at once, and the "interface name-request-return" under each function can be parsed out. Then, these names and the corresponding gateway interfaces are mapped one by one. Each interface in the gateway interface will generate a "interface name-request-return" mapping record, which is the gateway interface mapping table.
[0066] It should be noted that the above explanation uses the name of the gateway interface as the identifier of each gateway interface as an example. Of course, the identifier of each gateway interface can also be an identity identifier assigned to that gateway interface. The "request" and "return" in "interface name-request-return" under each function can also be the name of the "request" and "return" or the assigned identity identifier. There are no specific restrictions, as long as the correspondence between each gateway interface in the public gateway interface and the "request" and "return" in the proto protocol can be constructed.
[0067] 203. Obtain the first request field information corresponding to the first request data structure identifier and the first return field information corresponding to the first return data structure identifier.
[0068] In this embodiment, the server can import the field information of the target protocol into the protocol file to generate the full code corresponding to the target protocol; then, it retrieves the first request field information from the full code based on the first request data structure identifier; and retrieves the first return field information from the full code based on the first return data structure identifier. That is, for proto data structure information, all proto field information can be imported into the proto file, generating a full set of executable proto code at once, without distinguishing which gateway interface corresponds to the request and return field information. Thus, when testing a specific gateway interface, it is only necessary to look up the request and return proto data structure names corresponding to the identifier of that gateway interface using the gateway interface mapping table, and then reference the matched proto field information from the full code corresponding to the proto protocol in real time to obtain the request and return field information corresponding to that gateway interface.
[0069] Understandably, the request and return field information is defined using the proto format. For example, for a gateway interface to be tested, the proto name of the request corresponding to that gateway interface can be obtained through the gateway interface mapping table as "sendtextRequest". The request field information can be defined as {"send_id": integer; "text": String; "to_id": integer}, indicating that this request includes three pieces of information: "send_id" represents the sender identifier, "to_id" represents the receiver identifier, and "text" represents the content to be sent. These three pieces of information constitute the definition of the "sendtextRequest" "request", that is, the specific field information of the proto corresponding to the "request". Thus, after obtaining the data structure identifier "sendtextRequest", the specific field information corresponding to the data structure identifier can be obtained from the full code corresponding to the proto based on the data structure identifier.
[0070] It's important to note that a proto file is a format file that defines structured data. The `protoc` tool is used to compile and generate executable proto code. For example, `protoc --python_out=. / test.proto` will compile the `test.proto` structure file into an executable code file `test_proto.py`. Furthermore, the example above illustrates retrieving request field information from the full code corresponding to the proto protocol based on the request data structure identifier. The method for retrieving return field information from the full code corresponding to the proto based on the return data structure identifier is similar and will not be elaborated upon here.
[0071] 204. Determine the test results of N gateway interfaces based on the information in the first request field and the information in the first return field.
[0072] In this embodiment, after receiving the first request field information and the first return field information, the server can determine the test results of N gateway interfaces based on these information. The testing of the target gateway interfaces is described in detail below:
[0073] 1. Determine whether the target gateway interface passes the test based on whether the request content included in the first request field information matches the return content included in the first return field information;
[0074] The server can parse the first request field information and the first return field information separately to obtain the request content corresponding to the first request field information (such as "String" in "text":String in the example above) and the return content corresponding to the first return field information. Then, it determines whether the request content and the return content match. If the request content and the return content match, the gateway interface is determined to have passed the test. If the request content and the return content do not match, the gateway interface is determined to have failed the test. For example, if the target gateway interface should return 1, but the actual return content is 2, the target gateway interface is determined to have failed the test; if the actual return is also 1, the target gateway interface is determined to have passed the test.
[0075] 2. Determine whether the target gateway interface passes the test by comparing the requester and sender information included in the first request field with the requester and sender information included in the first return field.
[0076] The server can parse the first request field information to obtain the first sent information (i.e., sender identifier) and the first received information (receiver identifier) corresponding to the first request field information. It can also parse the first return field information to obtain the second sent information and the second received information corresponding to the first return field information. It can be understood that since the first request field information and the first return field information are the specific field information included in the "request" and "return" of the target gateway interface, to verify whether the target gateway interface passes the test, it can be done by judging whether the sender identifier of the "request" matches the receiver identifier of the "return". The test checks whether the recipient identifier of the "request" and the sender identifier of the "return" are consistent. If they are consistent, it means that the target of the "request" is the "return", and the target of the "return" is the "request", thus confirming that the gateway interface test passes. If one of them is inconsistent, such as the sender identifier of the "request" and the recipient identifier of the "return" being inconsistent, or the recipient identifier of the "request" and the sender identifier of the "return" being inconsistent, it means that the target of the "request" is not the "return", or the target of the "return" is not the "request", thus confirming that the gateway interface test fails.
[0077] It should be noted that the above descriptions of the target gateway interface testing are presented separately from two different aspects. Of course, in the process of testing the target gateway interface, the two aspects are also combined for testing. For example, it is necessary to determine whether the sent information and received information match, and at the same time, it is necessary to determine whether the request content and the return content match. Only when both match is the target gateway interface determined to have passed the test. If one of them does not match, the target gateway interface is determined to have failed the test.
[0078] In one embodiment, to prevent gateway interface testing issues caused by temporary changes to the gateway interface mapping table or by failure to promptly detect changes in the request and returned proto data structure of a gateway interface, the server also performs the following operations:
[0079] Monitor project code change information;
[0080] If the project code change information includes change information for the target code, then obtain the change information corresponding to the target code from the project code change information. The target code is the code associated with the gateway interface in the full code.
[0081] Update the gateway interface mapping table and the entire code based on the change information corresponding to the target code in the project code change information.
[0082] In this embodiment, the server incorporates a Git code management tool (Git is a distributed version control system used to store all historical data, mainly including the current status of each file, historical modification time, who made the modifications, and the reasons for the modifications). Git is used to manage the code, and a webhook notification mechanism is set up to notify developers when they commit or modify code. This allows for real-time monitoring of the project code. If changes are detected, the server retrieves the change information and determines whether it includes changes to the target code. The target code is the code associated with the gateway interface in the full code corresponding to the proto protocol. If the change information includes changes to the target code, the gateway interface mapping table and the full code corresponding to the proto protocol are updated based on these changes. The proto data structures for the "request" and "return" of the gateway interface corresponding to the target code are updated, and the updated proto file is then recompiled using protoc to obtain the latest full code corresponding to the proto protocol. This allows for timely notification of code changes and updates to the proto code, enabling gateway interface testing to be conducted immediately based on the updated proto code, rather than passively relying on manual checks to determine if the proto data structure has changed, thereby improving the testing efficiency of the gateway interface.
[0083] It's important to note that a Webhook is a "user-defined HTTP callback," typically triggered by events such as "pushing code to a repository" or "posting a comment to a blog." When an event occurs, a Hypertext Transfer Protocol (HTTP) request is initiated to the Uniform Resource Locator (URL) configured in the webhook. Subsequently, by triggering an event on one site, the behavior of another site can be invoked. In this context, it refers to triggering an update to the gateway interface mapping table and the corresponding full code in the proto protocol when there are changes to the project code. This update determines whether the changes affect the target code, which is the code associated with the gateway interface within the full codebase corresponding to the proto protocol. If so, it triggers an update operation on the proto protocol's full codebase.
[0084] It should also be noted that after the server completes the update of the gateway interface mapping table and the full code corresponding to the target protocol, it can retest each gateway interface in the gateway interface, or only test the gateway interfaces involved in this update. There is no specific limitation. It is only necessary to use the updated gateway interface mapping table to obtain the request data structure identifier and return data structure identifier corresponding to the gateway interface to be tested, and then look up the corresponding request field information in the full code corresponding to the target protocol based on the request data structure identifier, and look up the corresponding return field information in the full code corresponding to the target protocol based on the return data structure identifier, and determine the test result of the gateway interface to be tested based on the request field information and return field information.
[0085] In summary, it can be seen that in the embodiments provided in this application, when testing a gateway interface, a mapping table can be constructed between all gateway interfaces and their request data structure identifiers and return data structure identifiers. Then, the request data structure identifier and return data structure identifier corresponding to the gateway interface currently under test are obtained from the mapping table, along with the corresponding request field information and return field information. Finally, the gateway interface under test is tested based on the request field information and return field information. This eliminates the need for manual searching of the corresponding structure data for the request field information and return field information of each gateway interface, improving the efficiency of gateway testing and reducing the waste of manual labor costs.
[0086] The embodiments of this application have been described above from the perspective of gateway interface testing methods. The embodiments of this application will now be described below from the perspective of gateway interface testing devices.
[0087] Please see Figure 3 This application provides a gateway interface testing device 300, which includes:
[0088] The first determining unit 301 is used to determine N gateway interfaces to be tested, where N is an integer greater than or equal to 1;
[0089] The first acquisition unit 302 is used to acquire the first request data structure identifier and the first return data structure identifier corresponding to the target gateway interface from the gateway interface mapping table. The target gateway interface is any one of the N gateway interfaces. The gateway interface mapping table is used to represent the association between the gateway interface and the request data structure identifier and the return data structure identifier. The gateway interface includes N gateway interfaces.
[0090] The second acquisition unit 303 is used to acquire the first request field information corresponding to the first request data structure identifier and the first return field information corresponding to the first return data structure identifier;
[0091] The second determining unit 304 is used to determine the test results of N gateway interfaces based on the first request field information and the first return field information.
[0092] In one possible design, the first determining unit 301 is also used for:
[0093] Retrieve the identifier of each gateway interface in the gateway interface list;
[0094] Find the request data structure identifier and return data structure identifier corresponding to the identifier of each gateway interface from the full code of the target protocol;
[0095] Map the identifier of each gateway interface, the request data structure identifier corresponding to each gateway interface identifier, and the return data structure identifier corresponding to each gateway interface identifier to obtain the gateway interface mapping table.
[0096] In one possible design, the second acquisition unit 303 is specifically used for:
[0097] Import the field information of the target protocol into the protocol file to generate the full code corresponding to the target protocol;
[0098] The first request field information is obtained from the full code based on the first request data structure identifier;
[0099] The first returned field information is obtained from the full code based on the first returned data structure identifier.
[0100] In one possible design, the gateway interface testing device 300 also includes:
[0101] Update unit 305, update unit 305 is used for:
[0102] Monitor project code change information;
[0103] If the project code change information includes change information for the target code, then obtain the change information corresponding to the target code from the project code change information. The target code is the code associated with the gateway interface in the full code.
[0104] Update the gateway interface mapping table and the entire code based on the change information corresponding to the target code in the project code change information.
[0105] In one possible design,
[0106] The second acquisition unit 303 is further configured to, if the project code change information includes change code for the target gateway interface, obtain the second request data structure identifier and the second return data structure identifier corresponding to the target gateway interface from the updated gateway interface mapping table;
[0107] The second acquisition unit 303 is further configured to acquire the second request field information corresponding to the second request data structure identifier and the second return field information corresponding to the second return data structure identifier;
[0108] The second determining unit 304 is also used to determine the test results of N gateway interfaces based on the second request field information and the second return field information.
[0109] In one possible design, the second determining unit 304 is specifically used for:
[0110] The first request field information is parsed to obtain the first sending information and the first receiving information included in the first request field information;
[0111] The first returned field information is parsed to obtain the second sent information and the second received information included in the first returned field information;
[0112] If the first sent information matches the second received information, and the first received information matches the second sent information, then it is determined that N gateway interfaces have passed the test.
[0113] If the first sent information does not match the second received information, or if the first received information does not match the second sent information, then it is determined that N gateway interface tests have failed.
[0114] In one possible design, the second determining unit 304 is further specifically used for:
[0115] The first request field information is parsed to obtain the request content included in the first request field information;
[0116] The first returned field information is parsed to obtain the returned content included in the first returned field information;
[0117] If the requested content matches the returned content, then N gateway interfaces are confirmed to have passed the test.
[0118] If the requested content and the returned content do not match, then N gateway interface tests are determined to have failed.
[0119] This application also provides another gateway interface testing device, which is deployed on a server. Please refer to... Figure 4 , Figure 4This is a schematic diagram of a server structure provided in an embodiment of this application. The server 400 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 422 (e.g., one or more processors) and a memory 432, and one or more storage media 430 (e.g., one or more mass storage devices) for storing application programs 442 or data 444. The memory 432 and storage media 430 can be temporary or persistent storage. The program stored in the storage media 430 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the server. Furthermore, the CPU 422 may be configured to communicate with the storage media 430 and execute the series of instruction operations stored in the storage media 430 on the server 400.
[0120] Server 400 may further include: one or more power supplies 426, one or more wired or wireless network interfaces 450, one or more input / output interfaces 458, and at least one of one or more operating systems 441, wherein the operating system 441 may be Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM Operating systems, etc.
[0121] The steps performed by the gateway interface testing device in the above embodiments can be based on this. Figure 4 The server structure shown.
[0122] This application also provides a computer-readable storage medium storing a computer program thereon. When executed by a computer, the computer program implements the method flow related to the gateway interface testing device in any of the above method embodiments. Correspondingly, the computer can be the aforementioned gateway interface testing device.
[0123] This application also provides a computer program or a computer program product including a computer program, which, when executed on a computer, will cause the computer to implement the method flow related to the gateway interface testing device in any of the above method embodiments. Correspondingly, the computer can be the aforementioned gateway interface testing device.
[0124] In the above Figure 2 In the corresponding embodiments, it can be implemented entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product.
[0125] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state disk (SSD)).
[0126] It should be understood that the processor mentioned in this application can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0127] It should also be understood that the number of processors in this application can be one or more, and the specific number can be adjusted according to the actual application scenario. This is merely an illustrative example and is not intended to limit the application. The number of memory in the embodiments of this application can also be one or more, and the specific number can be adjusted according to the actual application scenario. This is merely an illustrative example and is not intended to limit the application.
[0128] It should also be noted that when the gateway interface testing device includes a processor (or processing unit) and a memory, the processor in this application may be integrated with the memory, or the processor and the memory may be connected through an interface. The specific configuration can be adjusted according to the actual application scenario and is not limited.
[0129] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0130] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0131] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0132] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0133] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or other device, etc.) to execute this application. Figure 2 All or part of the steps of the test method for the gateway interface.
[0134] It should be understood that the storage medium or memory mentioned in this application may include volatile memory or non-volatile memory, or both. Non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
[0135] It should be noted that the memories described herein are intended to include, but are not limited to, these and any other suitable types of memories.
[0136] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A testing method for a gateway interface, characterized in that, include: Determine N gateway interfaces to be tested, where N is an integer greater than or equal to 1; Obtain the first request data structure identifier and the first return data structure identifier corresponding to the target gateway interface from the gateway interface mapping table. The target gateway interface is any one of the N gateway interfaces. The gateway interface mapping table is used to represent the association between the gateway interface and the request data structure identifier and the return data structure identifier. The gateway interface includes the N gateway interfaces. Obtaining the first request field information corresponding to the first request data structure identifier and the first return field information corresponding to the first return data structure identifier includes: importing the field information of the target protocol into a protocol file to generate the full code corresponding to the target protocol; obtaining the first request field information from the full code according to the first request data structure identifier; and obtaining the first return field information from the full code according to the first return data structure identifier, wherein the request field information and the return field information are defined in proto format; The test results of the N gateway interfaces are determined based on the first request field information and the first return field information.
2. The test method according to claim 1, characterized in that, The method further includes: Obtain the identifier of each gateway interface in the gateway interface; Search for the request data structure identifier and return data structure identifier corresponding to the identifier of each gateway interface from the full code corresponding to the target protocol; The gateway interface mapping table is obtained by mapping the identifier of each gateway interface, the request data structure identifier corresponding to the identifier of each gateway interface, and the return data structure identifier corresponding to the identifier of each gateway interface.
3. The test method according to claim 1, characterized in that, The method further includes: Monitor project code change information; If the project code change information includes change information for the target code, then the change information corresponding to the target code in the project code change information is obtained, where the target code is the code associated with the gateway interface in the full code; Update the gateway interface mapping table and the full code based on the change information corresponding to the target code in the project code change information.
4. The test method according to claim 3, characterized in that, The method further includes: If the project code change information includes change code for the target gateway interface, then the second request data structure identifier and the second return data structure identifier corresponding to the target gateway interface are obtained from the updated gateway interface mapping table. Obtain the second request field information corresponding to the second request data structure identifier and the second return field information corresponding to the second return data structure identifier; The test results of the N gateway interfaces are determined based on the second request field information and the second return field information.
5. The test method according to any one of claims 1 to 4, characterized in that, The step of determining the test results of the N gateway interfaces based on the first request field information and the first return field information includes: The first request field information is parsed to obtain the first sending information and the first receiving information included in the first request field information; The first returned field information is parsed to obtain the second sending information and the second receiving information included in the first returned field information; If the first sent information matches the second received information, and the first received information matches the second sent information, then the N gateway interface tests are deemed to have passed. If the first sent information does not match the second received information, or if the first received information does not match the second sent information, then the N gateway interface tests are determined to have failed.
6. The test method according to any one of claims 1 to 4, characterized in that, The step of determining the test results of the N gateway interfaces to be tested based on the first request field information and the first return field information includes: The first request field information is parsed to obtain the request content included in the first request field information; The first returned field information is parsed to obtain the returned content included in the first returned field information; If the requested content matches the returned content, then the N gateway interface tests are deemed to have passed. If the requested content does not match the returned content, then the N gateway interface tests are deemed to have failed.
7. A gateway interface testing device, characterized in that, include: The first determining unit is used to determine N gateway interfaces to be tested, wherein N is an integer greater than or equal to 1; The first acquisition unit is used to acquire the first request data structure identifier and the first return data structure identifier corresponding to the target gateway interface from the gateway interface mapping table. The target gateway interface is any one of the N gateway interfaces. The gateway interface mapping table is used to represent the association between the gateway interface and the request data structure identifier and the return data structure identifier. The gateway interface includes the N gateway interfaces. The second acquisition unit is configured to acquire first request field information corresponding to the first request data structure identifier and first return field information corresponding to the first return data structure identifier, including: importing the field information of the target protocol into a protocol file to generate the full code corresponding to the target protocol; acquiring the first request field information from the full code according to the first request data structure identifier; and acquiring the first return field information from the full code according to the first return data structure identifier, wherein the request field information and the return field information are defined in proto format; The second determining unit is used to determine the test results of the N gateway interfaces based on the first request field information and the first return field information.
8. A computer device, characterized in that, include: Memory, processor, and bus system; The memory is used to store programs; The processor is configured to execute a program in the memory, and the processor is configured to execute the test method according to any one of claims 1 to 6 according to the instructions in the program code; The bus system is used to connect the memory and the processor to enable communication between the memory and the processor.
9. A computer storage medium, characterized in that, It includes instructions that, when executed on a computer, cause the computer to perform the test method as described in any one of claims 1-6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed on a computer, causes the computer to perform the test method as described in any one of claims 1-6.
Citation Information
Patent Citations
Gateway interface test method and device, terminal equipment and storage medium
CN110519115A