Dubbo service testing system and method

Through the Dubbo service testing system, users can select interfaces, scripts and environments on the browser page to achieve fast switching and cross-environment assertion comparison, solving the problems of low testing efficiency and slow environment switching in the existing technology, and improving the testing Efficiency and flexibility.

CN113377680BActive Publication Date: 2024-12-06INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110793439.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-14
Publication Date
2024-12-06
Estimated Expiration
2041-07-14

AI Technical Summary

Technical Problem

The existing Dubbo service testing method is inefficient, requires the container to be started every time, and the environment switching and data assertion comparison are not efficient, so cross-environment data comparison cannot be achieved.

Method used

A Dubbo service testing system has been designed, including a browser, a unified access server, a management server, an auxiliary server and a proxy server. Through HTTP+Dubbo proxy service, users can select service interfaces, test scripts and environments through the browser page to perform Dubbo service testing, implements fast environment switching and cross-environment data assertion comparison.

Benefits of technology

It realizes that testing can be performed without IDE writing scripts, quickly switch environments, improves testing efficiency, supports unlimited run of test scripts, and solves the problems of slow startup, slow environment switching and cross-environment data assertion processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113377680B_ABST
    Figure CN113377680B_ABST
Patent Text Reader

Abstract

The present invention discloses a Dubbo service testing system and method, which includes: a browser is used to provide users with service interface selection, test script selection and test environment selection, and display service results; a unified access server is used to call a management server, a proxy server or an auxiliary server according to the service interface, the test script and the test environment to perform corresponding processing, and receive and process the service results returned by the management server, the proxy server or the auxiliary server; the management server is used to manage the service interface, the test script and the test environment; the auxiliary server is used to obtain dynamic parameters based on the test script and identify the assertion logic of the test script; the proxy server is used to perform Dubbo service testing based on the service interface, the test script and the test environment. The present invention solves the problems of slow startup of Dubbo service test scripts, slow direct switching between different environments, and inability to assert cross-environment data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed service testing technology, and in particular to a Dubbo service testing system and method. Background Art

[0002] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by inclusion in this section.

[0003] Currently, the testing of the distributed service framework Dubbo is usually carried out using Java test components such as TestNg. The disadvantage of this testing method is that the Dubbo container needs to be started every time the test script is run. If it is a large project, the corresponding test project will also be very large. Each time the test script is executed, it takes more than 1 minute to start the Dubbo container, which is too inefficient. In addition, for different test environments, the code flow of the test project needs to be switched to complete the environment switching, which is too inefficient and cannot achieve data assertion comparison between different environments. Summary of the invention

[0004] An embodiment of the present invention provides a Dubbo service testing system, the system comprising:

[0005] Browser, unified access server, management server, auxiliary server, proxy server and;

[0006] The browser is used to: provide users with service interface selection, test script selection, and test environment selection, and display service results to users;

[0007] The unified access server is used to: determine the call of the management server, proxy server or auxiliary server for corresponding processing according to the service interface, test script and test environment selected by the user, and receive and process the service results returned by the management server, proxy server or auxiliary server;

[0008] The management server is used to: manage service interfaces, test scripts, and test environments;

[0009] The auxiliary server is used to: obtain dynamic parameters based on the test script and identify the assertion logic of the test script;

[0010] The proxy server is used to connect to the Dubbo server and perform Dubbo service testing based on the service interface, test scripts, and test environment.

[0011] The embodiment of the present invention also provides a Dubbo service testing method, the method comprising:

[0012] The user selects the service interface, test script and test environment through the browser;

[0013] The unified access server determines to call the management server, proxy server or auxiliary server for corresponding processing according to the service interface, test script and test environment selected by the user;

[0014] The management server manages the service interface, test scripts and test environment;

[0015] The auxiliary server obtains dynamic parameters based on the test script and identifies the assertion logic of the test script;

[0016] The proxy server connects to the Dubbo server and performs Dubbo service testing based on the service interface, test scripts, and test environment;

[0017] The unified access server receives and processes the service results returned by the management server, proxy server or auxiliary server.

[0018] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned Dubbo service testing method when executing the computer program.

[0019] An embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the above-mentioned Dubbo service testing method are implemented.

[0020] In the embodiment of the present invention, based on HTTP+Dubbo proxy service, the test can be initiated through the browser page, without using IDE to write scripts and start the Dubbo container. The environment can be quickly switched through the interface selection box without using the switching code flow. Different environments can be selected, transactions can be initiated using the same message, and assertions can be compared on transaction results in different environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0022] Figure 1 This is a structural block diagram of the Dubbo service test system in an embodiment of the present invention;

[0023] Figure 2 This is a structural block diagram of a unified access server in an embodiment of the present invention;

[0024] Figure 3 This is a structural block diagram of a management server in an embodiment of the present invention;

[0025] Figure 4 This is a structural block diagram of an auxiliary server in an embodiment of the present invention;

[0026] Figure 5 It is a structural block diagram of a proxy server in an embodiment of the present invention;

[0027] Figure 6 This is a flow chart of the Dubbo service testing method in an embodiment of the present invention. DETAILED DESCRIPTION

[0028] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.

[0029] The purpose of the present invention is to provide an efficient multi-environment switching and data comparison Dubbo service testing method, based on HTTP+Dubbo proxy service, which can initiate testing through a browser page without using an IDE to write scripts and start the Dubbo container. It can quickly switch environments through an interface selection box without using a switching code flow. It can select different environments, use the same message to initiate transactions, and assert and compare transaction results in different environments.

[0030] In an embodiment of the present invention, Figure 1 This is a structural block diagram of the Dubbo service test system in an embodiment of the present invention, including a browser, a gateway server, a proxy service registration center configuration center, a unified access server, a management server, a proxy server, and an auxiliary server.

[0031] Browser: Users open the test page through the browser to operate. They can manage interfaces, messages, edit scripts, execute scripts, view request results (request results refer to the return message of the service interface. For example, when calling the account balance query service interface, the request result should include information about the balance), view data comparison assertion results, etc.

[0032] Service interface: It is a Java interface class that the service provider exposes to the service consumer, which contains a series of method definitions. The service consumer needs to specify the interface and method name to call.

[0033] Test script: After being processed by the server, the test script will be converted into a message sent when calling the service interface.

[0034] Test environment: Since there are multiple test environments, each with a different IP and port, you need to specify the corresponding environment for calling.

[0035] Gateway server: used to configure multiple unified access servers for load balancing. You can use nginx.

[0036] Proxy Service Registration Center Configuration Center: The registration center is responsible for unified service management and service scheduling, and the configuration center is responsible for dynamic environment variable configuration of each server. Nacos can be used. That is, registration and configuration management of unified access servers, management servers, auxiliary servers and proxy servers are performed.

[0037] Unified access server: used to receive all operation requests from users (i.e. the service interface, test script and test environment selected by the user), and perform the next operation according to the user's instructions. Responsible for identifying user instructions to schedule auxiliary servers, proxy servers and management servers. Connect to the proxy service registration center configuration center to realize service discovery and configuration loading. That is, according to the service interface, test script and test environment selected by the user, determine to call the management server, proxy server or auxiliary server for corresponding processing, and receive and process the service results returned by the management server, proxy server or auxiliary server;

[0038] Management server: connected to the proxy service registration center configuration center to realize service registration and configuration loading. Used for interface management, script management, and environment configuration management. All functional implementations in the present invention are composed of microservices one by one. Therefore, not only the service interface to be tested is a service, but all cross-server calls in the present invention are implemented by service calls, so all functions involve service registration.

[0039] Auxiliary server: connects to the proxy service registration center configuration center to implement service registration and configuration loading. It is used to do a series of auxiliary processing, such as parsing dynamic parameters, executing result assertions, etc. When the test script contains dynamic parameters, it needs to go through the auxiliary server first, translate the test script into an upload message, and then pass the upload message to the proxy server.

[0040] Proxy server: Each test environment requires at least one proxy server, which is connected to the registration center of the environment where the Dubbo service is deployed to implement service subscription. Then it is connected to the proxy service registration center configuration center to implement service registration and configuration loading. It is used to call Dubbo services, that is, to perform Dubbo service tests based on service interfaces, test scripts, and test environments.

[0041] Figure 2 FIG. 1 is a structural block diagram of a unified access server in an embodiment of the present invention. Figure 2As shown, the unified access server is mainly composed of an instruction parsing module, a service calling module, and a result processing module.

[0042] Instruction parsing module: Determine which services to call based on the parameters sent by the front end. If it involves dynamic parameter acquisition, it is necessary to call the auxiliary helper to handle it. If it involves script execution, it is necessary to call the proxy server of the corresponding environment based on the environment parameters to handle it. If it involves interface management, script management and environment configuration management, it is necessary to call the management server to handle it.

[0043] Service call module: implements dynamic service discovery through the registration center, executes service calls and receives service return values.

[0044] Result processing module: processes the service return results, including assertion judgment and dynamic parameter echo.

[0045] Figure 3 FIG. 1 is a structural diagram of a management server in an embodiment of the present invention. Figure 3 As shown, the management server is mainly composed of an interface management module, a script management module, and an environment management module.

[0046] Interface management module: performs persistent processing on interfaces and provides the functions of adding, modifying, deleting and querying service interfaces.

[0047] Script management module: Persistently process the scripts of the interface. Provide the functions of adding, modifying, deleting and querying the interface scripts.

[0048] Environment management module: handles the configuration of the test environment. The environment administrator performs unified environment configuration.

[0049] Figure 4 The auxiliary server is a structural block diagram of an embodiment of the present invention. The auxiliary server is composed of a dynamic variable parsing module and an assertion processing module.

[0050] Dynamic variable parsing module: parses the dynamic parameters in the script. Its purpose is to generate dynamic parameters through technical means and assign them to the specified sent message.

[0051] For working date, working time, timestamp, etc., it is necessary to parse the variable value of the corresponding environment according to different environments. For parameters such as event number, transaction serial number, transaction retrieval number, etc., it is necessary to generate dynamically and ensure uniqueness.

[0052] For example, when buying things on Taobao, there will be an order number in the order information. These are similar to order numbers and need to be unique within the system. This parameter can be generated dynamically and uniformly by the test tool. For example, the "order number" needs to be globally unique within the system. If it is filled in manually by the tester, there is no way to ensure that the values ​​filled in by tester A and tester B are not repeated. Therefore, the auxiliary server parses the dynamic parameters and converts them into specific "order numbers".

[0053] For example, in a banking system, the transaction serial number will be accumulated from 1 in each branch in each region every day, and it is necessary to ensure that the serial number increases in sequence and is not repeated, so it should be generated by the auxiliary server as a dynamic parameter.

[0054] For SQL script variables, you need to query in the database of the corresponding environment.

[0055] SQL script variables are similar to dynamic parameters. For example, if you want to test the activation of a batch of debit cards, you can write a SQL script variable and let the auxiliary server retrieve the unactivated card numbers from the database. This way, testers don’t have to find the data one by one.

[0056] Assertion processing module: Identify the assertion logic of the script. When receiving the return message of the interface, perform assertion analysis according to the assertion logic, that is, execute the assertion. The assertion logic can be to compare the return value with a constant, to compare the return value with a specified value in the database, to compare the return value with a specified value in the cache, or to compare the same-name fields of the return values ​​of two environments.

[0057] For example, if Zhang San transfers 100 yuan to Li Si, in the assertion logic, you can write that Zhang San's balance is reduced by 100 yuan, and there are details of the deduction. Li Si's balance is increased by 100 yuan, and there are details of the credit.

[0058] Figure 5 The structure diagram of the proxy server in the embodiment of the present invention is shown in FIG. The proxy server is mainly composed of a transaction proxy module and a Dubbo call module.

[0059] Transaction proxy module: Applicable to the related processing of SAGA and TCC subtransactions. Since SAGA and TCC subtransactions can only be called by the main transaction or subtransaction of the transaction, when the subtransaction is called, the transaction proxy module opens a main transaction and is responsible for coordinating the transactions of all subsequent subtransactions. When one of the subtransactions fails, it is responsible for triggering the reverse compensation of all subtransactions. After executing the entire transaction, the ID of the main transaction is returned to the outside. After the front end receives the ID of the main transaction, it can execute the transaction query and manually trigger the reverse compensation.

[0060] The relationship between the transaction agent and the service interface: Before calling the service interface, the transaction agent needs to open a transaction first, and then call the service interface. When the service interface involves multiple service calls, the atomicity of the transaction must be guaranteed. For example, when testing a transfer service interface, it is necessary to ensure that the debit and credit are processed successfully at the same time. If the debit deduction is successful, but the credit entry fails, the transaction opened by the agent service will call the compensation transaction for the debit deduction and return the debit deduction.

[0061] The relationship between the transaction agent and the test script: The transaction agent is only a link in the service call and is only responsible for transmitting the uploaded message (the uploaded message is converted by the test environment).

[0062] Relationship between transaction agent and test environment: There is no direct relationship between transaction agent and test environment. Figure 1 and Figure 5 Generally speaking, the transaction proxy module is in the proxy server. Each environment will deploy a group of proxy servers to process transactions.

[0063] Dubbo call module: through the interface class path, interface version number, interface method name (these are passed from the client browser as parameters. These can be maintained by the interface management function in the browser), the main transaction can use the generalized call technology to call the sub-transaction. Generalized call is provided by the dubbo framework. Simply put, when calling a service, you don't need to get the interface class file provided by the interface provider, you only need to know the interface class path to call it.

[0064] Figure 6 The following is a flow chart of the Dubbo service testing method in an embodiment of the present invention, including the following process:

[0065] Step 6.1: The user selects an interface through the selection box. If the interface the user needs does not exist in the selection box, the user can first add an interface through the Add button of the interface management function. If the existing interface needs to be modified, the interface can be modified through the Modify button of the interface management. If the interface in the selection box is no longer needed, the interface can be deleted through the Delete button of the interface management.

[0066] Step 6.2: The user selects a test script through the selection box. If the test script required by the user does not exist in the selection box, you can add a script first by clicking the Add button in the Test Script Management. If you need to modify the existing test script, you can modify the test script by clicking the Modify button in the Test Script Management. If the test script in the selection box is no longer needed, you can delete the test script by clicking the Delete button in the Test Script Management.

[0067] Step 6.3: The user selects the test environment through the selection box. You can select a single environment to execute one or more test scripts, or select multiple environments to execute one or more test scripts simultaneously. The test environment is uniformly configured by the configuration administrator. This method of environment switching eliminates the need to switch code flows or manually modify configuration files, which greatly reduces the cost of environment switching.

[0068] Step 6.4: When the user clicks the Execute Script button, a script execution request is initiated, and the backend servers coordinate and process to execute the test script. This method of script execution eliminates the need to start the Dubbo container, greatly improving script execution efficiency.

[0069] Step 6.5: The proxy server identifies the request parameters of the front end, executes the script, and displays the execution results on the front end interface for the user to view.

[0070] Among them, step 6.4 and step 6.5 specifically include:

[0071] The unified access server determines to call the management server, proxy server or auxiliary server for corresponding processing according to the service interface, test script and test environment selected by the user;

[0072] The management server manages the service interface, test scripts and test environment;

[0073] The auxiliary server obtains dynamic parameters based on the test script and identifies the assertion logic of the test script;

[0074] The proxy server connects to the Dubbo server and performs Dubbo service testing based on the service interface, test scripts, and test environment;

[0075] The unified access server receives and processes the service results returned by the management server, proxy server or auxiliary server.

[0076] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned Dubbo service testing method when executing the computer program.

[0077] An embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the above-mentioned Dubbo service testing method are implemented.

[0078] The Dubbo service testing system and method proposed in the present invention have the following beneficial effects:

[0079] (1) Based on HTTP+Dubbo proxy service, the test can be initiated through the browser page, without the need to use IDE to write scripts and start the Dubbo container. The problem of slow startup of Dubbo service test scripts is solved. The traditional method of starting a Dubbo container each time a test script is run is improved to only starting the server Dubbo container once, and the test script can be run unlimited times.

[0080] (2) Solved the problem of slow switching between different environments. The traditional method of switching the entire test project through code flow has been improved to only switching environments through a selection box on the interface.

[0081] (3) Solved the problem of cross-environment data assertion. Traditional test scripts can only connect to one environment for execution, but now can be selected through the interface to execute multiple environments simultaneously, and support cross-environment data assertion processing.

[0082] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0083] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0084] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0085] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0086] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A Dubbo service testing system, characterized in that: include: Browser, unified access server, management server, auxiliary server and proxy server; The browser is used to: provide users with service interface selection, test script selection, and test environment selection, and display service results to users; The unified access server is used to: determine the call of the management server, proxy server or auxiliary server for corresponding processing according to the service interface, test script and test environment selected by the user, and receive and process the service results returned by the management server, proxy server or auxiliary server; The management server is used to: manage service interfaces, test scripts, and test environments; The auxiliary server is used to: obtain dynamic parameters based on the test script and identify the assertion logic of the test script; The proxy server is used to: connect to the Dubbo server and perform Dubbo service testing based on the service interface, test scripts, and test environment; Also included is a gateway for: connecting a browser to a unified access server; It also includes a proxy service registration center configuration center, which is used to: perform registration configuration management on the unified access server, management server, auxiliary server and proxy server.

2. The Dubbo service testing system according to claim 1, characterized in that: The unified access server includes an instruction parsing module, a service calling module and a result processing module; The instruction parsing module is used to: parse the service interface, test script and test environment selected by the user, and determine the calling management server, proxy server or auxiliary server; The service calling module is used to: call the management server, proxy server or auxiliary server, and receive the service result returned by the management server, proxy server or auxiliary server; The result processing module is used to process the returned service results.

3. The Dubbo service testing system according to claim 1, characterized in that: The management server includes an interface management module, a script management module and an environment management module; The interface management module is used to: persist interfaces and provide the functions of adding, modifying, deleting and querying service interfaces. The script management module is used to: persist the scripts of the interface and provide the functions of adding, modifying, deleting and querying the interface scripts; The environment management module is used to process the configuration of the test environment.

4. The Dubbo service testing system according to claim 1, characterized in that: The auxiliary server includes a dynamic variable parsing module and an assertion processing module; The dynamic variable parsing module is used to: obtain dynamic parameters based on the test script; The assertion processing module is used to: identify the assertion logic of the test script.

5. The Dubbo service testing system according to claim 1, characterized in that: The proxy server includes a transaction proxy module and a Dubbo call module; The transaction proxy module is used to: start transactions and call service interfaces; The Dubbo call module is used to: connect to the Dubbo server, call the Dubbo server, and perform Dubbo service testing based on the service interface, test script, and test environment.

6. A Dubbo service testing method, characterized in that: The method is performed based on the Dubbo service testing system according to any one of claims 1 to 5, and includes: The user selects the service interface, test script and test environment through the browser; The unified access server determines to call the management server, proxy server or auxiliary server for corresponding processing according to the service interface, test script and test environment selected by the user; The management server manages the service interface, test scripts and test environment; The auxiliary server obtains dynamic parameters based on the test script and identifies the assertion logic of the test script; The proxy server connects to the Dubbo server and performs Dubbo service testing based on the service interface, test scripts, and test environment; The unified access server receives and processes the service results returned by the management server, proxy server or auxiliary server.

7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the Dubbo service testing method according to claim 6 is implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the Dubbo service testing method described in claim 6 are implemented.