CN118210479A - Interface request encapsulation method and computing device - Google Patents
Interface request encapsulation method and computing device Download PDFInfo
- Publication number
- CN118210479A CN118210479A CN202410362769.1A CN202410362769A CN118210479A CN 118210479 A CN118210479 A CN 118210479A CN 202410362769 A CN202410362769 A CN 202410362769A CN 118210479 A CN118210479 A CN 118210479A
- Authority
- CN
- China
- Prior art keywords
- request
- interface
- initial
- target
- determining
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/24—Object-oriented
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3696—Methods or tools to render software testable
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/73—Program documentation
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Library & Information Science (AREA)
- Stored Programmes (AREA)
Abstract
The embodiment of the application provides an encapsulation method and computing equipment of an interface request, wherein the method acquires an initial interface file of a target system; determining interface information corresponding to at least one object of a target system according to the initial interface file; and generating an encapsulation script of an interface request corresponding to the object according to the interface information corresponding to the object and the request encapsulation template aiming at any one object, wherein the encapsulation script is used for carrying out interface test on the interface of the object. The method can automatically analyze the initial interface file to determine the interface information corresponding to at least one object of the target system, and rapidly generate the encapsulation script of the interface request corresponding to each object according to the request encapsulation template and the interface information corresponding to each object, thereby reducing manual intervention and improving the encapsulation efficiency of the interface request.
Description
Technical Field
The embodiment of the application relates to the technical field of computing equipment, in particular to an interface request packaging method and computing equipment.
Background
In the process of realizing the automatic test of the interface of the target interface based on the script, the interface request of the target interface needs to be packaged.
In the related art, a tester needs to analyze an interface document to obtain interface information of each interface in the interface document, sort the interface information of each interface, and manually package interface requests corresponding to each interface one by one according to the sorted interface information of each interface.
However, when the number of interfaces in the interface document is large, if a tester is used to manually package the interface request corresponding to each interface, a lot of manpower and time are consumed, resulting in lower packaging efficiency of the interface request.
Disclosure of Invention
The embodiment of the application provides an encapsulation method and computing equipment for interface requests, which can automatically analyze an initial interface file to determine interface information corresponding to at least one object of a target system, and rapidly generate encapsulation scripts corresponding to the interface requests of each object according to a request encapsulation template and the interface information corresponding to each object, thereby reducing manual intervention and improving encapsulation efficiency of the interface requests.
In a first aspect, an embodiment of the present application provides a method for encapsulating an interface request, including:
acquiring an initial interface file of a target system;
Determining interface information corresponding to at least one object of the target system according to the initial interface file;
And generating an encapsulation script of an interface request corresponding to the object according to the interface information corresponding to the object and the request encapsulation template aiming at any one object, wherein the encapsulation script is used for carrying out interface test on the interface of the object.
According to the technical scheme, the method can automatically analyze and determine the interface information corresponding to at least one object of the target system for the initial interface file, and rapidly generate the encapsulation script corresponding to the interface request of each interface according to the request encapsulation template and the interface information corresponding to each interface, so that manual intervention is reduced, and the encapsulation efficiency of the interface request is improved. And based on the request packaging template, the style consistency of the packaging script of the interface request of each interface can be ensured, the packaging script corresponding to each object of the target system can be conveniently maintained in the later period, the maintenance time of the packaging script in the interface test process is shortened, and the efficiency of the interface test is further improved.
In one possible implementation manner, generating an encapsulation script of the interface request corresponding to the object according to the interface information corresponding to the object and the request encapsulation template includes:
determining a plurality of target configuration parameters according to the interface information corresponding to the object;
determining a filling position corresponding to each target configuration parameter in the request packaging template;
And filling the plurality of target configuration parameters in the request packaging template according to the filling positions corresponding to the target configuration parameters to obtain the packaging script.
According to the technical scheme, the encapsulation script of the interface request corresponding to each object is rapidly generated based on the request encapsulation template and the interface information corresponding to each object, so that manual intervention is reduced, and the encapsulation efficiency of the interface request is improved. And based on the request packaging template, the style consistency of the packaging script of the interface request of each object can be ensured, the packaging script corresponding to the interface request of each object of the target system can be conveniently maintained in a later period, and the improvement of the interface testing efficiency is facilitated.
In one possible implementation manner, determining a plurality of target configuration parameters according to interface information corresponding to the object includes:
Extracting a plurality of initial configuration parameters from interface information corresponding to the object, wherein the plurality of initial configuration parameters comprise an identifier of a functional module corresponding to the object, an initial request mode, a script language type, an initial request path, an initial request address and initial request parameters;
and determining the target configuration parameters according to the initial configuration parameters, wherein the target configuration parameters comprise request function identification, a parameter receiving method, a target request path, a target request mode and a target request body.
In the technical scheme, a plurality of initial configuration parameters can be extracted from the interface information corresponding to each object, and the plurality of initial configuration parameters are automatically processed to obtain a plurality of target configuration parameters corresponding to each object, so that the labor and time cost is reduced, the efficiency of determining the plurality of target configuration parameters corresponding to each object is improved, and further the efficiency of generating the encapsulation script is improved.
In one possible implementation, determining the plurality of target configuration parameters according to the plurality of initial configuration parameters includes:
combining the identification of the functional module corresponding to the object with the initial request mode to obtain the request function identification;
Determining the parameter receiving method according to the script language type;
determining the target request path according to the initial request mode, the initial request path and the initial request address;
Determining the initial request mode as the target request mode;
and determining the target request body according to the initial request mode.
In the technical scheme, the plurality of initial configuration parameters can be automatically processed to obtain the plurality of target configuration parameters corresponding to each interface, so that the labor and time cost is reduced, the efficiency of determining the plurality of target configuration parameters corresponding to each interface is improved, and further the efficiency of generating the encapsulation script is improved.
In one possible implementation manner, determining the target request body according to the initial request mode includes:
if the initial request mode is a deletion request mode or a query request mode, determining that the target request body is empty;
And if the initial request mode is an addition request mode or a modification request mode, determining the target request body according to the initial request parameters.
In the technical scheme, the target request body can be determined in different modes according to different initial request modes, so that the target request body is determined more flexibly.
In one possible implementation manner, determining the target request path according to the initial request mode, the initial request path and the initial request address includes:
Responding to the initial request mode as an addition request mode, a deletion request mode or a modification request mode, or combining the initial request path and the initial request address to obtain the target request path when the initial request mode is a query request mode and the query request mode is used for realizing unconditional query;
And when the initial request mode is a query request mode and the query request mode is used for realizing conditional query, extracting query parameters from interface information corresponding to the object, and carrying out combination processing on the initial request path, the initial request address and the query parameters to obtain the target request path.
In the technical scheme, different modes can be selected according to different initial request modes to determine the target request path, so that the target request path is more flexible in determination.
In one possible implementation manner, determining interface information corresponding to at least one object of the target system according to the initial interface file includes:
Classifying the initial interface file to obtain a sub-interface file corresponding to at least one functional module of the target system;
determining at least one object corresponding to each functional module and interface information corresponding to each object according to the sub-interface file corresponding to each functional module;
Determining interface information corresponding to at least one object of the target system, wherein the interface information corresponding to the at least one object comprises: interface information corresponding to each object of each functional module.
In the above technical solution, the initial interface file may be classified to obtain a sub-interface file corresponding to each functional module of the target system, and at least one object corresponding to the target system and interface information corresponding to each object may be further determined based on the sub-interface file, so that an encapsulation script of an interface request of each object may be quickly generated based on the interface information.
In one possible implementation manner, for any one functional module, determining at least one object corresponding to the functional module and interface information corresponding to each object according to a subinterface file corresponding to the functional module includes:
Analyzing the sub-interface file corresponding to the functional module to obtain at least one object corresponding to the functional module and an interface request type of each object, wherein the interface request type comprises at least one of the following: new type, delete type, modify type, and query type;
and determining interface information corresponding to each object in the sub-interface file according to the interface request type of each object.
In the above technical solution, the sub-interface file of each functional module may be further parsed to determine at least one object corresponding to the target system and interface information corresponding to each object, so that an encapsulation script of the interface request of each object may be quickly generated based on the interface information.
In one possible implementation manner, after generating the encapsulation script of the interface request corresponding to the object, the method further includes:
Determining an index node corresponding to the encapsulation script;
Determining the mounting position of the index node in a directory tree of the target system;
And adding the index node to the directory tree according to the mounting position.
In the technical scheme, the encapsulation script of the interface request of each object is carried out on the directory tree, so that the encapsulation script of the interface request of each object can be conveniently searched and called when the interface of the object is tested.
In a second aspect, an embodiment of the present application provides an apparatus for encapsulating an interface request, where the apparatus includes:
the acquisition module is used for acquiring an initial interface file of the target system;
the determining module is used for determining interface information corresponding to at least one object of the target system according to the initial interface file;
The generation module is used for generating an encapsulation script of the interface request corresponding to the object according to the interface information corresponding to the object and the request encapsulation template aiming at any one object, and the encapsulation script is used for carrying out interface test on the interface of the object.
In one possible implementation manner, the generating module is specifically configured to:
determining a plurality of target configuration parameters according to the interface information corresponding to the object;
determining a filling position corresponding to each target configuration parameter in the request packaging template;
And filling the plurality of target configuration parameters in the request packaging template according to the filling positions corresponding to the target configuration parameters to obtain the packaging script.
In a possible implementation manner, the generating module is specifically further configured to:
Extracting a plurality of initial configuration parameters from interface information corresponding to the object, wherein the plurality of initial configuration parameters comprise an identifier of a functional module corresponding to the object, an initial request mode, a script language type, an initial request path, an initial request address and initial request parameters;
and determining the target configuration parameters according to the initial configuration parameters, wherein the target configuration parameters comprise request function identification, a parameter receiving method, a target request path, a target request mode and a target request body.
In a possible implementation manner, the generating module is specifically further configured to:
combining the identification of the functional module corresponding to the object with the initial request mode to obtain the request function identification;
Determining the parameter receiving method according to the script language type;
determining the target request path according to the initial request mode, the initial request path and the initial request address;
Determining the initial request mode as the target request mode;
and determining the target request body according to the initial request mode.
In a possible implementation manner, the generating module is specifically further configured to:
if the initial request mode is a deletion request mode or a query request mode, determining that the target request body is empty;
And if the initial request mode is an addition request mode or a modification request mode, determining the target request body according to the initial request parameters.
In a possible implementation manner, the generating module is specifically further configured to:
Responding to the initial request mode as an addition request mode, a deletion request mode or a modification request mode, or combining the initial request path and the initial request address to obtain the target request path when the initial request mode is a query request mode and the query request mode is used for realizing unconditional query;
And when the initial request mode is a query request mode and the query request mode is used for realizing conditional query, extracting query parameters from interface information corresponding to the object, and carrying out combination processing on the initial request path, the initial request address and the query parameters to obtain the target request path.
In one possible implementation manner, the determining module is specifically configured to:
Classifying the initial interface file to obtain a sub-interface file corresponding to at least one functional module of the target system;
determining at least one object corresponding to each functional module and interface information corresponding to each object according to the sub-interface file corresponding to each functional module;
Determining interface information corresponding to at least one object of the target system, wherein the interface information corresponding to the at least one object comprises: interface information corresponding to each object of each functional module.
In one possible implementation manner, for any one of the functional modules, the determining module is specifically further configured to:
Analyzing the sub-interface file corresponding to the functional module to obtain at least one object corresponding to the functional module and an interface request type of each object, wherein the interface request type comprises at least one of the following: new type, delete type, modify type, and query type;
and determining interface information corresponding to each object in the sub-interface file according to the interface request type of each object.
In one possible implementation, the apparatus further includes a mounting module, wherein:
the determining module is further used for determining an index node corresponding to the encapsulation script;
The determining module is further configured to determine a mounting position of the index node in a directory tree of the target system;
and the mounting module is used for adding the index node to the directory tree according to the mounting position.
In a third aspect, embodiments of the present application provide a computing device comprising: a processor and a memory; the processor and the memory are coupled;
The memory is used for storing computer instructions;
the processor is configured to execute the computer instructions stored by the memory to perform the method according to any one of the first aspects.
In a fourth aspect, embodiments of the present application provide a chip for performing the method according to any one of the first aspects.
In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium having stored therein computer-executable instructions that, when executed by a computer, implement the method according to any of the first aspects.
In a sixth aspect, an embodiment of the application provides a computer program product comprising a computer program which, when executed by a processor, implements the method according to any of the first aspects.
The method can acquire the initial interface file of the target system and determine the interface information corresponding to at least one object of the target system according to the initial interface file; for any one object, an encapsulation script of an interface request corresponding to the object can be generated according to the interface information corresponding to the object and the request encapsulation template, and the encapsulation script is used for carrying out interface test on the interface of the object. According to the method, the interface information corresponding to at least one object of the target system can be automatically analyzed and determined on the initial interface file, and the encapsulation script corresponding to the interface request of each interface is rapidly generated according to the request encapsulation template and the interface information corresponding to each interface, so that manual intervention is reduced, and the encapsulation efficiency of the interface request is improved. And based on the request packaging template, the style consistency of the packaging script of the interface request of each object can be ensured, so that the packaging script corresponding to each object of the target system is convenient to carry out later maintenance.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions of the prior art, the drawings which are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings can be obtained according to these drawings without inventive faculty for a person skilled in the art.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application;
Fig. 2 is a flow chart of a method for encapsulating an interface request according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating another method for encapsulating an interface request according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a process for determining multiple target configuration parameters according to an embodiment of the present application;
fig. 5 is a process schematic diagram of a method for encapsulating an interface request according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an interface request encapsulation device according to an embodiment of the present application;
Fig. 7 is a schematic structural diagram of another device for encapsulating an interface request according to an embodiment of the present application;
fig. 8 is a schematic hardware structure of a computing device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with embodiments of the application. Rather, they are merely examples of apparatus and methods consistent with aspects of embodiments of the application as detailed in the accompanying claims.
In recent years, in the interface test process, a test script can be written based on a scripting language, and an automatic test of the interface is completed by utilizing a unit test framework and the test script, so as to realize verification of basic functions or abnormal parameters of the interface.
In the related art, a tester needs to analyze an interface document to obtain interface information of each interface in the interface document, sort the interface information of each interface, and manually package interface requests corresponding to each interface one by one according to the sorted interface information of each interface. However, when the number of interfaces in the interface document is large, if a tester is used to manually package the interface request corresponding to each interface, a lot of manpower and time are consumed, resulting in lower packaging efficiency of the interface request.
In view of this, the embodiment of the application provides a method for encapsulating an interface request, which can obtain an initial interface file of a target system, and determine interface information corresponding to at least one object of the target system according to the initial interface file; for any one object, according to the interface information and the request encapsulation template corresponding to the object, generating an encapsulation script corresponding to the interface request of the object, wherein the encapsulation script is used for carrying out interface test on the interface of the object. According to the method, the interface information corresponding to at least one object of the target system can be automatically analyzed and determined on the initial interface file, and the encapsulation script corresponding to the interface request of each interface is rapidly generated according to the request encapsulation template and the interface information corresponding to each interface, so that manual intervention is reduced, and the encapsulation efficiency of the interface request is improved. And based on the request packaging template, the style consistency of the packaging script of the interface request of each interface can be ensured, so that the packaging script corresponding to each object of the target system is convenient to carry out later maintenance.
The method for packaging the interface request provided by the embodiment of the application can be applied to the interface test process of the target system. In order to facilitate understanding, the method for encapsulating an interface request provided by the embodiment of the present application is described below with reference to fig. 1.
Fig. 1 is a schematic diagram of an application scenario provided in an embodiment of the present application. Referring to fig. 1, the method includes a computing device, where the computing device may obtain an initial interface file of a target system, and automatically generate, according to the initial interface file, an encapsulation script of an interface request corresponding to each object of the target system.
The target system may include a plurality of functional modules, each of which may include a plurality of objects. For example, the target system is an operating system of the computing device, the functional modules may be computer (computer) modules in the operating system, and the objects may be clusters (clusters) in the computer (computer) modules.
After the encapsulation script of the interface request of each object of the target system is generated, the encapsulation script can be applied to the process of programming, debugging and executing the interface automation use case of each object of the target system, so that the automation test efficiency of the interface is improved.
It should be noted that, the computing device in the embodiment of the present application includes, but is not limited to, an independent physical server or server node, or may be a server cluster formed by a plurality of physical servers, or may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a laptop computer, or the like.
The technical scheme of the embodiment of the application is described in detail below by using specific embodiments. The following embodiments may be combined with each other, and some embodiments may not be repeated for the same or similar concepts or processes.
Fig. 2 is a flow chart of a method for encapsulating an interface request according to an embodiment of the present application. Referring to fig. 2, the method specifically includes:
the subject of execution of the method may be the computing device of fig. 1, and in particular, may be executed by a processor in the computing device of fig. 1.
S201, acquiring an initial interface file of a target system.
Optionally, according to the identification of the target system, an initial interface file of the target system can be obtained in a preset storage space; or may receive an initial interface file of the target system sent by the client.
The form of the initial interface file may be any form, and in one example, the form of the initial interface file may be a document form.
When the format of the initial interface file is in the form of a document, the format of the document may include, but is not limited to, an extensible markup language (Extensible Markup Language, XML) format or an Excel format.
S202, determining interface information corresponding to at least one object of the target system according to the initial interface file.
In one possible implementation, the interface information corresponding to at least one object of the target system may be determined in the following manner.
(1) And classifying the initial interface file to obtain a sub-interface file corresponding to at least one functional module of the target system.
The target system may have a plurality of functional modules, for example, the target system is an operating system, and the functional modules may be a computing (computer) module, a container management (container) module, or a network (network) module.
Alternatively, the semantic recognition processing method in the related art may be used to perform classification processing on the initial interface file. For example, semantic recognition processing is performed on the initial interface file, so that sub-interface file contents corresponding to each functional module in the initial interface file can be recognized; and classifying the contents of the sub-interface files corresponding to the functional modules according to the semantic recognition result to obtain the sub-interface files corresponding to each functional module.
(2) And determining at least one object corresponding to each functional module and interface information corresponding to each object according to the sub-interface file corresponding to each functional module.
Aiming at any one functional module, analyzing and processing the sub-interface file corresponding to the functional module to obtain at least one object corresponding to the functional module and the interface request type of each object; and determining the interface information corresponding to each object in the sub-interface file according to the interface request type of each object.
The interface request type may include at least one of: new type, delete type, modify type, and query type.
In one example, a semantic recognition processing method in the related art may be used to parse the sub-interface file to identify at least one object corresponding to each functional module and an interface request type of each object.
Optionally, according to the identification of each object and the interface request type, extracting the interface information corresponding to each object under the interface request type from the sub-interface file.
At least one object corresponding to each functional module and interface information corresponding to each object can be stored by adopting a rule method. For example, the classification result of the initial interface file may be stored through an excel workbook. The excel workbook may include a plurality of table pages (sheets), where each table page is used to store interface information of at least one object corresponding to one functional module.
(3) Determining interface information corresponding to at least one object of the target system, wherein the interface information corresponding to the at least one object comprises: interface information corresponding to each object of each functional module.
The target system includes M functional modules, each of which may correspond to N objects, each of which may correspond to P interfaces, and the target system corresponds to mxn×p interfaces, each of which corresponds to one interface information, and has mxn×p interface information. Wherein M, N and P are positive integers.
S203, generating an encapsulation script of the interface request corresponding to the object according to the interface information corresponding to the object and the request encapsulation template aiming at any one object.
The encapsulation script may be used to interface test the interface of the object. In practical application, different types of scripting languages can be adopted to realize the encapsulation of the interface request, therefore, the embodiment of the application can provide various types of request encapsulation templates, and each type of request encapsulation module can realize the encapsulation of the interface request based on different scripting languages, thereby being beneficial to improving the flexibility of the encapsulation of the interface request.
Optionally, when the automatic test of the interfaces of the target system is performed based on the test tool, the package script corresponding to the interface request of each object of the target system may be imported, so as to implement the automatic test of the interfaces corresponding to each object. In the same target system, the interface requests of the objects of the target system can be packaged based on the same request packaging template, so that the style consistency of the packaging script of the interface request of each object is ensured, the packaging script corresponding to each object of the target system is convenient to carry out later maintenance, and the efficiency of the interface test of the target system is improved.
The types of the test scripts used by the different types of the test tools are different, and in the process of carrying out the interface automatic test of the target system based on the test tools, the script language type of the encapsulation script of the interface request corresponding to each object of the target system can be determined based on the test tools, and the target request encapsulation template can be determined in a plurality of types of request encapsulation templates based on the script language type.
It can be appreciated that, in at least one arbitrary object of the target system, the process of generating the encapsulation script of the interface request corresponding to each object is the same. In order to improve the encapsulation efficiency of the interface request, the encapsulation script of the interface request corresponding to each object may be generated in parallel in the manner of S203. It should be noted that, the process of generating the encapsulation script of the interface request corresponding to each object will be described in detail in the embodiment of fig. 3.
For any one object, after generating the encapsulation script of the interface request corresponding to the object, determining an index node corresponding to the encapsulation script; determining the mounting position of an index node in a directory tree of a target system; according to the mounting position, adding the index node to the directory tree.
Alternatively, the mounting process of the index node in the directory tree may be implemented based on a preset script. Specifically, according to the identification of the functional module corresponding to the object, determining an index node corresponding to the encapsulation script; acquiring the corresponding relation between each index node and the corresponding mounting position; determining the mounting position of the index node according to the index node corresponding to the encapsulation script and the corresponding relation; according to the mounting position, adding the index node to the directory tree.
The encapsulation script of the interface request of each object is carried out on the directory tree, so that the encapsulation script of the interface request of each object can be conveniently searched and called when the interface of the object is tested.
The method for encapsulating the interface request provided by the embodiment of the application can acquire the initial interface file of the target system and determine the interface information corresponding to at least one object of the target system according to the initial interface file; for any one object, an encapsulation script of an interface request corresponding to the object can be generated according to the interface information corresponding to the object and the request encapsulation template, and the encapsulation script is used for carrying out interface test on the interface of the object. The method can automatically analyze the initial interface file to determine the interface information corresponding to at least one object of the target system, and rapidly generate the encapsulation script of the interface request corresponding to each object according to the request encapsulation template and the interface information corresponding to each object, thereby reducing manual intervention and improving the encapsulation efficiency of the interface request. And based on the request packaging template, the style consistency of the packaging script of the interface request of each object can be ensured, so that the packaging script corresponding to each object of the target system is convenient to carry out later maintenance.
The embodiment of the application provides an interface request packaging method, which relates to a process of generating a packaging script of an interface request corresponding to each object according to interface information corresponding to each object of a target system and a request packaging template. Since the process of generating the encapsulation script of the interface request corresponding to each object is the same, a process of generating the encapsulation script of the interface request corresponding to the object according to the interface information corresponding to the object and the request encapsulation template will be described below with reference to fig. 3 by taking any one object as an example.
Fig. 3 is a flowchart of another method for encapsulating an interface request according to an embodiment of the present application. Referring to fig. 3, the method specifically includes:
S301, extracting a plurality of initial configuration parameters from interface information corresponding to the object.
The plurality of initial configuration parameters comprise an identification of a functional module corresponding to the object, an initial request mode, a script language type, an initial request path, an initial request address and an initial request parameter.
The identity of the functional module may be the name of the functional module, e.g., the identity of the functional module may be a Virtual Machine (VM) or a cluster (cluster).
The initial request mode may be an add (post) request mode, a delete (del) request mode, a query (get) request mode, or a modify (put) request mode. In some examples, the add request mode may also be referred to as a create request mode.
The script language type may be a language type used for script writing in the related art, and for example, the script language type may be a Python type.
The initial request parameters may include 1 or more sub-parameters, for example, the initial request parameters may include: name (name), vendor information (cpuVender) of the processor, tag (tag), description information (description), and the like.
In one example, the initial request path may be a cluster (/% s/clusters) and the initial request address may be a site identification (% site_id).
S302, determining a plurality of target configuration parameters according to the plurality of initial configuration parameters.
The plurality of target configuration parameters include a request function identification, a parameter receiving method, a target request path, a target request mode and a target request body.
For ease of understanding, the process of determining the plurality of target configuration parameters is described in detail below in conjunction with FIG. 4.
Fig. 4 is a schematic diagram of a process for determining multiple target configuration parameters according to an embodiment of the present application. Referring to fig. 4, the process specifically includes:
s401, the identification of the functional module corresponding to the object and the initial request mode are combined and processed to obtain the request function identification.
In one example, the identity of the functional module corresponding to the object is a Virtual Machine (VM), the initial request mode is a create request mode (post), and the request function is identified as creating a virtual machine (vm_post).
S402, determining a parameter receiving method according to the script language type.
It is understood that different scripting language types may correspond to different parameter-receiving methods. For example, when the script language type is a Python type, the parameter receiving method may be a keyword parameter (keyword arguments, kwargs) method.
S403, determining a target request path according to the initial request mode, the initial request path and the initial request address.
In one implementation, the target request path may be determined as follows:
(1) And when the initial request mode is an addition request mode, a deletion request mode or a modification request mode or the initial request mode is a query request mode and the query request mode is used for realizing unconditional query, combining the initial request path and the initial request address to obtain a target request path.
When a query request mode is used for querying specific information of a certain sub-object in the target object, the query request mode can be determined to be used for realizing unconditional query.
For example, the initial request mode is the add request mode, the initial request path is the cluster (/%s/clusters), the initial request address is the site identification (%site_id), and the target request path is the cluster+site identification ("/%s/clusters"%site_id).
For example, when the initial request mode is a query request mode and the query request mode is used for querying the first 3 columns of data in the table a, the initial request path is path 1, the initial request address is address 1, and the target request path is: path 1+Address 1.
(2) When the initial request mode is a query request mode and the query request mode is used for realizing conditional query, extracting query parameters from interface information corresponding to the object, and carrying out combination processing on the initial request path, the initial request address and the query parameters to obtain a target request path.
Alternatively, when a query request pattern is used to query all data of the target object, it may be determined that the query request pattern is used to implement the conditional query.
For example, when the initial request mode is a query request mode and the query request mode is used for querying all data of the table a, the initial request path is path 1, the initial request address is address 1, and the query parameters are: table a, the target request path is: path 1+Address 1+Table A.
S404, determining the initial request mode as a target request mode.
For example, the initial request mode is a delete (del) request mode, and the target request mode is a delete (del) request mode.
S405, determining a target request body according to the initial request mode.
When the initial request modes of the interfaces are different, the determined target request modes are different. Specifically:
If the initial request mode is a deletion request mode or a query request mode, determining that the target request body is empty.
If the initial request mode is an addition request mode or a modification request mode, determining a target request body according to the initial request parameters.
For example, when the initial request mode is a delete (delete) request mode or a query (get) request mode, the target request body may be: body= { }; when the initial request mode is an add (post) request mode or a modify (put) request mode, parameter assignment processing may be performed on the initial request parameters in the target request body.
The method for encapsulating the interface request can extract a plurality of initial configuration parameters from the interface information corresponding to each object, and automatically process the plurality of initial configuration parameters to obtain a plurality of target configuration parameters corresponding to each object, so that manual intervention is not needed, labor and time cost are reduced, and efficiency of determining the plurality of target configuration parameters corresponding to each object is improved.
S303, determining filling positions corresponding to each target configuration parameter in the request packaging template.
The association relationship between each target configuration parameter and the corresponding filling position may be stored in advance, so that after the plurality of target configuration parameters are acquired, the filling position corresponding to each target configuration parameter may be determined based on each target configuration parameter and the association relationship.
S304, filling a plurality of target configuration parameters in the request packaging template according to the filling position corresponding to each target configuration parameter to obtain a packaging script.
Each target configuration parameter may be automatically filled to a filling position corresponding to each target configuration parameter by using an automatic filling tool in the related art or based on a preset execution script.
Request information of at least one interface request of the object may be included in the encapsulation script, and the at least one interface request may include at least one of: add (or create) requests, delete requests, modify requests, and query requests. The request information of each interface request may include: request method specification, request uniform resource location system (uniform resource locator, URL), request mode, request body and return request body.
The request method specification may include a request function identification and a parameter receiving method corresponding to the interface request.
The request URL may include a target request path corresponding to the interface request.
The request mode may include a target request mode corresponding to the interface request.
The request body may include a target request body corresponding to the interface request.
The return request body may be a default configuration parameter set in the request encapsulation template, and may be used to indicate that the complete request is returned, including the path, the request mode, the request address, and the request body.
It will be appreciated that for each object of the target system, the method of the embodiment of fig. 3 may be performed to generate an encapsulation script for the interface request corresponding to that object.
According to the method for encapsulating the interface request, provided by the embodiment of the application, a plurality of initial configuration parameters can be extracted from the interface information corresponding to each object, a plurality of target configuration parameters are determined according to the plurality of initial configuration parameters, the filling position corresponding to each target configuration parameter is determined in the request encapsulation template, and a plurality of target configuration parameters can be filled in the request encapsulation template according to the filling position corresponding to each target configuration parameter, so that the encapsulation script is obtained. According to the method, the encapsulation script of the interface request corresponding to each object is rapidly generated based on the request encapsulation template and the interface information corresponding to each object, so that manual intervention is reduced, and the encapsulation efficiency of the interface request is improved. And based on the request packaging template, the style consistency of the packaging script of the interface request of each object can be ensured, the packaging script corresponding to the interface request of each object of the target system can be conveniently maintained in a later period, and the improvement of the interface testing efficiency is facilitated.
Fig. 5 is a process schematic diagram of an encapsulation method for an interface request according to an embodiment of the present application. Referring to fig. 5, an initial interface file is obtained, and classification processing is performed on the initial interface file to obtain sub-interface files corresponding to n functional modules. And analyzing each sub-interface file to obtain at least one object corresponding to each functional module and interface information corresponding to each object.
For example, in fig. 5, the sub-interface file corresponding to the function module 1 is analyzed, so that m objects corresponding to the function module 1 and interface information corresponding to each object can be obtained. Multiple initial configuration parameters can be extracted from the interface information corresponding to each object, and multiple target configuration parameters can be determined according to the multiple initial configuration parameters. And determining the filling position corresponding to each target configuration parameter in the request packaging template, and filling the plurality of target configuration parameters in the request packaging template according to the filling position corresponding to each target configuration parameter to obtain the packaging script of the interface request corresponding to each object.
It should be noted that, the target configuration parameter of each object may include target configuration parameters of a plurality of interfaces corresponding to the object, and the request information corresponding to each interface may be obtained according to the target configuration parameter of each interface and the request encapsulation template, where the request information may include: request method specification, request URL, request mode, request body and return request body. The encapsulation script of the interface request corresponding to each object may include request information corresponding to each interface of each object.
Fig. 6 is a schematic structural diagram of an encapsulation device for interface request according to an embodiment of the present application. Referring to fig. 6, the encapsulation device 10 for interface request includes:
an obtaining module 11, configured to obtain an initial interface file of a target system;
A determining module 12, configured to determine interface information corresponding to at least one object of the target system according to the initial interface file;
The generating module 13 is configured to generate, for any one object, an encapsulation script of an interface request corresponding to the object according to interface information and a request encapsulation template corresponding to the object, where the encapsulation script is used to perform an interface test on an interface of the object.
In one possible implementation, the generating module 13 is specifically configured to:
determining a plurality of target configuration parameters according to the interface information corresponding to the object;
determining a filling position corresponding to each target configuration parameter in the request packaging template;
And filling the plurality of target configuration parameters in the request packaging template according to the filling positions corresponding to the target configuration parameters to obtain the packaging script.
In a possible implementation, the generating module 13 is specifically further configured to:
Extracting a plurality of initial configuration parameters from interface information corresponding to the object, wherein the plurality of initial configuration parameters comprise an identifier of a functional module corresponding to the object, an initial request mode, a script language type, an initial request path, an initial request address and initial request parameters;
and determining the target configuration parameters according to the initial configuration parameters, wherein the target configuration parameters comprise request function identification, a parameter receiving method, a target request path, a target request mode and a target request body.
In a possible implementation, the generating module 13 is specifically further configured to:
combining the identification of the functional module corresponding to the object with the initial request mode to obtain the request function identification;
Determining the parameter receiving method according to the script language type;
determining the target request path according to the initial request mode, the initial request path and the initial request address;
Determining the initial request mode as the target request mode;
and determining the target request body according to the initial request mode.
In a possible implementation, the generating module 13 is specifically further configured to:
if the initial request mode is a deletion request mode or a query request mode, determining that the target request body is empty;
And if the initial request mode is an addition request mode or a modification request mode, determining the target request body according to the initial request parameters.
In a possible implementation, the generating module 13 is specifically further configured to:
Responding to the initial request mode as an addition request mode, a deletion request mode or a modification request mode, or combining the initial request path and the initial request address to obtain the target request path when the initial request mode is a query request mode and the query request mode is used for realizing unconditional query;
And when the initial request mode is a query request mode and the query request mode is used for realizing conditional query, extracting query parameters from interface information corresponding to the object, and carrying out combination processing on the initial request path, the initial request address and the query parameters to obtain the target request path.
In one possible implementation, the determining module 12 is specifically configured to:
Classifying the initial interface file to obtain a sub-interface file corresponding to at least one functional module of the target system;
determining at least one object corresponding to each functional module and interface information corresponding to each object according to the sub-interface file corresponding to each functional module;
Determining interface information corresponding to at least one object of the target system, wherein the interface information corresponding to the at least one object comprises: interface information corresponding to each object of each functional module.
In one possible implementation manner, for any one of the functional modules, the determining module 12 is specifically further configured to:
Analyzing the sub-interface file corresponding to the functional module to obtain at least one object corresponding to the functional module and an interface request type of each object, wherein the interface request type comprises at least one of the following: new type, delete type, modify type, and query type;
and determining interface information corresponding to each object in the sub-interface file according to the interface request type of each object.
Fig. 7 is a schematic structural diagram of another device for encapsulating an interface request according to an embodiment of the present application. Referring to fig. 7, based on the structure of the interface request encapsulation apparatus 10 shown in fig. 6, the interface request encapsulation apparatus 10 further includes a mounting module 14, wherein:
The determining module 12 is further configured to determine an inode corresponding to the encapsulation script;
The determining module 12 is further configured to determine a mounting location of the inode in a directory tree of the target system;
the mounting module 14 is configured to add the inode to the directory tree according to the mounting location.
The packaging device for interface request provided by the embodiment of the application can execute the technical scheme shown in the embodiment of the method, and the implementation principle and beneficial effects are similar, and are not repeated here.
Fig. 8 is a schematic hardware structure of a computing device according to an embodiment of the present application. Referring to fig. 8, the computing device 20 may include a processor 21 and a memory 22, the processor 21 and the memory 22 being coupled. Wherein the processor 21 and the memory 22 may communicate; the processor 21 and the memory 22 are in communication via a communication bus 23, as an example.
The memory 22 is used for storing computer instructions;
the processor 21 is configured to execute the computer instructions stored in the memory 22, so as to execute the technical solution as shown in the foregoing method embodiment.
Optionally, the computing device 20 may also include a communication interface, which may include a transmitter and/or a receiver.
Alternatively, the Processor may be a central processing unit (Central Processing Unit, CPU), other general purpose Processor, digital signal Processor (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in the processor for execution.
The embodiment of the application also provides a chip for executing the encapsulation method of the interface request described in the above embodiment, and its implementation principle and technical effects are similar, and will not be described here again.
Embodiments of the present application provide a computer-readable storage medium having stored thereon computer-executable instructions; the computer-executable instructions, when executed by a processor, implement the encapsulation method for interface requests as described in the above embodiments.
An embodiment of the present application provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, causes the computer to execute the method for encapsulating an interface request described in the foregoing embodiment.
All or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The aforementioned program may be stored in a readable memory. The program, when executed, performs steps including the method embodiments described above; and the aforementioned memory (storage medium) includes: read-only memory (abbreviated as ROM), RAM, flash memory, hard disk, solid state disk, magnetic tape (English: MAGNETIC TAPE), floppy disk (English: floppy disk), optical disk (English: optical disk), and any combination thereof.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processing unit of a general purpose computer, special purpose computer, embedded processor, or other programmable terminal device to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable terminal device to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable terminal device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer implemented process such that the instructions which execute on the computer or other programmable device provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In embodiments of the present application, the term "include" and variations thereof may refer to non-limiting inclusion; the term "or" and variations thereof may refer to "and/or". The terms "first," "second," and the like in embodiments of the present application are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. In the embodiments of the present application, "a plurality" means two or more. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the embodiments of the present application, and are not limited thereto; although embodiments of the present application have been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims (10)
1. A method for encapsulating an interface request, comprising:
acquiring an initial interface file of a target system;
Determining interface information corresponding to at least one object of the target system according to the initial interface file;
And generating an encapsulation script of an interface request corresponding to the object according to the interface information corresponding to the object and the request encapsulation template aiming at any one object, wherein the encapsulation script is used for carrying out interface test on the interface of the object.
2. The method of claim 1, wherein generating an encapsulation script for the interface request corresponding to the object according to the interface information and the request encapsulation template corresponding to the object comprises:
determining a plurality of target configuration parameters according to the interface information corresponding to the object;
determining a filling position corresponding to each target configuration parameter in the request packaging template;
And filling the plurality of target configuration parameters in the request packaging template according to the filling positions corresponding to the target configuration parameters to obtain the packaging script.
3. The method of claim 2, wherein determining a plurality of target configuration parameters from interface information corresponding to the object comprises:
Extracting a plurality of initial configuration parameters from interface information corresponding to the object, wherein the plurality of initial configuration parameters comprise an identifier of a functional module corresponding to the object, an initial request mode, a script language type, an initial request path, an initial request address and initial request parameters;
and determining the target configuration parameters according to the initial configuration parameters, wherein the target configuration parameters comprise request function identification, a parameter receiving method, a target request path, a target request mode and a target request body.
4. A method according to claim 3, wherein determining the plurality of target configuration parameters from the plurality of initial configuration parameters comprises:
combining the identification of the functional module corresponding to the object with the initial request mode to obtain the request function identification;
Determining the parameter receiving method according to the script language type;
determining the target request path according to the initial request mode, the initial request path and the initial request address;
Determining the initial request mode as the target request mode;
and determining the target request body according to the initial request mode.
5. The method of claim 4, wherein determining the target requestor based on the initial request pattern comprises:
if the initial request mode is a deletion request mode or a query request mode, determining that the target request body is empty;
And if the initial request mode is an addition request mode or a modification request mode, determining the target request body according to the initial request parameters.
6. The method of claim 4, wherein determining the target request path based on the initial request pattern, the initial request path, and the initial request address comprises:
Responding to the initial request mode as an addition request mode, a deletion request mode or a modification request mode, or combining the initial request path and the initial request address to obtain the target request path when the initial request mode is a query request mode and the query request mode is used for realizing unconditional query;
And when the initial request mode is a query request mode and the query request mode is used for realizing conditional query, extracting query parameters from interface information corresponding to the object, and carrying out combination processing on the initial request path, the initial request address and the query parameters to obtain the target request path.
7. The method according to any one of claims 1-6, wherein determining interface information corresponding to at least one object of the target system from the initial interface file comprises:
Classifying the initial interface file to obtain a sub-interface file corresponding to at least one functional module of the target system;
determining at least one object corresponding to each functional module and interface information corresponding to each object according to the sub-interface file corresponding to each functional module;
Determining interface information corresponding to at least one object of the target system, wherein the interface information corresponding to the at least one object comprises: interface information corresponding to each object of each functional module.
8. The method according to claim 7, wherein for any one of the function modules, determining at least one object corresponding to the function module and interface information corresponding to each object according to the sub-interface file corresponding to the function module includes:
Analyzing the sub-interface file corresponding to the functional module to obtain at least one object corresponding to the functional module and an interface request type of each object, wherein the interface request type comprises at least one of the following: new type, delete type, modify type, and query type;
and determining interface information corresponding to each object in the sub-interface file according to the interface request type of each object.
9. The method of any of claims 1-8, wherein after generating the encapsulation script of the interface request corresponding to the object, the method further comprises:
Determining an index node corresponding to the encapsulation script;
Determining the mounting position of the index node in a directory tree of the target system;
And adding the index node to the directory tree according to the mounting position.
10. A computing device, comprising: a processor and a memory; the processor and the memory are coupled;
The memory is used for storing computer instructions;
The processor is configured to execute computer instructions stored in the memory to perform the method of any one of claims 1 to 9.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410362769.1A CN118210479A (en) | 2024-03-27 | 2024-03-27 | Interface request encapsulation method and computing device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410362769.1A CN118210479A (en) | 2024-03-27 | 2024-03-27 | Interface request encapsulation method and computing device |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN118210479A true CN118210479A (en) | 2024-06-18 |
Family
ID=91450182
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202410362769.1A Pending CN118210479A (en) | 2024-03-27 | 2024-03-27 | Interface request encapsulation method and computing device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN118210479A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119603362A (en) * | 2024-12-05 | 2025-03-11 | 天翼云科技有限公司 | Request management method, device, computer equipment, storage medium and program product |
-
2024
- 2024-03-27 CN CN202410362769.1A patent/CN118210479A/en active Pending
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119603362A (en) * | 2024-12-05 | 2025-03-11 | 天翼云科技有限公司 | Request management method, device, computer equipment, storage medium and program product |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN108415832B (en) | Interface automation test method, device, equipment and storage medium | |
| CN107908541B (en) | Interface testing method and device, computer equipment and storage medium | |
| CN110069297B (en) | SPRING MVC-based exception handling method, SPRING MVC-based exception handling device, computer equipment and storage medium | |
| CN109800258B (en) | Data file deployment method, device, computer equipment and storage medium | |
| CN109032631B (en) | Application program patch package obtaining method and device, computer equipment and storage medium | |
| CN110673839B (en) | Distributed tool configuration construction generation method and system | |
| CN111679886A (en) | Heterogeneous computing resource scheduling method, system, electronic device and storage medium | |
| CN113220657B (en) | Data processing method and device and computer equipment | |
| CN115408193A (en) | Method and device for processing error codes among multiple modules | |
| CN116578389A (en) | Automatic generation method and device for container mirror image configuration file based on template representation | |
| CN115599359A (en) | Code generation method, device, equipment and medium | |
| CN112579454B (en) | Task data processing method, device and equipment | |
| CN118210479A (en) | Interface request encapsulation method and computing device | |
| CN110750440A (en) | Data testing method and terminal equipment | |
| CN117743145A (en) | Test script generation method and device based on coding template and processing equipment | |
| CN117370203A (en) | Automatic test method, system, electronic equipment and storage medium | |
| CN112187713A (en) | Message conversion method, device, computer equipment and storage medium | |
| CN113110870B (en) | Resource packaging management method, device, equipment and storage medium | |
| CN110471708B (en) | Method and device for acquiring configuration items based on reusable components | |
| CN108052654A (en) | Data extraction method, device, equipment and storage medium | |
| CN113342647A (en) | Test data generation method and device | |
| CN112558973A (en) | Front-end page generation method and device, storage medium and electronic device | |
| CN114528013B (en) | Text generation method, device, electronic device, storage medium and product | |
| CN118606576A (en) | Front-end page testing method, device, storage medium and electronic device | |
| CN110245072A (en) | A kind of test method and device |
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 | ||
| CB02 | Change of applicant information |
Country or region after: China Address after: 450000 Henan Province, Zhengzhou City, Free Trade Zone Zhengzhou Area (Zhengdong), Inner Ring North Road of Longhu, No. 99 Applicant after: xFusion Digital Technologies Co., Ltd. Address before: 450000 Floor 9, building 1, Zhengshang Boya Plaza, Longzihu smart Island, Zhengdong New District, Zhengzhou City, Henan Province Applicant before: xFusion Digital Technologies Co., Ltd. Country or region before: China |
|
| CB02 | Change of applicant information |