CN111966591A - Dubbo service test method, device and equipment - Google Patents

Dubbo service test method, device and equipment Download PDF

Info

Publication number
CN111966591A
CN111966591A CN202010794273.3A CN202010794273A CN111966591A CN 111966591 A CN111966591 A CN 111966591A CN 202010794273 A CN202010794273 A CN 202010794273A CN 111966591 A CN111966591 A CN 111966591A
Authority
CN
China
Prior art keywords
service
mock
dubbo
real
tag
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010794273.3A
Other languages
Chinese (zh)
Inventor
龚强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Zhongtongji Network Technology Co Ltd
Original Assignee
Shanghai Zhongtongji 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 Shanghai Zhongtongji Network Technology Co Ltd filed Critical Shanghai Zhongtongji Network Technology Co Ltd
Priority to CN202010794273.3A priority Critical patent/CN111966591A/en
Publication of CN111966591A publication Critical patent/CN111966591A/en
Pending legal-status Critical Current

Links

Images

Classifications

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

Abstract

The invention relates to a method, a device and equipment for testing a dubbo service, which comprise the following steps: acquiring information of a target interface; generating a mock service based on the information and a preset mock template; packaging the mock service and starting the mock service; adding a mock service node to a service provider list of the real dubbo service in the zookeeper, and rewriting a method and marking a tag; and acquiring a mock method in the real dubbo service called by the consumer, calling the mock service if the mock method has a tag, and calling the real dubbo service if the mock method does not have the tag. The invention has the beneficial effects that: the mock service can be generated through the information based on the acquired target interface and a preset mock module board without manual coding; and by adding a mock node into the zookeeper, modifying a method and marking a tag, a tester can test each dubbo service independently, the mock can test the required result per se and can also perform comprehensive test on a plurality of serial dubbo services, so that the test efficiency and the service stability are improved.

Description

Dubbo service test method, device and equipment
Technical Field
The invention belongs to the technical field of application testing, and particularly relates to a method, a device and equipment for testing a dubbo service.
Background
In the prior art, most of the applications of most companies are developed based on dubbo, and the stability of dubbo services is important. Currently, there are roughly three categories for dubbo service testing: firstly, a mock test of a dubbo native requires a developer to allocate a mock to a dubbof service and to compile a mock code corresponding to the service, and requires a dubbo service development service to allocate the mock at a service end and to provide a ServiceMock; secondly, a third-party tool is used for installing a plug-in unit for testing, such as a jereter, and only a single dubbo service can be used for mock on the basis of the jereter tool; thirdly, testing by using items such as open source mockuto, easymock, powermock, mockuto and the like, introducing an open source jar packet, and compiling a unit test code or js code; the above-described methods of testing make it difficult for a tester to test a complete case containing multiple dubbo services.
Disclosure of Invention
In order to solve the problem that the prior art cannot test a plurality of dubbo services, the invention provides a method, a device and equipment for testing the dubbo services, which have the characteristics of no need of manual coding, improvement of test efficiency, capability of testing complex test cases comprising a plurality of dubbo service calls and the like.
A method for testing a dubbo service according to an embodiment of the invention comprises the following steps:
acquiring information of a target interface;
generating a mock service based on the information and a preset mock template;
packaging the mock service and starting the mock service;
adding the mock service node to a service provider list of a real dubbo service in a zookeeper, and rewriting a method and tagging a tag;
and acquiring a mock method in the real dubbo service called by a consumer, calling the mock service if the mock method carries the tag, and calling the real dubbo service if the mock method does not carry the tag.
Further, the information of the target interface includes:
the registry address of the real dubbo service.
Further, the information of the target interface further includes:
the service name, method name, participation type and return value of the real dubbo service.
Further, the information of the target interface further includes:
dependent coordinates in the real service pom.xml: groupId, artifactId, and version.
Further, the packaging the mock service and starting the mock service specifically includes:
and calling a maven command to pack the mock service, and calling a Java command to start the mock service.
Further, the preset mock template is a basic dubbo service item with a filter function.
Further, the adding the mock service node to the real dubbo service in a service provider list in a zookeeper, and the rewriting the method and tagging the tag specifically include:
and correspondingly operating the nodes in the zookeeper based on the zkClient.
Further, the starting the mock service further comprises:
and starting the mock service based on a Docker service starting mode.
According to the specific embodiment of the invention, the dubbo service testing device comprises:
the interface information acquisition module is used for acquiring the information of the target interface;
the mock service generation module is used for generating mock service based on the information and a preset mock template;
the mock service starting module is used for packaging the mock service and starting the mock service;
the mock service node adding module is used for adding the mock service node to a service provider list of a real dubbo service in a zookeeper, rewriting a method and marking a tag; and
and the verification module is used for acquiring a mock method in the real dubbo service called by a consumer, calling the mock service if the mock method carries the tag, and calling the real dubbo service if the mock method does not carry the tag.
According to a specific embodiment of the present invention, there is provided an apparatus including:
a processor, and a memory coupled to the processor;
the memory for storing a computer program for at least performing the dubbo service testing method described above;
the processor is used for calling and executing the computer program in the memory.
The invention has the beneficial effects that: the mock service can be generated through the information based on the acquired target interface and a preset mock module board without manual coding; and by adding a mock node into the zookeeper, modifying a method and marking a tag, for a complex test case comprising a plurality of dubbo service calls, a tester can test each dubbo service independently, the mock needs a result per se, and can also perform comprehensive test on a plurality of serial dubbo services, so that the test of the case flow comprising the calls of the plurality of dubbo services is realized, and the test efficiency and the service stability are improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow diagram of a method of Dubbo service testing provided in accordance with an exemplary embodiment;
FIG. 2 is a schematic diagram of a dubbo service test apparatus provided in accordance with an exemplary embodiment;
fig. 3 is a schematic diagram of an apparatus provided in accordance with an example embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be described in detail below. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the examples given herein without any inventive step, are within the scope of the present invention.
Referring to fig. 1, an embodiment of the present invention provides a dubbo service testing method, including the following steps:
101. acquiring information of a target interface;
102. generating a mock service based on the information of the interface and a preset mock template;
103. packaging the mock service and starting the mock service;
104. adding a mock service node to a service provider list of the real dubbo service in the zookeeper, and rewriting a method and marking a tag;
105. and acquiring a mock method in the real dubbo service called by the consumer, calling the mock service if the mock method has a tag, and calling the real dubbo service if the mock method does not have the tag.
Specifically, information of a target interface can be acquired based on data filled in a Web interface, a preset mock template can be synthesized based on a freemarker, the freemarker is a template engine and a general tool for generating other files based on template files, a pure Java is used for writing and generating HTML Web pages, and the mock template refers to a basic dubbo service item and provides a filter function in a specific implementation process; rewriting the contents of a service to be mock in a provider in a zookeeper, wherein the contents comprise a method parameter, after a tag is written in the provider, calling a specified mock method of a dubbo service by a service consumer, calling the mock service if the tag is carried on, and calling the real service if the tag is not carried. The adopted decoupling mode with the dubbo service provider is non-invasive, so that the safety of the test is ensured, and the mock service is dynamically generated according to the template file without manual coding; from the perspective of a service consumer, the test complexity is reduced, and the test efficiency is effectively improved; for a complex test case comprising a plurality of dubbo service calls, a tester can test each dubbo service independently, the mock can test the required result per se, and can also perform comprehensive test on a plurality of serial dubbo services.
In some embodiments of the invention, the information of the target interface comprises:
a registry address (zookeeper) of the real dubbo service;
the service name, method name, participation type and return value of the real dubbo service;
dependent coordinates in real service pom.xml: groupId, artifactId, and version. Wherein the dependency coordinates are the dependencies cited when developing such as:
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.1</version>
</dependency>。
packaging the mock service and starting the mock service specifically comprise: docker can be used for packaging and starting, the Docker is an open-source application container engine, developers can package their applications and rely on the packages to a portable mirror image, and then the application can be distributed to any popular Linux or Windows machine, and virtualization can also be realized. The moven command packed mock service can be called, and the Java command is called to start the mock service.
Adding a mock service node in a service provider list in a zookeeper for real dubbo service, and rewriting the method and tagging the tag can perform corresponding operations on the node in the zookeeper based on zkClient. The zkClient is a simple and efficient Zookeeper Java client, is very convenient for subscribing various events and automatically rebinding the events (session establishment, node modification, node deletion, child node change and the like), can add mock service nodes into the provider list through the zkClient, and can rewrite the method and print tag labels.
In addition, in another embodiment of the present invention, the mock service may also be started based on a manner of Docker starting service. Docker utilizes system resources more efficiently: because the container does not need extra expenses such as hardware virtualization and complete operating system running, the utilization rate of system resources by the Docker is higher. The method is more efficient than the traditional virtual machine technology in terms of application execution speed, memory loss or file storage speed. Therefore, a host with the same configuration can often run a larger number of applications than virtual machine technology.
Based on the same design concept as shown in fig. 2, some embodiments of the present invention further provide a dubbo service testing apparatus, including:
the interface information acquisition module is used for acquiring the information of the target interface;
the mock service generation module is used for generating mock service based on the interface information and a preset mock template;
the mock service starting module is used for packaging the mock service and starting the mock service;
the mock service node adding module is used for adding a mock service node to a service provider list of the real dubbo service in the zookeeper, rewriting a method and marking a tag label; and
and the verification module is used for acquiring a mock method in the real dubbo service called by the consumer, calling the mock service if the mock method has a tag, and calling the real dubbo service if the mock method does not have the tag. For a specific implementation manner of the dubbo service testing apparatus, reference may be made to the specific implementation manner of the dubbo service testing method described above, and details of the present invention are not described herein again.
In order to adapt to the dubbo service testing apparatus provided in the above embodiment of the present invention, the embodiment of the present invention shown in fig. 3 further provides an apparatus, including:
a processor, and a memory coupled to the processor;
the memory is used for storing a computer program, and the computer program is at least used for executing the dubbo service test method in the embodiment;
the processor is used to call and execute the computer program in the memory. The storage medium referred to herein may be a read-only memory, a magnetic or optical disk, or the like.
According to the method, the device and the equipment for testing the dubbo service, provided by the embodiment of the invention, the dubbo interface mock service (comprising the dubbo filter) is generated by collecting the interface information, the generated mock service is started, the real dubbo service zookeeper node information is newly added, the tag label is printed, and the method is rewritten, so that the purposes that a service provider does not need to encode, the invasiveness is avoided, a tester does not need to encode, and the testing difficulty is reduced are achieved; complex test cases containing calls to multiple dubbo services can be tested.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, any use of the term "or" in the specification of the claims is intended to mean a "non-exclusive or".
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (10)

1. A method for testing a dubbo service, comprising:
acquiring information of a target interface;
generating a mock service based on the information and a preset mock template;
packaging the mock service and starting the mock service;
adding the mock service node to a service provider list of a real dubbo service in a zookeeper, and rewriting a method and tagging a tag;
and acquiring a mock method in the real dubbo service called by a consumer, calling the mock service if the mock method carries the tag, and calling the real dubbo service if the mock method does not carry the tag.
2. The dubbo service testing method of claim 1, wherein the information of the target interface comprises:
the registry address of the real dubbo service.
3. The dubbo service testing method of claim 1, wherein the information of the target interface further comprises:
the service name, method name, participation type and return value of the real dubbo service.
4. The dubbo service testing method of claim 1, wherein the information of the target interface further comprises:
dependent coordinates in the real service pom.xml: groupId, artifactId, and version.
5. The dubbo service testing method of claim 1, wherein the packaging the mock service and starting the mock service specifically comprises:
and calling a maven command to pack the mock service, and calling a Java command to start the mock service.
6. The dubbo service test method of claim 1, wherein the preset mock template is a basic dubbo service item with a filter function.
7. The dubbo service testing method of claim 1, wherein the adding the mock service node to the real dubbo service in a service provider list in zookeeper, and the rewriting the method and tagging the tag specifically comprises:
and correspondingly operating the nodes in the zookeeper based on the zkClient.
8. The dubbo service testing method of any of claims 1 to 7, wherein the starting of the mock service further comprises:
and starting the mock service based on a Docker service starting mode.
9. A dubbo service testing arrangement, comprising:
the interface information acquisition module is used for acquiring the information of the target interface;
the mock service generation module is used for generating mock service based on the information and a preset mock template;
the mock service starting module is used for packaging the mock service and starting the mock service;
the mock service node adding module is used for adding the mock service node to a service provider list of a real dubbo service in a zookeeper, rewriting a method and marking a tag; and
and the verification module is used for acquiring a mock method in the real dubbo service called by a consumer, calling the mock service if the mock method carries the tag, and calling the real dubbo service if the mock method does not carry the tag.
10. An apparatus, comprising:
a processor, and a memory coupled to the processor;
the memory for storing a computer program for performing at least the dubbo service testing method of any of claims 1 to 8;
the processor is used for calling and executing the computer program in the memory.
CN202010794273.3A 2020-08-10 2020-08-10 Dubbo service test method, device and equipment Pending CN111966591A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010794273.3A CN111966591A (en) 2020-08-10 2020-08-10 Dubbo service test method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010794273.3A CN111966591A (en) 2020-08-10 2020-08-10 Dubbo service test method, device and equipment

Publications (1)

Publication Number Publication Date
CN111966591A true CN111966591A (en) 2020-11-20

Family

ID=73365408

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010794273.3A Pending CN111966591A (en) 2020-08-10 2020-08-10 Dubbo service test method, device and equipment

Country Status (1)

Country Link
CN (1) CN111966591A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527280A (en) * 2020-12-16 2021-03-19 平安银行股份有限公司 Interface display method and device, server and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010224843A (en) * 2009-03-24 2010-10-07 Fujitsu Ltd Operation confirmation device, system, method and program for test rule for black box test
CN102855178A (en) * 2011-06-30 2013-01-02 阿里巴巴集团控股有限公司 Method and device for generating Mock base during unit test
CN107832217A (en) * 2017-11-09 2018-03-23 政采云有限公司 A kind of automated testing method and device
CN109656807A (en) * 2018-11-01 2019-04-19 平安科技(深圳)有限公司 Interface mock test method, device, equipment and storage medium based on information security
CN111427766A (en) * 2020-02-20 2020-07-17 北京齐尔布莱特科技有限公司 Request processing method and device and proxy server

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010224843A (en) * 2009-03-24 2010-10-07 Fujitsu Ltd Operation confirmation device, system, method and program for test rule for black box test
CN102855178A (en) * 2011-06-30 2013-01-02 阿里巴巴集团控股有限公司 Method and device for generating Mock base during unit test
CN107832217A (en) * 2017-11-09 2018-03-23 政采云有限公司 A kind of automated testing method and device
CN109656807A (en) * 2018-11-01 2019-04-19 平安科技(深圳)有限公司 Interface mock test method, device, equipment and storage medium based on information security
CN111427766A (en) * 2020-02-20 2020-07-17 北京齐尔布莱特科技有限公司 Request processing method and device and proxy server

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
捉虫大师: ""以为是青铜,没想到是王者的dubbo标签路由"", pages 1 - 5, Retrieved from the Internet <URL:《https://juejin.cn/post/6844904122152386568》> *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527280A (en) * 2020-12-16 2021-03-19 平安银行股份有限公司 Interface display method and device, server and readable storage medium
CN112527280B (en) * 2020-12-16 2023-11-07 平安银行股份有限公司 Interface display method, device, server and readable storage medium

Similar Documents

Publication Publication Date Title
CN109976761B (en) Software development kit generation method and device and terminal equipment
US9411568B2 (en) Asynchronous workflows
US9417931B2 (en) Unified metadata for external components
US20080115116A1 (en) Method and apparatus for dynamically binding service component implementations for specific unit test cases
JPH09101883A (en) Object directed communication frame work system and method for constructing plural application programs by using the frame work
US10338952B2 (en) Program execution without the use of bytecode modification or injection
WO2007090817A1 (en) Collaborative classloader system and method
CN111290778A (en) AI model packaging method, platform and electronic equipment
US10083029B2 (en) Detect application defects by correlating contracts in application dependencies
US20090320007A1 (en) Local metadata for external components
US11321090B2 (en) Serializing and/or deserializing programs with serializable state
CN112769706B (en) Componentized routing method and system
CN113010227A (en) Simulation platform implementation method based on model drive
US8516455B2 (en) Dynamic loading of kernel extensions
CN111966591A (en) Dubbo service test method, device and equipment
CN112667305A (en) Page display method and device
CN111580804B (en) Method and device for developing software project
EP4204957A1 (en) Native emulation compatible application binary interface for supporting emulation of foreign code
CN111258802A (en) Method for capturing application program crash information and related equipment
US20230083849A1 (en) Parsing tool for optimizing code for deployment on a serverless platform
CN116243923A (en) Applet processing method and device and electronic equipment
CN115525561A (en) Protocol interface testing method, device, terminal equipment and storage medium
WO2022046229A1 (en) Dual architecture function pointers having consistent reference addresses
CN115997194A (en) Hybrid binary system supporting stream folding
US8135943B1 (en) Method, apparatus, and computer-readable medium for generating a dispatching function

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