CN111338944B - Remote Procedure Call (RPC) interface testing method, device, medium and equipment - Google Patents

Remote Procedure Call (RPC) interface testing method, device, medium and equipment Download PDF

Info

Publication number
CN111338944B
CN111338944B CN202010108845.8A CN202010108845A CN111338944B CN 111338944 B CN111338944 B CN 111338944B CN 202010108845 A CN202010108845 A CN 202010108845A CN 111338944 B CN111338944 B CN 111338944B
Authority
CN
China
Prior art keywords
file
file corresponding
tested
interface definition
identifier
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.)
Active
Application number
CN202010108845.8A
Other languages
Chinese (zh)
Other versions
CN111338944A (en
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 ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network 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 ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010108845.8A priority Critical patent/CN111338944B/en
Publication of CN111338944A publication Critical patent/CN111338944A/en
Application granted granted Critical
Publication of CN111338944B publication Critical patent/CN111338944B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The present disclosure relates to a remote procedure call RPC interface testing method, device, medium and equipment, the method comprising: acquiring an entry file corresponding to a service to be tested of the RPC interface, wherein the entry file contains a plurality of methods of the service to be tested; carrying out grammar analysis on the entry file to obtain dependency relationship representations among a plurality of methods contained in the entry file; acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation, wherein the target method is a method to be tested in a plurality of methods of the service to be tested; and creating a client object in a memory based on an interface definition file corresponding to the target method, so as to test the target method based on the client object. Therefore, the client can be generated without pre-compiling, so that the time consumed by interface testing and the occupation of storage resources can be effectively saved.

Description

Remote Procedure Call (RPC) interface testing method, device, medium and equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a remote procedure call RPC interface testing method, apparatus, medium, and device.
Background
In the related art, when performing service interface test, an RPC (Remote Procedure Call Protocol ) interface is required to test based on an RPC request created by an interface definition. In the prior art, a pre-compiling generation client is generally required, so that a request is initiated at the pre-generated client to test a interface. However, the time spent for compiling the client is relatively long and the memory occupation is relatively large, and the client is inconvenient to maintain.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
In a first aspect, the present disclosure provides a remote procedure call RPC interface testing method, the method comprising:
acquiring an entry file corresponding to a service to be tested of the RPC interface, wherein the entry file contains a plurality of methods of the service to be tested;
Carrying out grammar analysis on the entry file to obtain dependency relationship representations among a plurality of methods contained in the entry file;
acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation, wherein the target method is a method to be tested in a plurality of methods of the service to be tested;
and creating a client object in a memory based on an interface definition file corresponding to the target method, so as to test the target method based on the client object.
In a second aspect, the present disclosure provides a remote procedure call, RPC, interface testing apparatus, the apparatus comprising:
the first acquisition module is used for acquiring an entry file corresponding to the service to be tested of the RPC interface, wherein the entry file contains a plurality of methods of the service to be tested;
the analysis module is used for carrying out grammar analysis on the entry file and obtaining dependency relationship representations among a plurality of methods contained in the entry file;
the second acquisition module is used for acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation, wherein the target method is a method to be tested in a plurality of methods of the service to be tested;
And the creation module is used for creating a client object in the memory based on the interface definition file corresponding to the target method so as to test the target method based on the client object.
In a third aspect, the present disclosure provides a computer readable medium having stored thereon a computer program which when executed by a processing device performs the steps of the method of the first aspect.
In a fourth aspect, the present disclosure provides an electronic device comprising:
a storage device having a computer program stored thereon;
processing means for executing said computer program in said storage means to carry out the steps of the method of the first aspect.
In the technical scheme, through acquiring an entry file corresponding to the service to be tested of the RPC interface, carrying out grammar analysis on the entry file to obtain dependency relationship expression among a plurality of methods contained in the entry file; acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation; and creating a client object in a memory based on an interface definition file corresponding to the target method, so as to test the target method based on the client object. Therefore, by the technical scheme, the client object is created in the memory based on the interface definition file, and the client can be generated without pre-compiling, so that the time consumed by the interface test and the occupation of storage resources can be effectively saved. In addition, the client object can be directly read from the memory without creating an additional client process to communicate, so that the complexity of interface test is effectively simplified, and the test efficiency and accuracy can be improved.
Additional features and advantages of the present disclosure will be set forth in the detailed description which follows.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
In the drawings:
FIG. 1 is a flow chart of a remote procedure call, RPC, interface test method provided in accordance with one embodiment of the present disclosure;
FIG. 2 is a flowchart of an exemplary embodiment of obtaining an interface definition file corresponding to a target method in a service under test according to a dependency representation provided in accordance with one embodiment of the present disclosure;
FIG. 3 is a block diagram of a remote procedure call RPC interface test apparatus provided according to one embodiment of the present disclosure;
fig. 4 is a schematic structural view of an electronic device provided according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
As described in the background section above, the applicant has found that, in the prior art, when testing an RPC interface, it is necessary to compile in advance each method based on a service to be tested in the RPC interface to generate a large number of clients for testing, for example, creating clients using a thraft-gen. The client comprises a method needing to be tested and a method needing to be tested. And when testing the RPC interface based on the pre-generated client, an additional process needs to be created to enable the client to interact with the test platform, so that the consumption of time and memory is high. Based on the above, the applicant provides the following technical scheme to effectively reduce the occupation of time and memory when performing the RPC interface test.
Fig. 1 is a flow chart of a remote procedure call RPC interface testing method provided according to one embodiment of the present disclosure. As shown in fig. 1, the method includes:
in S11, an entry file corresponding to a service to be tested of the RPC interface is obtained, where the entry file includes a plurality of methods of the service to be tested.
The entry file may be an Import file corresponding to the RPC interface, and the entry file may be specified by a service person, for example, an absolute path of the entry file is specified, so that the position of the entry file may be determined through the absolute path, and the entry file may be further obtained. The method to be tested can be imported based on the entry file.
In S12, the entry file is parsed to obtain a dependency relationship expression between a plurality of methods included in the entry file.
The entry file may be parsed by a syntax parser that obtains a dependency representation by performing dependency syntax analysis to output dependencies of each method therein. The dependency syntax analysis is a common method in the art, and is not described herein.
In S13, according to the dependency relationship representation, an interface definition file corresponding to a target method in the service to be tested is obtained, where the target method is a method to be tested in the multiple methods of the service to be tested.
The RPC interface is generally created by adopting an IDL (Interface description language ), and an interface definition file corresponding to the method, that is, a corresponding IDL file, is used for describing related information of the interface, such as a return value, a parameter, a name, and the like. Based on the interface definition file, information of a corresponding method can be obtained, so that the method can be tested.
In an embodiment, the target method may be all methods in the RPC interface, and the corresponding interface definition file may be obtained according to each method to be tested. In another embodiment, the target method may be a part of methods in the RPC interface, so in this embodiment, only the corresponding interface definition file of the method to be tested is needed to be obtained, and for the method in the RPC interface that does not need to be tested, the corresponding interface definition file is not needed to be obtained, thereby the number of interface definition files can be effectively reduced, resource waste caused by obtaining unnecessary interface definition files is avoided, file importing according to needs is realized, and interface testing efficiency is improved.
In S14, a client object is created in the memory based on the interface definition file corresponding to the target method, so as to test the target method based on the client object.
After the interface definition file corresponding to the target method is acquired, the interface definition file can be imported into the test platform, so that the client object can be created in the memory through nodeJS in the test platform. In the related art, however, it is necessary to compile each method in accordance with the service to be tested to generate a file, i.e., a local client. When the interface test is performed, a process is required to be created by the local client so as to interact with the test platform to realize the test. In this disclosure, only an object is needed to be created in the memory according to the method to be tested, and the object is used to initiate the connection and parse request, i.e. the client object. Because the client object is created in the memory, when the target method is tested according to the client object, no additional client process or execution file needs to be created, and the client object initiation request can be directly read from the memory to perform the test, for example, the request can be initiated based on the client object carrying the object identifier, so that the interface is tested through the record delay, wherein the test based on the initiated request is a common choice in the art and is not described herein.
In the technical scheme, through acquiring an entry file corresponding to the service to be tested of the RPC interface, carrying out grammar analysis on the entry file to obtain dependency relationship expression among a plurality of methods contained in the entry file; acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation; and creating a client object in a memory based on an interface definition file corresponding to the target method, so as to test the target method based on the client object. Therefore, by the technical scheme, the client object is created in the memory based on the interface definition file, and the client can be generated without pre-compiling, so that the time consumed by the interface test and the occupation of storage resources can be effectively saved. In addition, the client object can be directly read from the memory without creating an additional client process to communicate, so that the complexity of interface test is effectively simplified, and the test efficiency and accuracy can be improved.
Optionally, the dependency relationship is expressed as an abstract syntax tree (Abstract Syntax Tree, AST), in S13, according to the dependency relationship expression, an exemplary embodiment of obtaining an interface definition file corresponding to a target method in a service to be tested is as follows, as shown in fig. 2, and this step may include:
In S21, the identity of each dependency file required for executing the target method is determined according to an abstract syntax tree generated according to the dependency relationship of each method of the service to be tested.
The way to generate the abstract syntax tree is the prior art, and is not described herein. In the step, the dependency relationships among the methods of the service to be tested are represented through the abstract syntax tree, so that each dependency file of the target method can be rapidly determined based on the tree structure of the abstract syntax tree. By way of example, the dependency file may be a description file of the interfaces/methods on which the target method is dependent when executing. For example, if the execution of the target method a requires execution of the method B and the execution of the method B requires execution of the method C, the dependent files of the target method a are description files corresponding to the methods A, B, C respectively.
It should be noted that, the description file of the target method itself also belongs to one of the corresponding dependency files. Each dependency file required by the target method can be rapidly positioned based on the dependency relationship among the methods based on the grammar abstract tree, and the identification of each dependency file is further obtained. Wherein the identity of each dependent file can be determined recursively based on the abstract syntax tree.
In S22, according to the identifier of each dependent file, an interface definition file corresponding to the target method is obtained.
In one embodiment, the corresponding file may be pulled from the GIT repository based on the identity of each dependent file. Wherein the GIT repository is an open-source distributed version control system that can efficiently handle very large to very small project version management at high speed. The staff can submit the written interface files to the GIT warehouse, so that each interface definition file can be obtained from the GIT warehouse, and the interface definition files are convenient to carry out version control.
Optionally, in another embodiment, in S22, according to the identification of the dependent file, an exemplary implementation manner of obtaining the interface definition file corresponding to the target method is as follows, where the steps may include:
querying the identification of the dependent file from the cache system. The buffer system may be coupled to a test platform for performing RPC interface test, or may be independent of the test platform, which is not limited in this disclosure. Optionally, the cache system may be a system based on a distributed cache, for example, a dis database, so that consistency of file versions may be achieved based on synchronization of the distributed cache, and technical support is provided for accuracy of interface testing.
If the identifier is queried and the version information of the dependent file is the same as the version information of the file corresponding to the identifier in the cache system, determining the file corresponding to the identifier in the cache system as an interface definition file corresponding to the target method.
As an example, the identifier is queried from the cache system, and then the dependent file corresponding to the identifier is indicated to be stored in the cache system. Since version control is performed on the dependent file, in order to ensure that the version of the dependent file is the latest version, the latest version number of the dependent file may be determined as version information of the dependent file when the dependent file is determined.
Wherein, the version information of the dependent file can be updated when the GIT warehouse is updated. For example, after the worker updates the interface code, the updated file is submitted to the GIT repository, and at this time, the GIT repository may update the version information of the dependent file at the same time, i.e., determine the version information of the newly submitted file as the version information of the dependent file.
In another embodiment, the latest version information of each file may also be requested from the GIT repository at regular time, and the requested version information may be determined as the version information of the corresponding dependent file.
Therefore, when the identifier is queried from the cache system, it is required to determine whether the version information of the file corresponding to the identifier in the cache system is the same as the version information of the dependent file, that is, whether the file corresponding to the identifier in the cache system is the latest version. If the file and the file are the same, the file in the cache system is the latest version, and the file can be directly read from the cache system, so that the file pulling time is saved, and the testing efficiency is improved.
And if the identifier is not queried, requesting a file corresponding to the identifier from a distributed version control system GIT warehouse, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method.
In this embodiment, if the identification is not queried, it indicates that the dependent file is not present in the cache system, and at this time, a request is required to the GIT repository to pull the dependent file from the GIT repository. The submitting and pulling of the file through the GIT repository may be performed by related commands in the prior art, such as a commit command, which is not described herein.
In the above technical solution, when the interface definition file corresponding to the target method is acquired, it is first determined whether a file of a corresponding version exists in the cache system, and if so, the file can be directly acquired from the cache system; if not, the pull file may be requested from the GIT repository. Therefore, by the technical scheme, when the interface definition file corresponding to the target method is acquired, the cache system can be read preferentially, so that the file pulling efficiency can be improved, the pressure of the GIT warehouse can be effectively reduced, and meanwhile, the consistency of file versions can be ensured.
Optionally, in S22, according to the identification of the dependent file, another exemplary implementation manner of obtaining the interface definition file corresponding to the target method is as follows, where the step may further include:
if the identifier is queried and the version information of the dependent file is different from the version information of the file corresponding to the identifier in the cache system, requesting the file corresponding to the identifier from a GIT warehouse, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method.
If the version information of the dependent file is different from the version information of the file corresponding to the identifier in the cache system, it indicates that the file corresponding to the identifier in the cache system is not the latest version, and at this time, the file corresponding to the identifier needs to be requested from the GIT repository, so as to avoid the influence of file version errors on the interface test.
And updating the file corresponding to the identifier in the cache system according to the file corresponding to the identifier requested from the GIT warehouse.
As an example, the file corresponding to the identifier in the cache system may be directly deleted, and the file corresponding to the identifier requested from the GIT repository may be saved in the cache system, so as to implement replacement update. As another example, delta updates may be performed by comparing the file corresponding to the identification requested from the GIT repository with the file corresponding to the identification in the cache system.
Therefore, through the technical scheme, the accuracy of the interface definition file corresponding to the target method can be ensured, the accuracy of the interface test can be ensured, and the real-time version of each file in the cache system can be ensured, so that the problems that the client is not easy to maintain and is not updated timely in the prior art can be effectively avoided. Meanwhile, the file is acquired based on the cache system, so that the cache and the file pulling are separated from a command line, a local deployment client is not needed, the method can be deployed in a cloud cluster, and the application range of the method is effectively widened.
Optionally, after the step of obtaining the interface definition file corresponding to the target method in the service to be tested in S13, the method may further include:
if the interface definition file does not exist in the cache system, the interface definition file, and the identification and version information corresponding to the interface definition file are stored in the cache system.
As an example, when the interface definition file is acquired for the first time, since no interface definition file is stored in the cache system at this time, the acquired interface definition file and the corresponding identifier and version information thereof may be directly stored in the cache system at this time.
As another example, when the interface definition file is acquired after the first time, it may be determined whether the acquired interface definition file is in the cache system, and if not, the acquired interface definition file and the identifier and version information corresponding to the acquired interface definition file may be stored in the cache system. For example, when the identifier is not queried in the cache system as described above, after the file corresponding to the identifier is requested from the distributed version control system GIT repository, the obtained interface definition file and the identifier and version information corresponding to the obtained interface definition file may be directly stored in the cache system.
Through the technical scheme, the interface definition file and the identification and version information corresponding to the interface definition file are stored in the cache system, so that the file can be obtained from the cache system, the instantaneity and the comprehensiveness of the file in the cache system can be ensured, the pressure on the GIT warehouse when the file is pulled can be effectively relieved, and the efficiency of interface test can be improved.
The present disclosure also provides a remote procedure call RPC interface testing apparatus, as shown in fig. 3, the apparatus 10 includes:
the first obtaining module 100 is configured to obtain an entry file corresponding to a service to be tested of the RPC interface, where the entry file includes a plurality of methods of the service to be tested;
The parsing module 200 is configured to parse the entry file to obtain a dependency relationship representation between a plurality of methods included in the entry file;
the second obtaining module 300 is configured to obtain, according to the dependency relationship representation, an interface definition file corresponding to a target method in the service to be tested, where the target method is a method to be tested in the multiple methods of the service to be tested;
the creating module 400 is configured to create a client object in the memory based on the interface definition file corresponding to the target method, so as to test the target method based on the client object.
Optionally, the dependency is expressed as an abstract syntax tree, and the second obtaining module includes:
a determining submodule, configured to determine, according to the abstract syntax tree, an identifier of each dependency file required for executing the target method, where the abstract syntax tree is generated according to a dependency relationship of each method of the service to be tested;
and the acquisition sub-module is used for acquiring the interface definition file corresponding to the target method according to the identification of each dependent file.
Optionally, the acquiring submodule includes:
The inquiring submodule is used for inquiring the identification of the dependent file from the cache system;
a second determining submodule, configured to determine, if the identifier is queried and version information of the dependent file is the same as version information of a file corresponding to the identifier in the cache system, a file corresponding to the identifier in the cache system as an interface definition file corresponding to the target method;
and the first request submodule is used for requesting the file corresponding to the identifier from a distributed version control system GIT warehouse if the identifier is not queried, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method.
Optionally, the acquiring sub-module further includes:
the second request submodule is used for requesting the file corresponding to the identifier from the GIT warehouse if the identifier is queried and the version information of the dependent file is different from the version information of the file corresponding to the identifier in the cache system, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method;
and the updating sub-module is used for updating the file corresponding to the identifier in the cache system according to the file corresponding to the identifier requested from the GIT warehouse.
Optionally, the apparatus further comprises:
and the storage module is used for storing the interface definition file, the identification corresponding to the interface definition file and version information into the cache system if the interface definition file does not exist in the cache system after the second acquisition module acquires the interface definition file corresponding to the target method in the service to be tested.
Optionally, the cache system is a distributed cache based system.
Referring now to fig. 4, a schematic diagram of an electronic device 600 suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 4 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 4, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 4 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 601.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having 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 portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring an entry file corresponding to a service to be tested of the RPC interface, wherein the entry file contains a plurality of methods of the service to be tested; carrying out grammar analysis on the entry file to obtain dependency relationship representations among a plurality of methods contained in the entry file; acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation, wherein the target method is a method to be tested in a plurality of methods of the service to be tested; and creating a client object in a memory based on an interface definition file corresponding to the target method, so as to test the target method based on the client object. .
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including, but not limited to, an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented in software or hardware. The name of the module is not limited to the module itself in some cases, for example, the first obtaining module may also be described as "a module for obtaining an entry file corresponding to a service to be tested of the RPC interface".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
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. The 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 portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In accordance with one or more embodiments of the present disclosure, example 1 provides a remote procedure call, RPC, interface testing method comprising:
acquiring an entry file corresponding to a service to be tested of the RPC interface, wherein the entry file contains a plurality of methods of the service to be tested;
carrying out grammar analysis on the entry file to obtain dependency relationship representations among a plurality of methods contained in the entry file;
acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation, wherein the target method is a method to be tested in a plurality of methods of the service to be tested;
and creating a client object in a memory based on an interface definition file corresponding to the target method, so as to test the target method based on the client object.
According to one or more embodiments of the present disclosure, example 2 provides the method of example 1, wherein the dependency relationship is represented as an abstract syntax tree, and the obtaining, according to the dependency relationship representation, an interface definition file corresponding to the target method in the service to be tested includes:
determining the identification of each dependency file required for executing the target method according to the abstract syntax tree, wherein the abstract syntax tree is generated according to the dependency relationship of each method of the service to be tested;
And acquiring an interface definition file corresponding to the target method according to the identification of each dependent file.
According to one or more embodiments of the present disclosure, example 3 provides the method of example 2, wherein the obtaining, according to the identification of the dependency file, an interface definition file corresponding to the target method includes:
querying the identification of the dependent file from a cache system;
if the identifier is queried and the version information of the dependent file is the same as the version information of the file corresponding to the identifier in the cache system, determining the file corresponding to the identifier in the cache system as an interface definition file corresponding to the target method;
and if the identifier is not queried, requesting a file corresponding to the identifier from a distributed version control system GIT warehouse, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method.
According to one or more embodiments of the present disclosure, example 4 provides the method of example 3, wherein the obtaining, according to the identification of the dependency file, an interface definition file corresponding to the target method further includes:
if the identifier is queried and the version information of the dependent file is different from the version information of the file corresponding to the identifier in the cache system, requesting the file corresponding to the identifier from a GIT warehouse, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method;
And updating the file corresponding to the identifier in the cache system according to the file corresponding to the identifier requested from the GIT warehouse.
According to one or more embodiments of the present disclosure, example 5 provides the method of example 1, wherein, after the step of obtaining the interface definition file corresponding to the target method in the service to be tested, the method further includes:
if the interface definition file does not exist in the cache system, the interface definition file, and the identification and version information corresponding to the interface definition file are stored in the cache system.
In accordance with one or more embodiments of the present disclosure, example 6 provides the method of any one of examples 3-5, wherein the cache system is a distributed cache-based system.
Example 7 provides a remote procedure call, RPC, interface testing apparatus according to one or more embodiments of the present disclosure, the apparatus comprising:
the first acquisition module is used for acquiring an entry file corresponding to the service to be tested of the RPC interface, wherein the entry file contains a plurality of methods of the service to be tested;
the analysis module is used for carrying out grammar analysis on the entry file and obtaining dependency relationship representations among a plurality of methods contained in the entry file;
The second acquisition module is used for acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation, wherein the target method is a method to be tested in a plurality of methods of the service to be tested;
and the creation module is used for creating a client object in the memory based on the interface definition file corresponding to the target method so as to test the target method based on the client object.
According to one or more embodiments of the present disclosure, example 8 provides the apparatus of example 7, wherein the dependency relationship is represented as an abstract syntax tree, and the second obtaining module comprises:
a determining submodule, configured to determine, according to the abstract syntax tree, an identifier of each dependency file required for executing the target method, where the abstract syntax tree is generated according to a dependency relationship of each method of the service to be tested;
and the acquisition sub-module is used for acquiring the interface definition file corresponding to the target method according to the identification of each dependent file.
According to one or more embodiments of the present disclosure, example 9 provides the apparatus of example 8, wherein the acquisition sub-module comprises:
The inquiring submodule is used for inquiring the identification of the dependent file from the cache system;
a second determining submodule, configured to determine, if the identifier is queried and version information of the dependent file is the same as version information of a file corresponding to the identifier in the cache system, a file corresponding to the identifier in the cache system as an interface definition file corresponding to the target method;
and the first request submodule is used for requesting the file corresponding to the identifier from a distributed version control system GIT warehouse if the identifier is not queried, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method.
According to one or more embodiments of the present disclosure, example 10 provides the apparatus of example 9, wherein the acquisition sub-module further comprises:
the second request submodule is used for requesting the file corresponding to the identifier from the GIT warehouse if the identifier is queried and the version information of the dependent file is different from the version information of the file corresponding to the identifier in the cache system, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method;
And the updating sub-module is used for updating the file corresponding to the identifier in the cache system according to the file corresponding to the identifier requested from the GIT warehouse.
Example 11 provides the apparatus of example 7, according to one or more embodiments of the disclosure, wherein the apparatus further comprises:
and the storage module is used for storing the interface definition file, the identification corresponding to the interface definition file and version information into the cache system if the interface definition file does not exist in the cache system after the second acquisition module acquires the interface definition file corresponding to the target method in the service to be tested.
Example 12 provides the apparatus of any one of examples 9-11, wherein the cache system is a distributed cache-based system, according to one or more embodiments of the present disclosure.
Example 13 provides a computer-readable medium having stored thereon a computer program that, when executed by a processing device, performs the steps of a remote procedure call, RPC, interface testing method, according to one or more embodiments of the present disclosure.
Example 14 provides an electronic device according to one or more embodiments of the present disclosure, comprising:
A storage device having a computer program stored thereon;
and the processing device is used for executing the computer program in the storage device to realize the steps of Remote Procedure Call (RPC) interface test method.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims. The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.

Claims (10)

1. A remote procedure call, RPC, interface testing method, the method comprising:
acquiring an entry file corresponding to a service to be tested of the RPC interface, wherein the entry file contains a plurality of methods of the service to be tested;
carrying out grammar analysis on the entry file to obtain dependency relationship representations among a plurality of methods contained in the entry file;
acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation, wherein the target method is a method to be tested in a plurality of methods of the service to be tested;
And creating a client object in a memory based on an interface definition file corresponding to the target method, so as to test the target method based on the client object.
2. The method according to claim 1, wherein the dependency relationship is represented as an abstract syntax tree, and the obtaining, according to the dependency relationship representation, an interface definition file corresponding to the target method in the service to be tested includes:
determining the identification of each dependency file required for executing the target method according to the abstract syntax tree, wherein the abstract syntax tree is generated according to the dependency relationship of each method of the service to be tested;
and acquiring an interface definition file corresponding to the target method according to the identification of each dependent file.
3. The method according to claim 2, wherein the obtaining the interface definition file corresponding to the target method according to the identification of the dependent file includes:
querying the identification of the dependent file from a cache system;
if the identifier is queried and the version information of the dependent file is the same as the version information of the file corresponding to the identifier in the cache system, determining the file corresponding to the identifier in the cache system as an interface definition file corresponding to the target method;
And if the identifier is not queried, requesting a file corresponding to the identifier from a distributed version control system GIT warehouse, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method.
4. The method of claim 3, wherein the obtaining the interface definition file corresponding to the target method according to the identification of the dependent file further includes:
if the identifier is queried and the version information of the dependent file is different from the version information of the file corresponding to the identifier in the cache system, requesting the file corresponding to the identifier from a GIT warehouse, and determining the file corresponding to the identifier which is requested as an interface definition file corresponding to the target method;
and updating the file corresponding to the identifier in the cache system according to the file corresponding to the identifier requested from the GIT warehouse.
5. The method according to claim 1, wherein after the step of obtaining an interface definition file corresponding to a target method in the service to be tested, the method further comprises:
if the interface definition file does not exist in the cache system, the interface definition file, and the identification and version information corresponding to the interface definition file are stored in the cache system.
6. The method of any of claims 3-5, wherein the cache system is a distributed cache-based system.
7. A remote procedure call, RPC, interface testing apparatus, the apparatus comprising:
the first acquisition module is used for acquiring an entry file corresponding to the service to be tested of the RPC interface, wherein the entry file contains a plurality of methods of the service to be tested;
the analysis module is used for carrying out grammar analysis on the entry file and obtaining dependency relationship representations among a plurality of methods contained in the entry file;
the second acquisition module is used for acquiring an interface definition file corresponding to a target method in the service to be tested according to the dependency relationship representation, wherein the target method is a method to be tested in a plurality of methods of the service to be tested;
and the creation module is used for creating a client object in the memory based on the interface definition file corresponding to the target method so as to test the target method based on the client object.
8. The apparatus of claim 7, wherein the dependency relationship is represented as an abstract syntax tree, and wherein the second obtaining module comprises:
A first determining submodule, configured to determine, according to the abstract syntax tree, an identifier of each dependency file required for executing the target method, where the abstract syntax tree is generated according to a dependency relationship of each method of the service to be tested;
and the acquisition sub-module is used for acquiring the interface definition file corresponding to the target method according to the identification of each dependent file.
9. A computer readable medium on which a computer program is stored, characterized in that the program, when being executed by a processing device, carries out the steps of the method according to any one of claims 1-6.
10. An electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing said computer program in said storage means to carry out the steps of the method according to any one of claims 1-6.
CN202010108845.8A 2020-02-21 2020-02-21 Remote Procedure Call (RPC) interface testing method, device, medium and equipment Active CN111338944B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010108845.8A CN111338944B (en) 2020-02-21 2020-02-21 Remote Procedure Call (RPC) interface testing method, device, medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010108845.8A CN111338944B (en) 2020-02-21 2020-02-21 Remote Procedure Call (RPC) interface testing method, device, medium and equipment

Publications (2)

Publication Number Publication Date
CN111338944A CN111338944A (en) 2020-06-26
CN111338944B true CN111338944B (en) 2023-09-08

Family

ID=71184658

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010108845.8A Active CN111338944B (en) 2020-02-21 2020-02-21 Remote Procedure Call (RPC) interface testing method, device, medium and equipment

Country Status (1)

Country Link
CN (1) CN111338944B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113760707A (en) * 2020-09-23 2021-12-07 北京沃东天骏信息技术有限公司 Interface testing method, device, equipment and computer readable storage medium
CN112782560A (en) * 2020-12-31 2021-05-11 海光信息技术股份有限公司 Chip testing method, device, storage medium and equipment
CN113645090B (en) * 2021-06-30 2022-08-26 四川新网银行股份有限公司 Novel RPC interface simulation test method

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5812851A (en) * 1995-03-29 1998-09-22 Sun Microsystems, Inc. Compiler with generic front end and dynamically loadable back ends
CN101017447A (en) * 2007-02-13 2007-08-15 华为技术有限公司 IDE calling device and calling method therefor
CN101719902A (en) * 2009-12-04 2010-06-02 深圳创维数字技术股份有限公司 Remote procedure calling (PRC) method and system
CN101873323A (en) * 2010-06-21 2010-10-27 南京邮电大学 Web service platform based on program slicing technique
CN104035859A (en) * 2013-03-07 2014-09-10 腾讯科技(深圳)有限公司 Visualized automatic testing method and system thereof
CN106294177A (en) * 2016-08-22 2017-01-04 腾讯科技(深圳)有限公司 The method for testing pressure of a kind of interface and test equipment
CN106919509A (en) * 2017-03-09 2017-07-04 腾讯科技(深圳)有限公司 A kind of client generation method, device and electronic equipment
CN107704398A (en) * 2017-11-01 2018-02-16 网易(杭州)网络有限公司 Automated testing method and device, storage medium, electronic equipment
CN110069259A (en) * 2019-03-04 2019-07-30 北京三快在线科技有限公司 Analytic method, device, electronic equipment and storage medium based on idl file
US10452522B1 (en) * 2015-06-19 2019-10-22 Amazon Technologies, Inc. Synthetic data generation from a service description language model
CN110489323A (en) * 2019-07-09 2019-11-22 北京字节跳动网络技术有限公司 Visual RPC API adjustment method, device, medium and equipment
CN110806967A (en) * 2018-08-06 2020-02-18 北京京东尚科信息技术有限公司 Unit testing method and device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7366734B2 (en) * 2004-12-25 2008-04-29 Oracle International Corporation Enabling client systems to discover services accessible by remote procedure calls (RPC) on server systems
EP2088506A1 (en) * 2008-02-06 2009-08-12 Software AG Method and system for calling services from a remote client
US20090282136A1 (en) * 2008-05-08 2009-11-12 Oracle International Corporation Automatic Generation of Web Service client for Web Services Interoperability Testing
US9015672B2 (en) * 2012-01-31 2015-04-21 The United States Of America As Represented By The Secretary Of The Navy Interface simulator for test rig in data distribution service
US9699249B2 (en) * 2014-12-05 2017-07-04 Vmware, Inc. Runtime generation of application programming interfaces for remote procedure call services

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5812851A (en) * 1995-03-29 1998-09-22 Sun Microsystems, Inc. Compiler with generic front end and dynamically loadable back ends
CN101017447A (en) * 2007-02-13 2007-08-15 华为技术有限公司 IDE calling device and calling method therefor
CN101719902A (en) * 2009-12-04 2010-06-02 深圳创维数字技术股份有限公司 Remote procedure calling (PRC) method and system
CN101873323A (en) * 2010-06-21 2010-10-27 南京邮电大学 Web service platform based on program slicing technique
CN104035859A (en) * 2013-03-07 2014-09-10 腾讯科技(深圳)有限公司 Visualized automatic testing method and system thereof
US10452522B1 (en) * 2015-06-19 2019-10-22 Amazon Technologies, Inc. Synthetic data generation from a service description language model
CN106294177A (en) * 2016-08-22 2017-01-04 腾讯科技(深圳)有限公司 The method for testing pressure of a kind of interface and test equipment
CN106919509A (en) * 2017-03-09 2017-07-04 腾讯科技(深圳)有限公司 A kind of client generation method, device and electronic equipment
CN107704398A (en) * 2017-11-01 2018-02-16 网易(杭州)网络有限公司 Automated testing method and device, storage medium, electronic equipment
CN110806967A (en) * 2018-08-06 2020-02-18 北京京东尚科信息技术有限公司 Unit testing method and device
CN110069259A (en) * 2019-03-04 2019-07-30 北京三快在线科技有限公司 Analytic method, device, electronic equipment and storage medium based on idl file
CN110489323A (en) * 2019-07-09 2019-11-22 北京字节跳动网络技术有限公司 Visual RPC API adjustment method, device, medium and equipment

Also Published As

Publication number Publication date
CN111338944A (en) 2020-06-26

Similar Documents

Publication Publication Date Title
CN111338944B (en) Remote Procedure Call (RPC) interface testing method, device, medium and equipment
CN110391938B (en) Method and apparatus for deploying services
CN111367516B (en) Application interface generation method and device and electronic equipment
CN111324342B (en) Method, device, medium and electronic equipment for generating interface layer code
CN112395253B (en) Index file generation method, terminal device, electronic device and medium
CN111930534A (en) Data calling method and device and electronic equipment
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN111666293A (en) Database access method and device
CN116860286A (en) Page dynamic update method, device, electronic equipment and computer readable medium
CN113468342B (en) Knowledge graph-based data model construction method, device, equipment and medium
CN112422648B (en) Data synchronization method and system
CN111414161B (en) Method, device, medium and electronic equipment for generating IDL file
CN109669720B (en) Chain type asynchronous request processing method and device based on Promise and electronic equipment
CN113419740A (en) Program data stream analysis method and device, electronic device and readable storage medium
CN112596729A (en) Target application interface generation method and device, readable medium and electronic equipment
CN112328841A (en) Document processing method and device, electronic equipment and storage medium
CN111581305B (en) Feature processing method, device, electronic equipment and medium
CN111399902B (en) Client source file processing method and device, readable medium and electronic equipment
CN114253520B (en) Interface code generation method and device
CN111625232B (en) Method and device for generating application program installation package, readable medium and electronic equipment
CN114040014B (en) Content pushing method, device, electronic equipment and computer readable storage medium
CN112860268B (en) Method and device for hot deployment of templates
CN112988528B (en) Log processing method, device and container group
CN110750242B (en) File deployment method, system, medium and electronic equipment
CN116932123A (en) Method and device for displaying small component page

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
GR01 Patent grant
GR01 Patent grant