CN115408260A - Gateway interface testing method and device and readable storage medium - Google Patents

Gateway interface testing method and device and readable storage medium Download PDF

Info

Publication number
CN115408260A
CN115408260A CN202110592732.4A CN202110592732A CN115408260A CN 115408260 A CN115408260 A CN 115408260A CN 202110592732 A CN202110592732 A CN 202110592732A CN 115408260 A CN115408260 A CN 115408260A
Authority
CN
China
Prior art keywords
gateway interface
data structure
gateway
field information
return
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110592732.4A
Other languages
Chinese (zh)
Inventor
黄礼坤
蒋剑琴
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110592732.4A priority Critical patent/CN115408260A/en
Publication of CN115408260A publication Critical patent/CN115408260A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the application provides a method and related equipment for testing a gateway interface, which are used for testing the gateway interface in a parallel computing mode and improving the testing efficiency of the gateway interface. The method comprises the following steps: determining N gateway interfaces to be tested, wherein N is an integer greater than or equal to 1; acquiring a first request data structure identifier and a first return data structure identifier corresponding to a target gateway interface from a gateway interface mapping table, wherein the target gateway interface is any one of N gateway interfaces, the gateway interface mapping table is used for expressing the association relationship between the gateway interface and the request data structure identifier and between the gateway interface and the return data structure identifier, and the gateway interface comprises N gateway interfaces; acquiring first request field information corresponding to the first request data structure identification and first return field information corresponding to the first return data structure identification; and determining the test results of the N gateway interfaces according to the first request field information and the first return field information.

Description

Method and device for testing gateway interface and readable storage medium
Technical Field
The present application relates to the field of computing, and in particular, to a method and an apparatus for testing a gateway interface, and a readable storage medium.
Background
Protocol Buffers are a lightweight and efficient structured data storage format defined by google, can be used for structured data serialization, are used as exchange formats of data storage, remote Procedure Call (RPC) and continuous data, and can be used for language-independent, platform-independent and extensible serialized structured data formats in the fields of communication protocols, data storage and the like.
In Common Gateway Interface (CGI) testing based on proto protocol, for each Gateway testing request, a data structure of the Gateway testing request needs to be assembled according to a corresponding proto structure statement, then the data structure is serialized into binary data and then sent, for the returned content, which is also in a binary data form, the returned content needs to be deserialized into a corresponding proto structure and then specific field data in the proto structure is analyzed, and after one testing of the network request is completed, checking and checking are carried out to determine a Gateway testing result.
However, in practical applications, because the number of CGIs in the background is large (e.g., thousands of gateway interfaces), it is necessary to test the request interfaces in the background one by one to ensure the quality and stability of the CGIs in the background. For each requested test, a manual work is needed to search the proto structure body of the requested request corresponding to the request gateway interface and the proto structure body of the returned response from the proto protocol so as to smoothly perform data assembly and analysis. The process is complicated and inefficient, and not only is the efficiency of CGI testing based on the proto protocol too low, but also labor cost is wasted.
Disclosure of Invention
The application provides a testing method of a gateway interface and related equipment, which can improve the testing efficiency of the gateway interface and reduce the waste of labor cost.
An embodiment of the present application provides a method for testing a gateway interface, including:
determining N gateway interfaces to be tested, wherein N is an integer greater than or equal to 1;
acquiring a first request data structure identifier and a first return data structure identifier corresponding to a target gateway interface from a gateway interface mapping table, wherein the target gateway interface is any one of N gateway interfaces, the gateway interface mapping table is used for expressing the association relationship between the gateway interface and the request data structure identifier and between the gateway interface and the return data structure identifier, and the gateway interface comprises N gateway interfaces;
acquiring first request field information corresponding to the first request data structure identification and first return field information corresponding to the first return data structure identification;
and determining the test results of the N gateway interfaces according to the first request field information and the first return field information.
This application another aspect provides a gateway interface testing arrangement, which characterized in that includes:
the first determining unit is used for determining N gateway interfaces to be tested, wherein N is an integer greater than or equal to 1;
the gateway interface mapping table is used for representing the association relation among the gateway interface, the request data structure identification and the returned data structure identification, and the gateway interface comprises N gateway interfaces;
the second acquisition unit is used for acquiring first request field information corresponding to the first request data structure identification and first return field information corresponding to the first return data structure identification;
and the second determining unit is used for determining the test results of the N gateway interfaces according to the first request field information and the first return field information.
In one possible design, the first determination unit is further configured to:
acquiring an identifier of each gateway interface in the gateway interfaces;
searching a request data structure identifier and a return data structure identifier corresponding to the identifier of each gateway interface from the full code corresponding to the target protocol;
and 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 to obtain a gateway interface mapping table.
In one possible design, the second obtaining unit is specifically configured to:
importing field information of a target protocol into a protocol file to generate a full code corresponding to the target protocol;
acquiring first request field information from a full code according to the first request data structure identifier;
and acquiring first return field information from the full-size code according to the first return data structure identification.
In one possible design, the gateway interface testing apparatus further includes:
an update unit to:
monitoring item code change information;
if the item code change information comprises change information aiming at the target code, obtaining the change information corresponding to the target code in the item code change information, wherein the target code is a code associated with a gateway interface in the full code;
and updating the gateway interface mapping table and the full code according to the change information corresponding to the target code in the item code change information.
In one possible design, the first and second electrodes are,
the second obtaining unit is further configured to obtain, if the item code change information includes a change code for the target gateway interface, a second request data structure identifier and a second return data structure identifier corresponding to the target gateway interface from the updated gateway interface mapping table;
the second obtaining unit is further configured to obtain second request field information corresponding to the second request data structure identifier and second return field information corresponding to the second return data structure identifier;
and the second determining unit is further configured to determine test results of the N gateway interfaces according to the second request field information and the second return field information.
In one possible design, the second determining unit is specifically configured to:
analyzing the first request field information to obtain first sending information and first receiving information which are included in the first request field information;
analyzing the first return field information to obtain second sending information and second receiving information which are included in the first return field information;
if the first sending information is matched with the second receiving information and the first receiving information is matched with the second sending information, determining that the N gateway interfaces pass the test;
and if the first sending information is not matched with the second receiving information or the first receiving information is not matched with the second sending information, determining that the N gateway interfaces do not pass the test.
In a possible design, the second determining unit is further specifically configured to:
analyzing the first request field information to obtain request content included in the first request field information;
analyzing the first return field information to obtain return contents included in the first return field information;
if the request content is matched with the return content, determining that the N gateway interfaces pass the test;
and if the request content is not matched with the return content, determining that the N gateway interfaces do not pass the test.
In another aspect, the present embodiment provides a computer device, which includes at least one connected processor, a memory and a transceiver, where the memory is used to store program codes, and the processor is used to call the program codes in the memory to execute the steps of the gateway interface testing method according to the above aspects.
Another aspect of the embodiments of the present application provides a computer storage medium, which includes instructions that, when executed on a computer, cause the computer to perform the steps of the method for testing a gateway interface according to the above aspects.
In summary, it can be seen that, in the embodiment of the present application, when a gateway interface is tested, a mapping table of all gateway interfaces in the gateway interface, a request data structure identifier and a returned data structure identifier may be constructed, then the request data structure identifier and the returned data structure identifier corresponding to a gateway interface to be tested are obtained from the mapping table, and request field information and returned field information corresponding to the request data structure identifier and the returned data structure identifier are obtained, so as to test the gateway interface to be tested according to the request field information and the returned field information. Therefore, the corresponding structure data of the request field information and the return field information of each gateway interface in the gateway interfaces does not need to be searched manually, the efficiency of gateway testing can be improved, and meanwhile, the waste of labor cost is reduced.
Drawings
Fig. 1 is a schematic architecture diagram of a gateway interface test system provided in an embodiment of the present application:
fig. 2 is a schematic flowchart of a method for testing a gateway interface according to an embodiment of the present application;
fig. 3 is a schematic view of a virtual structure of a gateway interface testing apparatus according to an embodiment of the present application;
fig. 4 is a schematic hardware structure diagram of a server according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments.
The terms "first," "second," and the like in the description and in the claims of the present application and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be implemented in other sequences than those illustrated or described herein. Furthermore, the terms "comprise," "include," and "have," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or modules is not necessarily limited to those steps or modules expressly listed, but may include other steps or modules not expressly listed or inherent to such process, method, article, or apparatus, wherein the division of modules presented herein is merely a logical division and may be implemented in a practical application in a different manner, such that a plurality of modules may be combined or integrated into another system or some feature vectors may be omitted or not implemented, and wherein shown or discussed as coupled or directly coupled or communicatively coupled to each other may be through some interfaces and indirectly coupled or communicatively coupled to each other module may be electrically or otherwise similarly configured, all without limitation. The modules or sub-modules described as separate components may or may not be physically separated, may or may not be physical modules, or may be distributed in a plurality of circuit modules, and some or all of the modules may be selected according to actual needs to achieve the purpose of the present disclosure.
The application provides a method for testing a gateway interface, which can be realized based on a cloud computing (cloud computing) technology and can realize automatic testing of the gateway interface. Cloud computing refers to a mode of delivery and use of Internet Technology (IT) infrastructure, and refers to obtaining required resources through a network in an on-demand, easily extensible manner; the broad cloud computing refers to a delivery and use mode of a service, and refers to obtaining a required service in an on-demand and easily-extensible manner through a network. Such services may be IT and software, internet related, or other services. Cloud Computing is a product of development and fusion of traditional computer and Network Technologies, such as Grid Computing (Grid Computing), distributed Computing (Distributed Computing), parallel Computing (Parallel Computing), utility Computing (Utility Computing), network Storage (Network Storage Technologies), virtualization (Virtualization), and Load balancing (Load Balance). With the development of diversification of internet, real-time data stream and connecting equipment and the promotion of demands of search service, social network, mobile commerce, open collaboration and the like, cloud computing is rapidly developed. Different from the prior parallel distributed computing, the generation of cloud computing can promote the revolutionary change of the whole internet mode and the enterprise management mode in concept.
Cloud computing relies on Cloud technology (Cloud technology), which is a hosting technology for unifying a series of resources such as hardware, software, and network in a wide area network or a local area network to realize computing, storing, processing, and sharing of data. The cloud technology is based on the general names of network technology, information technology, integration technology, management platform technology, application technology and the like applied in the cloud computing business model, can form a resource pool, is used as required, and is flexible and convenient. Cloud computing technology will become an important support. Background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture-like websites and more web portals. With the high development and application of the internet industry, each article may have its own identification mark and needs to be transmitted to a background system for logic processing, data in different levels are processed separately, and various industrial data need strong system background support and can only be realized through cloud computing.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a gateway interface testing system in an embodiment of the present application, as shown in fig. 1, the gateway interface testing system includes a terminal device 101, a network 102, and a server 103, where the terminal device 101 is in communication connection with the server 103 through the network 102, and the server 103 obtains a request data structure identifier and a return data structure identifier corresponding to a gateway interface to be tested through an association relationship between the gateway interface and the request data structure identifier and the return data structure identifier, obtains request field information according to the request data structure identifier, obtains return field information according to the return data structure identifier, and then determines a testing result of the gateway interface to be tested according to the request field information and the return field information; if the change information for the target code is included, the gateway interface mapping table and the full-size code corresponding to the protocol are updated according to the change information corresponding to the target code in the code change information. Therefore, the gateway interfaces are tested, the request field information corresponding to each gateway interface in the gateway interfaces and the corresponding structure data of the returned field information do not need to be searched manually from the full codes corresponding to the protocol, and meanwhile, when the codes in the protocol are updated, the mapping table and the full codes corresponding to the protocol are directly updated without manual participation, so that the efficiency of the gateway test can be improved, and meanwhile, the waste of labor cost is reduced.
It can be understood that the server related to the present application may be an independent physical server, may also be a server cluster or a distributed system formed by a plurality of physical servers, and may also be a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), and a big data and artificial intelligence platform. The present application will be described with reference to a cloud game server as an example. The terminal device may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a palm computer, a personal computer, a smart television, a smart watch, and the like. The terminal device and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein. The number of servers and terminal devices is not limited.
It should be noted that the Gateway Interface may be a CGI, a Fast Common Gateway Interface (FastCGI), a Web Server Gateway Interface (WSGI), an Application Programming Interface (API), or any other Gateway Interface, and is not limited specifically. In addition, the above-mentioned protocol may be a proto protocol, and of course, may also be other protocols, for example, JS Object Notation (JSON) protocol and Extensible Markup Language (XML) protocol, which are not limited specifically, and for convenience of description, the proto protocol is taken as an example to describe the testing method of the gateway interface provided in the present application.
With reference to fig. 2, an embodiment of a method for testing a gateway interface in the present application is described below from the perspective of a server, where the method for testing a gateway interface in the embodiment of the present application includes:
201. determining N gateway interfaces to be tested.
In this embodiment, the server may determine N gateway interfaces to be tested, where N is an integer greater than or equal to 1, and the N gateway interfaces are gateway interfaces in the gateway interfaces. It can be understood that each interface, request, and return required proto data structure in the gateway interface is predefined in the code of the proto protocol (here, the proto protocol is taken as an example for illustration, if the protocol is an XML protocol, the data structure is a data structure corresponding to XML), in order to test the gateway interface, it is necessary to find out the identifier of the interface to be tested from the code, then read out the contents of the requested proto data structure and the returned proto data structure corresponding to the identifier, and then compile an executable code file according to the proto command, so that the requested proto data structure and the returned proto data structure become executable code objects, and perform field assignment on the requested proto object and the returned proto object. The proto structure is a field definition, and the assignment refers to a process of assigning a field to the proto data structure according to actual conditions and filling the proto data structure.
202. And acquiring a first request data structure identifier and a first return data structure identifier corresponding to the target gateway interface from the gateway interface mapping table.
In this embodiment, the server may obtain, from a gateway interface mapping table, a first request data structure identifier and a first returned data structure representation corresponding to a target gateway interface, where the target gateway interface is any one of the N gateway interfaces, and the gateway interface mapping table is used to represent an association relationship between the gateway interface and the request data structure identifier and between the gateway interface and the first returned data structure identifier. That is, the server may first construct a gateway interface mapping table, then obtain the request data structure identifier corresponding to the target gateway interface and the return data structure identifier from the gateway interface mapping table, and the following describes in detail the construction of the gateway interface mapping table:
acquiring an identifier of each gateway interface in the gateway interfaces;
searching a request data structure identifier corresponding to the identifier of each gateway interface and a return data structure identifier from a full code corresponding to a target protocol;
and 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 to obtain a gateway interface mapping table.
In this embodiment, the server may define the function definition of each gateway interface through the full code corresponding to the target protocol, taking the proto protocol as an example, and the specific format is as follows: the method includes the steps of obtaining an identifier of each gateway interface in the gateway interfaces when a gateway interface mapping table is constructed, searching a request data structure identifier and a return data structure identifier corresponding to each gateway interface from a proto protocol defining a Function definition of each gateway interface based on the identifier of each gateway interface, and 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 each gateway interface to obtain the gateway interface mapping table. That is, for each gateway interface in the gateway interfaces, since the function definition of each gateway interface has been defined in advance in the full amount code corresponding to proto, the request and proto data structure name returned to response of each gateway interface can be found out from the full amount code corresponding to proto protocol through code search, so that the function definitions of all gateway interfaces in the gateway interfaces can be all taken out at one time, the interface name-request-return under each function is analyzed, then the names and the corresponding gateway interfaces are made into one-to-one mapping records, each interface in the gateway interfaces generates one mapping record of the interface name-request-return, and the mapping record is the gateway interface mapping table.
It should be noted that, the above description is given by taking the identifier of each gateway interface as the name of the gateway interface, and of course, the identifier of each gateway interface may also be an identity identifier assigned to the gateway interface, and the "request" and the "return" in the "interface name-request-return" under each function may also be names of the "request" and the "return" or assigned identities, which is not specifically limited, as long as the corresponding relationship between each gateway interface in the public gateway interface and the "request" and the "return" in the proto protocol can be established.
203. And acquiring first request field information corresponding to the first request data structure identification and first return field information corresponding to the first return data structure identification.
In this embodiment, the server may import field information of the target protocol into the protocol file to generate a full code corresponding to the target protocol; then acquiring first request field information from the full code according to the first request data structure identifier; and acquiring first return field information from the full-size code according to the first return data structure identification. That is, for the information of the proto data structure, all the proto field information can be imported into the proto file, so that a full amount of executable proto codes can be generated at one time, and the request field information and the return field information corresponding to which gateway interface are not distinguished any more. Therefore, when a certain gateway interface is tested, the request corresponding to the identifier of the gateway interface and the returned proto data structure name can be searched only according to the gateway interface mapping table, and the hit proto field information is quoted from the full code corresponding to the proto protocol in real time, so that the request field information and the returned field information corresponding to the gateway interface can be obtained.
It can be understood that the request field information and the return field information are defined by a proto format, for example, a gateway interface to be tested, a proto name "sendextrequest" of a request corresponding to the gateway interface can be obtained through a gateway interface mapping table, and the request field information can be defined as { "send _ id": interger; "text": string; the "to _ id" indicates that the request includes three pieces of information, where "send _ id" indicates a sender identifier, "to _ id" indicates a receiver identifier, and "text" indicates transmission content, where the three pieces of information are definitions of "sendextrequest" and the "request," that is, specific field information of the proto corresponding to the "request," so that after the data structure identifier "sendextrequest" is obtained, the specific field information corresponding to the data structure identifier can be obtained from the full code corresponding to the proto according to the data structure identifier.
It should be noted that the proto file is a format file defining structured data, and is compiled to generate executable proto code through a protoc tool command, for example, when protoc-python _ out =/test. In addition, the above description illustrates the request field information obtained from the full code corresponding to the proto protocol according to the request data structure identifier, and the manner of obtaining the return field information from the full code corresponding to the proto according to the return data structure identifier is similar to the above description, and details are not repeated here.
204. And determining the test results of the N gateway interfaces according to the first request field information and the first return field information.
In this embodiment, after obtaining the first request field information and the first return field information, the server may determine the test results of the N gateway interfaces according to the first request field information and the first return field information. The following describes the testing of the target gateway interface specifically:
1. determining whether the target gateway interface passes the test according to whether the request content included in the first request field information is matched with the return content included in the first return field information;
the server may analyze the first request field information and the first return field information, respectively, to obtain request content (e.g., "text" in "String") corresponding to the first request field information and return content corresponding to the first return field information, then determine whether the request content matches the return content, if the request content matches the return content, determine that the gateway interface passes the test, if the request content does not match the return content, determine that the gateway interface fails the test, for example, the content that the request of the target gateway interface should return is 1, and if the actual return content is 2, determine that the target gateway interface fails the test; if the actual return is also 1, the target gateway interface is determined to pass the test.
2. According to the requester and the sender included in the first request field information, whether the requester and the sender included in the first return field information are matched is determined to determine whether the target gateway interface passes the test;
the server may analyze the first request field information to obtain first sending information (i.e., a sender identifier) and first receiving information (a receiver identifier) corresponding to the first request field information, may analyze the first returning field information to obtain second sending information and second receiving information corresponding to the first returning field information, and it may be understood that, since the first request field information and the first returning field information are respectively specific field information included in a "request" and a "return" corresponding to a target gateway interface, if it is verified that the target gateway interface passes a test, it may be determined that a sender identifier of the "request" is consistent with a receiver identifier of the "return", and it is determined that a receiver identifier of the "request" is consistent with a sender identifier of the "return", and if both are consistent, it is described that an object targeted by the "request" is a "return", and an object targeted by the "return" is the "request", it is determined that the gateway interface passes the test; if there is an inconsistency, for example, the sender identifier of the "request" is inconsistent with the receiver identifier of the "return", or the receiver identifier of the "request" is inconsistent with the sender identifier of the "return", it indicates that the object targeted by the "request" is not the "return", or that the object targeted by the "return" is not the "request", it indicates that the gateway interface test fails.
It should be noted that, the above description separately describes the test of the target gateway interface from two aspects, and certainly, in the process of testing the target gateway interface, the two are also combined to test the target gateway interface, for example, whether the sent information and the received information are matched is judged, and at the same time, whether the requested content and the returned content are matched is judged, only when the two are matched, it is determined that the target gateway interface passes the test, and if there is a mismatch, it is determined that the target gateway interface fails the test.
In one embodiment, in order to prevent the gateway interface testing problem caused by temporary change of the gateway interface mapping table or change of a request and a returned proto data structure of a certain gateway interface being not discovered in time, the server further performs the following operations:
monitoring item code change information;
if the item code change information comprises change information aiming at the target code, obtaining the change information corresponding to the target code in the item code change information, wherein the target code is a code associated with the gateway interface in the full code;
and updating the gateway interface mapping table and the full code according to the change information corresponding to the target code in the item code change information.
In the embodiment, a server introduces a Git code management tool (Git is a distributed version control system and is used for storing all historical data, and mainly storing information such as the current state, the historical modification time, the modification of who makes and the reason of the modification of each file, and the like), uses Git management codes, and notifies when development is submitted or the codes are modified by setting a notification mechanism webhook, so that project codes can be monitored in real time, if the project codes are monitored to be modified, project code change information is obtained, and whether the project code change information includes change information aiming at target codes, wherein the target codes are codes related to a gateway interface in full-volume codes corresponding to a proto protocol, and if the project code change information includes the change information aiming at the target codes, a gateway interface mapping table and the full-volume codes corresponding to the proto protocol are updated according to the change information aiming at the target codes. And updating the proto data structures of the request and the return of the gateway interface corresponding to the object code, and then performing protoc compilation on the updated proto file again to obtain the latest full code corresponding to the proto protocol. Therefore, the code change information can be timely notified, and the proto code is updated, so that the test of the gateway interface can be performed according to the updated proto code at the first time, and whether the proto data structure changes or not is determined in a passive mode of manual checking, and the test efficiency of the gateway interface is improved.
It should be noted that Webhook is "user-defined HTTP callback", and is usually triggered by some events, for example, "push code to reply", or "post a comment to blog", that is, when an event occurs, a HyperText Transfer Protocol (HTTP) request may be initiated to a Uniform Resource Locator (URL) configured by Webhook, and then, an event may be triggered at a site to invoke a behavior of another site, where when the item code has a change, the event may trigger to determine whether the change of the item code is a change for an object code, where the object code is a code associated with a gateway interface in a full code corresponding to the proto Protocol, and if so, trigger to perform an update operation on a mapping table of the gateway interface and the full code corresponding to the proto Protocol.
It should be further noted that, after the server completes updating the gateway interface mapping table and the full code corresponding to the target protocol, it may retest each gateway interface in the gateway interfaces, or only test the gateway interface related to the update, and is not specifically limited, and it is only necessary to use the updated gateway interface mapping table to obtain the request data structure identifier and the returned data structure identifier corresponding to the gateway interface to be tested, and search the corresponding request field information from the full code corresponding to the target protocol according to the request data structure identifier, and search the corresponding returned field information from the full code corresponding to the target protocol according to the returned data structure identifier, and determine the test result of the gateway interface to be tested according to the request field information and the returned field information.
In summary, it can be seen that, in the embodiment provided by the present application, when a gateway interface is tested, a mapping table of all gateway interfaces in the gateway interface, a request data structure identifier and a returned data structure identifier may be constructed, then the request data structure identifier and the returned data structure identifier corresponding to a gateway interface to be tested are obtained from the mapping table, and request field information and returned field information corresponding to the request data structure identifier and the returned data structure identifier are obtained, so that the gateway interface to be tested is tested according to the request field information and the returned field information. Therefore, the corresponding structure data of the request field information and the return field information of each gateway interface in the gateway interfaces does not need to be searched manually, the efficiency of gateway testing can be improved, and meanwhile, the waste of labor cost is reduced.
The embodiments of the present application are described above from the perspective of a method for testing a gateway interface, and the embodiments of the present application are described below from the perspective of a device for testing a gateway interface.
Referring to fig. 3, in an embodiment of the present application, a gateway interface testing apparatus is provided, where the gateway interface testing apparatus 300 includes:
a first determining unit 301, configured to determine N gateway interfaces to be tested, where N is an integer greater than or equal to 1;
a first obtaining unit 302, configured to obtain a first request data structure identifier and a first return data structure identifier corresponding to a target gateway interface from a gateway interface mapping table, where the target gateway interface is any one of N gateway interfaces, the gateway interface mapping table is used to represent an association relationship between the gateway interface and the request data structure identifier and between the gateway interface and the return data structure identifier, and the gateway interface includes N gateway interfaces;
a second obtaining unit 303, configured to obtain 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;
a second determining unit 304, configured to determine test results of the N gateway interfaces according to the first request field information and the first return field information.
In one possible design, the first determining unit 301 is further configured to:
acquiring an identifier of each gateway interface in the gateway interfaces;
searching a request data structure identifier and a return data structure identifier corresponding to the identifier of each gateway interface from the full code corresponding to the target protocol;
and 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 to obtain a gateway interface mapping table.
In a possible design, the second obtaining unit 303 is specifically configured to:
importing field information of a target protocol into a protocol file to generate a full code corresponding to the target protocol;
acquiring first request field information from a full code according to the first request data structure identifier;
and acquiring first return field information from the full-size code according to the first return data structure identifier.
In one possible design, the gateway interface testing apparatus 300 further includes:
an updating unit 305, the updating unit 305 being configured to:
monitoring item code change information;
if the item code change information comprises change information aiming at the target code, obtaining the change information corresponding to the target code in the item code change information, wherein the target code is a code associated with a gateway interface in the full code;
and updating the gateway interface mapping table and the full code according to the change information corresponding to the target code in the item code change information.
In one possible design, the first and second electrodes are,
a second obtaining unit 303, configured to obtain, if the item code change information includes a change code for the target gateway interface, a second request data structure identifier and a second return data structure identifier corresponding to the target gateway interface from the updated gateway interface mapping table;
a second obtaining unit 303, further configured to obtain second request field information corresponding to the second request data structure identifier and second return field information corresponding to the second return data structure identifier;
the second determining unit 304 is further configured to determine test results of the N gateway interfaces according to the second request field information and the second return field information.
In one possible design, the second determining unit 304 is specifically configured to:
analyzing the first request field information to obtain first sending information and first receiving information which are included in the first request field information;
analyzing the first return field information to obtain second sending information and second receiving information which are included in the first return field information;
if the first sending information is matched with the second receiving information and the first receiving information is matched with the second sending information, determining that the N gateway interfaces pass the test;
and if the first sending information is not matched with the second receiving information or the first receiving information is not matched with the second sending information, determining that the N gateway interfaces do not pass the test.
In one possible design, the second determining unit 304 is further specifically configured to:
analyzing the first request field information to obtain request content included in the first request field information;
analyzing the first return field information to obtain return contents included in the first return field information;
if the request content is matched with the return content, determining that the N gateway interfaces pass the test;
and if the request content is not matched with the return content, determining that the N gateway interfaces fail to test.
The embodiment of the application also provides another gateway interface testing device, and the gateway interface testing device is deployed in a server. Referring to fig. 4, fig. 4 is a schematic structural diagram of a server 400 according to an embodiment of the present disclosure, where the server 400 may have a relatively large difference due to different configurations or performances, and 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) storing an application 442 or data 444. Wherein the memory 432 and storage medium 430 may be transient or persistent storage. The program stored on the storage medium 430 may include one or more modules (not shown), each of which may include a series of instruction operations for the server. Still further, the central processor 422 may be arranged to communicate with the storage medium 430, and execute a series of instruction operations in the storage medium 430 on the server 400.
The server 400 may further include: at least one of the one or more power supplies 426, one or more wired or wireless network interfaces 450, one or more input-output interfaces 458, and one or more operating systems 441, wherein the operating system 441 may be a Windows Server TM ,Mac OS X TM ,Unix TM ,Linux TM ,FreeBSD TM And so on operating systems.
The steps performed by the gateway interface testing apparatus in the above embodiment may be based on the server structure shown in fig. 4.
The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a computer, implements the method flow related to the gateway interface testing apparatus in any of the above method embodiments. Correspondingly, the computer can be the gateway interface testing device.
The present invention further provides a computer program or a computer program product including a computer program, which, when executed on a computer, will make the computer implement the method flows related to the gateway interface testing apparatus in any of the above method embodiments. Correspondingly, the computer may be the gateway interface testing apparatus described above.
In the embodiment corresponding to fig. 2, all or part of the above may be implemented by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product.
The computer program product includes one or more computer instructions. The procedures or functions described in accordance with the embodiments of the application are all or partially generated when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, 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, from one website site, computer, server, or data center to another website site, 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.). The computer-readable storage medium can be any available medium that a computer can store or a data storage device, such as a server, a data center, etc., that is integrated with one or more available media. The usable 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., solid State Disk (SSD)), among others.
It should be understood that the Processor referred to in this Application may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It should also be understood that the number of processors in the present application may be one or more, and may be specifically adjusted according to an actual application scenario, and this is merely an example and is not limited herein. The number of the memories in the embodiment of the present application may be one or multiple, and may be specifically adjusted according to an actual application scenario, and this is merely an exemplary illustration and is not limited.
It should be further noted that, when the gateway interface testing apparatus includes a processor (or a 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, which may be specifically adjusted according to an actual application scenario, and is not limited.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one type of logical functional division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application, or a part or all or part of the technical solution that contributes to the prior art, may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or other devices) to execute all or part of the steps of the method for testing the gateway interface described in fig. 2 of the present application.
It will be appreciated that the storage media or memories referred to in this application may comprise volatile memory or non-volatile memory, or may comprise both volatile and non-volatile memory. The non-volatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable PROM (EEPROM), or a flash Memory. Volatile Memory can be Random Access Memory (RAM), which acts as external cache Memory. By way of example, but not limitation, many forms of RAM are available, such as Static random access memory (Static RAM, SRAM), dynamic Random Access Memory (DRAM), synchronous Dynamic random access memory (Synchronous DRAM, SDRAM), double Data Rate Synchronous Dynamic random access memory (DDR SDRAM), enhanced Synchronous SDRAM (ESDRAM), synchronous link SDRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
It should be noted that the memory described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. A method for testing a gateway interface, comprising:
determining N gateway interfaces to be tested, wherein N is an integer greater than or equal to 1;
acquiring a first request data structure identifier and a first return data structure identifier corresponding to a target gateway interface from a gateway interface mapping table, wherein the target gateway interface is any one of the N gateway interfaces, the gateway interface mapping table is used for representing the association relationship among the gateway interface, the request data structure identifier and the return data structure identifier, and the gateway interface comprises the N gateway interfaces;
acquiring first request field information corresponding to the first request data structure identification and first return field information corresponding to the first return data structure identification;
and determining the test results of the N gateway interfaces according to the first request field information and the first return field information.
2. The method of testing of claim 1, further comprising:
acquiring the identifier of each gateway interface in the gateway interfaces;
searching a request data structure identifier and a return data structure identifier corresponding to the identifier of each gateway interface from the full code corresponding to the target protocol;
and 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 to obtain the gateway interface mapping table.
3. The method of claim 1, wherein the obtaining first request field information corresponding to the first request data structure identification and first return field information corresponding to the first return data structure identification comprises:
importing the field information of the target protocol into a protocol file to generate a full code corresponding to the target protocol;
acquiring the first request field information from the full-size code according to the first request data structure identification;
and acquiring the first return field information from the full-size code according to the first return data structure identifier.
4. The method of testing of claim 3, further comprising:
monitoring item code change information;
if the item code change information comprises change information aiming at a target code, obtaining the change information corresponding to the target code in the item code change information, wherein the target code is a code associated with the gateway interface in the full code;
and updating the gateway interface mapping table and the full code according to the change information corresponding to the target code in the item code change information.
5. The method of testing of claim 4, further comprising:
if the item code change information comprises a change code aiming at the target gateway interface, acquiring a second request data structure identifier and a second return data structure identifier corresponding to the target gateway interface from the updated gateway interface mapping table;
acquiring second request field information corresponding to the second request data structure identification and second return field information corresponding to the second return data structure identification;
and determining the test results of the N gateway interfaces according to the second request field information and the second return field information.
6. The method according to any one of claims 1 to 5, wherein the determining the test results of the N gateway interfaces according to the first request field information and the first return field information comprises:
analyzing the first request field information to obtain first sending information and first receiving information which are included in the first request field information;
analyzing the first return field information to obtain second sending information and second receiving information which are included in the first return field information;
if the first sending information is matched with the second receiving information and the first receiving information is matched with the second sending information, determining that the N gateway interfaces pass the test;
and if the first sending information is not matched with the second receiving information, or the first receiving information is not matched with the second sending information, determining that the N gateway interfaces do not pass the test.
7. The method according to any one of claims 1 to 5, wherein the determining the test results of the N gateway interfaces to be tested according to the first request field information and the first return field information comprises:
analyzing the first request field information to obtain request content included in the first request field information;
analyzing the first return field information to obtain return contents included in the first return field information;
if the request content is matched with the return content, determining that the N gateway interfaces pass the test;
and if the requested content is not matched with the returned content, determining that the N gateway interfaces fail to test.
8. A gateway interface testing apparatus, comprising:
the system comprises a first determining unit, a second determining unit and a third determining unit, wherein the first determining unit is used for determining N gateway interfaces to be tested, and N is an integer greater than or equal to 1;
a first obtaining unit, configured to obtain a first request data structure identifier and a first return data structure identifier corresponding to a target gateway interface from a gateway interface mapping table, where the target gateway interface is any one of the N gateway interfaces, the gateway interface mapping table is used to represent an association relationship between the gateway interface and the request data structure identifier and between the gateway interface and the return data structure identifier, and the gateway interface includes the N gateway interfaces;
a second obtaining unit, configured to obtain 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;
and a second determining unit, configured to determine test results of the N gateway interfaces according to the first request field information and the first return field information.
9. A computer device, comprising: a memory, a processor, and a bus system;
wherein the memory is used for storing programs;
the processor for executing the program in the memory, the processor for performing the test method of any one of claims 1 to 7 according to instructions in program code;
the bus system is used for connecting the memory and the processor so as to enable the memory and the processor to communicate.
10. A computer storage medium characterized in that it comprises instructions which, when run on a computer, cause the computer to perform the testing method according to any one of claims 1-7.
CN202110592732.4A 2021-05-28 2021-05-28 Gateway interface testing method and device and readable storage medium Pending CN115408260A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110592732.4A CN115408260A (en) 2021-05-28 2021-05-28 Gateway interface testing method and device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110592732.4A CN115408260A (en) 2021-05-28 2021-05-28 Gateway interface testing method and device and readable storage medium

Publications (1)

Publication Number Publication Date
CN115408260A true CN115408260A (en) 2022-11-29

Family

ID=84156577

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110592732.4A Pending CN115408260A (en) 2021-05-28 2021-05-28 Gateway interface testing method and device and readable storage medium

Country Status (1)

Country Link
CN (1) CN115408260A (en)

Similar Documents

Publication Publication Date Title
US10769228B2 (en) Systems and methods for web analytics testing and web development
CN108804618B (en) Database configuration method, device, computer equipment and storage medium
US9444899B2 (en) Use of internet information services logging to collect user information in an asynchronous manner
US9639444B2 (en) Architecture for end-to-end testing of long-running, multi-stage asynchronous data processing services
CN105872083A (en) Method and system supporting server access by different types of clients as well as server
CN110365724B (en) Task processing method and device and electronic equipment
US9558307B1 (en) System and method for providing a scalable server-implemented regression query environment for remote testing and analysis of a chip-design model
US10025562B2 (en) Collaborative development of a web-based service
Rattanapoka et al. An MQTT-based IoT cloud platform with flow design by Node-RED
CN113726770A (en) Data interception method and device, computer equipment and storage medium
Potti On the design of web services: SOAP vs. REST
CN116700778B (en) Interface difference analysis method, device, storage medium and apparatus
CN115705190A (en) Method and device for determining dependence degree
CN113407511A (en) Log aggregation method, log aggregation equipment and computer program product
US20230118838A1 (en) Advanced agent instrumentation for opentelemetry implementations
CN111488386A (en) Data query method and device
CN107347024B (en) Method, equipment and system for storing operation log
CN115408260A (en) Gateway interface testing method and device and readable storage medium
CN115455006A (en) Data processing method, data processing device, electronic device, and storage medium
CN112231377A (en) Data mapping method, system, device, server and storage medium
CN114139039B (en) Service stability determination method, device, equipment and storage medium
CN117112451B (en) Test method, test device, electronic equipment and computer readable storage medium
Jakóbczyk et al. Cloud-Native Architecture
CN117632445B (en) Request processing method and device, task execution method and device
Suciu et al. Cloud and big data acceleration platform for innovation in environmental industry

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination