CN115858345A - Application service module verification method and device, electronic equipment and storage medium - Google Patents

Application service module verification method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115858345A
CN115858345A CN202211475870.5A CN202211475870A CN115858345A CN 115858345 A CN115858345 A CN 115858345A CN 202211475870 A CN202211475870 A CN 202211475870A CN 115858345 A CN115858345 A CN 115858345A
Authority
CN
China
Prior art keywords
request
response information
service module
traffic data
application service
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
CN202211475870.5A
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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology 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 Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202211475870.5A priority Critical patent/CN115858345A/en
Publication of CN115858345A publication Critical patent/CN115858345A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The disclosure provides a verification method and device of an application service module, electronic equipment and a storage medium, and relates to the technical field of computers, in particular to the field of application development. The specific implementation scheme is as follows: acquiring a first application layer traffic data set of a first application service module; wherein the first application layer traffic data set comprises a plurality of traffic data, each of the plurality of traffic data comprising request information and response information; determining a contract document corresponding to the first application service module based on the first application layer traffic data set, wherein the contract document comprises a request information structure and a response information structure; and checking the second application service module based on the contract document. By adopting the embodiment of the disclosure, the defects of the application service module can be timely discovered and corrected, the online problem is avoided, and the cost is low.

Description

Application service module checking method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technology, and more particularly, to the field of application development.
Background
Micro-service software architecture is often adopted in the development mode of modern software systems. The micro service software system is based on small Application service modules with single service function, and is combined into a complex large Application program in a modularized mode, wherein language-independent Application Programming Interfaces (APIs) are used for communication among the Application service modules.
The contract (API Doc) is a specific, characterized form of inter-microservice interaction API. The application service module developed or changed by the service provider needs to realize the functional logic corresponding to the contract. However, in the practical process of a specific software engineering, due to the lack of a historical contract management platform, the lack of standardization of a research and development process, the inadequate execution of a research and development standard, the limitation of a provider driving mode, and the like, the problem of contract loss or difficult recall occurs, so that the defects existing in the application service module cannot be found in an online environment, and further online problems are caused.
Disclosure of Invention
The disclosure provides a verification method and device of an application service module, electronic equipment and a storage medium.
According to an aspect of the present disclosure, there is provided a method for verifying an application service module, including:
acquiring a first application layer traffic data set of a first application service module; wherein the first application layer traffic data set comprises a plurality of traffic data, each of the plurality of traffic data comprising request information and response information;
determining a contract document corresponding to the first application service module based on the first application layer traffic data set, wherein the contract document comprises a request information structure and a response information structure;
and checking the second application service module based on the contract document.
According to another aspect of the present disclosure, there is provided a verification apparatus for an application service module, including:
the data acquisition module is used for acquiring a first application layer traffic data set of the first application service module; wherein the first application layer traffic data set comprises a plurality of traffic data, each of the plurality of traffic data comprising request information and response information;
a contract generation module, configured to determine, based on the first application layer traffic data set, a contract document corresponding to the first application service module, where the contract document includes a request information structure and a response information structure;
and the change recall module is used for verifying the second application service module based on the contract document.
According to another aspect of the present disclosure, there is provided an electronic device including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to cause the at least one processor to perform a method according to any one of the embodiments of the present disclosure.
According to another aspect of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon computer instructions for causing a computer to perform a method according to any one of the embodiments of the present disclosure.
According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program which, when executed by a processor, implements a method according to any of the embodiments of the present disclosure.
According to the technical scheme of the embodiment of the disclosure, the contract document is generated by utilizing the request information and the response information of each flow data in the application flow data set of the first application service module, so that the second application service module is verified based on the generated contract document. Defects of the application service module can be timely found and corrected through verification, and online problems are avoided. And the verification method does not need to recall the historical contract document, and the realization cost is lower.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
FIG. 1 is a flow diagram of a verification method of an application service module according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of information flow in an example application of the present disclosure;
FIG. 3 is a schematic diagram of a sample example of application layer traffic data in one example application of the present disclosure;
FIG. 4 is a schematic block diagram of a validation mechanism of an application service module of an embodiment of the present disclosure;
FIG. 5 is a schematic block diagram of a verification apparatus of an application service module of another embodiment of the present disclosure;
FIG. 6 is a schematic block diagram of a verification apparatus of an application service module of yet another embodiment of the present disclosure;
FIG. 7 is a schematic block diagram of a verification apparatus of an application service module of yet another embodiment of the present disclosure;
fig. 8 is a block diagram of an electronic device for implementing a verification method of an application service module according to an embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a flowchart illustrating a verification method for an application service module according to an embodiment of the disclosure. The method can be applied to a verification device of an application service module, and the device can be deployed in electronic equipment such as terminal equipment or a server, but is not limited to this. As shown in fig. 1, the method for verifying an application module includes the following steps S110 to S130.
Step S110, acquiring a first application layer traffic data set of a first application service module; the first application layer traffic data set comprises a plurality of traffic data, and each of the plurality of traffic data comprises request information and response information.
Illustratively, the first application service module may comprise an application service module that has been run in an online environment. Based on this, the application layer traffic data of the application service module can be acquired, and thus a first application layer traffic data set is obtained based on the acquired traffic data.
Illustratively, the first application layer traffic data set may be denoted as a traffic sample set D', in which the ith traffic data D i The data is the data of the user terminal and the first application service module in one request. Flow data d i May include request information q i And response information r i And may also include protocol information p i . Wherein the request information q i And sending the information when the user side initiates the interactive request to the first application service module. Response information r i Serving the first application module in response to the request information q i And returning the information to the user side.
Illustratively, the information q is requested i Can include a request header, request query parameters and a request body; response information r i A response head and a response body may be included.
Step S120, determining a contract document corresponding to the first application service module based on the first application layer traffic data set, wherein the contract document comprises a request information structure and a response information structure;
illustratively, the request information structure may be used to describe the request information q i The data of (2) constitutes a structure. For example, the request information structure may include request information q i Field name of each field in (1), description information, the domain in which the field is located, whether the field is required, the data type of the field value, options of the field value, etc. Alternatively, the description information of a field may be used to describe whether the field is a consumer identification.
For example, a request information structure may contain the following information: the name of a first field in the request information is ak; this field is the consumer identification; the data type of the field value is string; optional items for field values include Consumer A, consumer B.
Illustratively, the response information structure may be used to describe the response information r i The data of (2) constitutes a structure. For example, the response information structure may include response information r i Field name of each field in (1), description information, the domain in which the field is located, whether the field is required, the data type of the field value, etc.
For example, a response message structure may contain the following information: the name of a second field in the response information is msg, and the data type of the field value is string; the name of the third field in the response message is code, and the data type of the field value is int.
Illustratively, the response information structure may be characterized by a JSON Schema (JavaScript Object Notation Schema). The JSON Schema is a tool for validating the JSON data format and defines a set of vocabulary and rules for defining JSON metadata, which is also expressed in the form of JSON data. The JSON metadata defines specifications that JSON data needs to satisfy, including members, structures, types, constraints, and the like, and in the embodiment of the present disclosure, the specifications refer to fields in traffic data, fields where the fields are located, data types, and other description information.
In an alternative implementation manner, the request information structure may be determined based on request information of each flow data in the first application layer flow data set; and determining the response information structure based on the response information of each flow data in the first application layer flow data set. By assembling the request information structure and the response information structure, a contract document can be obtained, and the contract document is used for explaining the specific representation form of the information interacted between the user side and the application service module.
And step S130, verifying the second application service module based on the contract document.
Illustratively, the second application service module may include an application service module that is not running in an online environment, for example, the second application service module is an application service module in a pre-online environment after module change.
Illustratively, the second application service module may be changed based on the first application service module. For example, the second application service module is an updated version of the first application service module. Based on this, the second application service module should satisfy the same contract as the first application module. Accordingly, the step S130 may specifically include: and checking whether the second application service module meets the contract document. If so, it may be determined that the second application service module passes the verification. If not, it may be determined that the second application service module failed the verification.
In the verification method for the application service module provided in the foregoing embodiment, the contract document is generated by using the application traffic data of the first application service module in combination with the request information and the response information of each traffic data, so that the second application service module is verified based on the generated contract document. The defects of the application service module can be timely found and corrected through verification, and the online problem is avoided. And the verification method does not need to recall the historical contract document, and the realization cost is lower.
Optionally, in some exemplary embodiments, the obtaining of the first application layer traffic data set of the first application service module in step S110 may include: acquiring a second application layer traffic data set D by adopting an on-line drainage or gateway drainage mode; preprocessing the second application layer flow data set D to obtain a first application layer flow data set D '
Wherein the second application layer traffic data set D includes the collected original application layer traffic data. Through the mode of online drainage or gateway drainage, the full amount of original application layer flow data can be collected, and the data volume in the second application layer flow data set D is improved, so that the accuracy of contract documents is improved, and the accuracy of application service verification is improved.
In the above embodiment, the preprocessing performed on the second application layer traffic data set D may include data decoding, normalization, noise elimination, consumer identification, and the like. By preprocessing, the first application layer traffic data set D can be promoted ' The quality of the medium data, so that the accuracy of the contract document and the accuracy of the application service check are improved.
Optionally, in some exemplary embodiments, the step S120 of determining, based on the first application layer traffic data set, a contract document corresponding to the first application service module includes:
obtaining a plurality of data subsets of the first application layer traffic data set based on the request action corresponding to each traffic data in the first application layer traffic data set, wherein the data subsets correspond to the request actions respectively;
for each request action in a plurality of request actions, obtaining a request information structure and a response information structure corresponding to the request action based on request information and response information in each flow data in a data subset corresponding to the request action;
and obtaining a contract document based on the contract metadata and the request information structure and the response information structure corresponding to each request action.
Alternatively, a request action in an embodiment of the present disclosure may refer to a request action determined based on a request path and an action type. That is, a requested action refers to a particular type of action on a particular path. For example, a request action with an action type POST on path a and a request action with an action type POST on path B may be considered as different request actions.
In the above embodiment, the first application layer traffic data set may be divided into a plurality of subsets based on the request action corresponding to each traffic data set. Specifically, the traffic data corresponding to different request actions may be divided into different subsets, and the traffic data corresponding to the same request action may be divided into the same subset.
For example, for a first application layer traffic data set D', first, a plurality of sets D "are divided according to different request paths m . Then for each set d ″) m According to different action types, a plurality of sets d ″, are marked off mn . Where m is used to distinguish between different request paths and the subscript n is used to distinguish between differencesAn action is requested.
Alternatively, the plurality of subsets obtained by division may be used as the plurality of data subsets for constructing the request information structure and the response information structure.
Optionally, data sampling may be performed on the plurality of subsets obtained by the division, so as to obtain a plurality of data subsets used for constructing the request information structure and the response information structure. The data sampling process may include: and eliminating error data and redundant data from the subsets obtained by division, and sampling in each subset in a non-return random sampling mode to obtain data subsets for constructing a request information structure and a response information structure.
Optionally, in the foregoing embodiment, a request information structure corresponding to a request action may be obtained based on request information in each traffic data in a data subset corresponding to the request action; and based on the response information in each flow data in the data subset corresponding to the request action, obtaining a response information structure corresponding to the request action.
Optionally, the contract metadata may include information such as organization schema of the contract document, functional description of the application service module, module interface protocol type, document version of the generated contract, description information, tag, protocol type, etc.
According to the embodiment, for different request actions, corresponding request information structures and response information structures are obtained respectively, and contract documents are obtained by combining contract metadata. Therefore, the information granularity in the contract document is finer, the defect which is not consistent with the contract document and exists in the second application service module can be found in time through verification, and the defect finding and correcting efficiency is improved.
Optionally, in some exemplary embodiments, the response information structure may further include a response information structure related to the consumer identifier, and a response information structure unrelated to the consumer identifier.
In one example, obtaining a request information structure and a response information structure corresponding to the request action based on request information and response information in each traffic data in a data subset corresponding to the request action includes:
determining a plurality of flow data corresponding to the first consumer identification in the data subset corresponding to the request action;
and obtaining a response information structure corresponding to the request action and related to the first consumer identification based on the response information of each flow data in the plurality of flow data corresponding to the first consumer identification.
Illustratively, the first consumer identification may be any consumer identification. In practical applications, a plurality of consumer identifications appearing in the first application layer traffic data set D' may be all used as the first consumer identification. For example, for any consumer identifier appearing in D', a plurality of corresponding traffic data are extracted, so as to obtain a response information structure related to the consumer identifier based on response information in the plurality of traffic data.
In practical application, the data subset corresponding to the request action is further divided into a plurality of subsets, so that a plurality of flow data corresponding to any customer identification can be extracted. For example, set d "corresponding to a particular requested action mn The set d "may be set according to the customer id of each flow data therein mn Division into subsets d ″ mnc Then any subset d ″ mnc May be used to derive a response information structure associated with its corresponding consumer identification. Where index m is used to distinguish between different request paths, index n is used to distinguish between different action types, and index c is used to distinguish between different consumers.
According to the embodiment, the response information structure corresponding to the request action comprises the response information structure related to the consumer identifier, so that when verification is performed, for the request information containing the consumer identifier, the corresponding response information structure can be retrieved based on the consumer identifier, and verification is performed on the second application service based on the more targeted response information structure, so that the verification accuracy is improved.
In one example, obtaining a request information structure and a response information structure corresponding to the request action based on the request information and the response information in each traffic data in the data subset corresponding to the request action includes:
and obtaining a response information structure which is irrelevant to the consumer identification and corresponds to the request action based on the response information of each traffic data in the data subset corresponding to the request action.
That is, the response information structure corresponding to the request action includes a response information structure that is independent of the consumer identification, which may be derived based on the response information in the overall traffic data corresponding to the request action.
According to the example, when verification is performed, for request information not including the consumer identifier, verification can be performed on the second application service based on a response information structure unrelated to the consumer identifier, so that comprehensiveness of the verification can be improved.
Optionally, in some exemplary embodiments, the step S130 of verifying the second application service module based on the contract document may include:
triggering a second application service module to operate based on the playback request information which accords with the request information structure in the contract document to obtain playback response information corresponding to the playback request information;
and in response to the structural matching of the playback response information and the response information in the contract document, determining that the second application service module passes the verification.
Illustratively, the playback request information may be constructed according to a request information structure in the contract document, or may be sampled from the first application layer traffic data set.
For example, based on the request action corresponding to the playback request information, a corresponding response information structure may be retrieved from the contract document, so as to match the playback response information obtained by running the second application service module with the retrieved response information structure in the contract document, and determine whether the second application service module passes the verification according to the matching result.
Illustratively, if the playback response information and the response information structure in the contract document do not match, it may be determined that the second application service module fails the verification. In practical application, the second application service module which fails to be checked can be corrected.
In the above embodiment, the second application service module is enabled to respond to the playback request information to obtain the playback response information, so that the playback response information is used for matching with the response information structure. The matching result can indicate whether the second application service module responds and outputs according to the contract document, so that whether the second application service module passes the verification or not is determined according to the matching result, and the verification accuracy can be improved.
Optionally, in some exemplary embodiments, triggering the second application service module to run based on the playback request information conforming to the request information structure in the contract document, and obtaining playback response information corresponding to the playback request information includes:
sampling in a first application layer flow data set to obtain playback flow data;
and triggering the second application service module to operate based on the playback request information in the playback flow data to obtain playback response information corresponding to the playback request information.
For example, a plurality of traffic data may be sampled in the first application layer traffic data set according to a plurality of request actions corresponding to each request information structure in the contract document. And taking each flow data obtained by sampling as playback flow data, triggering the second application service module to operate and acquiring response information to check based on each flow data obtained by sampling, so as to check each request action.
In this embodiment, the playback request information is sampled in the first application layer traffic data set. Therefore, the obtaining efficiency of the playback request information can be improved, and the verification efficiency of the second application service module is improved.
Optionally, in some exemplary embodiments, in response to the playback response information and the response information structure in the contract document matching, determining that the second application service module passes the verification may include: and under the condition that the playback request information comprises the second consumer identification, if the playback response information is matched with a response information structure related to the second consumer identification in the contract document, determining that the second application service module passes the verification.
That is, for request information containing a consumer identification, a corresponding response information structure may be retrieved based on the consumer identification, such that the playback response information is matched with the consumer identification corresponding response information structure.
For example, in the case that the contract document includes a plurality of response information structures corresponding to a plurality of request actions, the corresponding response information structures may be retrieved according to the request actions and the consumer identification. For example, the response information structure corresponding to the request action is retrieved from the contract document according to the request action, and then the response information structure corresponding to the consumer identification is determined in the response information structure corresponding to the request action according to the consumer identification.
According to the embodiment, aiming at the problem that different consumers have different response information of the same request due to different business requirements, the pertinence of verification can be improved by matching the response information structure corresponding to the consumer identification with the playback response information, and therefore the accuracy of verification is improved.
Optionally, in some exemplary embodiments, in response to the structural matching between the playback response information and the response information in the contract document, determining that the second application service module passes the verification, may further include: and under the condition that the playback request information does not include the consumer identification, if the playback response information is matched with a response information structure irrelevant to the consumer identification in the contract document, determining that the second application service module passes the verification.
That is, for request information that does not contain a consumer identification, matching may be performed using a response information structure that is unrelated to the consumer identification. According to the embodiment, various request information can be checked, and the comprehensiveness of checking is improved.
In order to better understand the technical solution of the embodiments of the present disclosure, an application example is provided below based on the description of the above embodiments.
Fig. 2 shows a schematic diagram of the information flow in this application example. As shown in fig. 2, the implementation process of the verification method of the application service module includes 2 stages, which are a contract generation stage and a change recall stage.
In the contract generation phase, the traffic collection module 210 collects traffic of the online environment where the first application service module is located by using an online drainage or gateway drainage method. The data preprocessing module 220 preprocesses and samples the acquired data to obtain a first application layer traffic data set; the preprocessing comprises normal return filtering, consumer identification, data decoding, normalization and the like. Finally, the contract generation module 230 generates and assembles a contract document by using the contract generation component, and hosts the contract document to the public management platform 240; the contract generation component comprises a contract metadata generator, a request parameter generator, a consumer level response result JSON Schema generator, a contract assembler and the like.
In the change recall phase, the change recall module 250 samples the first application layer traffic data set acquired and preprocessed in the contract generation phase, and then performs traffic playback in the pre-online environment of the change module (i.e., the second application service module) based on the sampled traffic data. Finally, the mode verification is carried out on the response information generated by the playback by combining the contract in the contract public management platform 240, for example, the verification is carried out on the JSON Schema by using the consumer-level response result. If the verification is passed, the second application service module is confirmed to be compatible change relative to the first application service module, and online can be carried out. And if the verification fails, determining that the second application service module is incompatible change relative to the first application service module, and determining an influence surface and manually intervening and correcting.
The technical details in fig. 2 are described in detail below.
1. Contract generation phase
1. Flow collection
For the online environment of the application service module, acquiring application layer user flow data by using online drainage, gateway drainage and other modes, and constructing a second application layer flow data set D, wherein each flow data D i Containing protocol information p i Request information q i And response information r i Three parts; each request information q i The method comprises three parts of a request head, a request query parameter and a request body. Fig. 3 is a diagram of a sample example of HTTP (hypertext Transfer Protocol) application layer traffic data for a set of online environments. As shown in fig. 3, one piece of traffic data includes information such as an action and a path corresponding to the traffic data, a request header, an inquiry parameter, and a request body in the request information, and a response header, a response body, and the like in the response information.
2. Data pre-processing
2.1 data decoding and normalization
The original application layer traffic data has problems of data encoding, duplication, deletion, and the like, and therefore, the data in the second application layer traffic data set D needs to be decoded and normalized. The decoding and normalization method comprises the steps of decoding a request body and a response body respectively according to Content-Type and Charset information in a request header and a response header; and standardizing the contents of the request head, the request query parameter, the request body, the response head and the response body according to a protocol standard.
2.2 Normal response Filtering
The problems of more traffic, high attack traffic ratio and the like exist in the online environment, and noise data need to be removed to obtain an expected response so as to improve the accuracy of generating a contract. The filtering method comprises the following steps: first, traffic in which the response result is in an illegal format, such as a no-response result, a response format that is not in a predetermined format (e.g., JSON format), a response result content length that is too short, and the like, is rejected. And secondly, filtering out the non-compliant user traffic according to the user-defined response filtering rule.
By way of example, one example of a user-defined response filtering rule may be represented as follows:
Figure BDA0003959845210000111
where uri represents a request path; method represents a request action. The success _ rule represents a user-defined response filtering rule, including a response keyword key, a value, and a comparator operation. Specifically, the example represents response information with a request path of/v 2 and a request action of POST, and if a code field exists in a response body and the corresponding value of the code field is equal to 0, the response information is normal response information to be reserved. Wherein, the optional value of operation is =, ≠ < >, < or equal to or more than.
2.3 Consumer identification recognition
Aiming at the problem that under the same request path and request action in an interface contract, different consumers have different response information of the same request due to different business needs, consumer identification in the request information needs to be extracted, and a foundation is laid for subsequently determining a response information structure (namely, response information JSON Schema) related to the consumer identification.
The consumer identification method comprises the following steps: and identifying the consumer identification in the flow request information according to the user-defined consumer site rule. The consumer site rule may include two parts, namely a request keyword and a domain where the keyword is located. By way of example, one example of a consumer site rule may be represented as follows:
Figure BDA0003959845210000121
where uri represents a request path; method represents a request action. The consumer _ rule represents a user-defined consumer location rule, including a request keyword key and a domain scope in which the keyword is located. The selectable values of Scope are a request header (header), a query parameter (query) and a request body (body). The example shows that for the request information with the request path being/v 2 and the request action being POST, if an ak field exists in the request query parameter (query), the value of the ak field is the consumer identifier.
3. Contract generation
3.1 data sampling
Exemplarily, data sampling is carried out on a first application layer traffic data set D' obtained through preprocessing, and a contract is constructed to generate a sample data set D "; wherein the contract generation sample data set D' comprises different requests under different request pathsApplication layer user traffic of actions d ″) mn (ii) a The index m is used to distinguish between different request paths and the index n is used to distinguish between different request actions. The data sampling method for the first application layer traffic data set D' specifically includes:
step A1: for D', firstly, dividing according to different request paths to form D ″) m Then, according to different request actions, dividing the operation into d ″) mn Finally, the materials are divided into d ″' according to different consumers mnc (ii) a The subscript m is used for distinguishing different request paths, the subscript n is used for distinguishing different request actions, and the subscript c is used for distinguishing different consumers;
step A2: determining a contract generation sample unit quantity threshold value t;
step A3: for d ″) mnc Firstly eliminating error redundant data, then preserving samples according to random sampling without putting back, and finally d ″ mnc Is t.
3.2 contract metadata Generation
And for the contract generation sample data set D', generating information such as a contract document version, description information, a label, a protocol type and the like according to an organization mode of a contract document, the function description of an application service module and the module interface protocol type by using a contract metadata generator. For example, the contract metadata of one contract document S may be used to indicate that the contract document S is organized in Swagger version 2.0 mode, and contains interface contract information of the contract generation example module, and the interface protocol type is HTTP.
3.3 request parameter Generation
Generation sample set d' of different request actions for different request paths mn The request information structure is generated using a request parameter generator. The request information structure may include a request header, request query parameters, request parameter information in the request body. Wherein the request parameter information includes field name, description information (which can be used to describe whether the field is related to the consumer), field domain, whether the field is necessary, data type (or JSON Schema) of the field value, etc.
For example, a request message structure with a request path of/v 2 and a request action of POST may contain the following information: the field name of one field in the request information is ak, the field is the request query information, the data type of the field value is string, the description information is the consumer, and the selectable items of the consumer identification comprise a consumer A, a consumer B and the like; the field name of another field in the request information is body, the field is the request body, the description information is the request body, the object mode is the Draft-04 version mode, and the attribute information includes: the data type is field b of integer.
3.4 Generation of response information JSON Schema related to consumer identification
For sample set d ″) mn The response information JSON Schema generator is used to generate response information JSON Schema (which may also be referred to as default response information JSON Schema) irrelevant to the consumer identification.
For pair d according to consumer identification mn Each sample set d obtained by dividing mnc And respectively generating response information JSON Schema related to the consumer identification by using a response result JSON Schema generator.
For example, the response information structure with the request path being/v 2 and the request action being POST includes default response information JSON Schema and two sets of response information JSON Schema related to the consumer identification. The default response information JSON Schema comprises the following information: the object mode of the response information is a Draft-04 version mode, and the attribute information comprises: the data type is string field msg, the field type is int field code, and the data type is int or bool field data. Two groups of response information JSON Schema related to the consumer identification are respectively response information JSON Schema of a consumer A and response information JSON Schema of a consumer B.
3.5 contract Assembly
Combining the generated request information structure and response information JSON Schema into mode information S of different request actions under different request paths by using a contract assembler mn (ii) a The response information JSON Schema comprises default response information JSON Schema irrelevant to consumer identification and response information relevant to consumer identificationAnd (5) the JSON Schema.
For contract metadata and schema information S mn And combining the document S into a final contract document S by using a contract assembler.
2. Change recall phase
For a second application service module in the pre-online environment after program change, firstly, a first application layer traffic data set D is collected ' Sampling to obtain a playback data set, then carrying out flow playback to obtain response information, finally carrying out JSON Schema verification on the response information by using a contract document, and if the verification is passed, carrying out compatibility change; otherwise, the online process is terminated for the non-compatibility change, and manual intervention correction is carried out. The process of carrying out flow playback and response information JSON Schema verification comprises the following steps:
step B1: inquiring to obtain corresponding contract document according to module where program is changed
Figure BDA0003959845210000141
And step B2: according to playback flow data in the playback data set
Figure BDA0003959845210000142
Request path and request action of (2) retrieve the contract document>
Figure BDA0003959845210000143
Obtaining a request information structure of the flow data, analyzing to obtain a parameter name corresponding to the consumer identifier, and further obtaining a consumer identifier value;
and step B3: according to playback flow
Figure BDA0003959845210000144
Request path and request action of (2) retrieve the contract document>
Figure BDA0003959845210000145
Obtaining response information JSON Schema; the response information JSON Schema comprises default response information JSON Schema irrelevant to consumer identification and response information JS relevant to consumer identificationON Schema;
And step B4: if the flow data is played back
Figure BDA0003959845210000151
And if the consumer identifier exists, checking the response information JSON Schema related to the consumer identifier, otherwise, checking by using default response information JSON Schema.
It can be seen that according to the verification method of the application service module provided by the embodiment of the present disclosure, a contract document is generated by using the application traffic data of the first application service module in combination with the request information and the response information of each traffic data, so that the second application service module is verified based on the generated contract document. Defects of the application service module can be timely found and corrected through verification, and online problems are avoided. And the verification method does not need to recall the historical contract document, and has the advantage of low cost.
According to an embodiment of the present disclosure, the present disclosure further provides a verification apparatus for an application service module, which is used for implementing the above method. Fig. 4 shows a schematic block diagram of a verification apparatus for an application service module provided in an embodiment of the present disclosure.
A data obtaining module 410, configured to obtain a first application layer traffic data set of a first application service module; the first application layer traffic data set comprises a plurality of traffic data, and each traffic data in the plurality of traffic data comprises request information and response information;
the contract generation module 420 is configured to determine a contract document corresponding to the first application service module based on the first application layer traffic data set, where the contract document includes a request information structure and a response information structure;
and the change recall module 430 is used for checking the second application service module based on the contract document.
In some embodiments, based on fig. 4, as shown in fig. 5, the data obtaining module 410 includes:
a traffic collection unit 510, configured to obtain a second application layer traffic data set by using an on-line drainage or gateway drainage manner;
the data preprocessing unit 520 is configured to preprocess the second application layer traffic data set to obtain the first application layer traffic data set.
In some embodiments, based on fig. 4, as shown in fig. 6, the contract generating module 420 includes:
a data dividing unit 610, configured to obtain a plurality of data subsets of a first application layer traffic data set based on request actions corresponding to each traffic data in the first application layer traffic data set, where the plurality of data subsets correspond to the plurality of request actions, respectively;
an information structure generating unit 620, configured to, for each request action of the multiple request actions, obtain a request information structure and a response information structure corresponding to the request action based on request information and response information in each traffic data in the data subset corresponding to the request action;
and a contract assembling unit 630, configured to obtain a contract document based on the contract metadata and the request information structure and the response information structure corresponding to each request action.
In some embodiments, the information structure generating unit 620 is specifically configured to:
determining a plurality of flow data corresponding to the first consumer identification in the data subset corresponding to the request action;
and obtaining a response information structure corresponding to the request action and related to the first consumer identification based on the response information of each flow data in the plurality of flow data corresponding to the first consumer identification.
In some embodiments, the information structure generating unit 620 is specifically configured to:
and obtaining a response information structure which is irrelevant to the consumer identification and corresponds to the request action based on the response information of each traffic data in the data subset corresponding to the request action.
In some embodiments, based on fig. 4, as shown in fig. 7, the change recall module 430 includes:
the flow playback unit 710 is configured to trigger the second application service module to run based on the playback request information conforming to the request information structure in the contract document, so as to obtain playback response information corresponding to the playback request information;
and a verification confirming unit 720, configured to determine that the second application service module passes the verification in response to a structural match between the playback response information and the response information in the contract document.
In some embodiments, the traffic playback unit 710 is specifically configured to:
sampling in a first application layer flow data set to obtain playback flow data;
and triggering the second application service module to operate based on the playback request information in the playback flow data to obtain playback response information corresponding to the playback request information.
In some embodiments, the verification confirming unit 720 is specifically configured to:
and under the condition that the playback request information comprises the second consumer identification, if the playback response information is matched with a response information structure related to the second consumer identification in the contract document, determining that the second application service module passes the verification.
In some embodiments, the verification confirming unit 720 is specifically configured to:
and under the condition that the playback request information does not include the consumer identification, if the playback response information is matched with a response information structure irrelevant to the consumer identification in the contract document, determining that the second application service module passes the verification.
For a description of specific functions and examples of each module and sub-module of the apparatus in the embodiment of the present disclosure, reference may be made to the description of corresponding steps in the foregoing method embodiments, and details are not repeated here.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the personal information of the related user all accord with the regulations of related laws and regulations, and do not violate the good customs of the public order.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
FIG. 8 illustrates a schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic devices may also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 8, the apparatus 800 includes a computing unit 801 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 802 or a computer program loaded from a storage unit 808 into a Random Access Memory (RAM) 803. In the RAM803, various programs and data required for the operation of the device 800 can also be stored. The calculation unit 801, the ROM802, and the RAM803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
A number of components in the device 800 are connected to the I/O interface 805, including: an input unit 806, such as a keyboard, a mouse, or the like; an output unit 807 such as various types of displays, speakers, and the like; a storage unit 808, such as a magnetic disk, optical disk, or the like; and a communication unit 809 such as a network card, modem, wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
Computing unit 801 may be a variety of general and/or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and the like. The calculation unit 801 executes the respective methods and processes described above, such as the verification method of the application service module. For example, in some embodiments, the verification method of the application service module may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and/or installed onto device 800 via ROM802 and/or communications unit 809. When the computer program is loaded into the RAM803 and executed by the computing unit 801, one or more steps of the verification method of the application service module described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform the verification method of the application service module by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server with a combined blockchain.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel or sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the principle of the present disclosure should be included in the protection scope of the present disclosure.

Claims (16)

1. A verification method of an application service module comprises the following steps:
acquiring a first application layer traffic data set of a first application service module; wherein the first application layer traffic data set comprises a plurality of traffic data, each of the plurality of traffic data comprising request information and response information;
determining a contract document corresponding to the first application service module based on the first application layer traffic data set, wherein the contract document comprises a request information structure and a response information structure;
and checking the second application service module based on the contract document.
2. The method of claim 1, wherein the obtaining a first application layer traffic data set of a first application service module comprises:
acquiring a second application layer traffic data set by adopting an on-line drainage or gateway drainage mode;
and preprocessing the second application layer traffic data set to obtain the first application layer traffic data set.
3. The method of claim 2, wherein the determining a contract document corresponding to the first application service module based on the first application layer traffic data set comprises:
obtaining a plurality of data subsets of the first application layer traffic data set based on request actions corresponding to each traffic data in the first application layer traffic data set, wherein the data subsets correspond to the request actions respectively;
for each request action in the plurality of request actions, obtaining a request information structure and a response information structure corresponding to the request action based on request information and response information in each traffic data in a data subset corresponding to the request action;
and obtaining the contract document based on the contract metadata and the request information structure and the response information structure corresponding to each request action.
4. The method according to claim 3, wherein the obtaining a request information structure and a response information structure corresponding to the request action based on the request information and the response information in each traffic data in the data subset corresponding to the request action comprises:
determining a plurality of flow data corresponding to the first consumer identification in the data subset corresponding to the request action;
and obtaining a response information structure corresponding to the request action and related to the first consumer identification based on the response information of each flow data in the plurality of flow data corresponding to the first consumer identification.
5. The method according to claim 3 or 4, wherein the obtaining of the request information structure and the response information structure corresponding to the request action based on the request information and the response information in each traffic data in the data subset corresponding to the request action comprises:
and obtaining a response information structure which is irrelevant to the consumer identification and corresponds to the request action based on the response information of each traffic data in the data subset corresponding to the request action.
6. The method of any of claims 1-5, wherein the verifying a second application service module based on the contract document comprises:
triggering the second application service module to operate based on the playback request information which accords with the request information structure in the contract document, and obtaining playback response information corresponding to the playback request information;
and in response to the structural matching of the playback response information and the response information in the contract document, determining that the second application service module passes the verification.
7. The method of claim 6, wherein the triggering the second application service module to run based on the playback request information conforming to the request information structure in the contract document to obtain the playback response information corresponding to the playback request information comprises:
sampling in the first application layer flow data set to obtain playback flow data;
and triggering the second application service module to operate based on the playback request information in the playback flow data to obtain playback response information corresponding to the playback request information.
8. The method of claim 6 or 7, wherein the determining that the second application service module is verified in response to the playback response information and the response information structure in the contract document matching comprises:
and under the condition that the playback request information comprises a second consumer identifier, if the playback response information is matched with a response information structure related to the second consumer identifier in the contract document, determining that the second application service module passes verification.
9. The method of any of claims 6-8, wherein the determining that the second application service module is verified in response to the playback response information and the response information structure in the contract document comprises:
and under the condition that the playback request information does not comprise a consumer identifier, if the playback response information is matched with a response information structure irrelevant to the consumer identifier in the contract document, determining that the second application service module passes the verification.
10. A verification apparatus of an application service module, comprising:
the data acquisition module is used for acquiring a first application layer traffic data set of the first application service module; wherein the first application layer traffic data set comprises a plurality of traffic data, each of the plurality of traffic data comprising request information and response information;
a contract generation module, configured to determine, based on the first application layer traffic data set, a contract document corresponding to the first application service module, where the contract document includes a request information structure and a response information structure;
and the change recall module is used for verifying the second application service module based on the contract document.
11. The apparatus of claim 10, wherein the data acquisition module comprises:
the flow acquisition unit is used for acquiring a second application layer flow data set in an on-line drainage or gateway drainage mode;
and the data preprocessing unit is used for preprocessing the second application layer traffic data set to obtain the first application layer traffic data set.
12. The apparatus of claim 11, wherein the contract generation module comprises:
the data dividing unit is used for obtaining a plurality of data subsets of the first application layer traffic data set based on the request actions corresponding to the traffic data in the first application layer traffic data set, wherein the data subsets correspond to the request actions respectively;
an information structure generating unit, configured to obtain, for each request action of the plurality of request actions, a request information structure and a response information structure corresponding to the request action based on request information and response information in each traffic data in a data subset corresponding to the request action;
and the contract assembling unit is used for obtaining the contract document based on the contract metadata and the request information structure and the response information structure corresponding to each request action.
13. The apparatus of any of claims 10-12, wherein the change recall module comprises:
the flow playback unit is used for triggering the second application service module to run based on the playback request information conforming to the request information structure in the contract document, and obtaining playback response information corresponding to the playback request information;
and the verification confirming unit is used for responding to the matching of the playback response information and the response information structure in the contract document and determining that the second application service module passes the verification.
14. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.
15. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-9.
16. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-9.
CN202211475870.5A 2022-11-23 2022-11-23 Application service module verification method and device, electronic equipment and storage medium Pending CN115858345A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211475870.5A CN115858345A (en) 2022-11-23 2022-11-23 Application service module verification method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211475870.5A CN115858345A (en) 2022-11-23 2022-11-23 Application service module verification method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115858345A true CN115858345A (en) 2023-03-28

Family

ID=85665456

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211475870.5A Pending CN115858345A (en) 2022-11-23 2022-11-23 Application service module verification method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115858345A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116166568A (en) * 2023-04-25 2023-05-26 安元科技股份有限公司 Method and system for automatically checking interface contract applied to functional test

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116166568A (en) * 2023-04-25 2023-05-26 安元科技股份有限公司 Method and system for automatically checking interface contract applied to functional test

Similar Documents

Publication Publication Date Title
CN107809331B (en) Method and device for identifying abnormal flow
CN112527649A (en) Test case generation method and device
CN111339743B (en) Account number generation method and device
CN115858345A (en) Application service module verification method and device, electronic equipment and storage medium
CN113656315B (en) Data testing method and device, electronic equipment and storage medium
CN110719200A (en) Information identification method and device
CN110610365A (en) Method and device for identifying transaction request
CN111831682B (en) Method, apparatus, device and computer readable medium for processing accumulation fund service
CN108768742B (en) Network construction method and device, electronic equipment and storage medium
CN111767161A (en) Remote calling depth recognition method and device, computer equipment and readable storage medium
CN115330540A (en) Method and device for processing transaction data
CN113157911A (en) Service verification method and device
CN113590447B (en) Buried point processing method and device
CN113673977B (en) Transaction method, system, computer device and storage medium
CN115396183B (en) User identity recognition method and device
CN115529271B (en) Service request distribution method, device, equipment and medium
CN114647631A (en) Log query method, device and equipment based on secure shell protocol terminal
CN112650601A (en) Cross-host applet opening method, apparatus, device, storage medium, and program
CN114549211A (en) Data analysis method, device and equipment based on random forest and storage medium
CN114860614A (en) Data processing method, apparatus, device, medium and product
CN115879166A (en) Data identification method and device, electronic equipment and storage medium
CN116382640A (en) Method, device, equipment and storage medium for managing micro-service
CN116319716A (en) Information processing method, no-service system, electronic device, and storage medium
CN115454898A (en) Intersystem data processing method and device and electronic equipment
CN113110873A (en) Method and apparatus for unifying system coding specifications

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