CN113360377A - Test method and device - Google Patents

Test method and device Download PDF

Info

Publication number
CN113360377A
CN113360377A CN202110609691.5A CN202110609691A CN113360377A CN 113360377 A CN113360377 A CN 113360377A CN 202110609691 A CN202110609691 A CN 202110609691A CN 113360377 A CN113360377 A CN 113360377A
Authority
CN
China
Prior art keywords
remote service
service
client
remote
test
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.)
Granted
Application number
CN202110609691.5A
Other languages
Chinese (zh)
Other versions
CN113360377B (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 Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information 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 Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202110609691.5A priority Critical patent/CN113360377B/en
Publication of CN113360377A publication Critical patent/CN113360377A/en
Application granted granted Critical
Publication of CN113360377B publication Critical patent/CN113360377B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/3664Environments for testing or debugging software
    • 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
    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network

Abstract

The invention discloses a testing method and a testing device, and relates to the technical field of computers. One embodiment of the method comprises: obtaining a configuration descriptor that a remote service depends on based on a ByteBuddy toolkit; sending the configuration descriptor to a metadata configuration center to create a client of the remote service at the metadata configuration center; receiving registration success information and generating proxy service of remote service; intercepting a test method for calling remote service, acquiring input parameter data of the test method, sending the input parameter data to a client of the remote service through proxy service of the remote service, and calling the remote service in a generalization mode through the client of the remote service so as to test the remote service. The implementation method can realize interception and injection method dependence under the condition that a user does not sense, Hook logic code instrumentation is provided in a non-invasive mode, configuration information is written into a metadata configuration center in advance, automatic configuration registration and multiplexing are realized, and the test efficiency of research and development personnel is improved.

Description

Test method and device
Technical Field
The invention relates to the technical field of computers, in particular to a testing method and a testing device.
Background
In the research and development process of a large project, if research and development personnel need to debug a business flow unit, after the project needs to be deployed to a test server, a unit test environment is initialized locally, and a service interface verification logic of the test server is called. The unit test deployment process is complex, services depend on a lot and cannot be injected quickly, large projects are started slowly, complex service injection configurations are often required to be compiled for running through one unit test, and the instantiation process of the complex service injection configurations can increase project starting time and affect unit test efficiency and project delivery speed.
In addition, in the testing process, for the scene needing Hook data, a hard coding intrusion mode is needed to supplement data and dependency in the testing logic, and the business process and the testing dependency influence each other. After the test is completed, the metadata configuration used for the test is discarded, and the interfaces between multiple systems and multiple applications have frequent changes of interdependencies, so that the usability and accuracy need to be re-confirmed during iterative update, and a large amount of maintenance time needs to be consumed. The Hook program captures the message before the system does not call the function, and the Hook function obtains control right first, and the Hook function can process (change) the execution behavior of the function and also can forcibly end the transfer of the message. In short, the program of the system is pulled out to become a code segment for self execution.
Disclosure of Invention
In view of this, embodiments of the present invention provide a testing method and apparatus, which can analyze a remote service dependency in a code through a ByteBuddy toolkit before a test program is started, access a remote metadata configuration center to obtain data, dynamically generate a proxy object according to configuration data, and inject a test dependency, so that a method dependency can be intercepted and injected without perception by a user, and Hook logic code instrumentation is provided in a non-intrusive manner; interaction is carried out between the remote service and the generalized calling mode, dependence and method parameter difference between services are shielded, remote data are obtained in the debugging process, metadata configuration recording service is added between a caller and a provider, automatic configuration registration and multiplexing are achieved, and test efficiency of research and development personnel is improved.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a test method including:
obtaining a configuration descriptor that a remote service depends on based on a ByteBuddy toolkit;
sending the configuration descriptor to a metadata configuration center to create a client of the remote service at the metadata configuration center;
receiving registration success information and generating proxy service of the remote service; wherein the registration success message is generated by the metadata configuration center after the client of the remote service is created;
intercepting a test method for calling the remote service, acquiring the input parameter data of the test method, sending the input parameter data to a client of the remote service through proxy service of the remote service, and calling the remote service through the client of the remote service in a generalization manner so as to test the remote service.
Optionally, based on the ByteBuddy toolkit, obtaining the configuration descriptor that the remote service depends on includes:
based on the ByteBuddy toolkit, inserting the logic code of the registration service into the logic code of the test case;
obtaining annotation information on the class file of the test case through the logic code of the registration service, reflecting the annotation information, and obtaining a configuration descriptor depended by the remote service;
sending the configuration descriptor to a metadata configuration center comprises: sending the configuration descriptor to a metadata configuration center through the registration service logic code.
Optionally, when the logic code of the registry service is instrumented into the logic code of the test case based on the ByteBuddy toolkit, the method further comprises: based on the ByteBuddy toolkit, inserting the injection service logic code into the logic code of the test case;
generating a proxy service for the remote service includes: and generating a proxy service of the remote service, and injecting the proxy service of the remote service into the logic code of the test case through the injection service logic code.
Optionally, when the logic code of the registry service is instrumented into the logic code of the test case based on the ByteBuddy toolkit, the method further comprises: based on the ByteBuddy toolkit, inserting the interception service logic code into the logic code of the test case;
the test method for intercepting and calling the remote service comprises the following steps: and intercepting and calling the test method of the remote service through the interception service logic code, acquiring the entry parameter data of the test method, and encoding the entry parameter data.
Optionally, the process of the metadata configuration center creating the client of the remote service includes: searching configuration information corresponding to the remote service according to the configuration descriptor; according to the configuration information corresponding to the remote service, a client of the remote service is created, and an REST interface corresponding to the client is generated; sending the incoming parameter data to a client of the remote service through a proxy service of the remote service comprises: and sending the input parameter data to a REST interface corresponding to a client of the remote service through the proxy service of the remote service.
Optionally, before the client of the remote service generalizes and invokes the remote service, the method further includes: and determining that the input parameter is legal.
Optionally, the method further comprises: and receiving a calling result returned by the client side of the remote service through the interception service logic code, and sending the calling result to the test case.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a test apparatus including:
the descriptor determining module is used for obtaining a configuration descriptor depending on the remote service based on the ByteBuddy toolkit;
a registration module for sending the configuration descriptor to a metadata configuration center to create a client of the remote service at the metadata configuration center;
the proxy generating module is used for receiving the registration success information and generating the proxy service of the remote service; wherein the registration success message is generated by the metadata configuration center after the client of the remote service is created;
the intercepting module is used for intercepting and calling the testing method of the remote service, acquiring the input parameter data of the testing method, sending the input parameter data to the client of the remote service through the proxy service of the remote service, and calling the remote service through the client of the remote service in a generalization mode so as to test the remote service.
Optionally, the descriptor determining module is further configured to: based on the ByteBuddy toolkit, inserting the logic code of the registration service into the logic code of the test case; obtaining annotation information on the class file of the test case through the logic code of the registration service, reflecting the annotation information, and obtaining a configuration descriptor depended by the remote service;
the registration module is further configured to: sending the configuration descriptor to a metadata configuration center through the registration service logic code.
Optionally, the descriptor determining module is further configured to: based on the ByteBuddy toolkit, inserting the injection service logic code into the logic code of the test case;
the agent generation module is further configured to: and generating a proxy service of the remote service, and injecting the proxy service of the remote service into the logic code of the test case through the injection service logic code.
Optionally, the descriptor determining module is further configured to: based on the ByteBuddy toolkit, inserting the interception service logic code into the logic code of the test case;
the interception module is further configured to: and intercepting and calling the test method of the remote service through the interception service logic code, acquiring the entry parameter data of the test method, and encoding the entry parameter data.
Optionally, the metadata configuration center is further configured to search configuration information corresponding to the remote service according to the configuration descriptor; according to the configuration information corresponding to the remote service, a client of the remote service is created, and an REST interface corresponding to the client is generated;
the agent generation module is further configured to: and sending the input parameter data to a REST interface corresponding to a client of the remote service through the proxy service of the remote service.
Optionally, the metadata configuration center is further configured to determine that the entry parameter is legal.
Optionally, the interception module is further configured to receive, through the interception service logic code, a call result returned by the client of the remote service, and send the call result to the test case.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided an electronic apparatus including: one or more processors; a storage device, configured to store one or more programs, which when executed by the one or more processors, cause the one or more processors to implement the testing method of the embodiment of the present invention.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a computer-readable medium on which a computer program is stored, the program implementing a test method of an embodiment of the present invention when executed by a processor.
One embodiment of the above invention has the following advantages or benefits: by means of the ByteBuddy toolkit, before a test program is started, remote service dependence in the code is analyzed, a remote metadata configuration center is accessed to obtain data, a proxy object is dynamically generated according to configuration data, test dependence is injected, method dependence can be intercepted and injected under the condition that a user does not sense, and Hook logic code instrumentation is provided in a non-invasive mode; interaction is carried out between the remote service and the generalized calling mode, dependence and method parameter difference between services are shielded, remote data are obtained in the debugging process, metadata configuration recording service is added between a caller and a provider, automatic configuration registration and multiplexing are achieved, and test efficiency of research and development personnel is improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a test method of an embodiment of the present invention;
FIG. 2 is a schematic diagram of configuration information of a metadata configuration center according to an embodiment of the present invention;
FIG. 3 is a schematic main flow chart of a testing method according to another embodiment of the present invention;
FIG. 4 is a schematic diagram of information interaction of a testing method according to an embodiment of the present invention
FIG. 5 is a schematic diagram of the main modules of a test apparatus of an embodiment of the present invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 7 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic view of a main flow of a test method of an embodiment of the present invention. The test method can be used in unit testing. Unit testing (unit testingb) refers to the checking and verification of the smallest testable unit in software. For the meaning of a unit in a unit test, generally speaking, the specific meaning is determined according to the actual situation. In the embodiments of the present invention, the meaning of the unit refers to a remote service to be tested. The method may be used in a local test server. As shown in fig. 1, the method includes:
step S101: and obtaining the configuration descriptor depended by the remote service based on the ByteBuddy toolkit.
Among them, ByteBuddy is a code generation and operation library for creating and modifying Java classes while a Java application is running without the help of a compiler.
Based on the ByteBuddy toolkit, the process of obtaining the configuration descriptor that the remote service depends on comprises the following steps: based on the ByteBuddy toolkit, inserting the logic code of the registration service into the logic code of the test case; and obtaining annotation information on the class file of the test case through the logic code of the registration service, reflecting the annotation information, and obtaining a configuration descriptor depended by the remote service. That is, this step is based on the ByteBuddy toolkit, instrumentation the registry service logic code into the logic code of the testcase at the test case start. When the test case initializes the remote service dependence, the test case enters the logic code of the registration service, and the code reflects and obtains the configuration descriptor of the remote service dependence through the annotation information of the class file of the test case. Wherein the configuration descriptor may include a dependent package path and a key of the remote service. The key is used to uniquely indicate the remote service. The instrumentation means that some probes (also called "probes") are inserted into the program on the basis of ensuring the original logic integrity of the program to be tested, which are essentially code segments for information acquisition, and can be assignment statements or function calls for acquiring coverage information, and characteristic data (including methods, method parameter values, return values, and the like) of program operation is thrown out through the execution of the probes.
In the embodiment, based on the ByteBuddy toolkit, when the test program is started, an entry method of the test program is intercepted under the condition that a user does not sense, method dependence is injected in an annotation analysis mode, Hook logic code instrumentation is provided in a non-invasive mode, the workload of testers is reduced, and the starting speed and the testing efficiency of the test program are improved.
In an alternative embodiment, when the method is used for instrumentation the registered service logic code into the logic code of the test case based on the ByteBuddy toolkit, the injected service logic code and the intercepted service logic code can also be instrumented into the logic code of the test case based on the ByteBuddy toolkit. The injection service logic code is for injecting a proxy service for the remote service into the logic code of the test case. The interception service logic code is used for intercepting a test method for calling remote service and acquiring the access parameter data of the test method.
In the embodiment, based on the ByteBuddy toolkit, when the test program is started, an entry method of the test program is intercepted under the condition that a user does not sense, method dependence is injected in an annotation analysis mode, Hook logic code instrumentation is provided in a non-invasive mode, the workload of testers is reduced, and the starting speed and the testing efficiency of the test program are improved; by injecting service logic codes, developers can inject corresponding proxy services according to the requirements of the developers; the test method can be intercepted and the access parameter data can be obtained by intercepting the service logic code.
Step S102: sending the configuration descriptor to a metadata configuration center to create a client of the remote service at the metadata configuration center.
The metadata configuration center is used for storing configuration information of the remote service. The configuration information refers to the client configuration required when remote service components and service middleware (such as redis, dubbo, kafka, etc.) in the metadata configuration center establish a link. As an example, as shown in fig. 2, the configuration information may include one or more of the following: key, interface, access authentication authorization information (such as token, alias, password), remote link address url, service cluster address servers, message queue name Broker, and topic.
For the step, the logic code of the registered service sends the configuration descriptor to a metadata configuration center through an HTTP (Hyper Text Transfer Protocol), and the metadata configuration center searches the configuration information corresponding to the remote service in the metadata configuration of the remote service maintained by the metadata configuration center according to the configuration descriptor; if the remote service is found, a client of the remote service is established in the metadata configuration center, an external REST interface is packaged and exposed aiming at the client of the remote service, and meanwhile, registration success information is returned to the test case. If the configuration is not found, the registration failure information is returned to the test case.
Step S103: receiving registration success information and generating proxy service of the remote service; wherein the registration success message is generated by the metadata configuration center after the client of the remote service is created.
Specifically, after receiving the registration success message, the registration service logic code in the test case instantiates the proxy service dependent on the remote service by using the CGLib dynamic proxy technology, and injects the proxy service dependent on the remote service into the test case by injecting the service logic code.
Step S104: intercepting a test method for calling the remote service, acquiring the input parameter data of the test method, sending the input parameter data to a client of the remote service through proxy service of the remote service, and calling the remote service through the client of the remote service in a generalization manner so as to test the remote service.
Specifically, when a specific test method of the test case runs, before the logic code is executed to the remote service call, the interception service logic code intercepts the method to be executed in the test case, performs data coding on call-in parameter data, and sends the coded data to the REST interface through proxy service dependent on the remote service. And after receiving a call request from the test case, the REST interface performs deserialization operation to obtain a target method and an entry parameter, and calls a client of the remote service created in the metadata configuration center in a generalization call mode, so that the client and the remote service perform data interaction. And after the client of the remote service established in the metadata configuration center obtains the return value of the remote service, the client carries out the serialization work of the back reference, and returns the data to the interception service code logic. If the return value is not obtained, the calling failure information is returned to the test case. After receiving REST interface return data, the proxy service which the remote service depends on intercepts the service logic code, decodes the return data, and assigns the return data to a return value called by the remote service of the test case, thereby completing the test of the service to be tested.
In an optional embodiment, before the incoming parameter data is sent to the client of the remote service through the proxy service of the remote service, validity check of the incoming parameter data is performed, and if the incoming parameter data does not pass the validity check, check failure information is returned to the test case; and if the validity is verified, sending the incoming parameter data to the client of the remote service. The check may be performed according to a preset protocol or rule, for example, whether the format of the access data conforms to the preset protocol. The specific protocol or rule can be flexibly set according to the application scenario, and the invention is not limited herein.
According to the test method, through the ByteBuddy toolkit, before the test program is started, the remote service dependence in the code is analyzed, the remote metadata configuration center is accessed to obtain data, the proxy object is dynamically generated according to the configuration data, the test dependence is injected, the method dependence can be intercepted and injected under the condition that a user does not sense, and Hook logic code instrumentation is provided in a non-invasive mode; interaction is carried out between the remote service and the generalized calling mode, dependence and method parameter difference between services are shielded, remote data are obtained in the debugging process, metadata configuration recording service is added between a caller and a provider, automatic configuration registration and multiplexing are achieved, and test efficiency of research and development personnel is improved.
Fig. 3 is a schematic diagram of main steps of a testing method according to another embodiment of the present invention, and fig. 4 is a sample diagram of configuration information of the testing method according to the embodiment of the present invention. As shown in fig. 3 and 4, the test method includes:
(1) initializing the local test environment based on the ByteBuddy toolkit, and inserting stub codes (i.e. registration service code logic, injection service code logic and interception service code logic) into the local test environment: at test case start-up, the registration service code logic, injection service code logic and interception service code logic are instrumented into the runtime code logic of the test case by means of ByteBuddy bytecode modification techniques. When the test case initializes the remote service dependency, the logic of the registered service code is entered, and the logic reflects the configuration descriptor of the remote service dependency obtained through the annotation information on the test case class file. The configuration descriptors of remote service dependencies are as in fig. 4, for example, dubbo, key ═ com. The dubbo is a high-performance and light-weight open-source Java RPC framework and comprises a client and a server program. Redis is a non-relational database Kafka, a high-throughput distributed publish-subscribe message queuing system, comprising client and server programs.
(2) After obtaining the configuration descriptor that the remote service depends on, the local environment interacts with a registered remote service interaction module of the metadata configuration center, that is, the configuration descriptor that the remote service depends on is called to the metadata configuration center through an HTTP protocol to perform registration service through a registration service code logic, so as to determine whether the metadata configuration center has metadata configuration information that the remote service depends on.
(3) And the metadata configuration center retrieves the maintained metadata configuration of the remote service according to the configuration descriptor depended by the remote service, if the configuration is retrieved, the client of the remote service created in the metadata configuration center encapsulates the client of the remote service and exposes the external REST operation service, namely the remote service passes the registration, and meanwhile, the successful registration information is returned to the test case. If no configuration is retrieved, registration failure information is returned to the test case.
(4) And after receiving the registration success message, the registration service code logic in the test case instantiates the remote service dependent agent case by using the CGLib dynamic agent technology, and injects the remote service dependent agent case into the test case through the injection service code logic.
(5) When a specific test method of a test case runs and before code logic is executed to need remote service calling, intercepting a method which is about to execute the remote service calling in the test case by the intercepting service code logic, carrying out data coding work on calling parameter data, and sending coded data to an REST operation entrance through a proxy case which is depended by the remote service.
(6) After receiving a call request from a test case, the REST operation service performs legality verification on request parameters, verifies that a remote service interaction module of a metadata configuration center performs deserialization operation on the request parameters to obtain a target method and a reference, and calls a client of a remote service created in the metadata configuration center by using the target method and the reference in a generalized calling mode, so that the client and the remote service perform RPC data interaction. And if the validity check is not passed, returning check failure information to the test case. RPC (Remote Procedure Call), a protocol that requests services from a Remote computer program over a network without knowledge of the underlying network technology.
(7) And after the client of the remote service established in the metadata configuration center obtains the return value of the remote service, the client carries out the serialization work of the back reference, and returns the data to the interception service code logic. If the return value is not obtained, the calling failure information is returned to the test case.
(8) And decoding the data, returning to the proxy method for participating: after the agent instance which the remote service depends on receives REST operation service return data, the interception service code logic decodes the return data and assigns the return data to a return value of the remote service call of the test instance.
According to the test method, through the ByteBuddy toolkit, before the test program is started, the remote service dependence in the code is analyzed, the remote metadata configuration center is accessed to obtain data, the proxy object is dynamically generated according to the configuration data, the test dependence is injected, the method dependence can be intercepted and injected under the condition that a user does not sense, and Hook logic code instrumentation is provided in a non-invasive mode; interaction is carried out between the remote service and the generalized calling mode, dependence and method parameter difference between services are shielded, remote data are obtained in the debugging process, metadata configuration recording service is added between a caller and a provider, automatic configuration registration and multiplexing are achieved, and test efficiency of research and development personnel is improved.
Fig. 5 is a schematic diagram of main modules of a testing apparatus 500 according to an embodiment of the present invention, and as shown in fig. 5, the testing apparatus 500 includes:
a descriptor determining module 501, configured to obtain a configuration descriptor that a remote service depends on based on the ByteBuddy toolkit;
a registration module 502 for sending the configuration descriptor to a metadata configuration center to create a client of the remote service at the metadata configuration center;
an agent generating module 503, configured to receive registration success information and generate an agent service of the remote service; wherein the registration success message is generated by the metadata configuration center after the client of the remote service is created;
the interception module 504 is configured to intercept a test method for calling the remote service, obtain entry parameter data of the test method, send the entry parameter data to a client of the remote service through an agent service of the remote service, and call the remote service in a generalization manner through the client of the remote service to test the remote service.
Optionally, the descriptor determining module 501 is further configured to: based on the ByteBuddy toolkit, inserting the logic code of the registration service into the logic code of the test case; obtaining annotation information on the class file of the test case through the logic code of the registration service, reflecting the annotation information, and obtaining a configuration descriptor depended by the remote service;
the registration module 502 is further configured to: sending the configuration descriptor to a metadata configuration center through the registration service logic code.
Optionally, the descriptor determining module 501 is further configured to: based on the ByteBuddy toolkit, inserting the injection service logic code into the logic code of the test case;
the agent generation module 503 is further configured to: and generating a proxy service of the remote service, and injecting the proxy service of the remote service into the logic code of the test case through the injection service logic code.
Optionally, the descriptor determining module 501 is further configured to: based on the ByteBuddy toolkit, inserting the interception service logic code into the logic code of the test case;
the interception module 504 is further configured to: and intercepting and calling the test method of the remote service through the interception service logic code, acquiring the entry parameter data of the test method, and encoding the entry parameter data.
Optionally, the metadata configuration center is further configured to search configuration information corresponding to the remote service according to the configuration descriptor; according to the configuration information corresponding to the remote service, a client of the remote service is created, and an REST interface corresponding to the client is generated;
the agent generation module 502 is further configured to: and sending the input parameter data to a REST interface corresponding to a client of the remote service through the proxy service of the remote service.
Optionally, the metadata configuration center is further configured to determine that the entry parameter is legal.
Optionally, the interception module 504 is further configured to receive, through the interception service logic code, a call result returned by the client of the remote service, and send the call result to the test case.
According to the testing device, through the ByteBuddy toolkit, before the testing program is started, the remote service dependence in the code is analyzed, the remote metadata configuration center is accessed to obtain data, the proxy object is dynamically generated according to the configuration data, the testing dependence is injected, the method dependence can be intercepted and injected under the condition that a user does not sense, and Hook logic code instrumentation is provided in a non-invasive mode; interaction is carried out between the remote service and the generalized calling mode, dependence and method parameter difference between services are shielded, remote data are obtained in the debugging process, metadata configuration recording service is added between a caller and a provider, automatic configuration registration and multiplexing are achieved, and test efficiency of research and development personnel is improved.
The device can execute the method provided by the embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the method provided by the embodiment of the present invention.
Fig. 6 shows an exemplary system architecture 600 to which the test method or test apparatus of an embodiment of the invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 serves to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like, may be installed on the terminal devices 601, 602, and 603.
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 605 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 601, 602, and 603. The background management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (e.g., target push information and product information) to the terminal device.
It should be noted that the testing method provided by the embodiment of the present invention is generally executed by the server 605, and accordingly, the testing apparatus is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the 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 computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 present invention, 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 invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart 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 invention. 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 or flowchart illustration, and combinations of blocks in the block diagrams 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 invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a sending module, an obtaining module, a determining module, and a first processing module. The names of these modules do not in some cases constitute a limitation on the unit itself, and for example, the sending module may also be described as a "module that sends a picture acquisition request to a connected server".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise:
obtaining a configuration descriptor that a remote service depends on based on a ByteBuddy toolkit;
sending the configuration descriptor to a metadata configuration center to create a client of the remote service at the metadata configuration center;
receiving registration success information and generating proxy service of the remote service; wherein the registration success message is generated by the metadata configuration center after the client of the remote service is created;
intercepting a test method for calling the remote service, acquiring the input parameter data of the test method, sending the input parameter data to a client of the remote service through proxy service of the remote service, and calling the remote service through the client of the remote service in a generalization manner so as to test the remote service.
According to the technical scheme, the remote service dependence in the code is analyzed through the ByteBuddy toolkit before the test program is started, the remote metadata configuration center is accessed to obtain data, the proxy object is dynamically generated according to the configuration data, the test dependence is injected, the method dependence can be intercepted and injected under the condition that a user does not sense, and Hook logic code instrumentation is provided in a non-invasive mode; interaction is carried out between the remote service and the generalized calling mode, dependence and method parameter difference between services are shielded, remote data are obtained in the debugging process, metadata configuration recording service is added between a caller and a provider, automatic configuration registration and multiplexing are achieved, and test efficiency of research and development personnel is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method of testing, comprising:
obtaining a configuration descriptor that a remote service depends on based on a ByteBuddy toolkit;
sending the configuration descriptor to a metadata configuration center to create a client of the remote service at the metadata configuration center;
receiving registration success information and generating proxy service of the remote service; wherein the registration success message is generated by the metadata configuration center after the client of the remote service is created;
intercepting a test method for calling the remote service, acquiring the input parameter data of the test method, sending the input parameter data to a client of the remote service through proxy service of the remote service, and calling the remote service through the client of the remote service in a generalization manner so as to test the remote service.
2. The method of claim 1, wherein obtaining a remote service dependent configuration descriptor based on the ByteBuddy toolkit comprises:
based on the ByteBuddy toolkit, inserting the logic code of the registration service into the logic code of the test case;
obtaining annotation information on the class file of the test case through the logic code of the registration service, reflecting the annotation information, and obtaining a configuration descriptor depended by the remote service;
sending the configuration descriptor to a metadata configuration center comprises: sending the configuration descriptor to a metadata configuration center through the registration service logic code.
3. The method of claim 2, wherein when instrumentation registry service logic code into logic code of a test case based on ByteBuddy toolkit, the method further comprises: based on the ByteBuddy toolkit, inserting the injection service logic code into the logic code of the test case;
generating a proxy service for the remote service includes: and generating a proxy service of the remote service, and injecting the proxy service of the remote service into the logic code of the test case through the injection service logic code.
4. The method of claim 2, wherein when instrumentation registry service logic code into logic code of a test case based on ByteBuddy toolkit, the method further comprises: based on the ByteBuddy toolkit, inserting the interception service logic code into the logic code of the test case;
the test method for intercepting and calling the remote service comprises the following steps: and intercepting and calling the test method of the remote service through the interception service logic code, acquiring the entry parameter data of the test method, and encoding the entry parameter data.
5. The method of claim 1, wherein the metadata configuration center creating the client of the remote service comprises:
searching configuration information corresponding to the remote service according to the configuration descriptor;
according to the configuration information corresponding to the remote service, a client of the remote service is created, and an REST interface corresponding to the client is generated;
sending the incoming parameter data to a client of the remote service through a proxy service of the remote service comprises: and sending the input parameter data to a REST interface corresponding to a client of the remote service through the proxy service of the remote service.
6. The method of claim 1, wherein the client-side generalization of a remote service calls the remote service comprises:
and under the condition that the input parameters are legal, the client of the remote service calls the remote service in a generalization mode.
7. The method of claim 4, further comprising: and receiving a calling result returned by the client side of the remote service through the interception service logic code, and sending the calling result to the test case.
8. A test apparatus, comprising:
the descriptor determining module is used for obtaining a configuration descriptor depending on the remote service based on the ByteBuddy toolkit;
a registration module for sending the configuration descriptor to a metadata configuration center to create a client of the remote service at the metadata configuration center;
the proxy generating module is used for receiving the registration success information and generating the proxy service of the remote service; wherein the registration success message is generated by the metadata configuration center after the client of the remote service is created;
the intercepting module is used for intercepting and calling the testing method of the remote service, acquiring the input parameter data of the testing method, sending the input parameter data to the client of the remote service through the proxy service of the remote service, and calling the remote service through the client of the remote service in a generalization mode so as to test the remote service.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202110609691.5A 2021-06-01 2021-06-01 Test method and device Active CN113360377B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110609691.5A CN113360377B (en) 2021-06-01 2021-06-01 Test method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110609691.5A CN113360377B (en) 2021-06-01 2021-06-01 Test method and device

Publications (2)

Publication Number Publication Date
CN113360377A true CN113360377A (en) 2021-09-07
CN113360377B CN113360377B (en) 2023-11-07

Family

ID=77531018

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110609691.5A Active CN113360377B (en) 2021-06-01 2021-06-01 Test method and device

Country Status (1)

Country Link
CN (1) CN113360377B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115629992A (en) * 2022-12-16 2023-01-20 云筑信息科技(成都)有限公司 Method for debugging application system constructed by using Spring technology stack
WO2023103727A1 (en) * 2021-12-10 2023-06-15 易保网络技术(上海)有限公司 Routing method for service debugging, electronic device, medium and program product

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1987821A (en) * 2006-11-14 2007-06-27 无敌科技(西安)有限公司 Method and system for realizing unit test
US8555297B1 (en) * 2008-09-29 2013-10-08 Emc Corporation Techniques for performing a remote procedure call using remote procedure call configuration information
CN107092488A (en) * 2017-03-31 2017-08-25 武汉斗鱼网络科技有限公司 It is a kind of that application is carried out to bury realization method and system a little without intrusionization
CN108304195A (en) * 2017-09-08 2018-07-20 武汉斗鱼网络科技有限公司 A kind of implementation method, device and the electronic equipment of AOP components
CN111562950A (en) * 2020-04-28 2020-08-21 中国银行股份有限公司 System and method for dynamically releasing distributed application parameters
CN112114979A (en) * 2020-08-31 2020-12-22 厦门安胜网络科技有限公司 Remote procedure call method and device
CN112532490A (en) * 2020-11-30 2021-03-19 武汉悦学帮网络技术有限公司 Regression testing system and method and electronic equipment
US10977027B1 (en) * 2020-05-07 2021-04-13 Hcl Technologies Limited System and method of deploying java agents in runtime

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1987821A (en) * 2006-11-14 2007-06-27 无敌科技(西安)有限公司 Method and system for realizing unit test
US8555297B1 (en) * 2008-09-29 2013-10-08 Emc Corporation Techniques for performing a remote procedure call using remote procedure call configuration information
CN107092488A (en) * 2017-03-31 2017-08-25 武汉斗鱼网络科技有限公司 It is a kind of that application is carried out to bury realization method and system a little without intrusionization
CN108304195A (en) * 2017-09-08 2018-07-20 武汉斗鱼网络科技有限公司 A kind of implementation method, device and the electronic equipment of AOP components
CN111562950A (en) * 2020-04-28 2020-08-21 中国银行股份有限公司 System and method for dynamically releasing distributed application parameters
US10977027B1 (en) * 2020-05-07 2021-04-13 Hcl Technologies Limited System and method of deploying java agents in runtime
CN112114979A (en) * 2020-08-31 2020-12-22 厦门安胜网络科技有限公司 Remote procedure call method and device
CN112532490A (en) * 2020-11-30 2021-03-19 武汉悦学帮网络技术有限公司 Regression testing system and method and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
吴清寿;: "基于Proxy模式的远程处理框架研究", 长江大学学报(自科版), no. 19 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023103727A1 (en) * 2021-12-10 2023-06-15 易保网络技术(上海)有限公司 Routing method for service debugging, electronic device, medium and program product
CN115629992A (en) * 2022-12-16 2023-01-20 云筑信息科技(成都)有限公司 Method for debugging application system constructed by using Spring technology stack

Also Published As

Publication number Publication date
CN113360377B (en) 2023-11-07

Similar Documents

Publication Publication Date Title
KR102220127B1 (en) Method and apparatus for customized software development kit (sdk) generation
US8769502B2 (en) Template based asynchrony debugging configuration
US11550599B2 (en) Method and apparatus for running applet
US20070169015A1 (en) Web services development automation toolkit with test case driver and customized configuration file
US20230036980A1 (en) Micro-frontend system, sub-application loading method, electronic device, computer program product, and computer-readable storage medium
US9432469B2 (en) Automated server controlled client-side logging
CN111338623B (en) Method, device, medium and electronic equipment for developing user interface
CN104536890A (en) Testing system, method and device
CN113360377B (en) Test method and device
US10873628B2 (en) System and method for non-intrusive context correlation across cloud services
KR20130085856A (en) Method and apparatus for creating automatically a widget to invoke heterogeneous web services in a composite application
Tang et al. Xdebloat: Towards automated feature-oriented app debloating
CN112015383A (en) Login method and device
CN112559024A (en) Method and device for generating transaction code change list
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN112783903B (en) Method and device for generating update log
CN113468041A (en) Interface comparison test method and device
CN112860447A (en) Interaction method and system between different applications
CN113010174A (en) Service monitoring method and device
CN113031960B (en) Code compiling method, device, server and storage medium
CN112131095A (en) Pressure testing method and device
CN113342633B (en) Performance test method and device
US20230088655A1 (en) Automatic non-code test suite generation from api specification
CN113495747B (en) Gray scale release method and device
CN117193769A (en) Page rendering method and device, electronic equipment and computer readable storage medium

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