Micro-service test method, device, equipment, medium and product
By receiving the target test request from the simulated client on the consumer side and determining the target service instance using routing rules, the problem of poor microservice debugging flexibility in the prior art is solved, and the flexibility and operational convenience of microservice testing are achieved.
Patent Information
- Application Number
- CN202411614389.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-02-28
AI Technical Summary
The prior art is poor in debugging microservices and is difficult to operate, and it is necessary to modify the source code through hard code to achieve isolation of the target service instance.
By receiving the target test request from the simulated client on the consumer side, determining the target microservice based on the target test request, and determining the target instance information of the target service instance using the pre-received routing rules sent by the management platform, so that the target service instance of the target service is not required to hardcode the target test request to the target service instance of the target microservice.
Improves the flexibility and operational convenience of testing microservices, and can quickly determine the target instance information without modifying the source code.
Smart Images

Figure CN119537225A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a microservice testing method, device, equipment, medium and product. Background Art
[0002] With the deepening of digital transformation, microservice architecture has become the mainstream architecture model. Microservice architecture system has strong flexibility and scalability. Joint debugging and testing of microservices in microservice architecture has become a key link to ensure service security.
[0003] In the prior art, when debugging a microservice, in order not to affect the target microservice associated with the debugged microservice, the target service instance information of the target microservice to be called is usually embedded into the microservice architecture by hard coding, so as to isolate the target service instance. However, in the process of implementing the present invention, it is found that the prior art has at least the following technical problems: for different debugging requirements, the source code needs to be modified by hard coding each time, which is inflexible and difficult to operate. Summary of the invention
[0004] The embodiments of the present invention provide a microservice testing method, apparatus, device, medium and product to achieve the purpose of improving the flexibility and operational convenience of testing microservices.
[0005] According to one aspect of the present invention, a microservice testing method is provided, which is applied to a consumer end and includes:
[0006] In the case of receiving a target test request sent by a simulated client, determining at least one target microservice on a production side corresponding to the target test request based on the target test request;
[0007] Determine the target instance information of the target service instance in the target microservice based on the routing rules sent by the management platform received in advance; wherein the target microservice corresponds to at least one service instance, and the routing rules are used to reflect the corresponding relationship between the test request and the service instance that executes the test request;
[0008] Based on the target instance information, the target test request is routed to the target service instance of the target microservice, so as to call the target service instance to perform a test operation corresponding to the target test request.
[0009] According to another aspect of the present invention, a microservice testing device is provided, which is arranged at a consumer end, and includes:
[0010] A target microservice determination module is used to determine at least one target microservice corresponding to the target test request on the production side based on the target test request when receiving the target test request sent by the simulated client;
[0011] A target instance information determination module, used to determine the target instance information of the target service instance in the target microservice based on the routing rules sent by the management platform received in advance; wherein the target microservice corresponds to at least one service instance, and the routing rules are used to reflect the corresponding relationship between the test request and the service instance that executes the test request;
[0012] A request routing module is used to route the target test request to the target service instance of the target microservice based on the target instance information, so as to call the target service instance to perform a test operation corresponding to the target test request.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the microservice testing method described in any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the microservice testing method described in any embodiment of the present invention when executed.
[0018] According to another aspect of the present invention, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements the microservice testing method described in any embodiment of the present invention.
[0019] The technical solution of the embodiment of the present invention, in the case of receiving the target test request sent by the simulated client, determines at least one target microservice corresponding to the target test request on the production side based on the target test request; determines the target instance information of the target service instance in the target microservice based on the routing rules sent by the management platform received in advance; wherein, the target microservice corresponds to at least one service instance, and since the routing rules are used to reflect the correspondence between the test request and the service instance that executes the test request, the target instance information corresponding to the target test request can be determined without hard coding; finally, based on the target instance information, the target test request is routed to the target service instance of the target microservice to call the target service instance to execute the test operation corresponding to the target test request. This embodiment reflects the correspondence between the test request and the service instance through the routing rules, and can quickly determine the target instance information corresponding to the target test request without modifying the source code, thereby improving the flexibility and convenience of testing the microservice.
[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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.
[0022] Figure 1 is a flowchart of a microservice testing method provided according to an embodiment of the present invention;
[0023] Figure 2 is a structural schematic diagram of a microservice testing device provided according to an embodiment of the present invention;
[0024] Figure 3 It is a structural schematic diagram of an electronic device for implementing the microservice testing method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "etc." and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] Figure 1 This is a flow chart of a microservice testing method provided according to an embodiment of the present invention. This embodiment can be applied to calling a target service instance corresponding to a target test request to perform a test on a microservice in a microservice architecture to be tested. The method can be performed by a microservice testing device, which can be implemented in the form of hardware and / or software.
[0028] like Figure 1 As shown, the method of this embodiment is applied to the consumer end, and may specifically include:
[0029] S110. When receiving a target test request sent by a simulated client, determine at least one target microservice on the production side corresponding to the target test request based on the target test request.
[0030] It should be noted that the present embodiment pre-builds a simulation client, which is used to simulate the requests issued by the user in the actual application process, and completes the testing of the microservices in the microservice architecture of the production end through the simulation client. The request initiated by the simulation client contains multiple request parameters; for example, the request parameters include request header parameters, session parameters, and query strings. The method of this embodiment is applied to the consumer end, and the consumer end is used to receive the request sent by the simulation client and parse the request parameters contained in the request. The production end is connected to the consumer end in communication, and the production end can be used to generate, create or send data. The production end can provide multiple microservices.
[0031] In this embodiment, a target test request can be generated by simulating a client, and the target test request can be sent to a consumer. The target test request is a request generated by a simulated client for testing a microservice in a microservice architecture. The target test request can be a test request generated based on actual test content. When the consumer receives the target test request, it can parse the target test request. Exemplarily, the request header, session, and query string in the target test request can be parsed. Based on the parsing result, the microservice corresponding to the target test request on the production side is determined as the target microservice.
[0032] S120: Determine target instance information of a target service instance in a target microservice based on a routing rule sent by a management platform and received in advance.
[0033] The target microservice corresponds to at least one service instance, and the routing rule is used to reflect the corresponding relationship between the test request and the service instance that executes the test request. Each test request can correspond to multiple target microservices.
[0034] In this embodiment, a management platform connected to the consumer end is provided, and the management platform is used to manage routing rules. The routing rules can be sent to the consumer end through the management platform. Specifically, before determining the target instance information of the target service instance in the target microservice based on the routing rules sent by the management platform received in advance, it also includes: receiving the routing rules sent by the management platform; wherein the routing rules are generated based on the configuration file of the microservice on the production end, and the configuration file includes the instance information and service label of the service instance corresponding to the microservice.
[0035] In this embodiment, the instance information includes the Internet Protocol address, interface information, name and number of the service instance. The service tag is used to mark whether the service instance executes the test request and the request type of the executed test request. It should be noted that the R&D personnel can pre-mark the service tag of the service instance corresponding to the microservice on the production side in the configuration file based on the actual situation when the service instance executes the test request. Based on the configuration file, the management platform determines the correspondence between different test requests and service instances, that is, the routing rules. In addition, the management platform sends the routing rules to the consumer end. After receiving the routing rules, the consumer end stores the routing rules.
[0036] This embodiment manages routing rules through a management platform, and before determining the target instance information, sends the routing rules to the consumer end through the management platform, thereby improving the convenience of the consumer end in determining the target instance information.
[0037] Optionally, before receiving the routing rules sent by the management platform, it also includes: generating a production-side service list for recording the service instances of each microservice provided by the production end, uploading the production-side service list to the registration center to perform registration operations on the service instances, and synchronizing the service tags corresponding to the service instances to the service metadata of the registration center.
[0038] In order to facilitate timely understanding of the microservices on the production side, a production side service list for recording the service instances of each microservice provided by the production side can be generated before receiving the routing rules sent by the management platform. Specifically, the production side service list records the instance information of each service instance on the production side. The production side service list is uploaded to the registration center to complete the registration operation of the service instance.
[0039] Furthermore, the service tag corresponding to the service instance can also be synchronized to the service metadata of the registration center, so that whether each service instance executes the test request can be clearly determined through the service metadata.
[0040] This embodiment manages the production-side service list and service metadata through the registration center, which facilitates the management of microservices and service instances on the production side.
[0041] In a specific implementation, the target test request can be parsed to obtain all request parameters corresponding to the target test request. For each target microservice, based on the routing rules, it is determined whether each request parameter corresponds to each service instance of the target microservice. If so, the service instance corresponding to the request parameter is used as the target service instance.
[0042] Alternatively, based on the routing rules sent by the management platform received in advance, the target instance information of the target service instance in the target microservice is determined, and it also includes: based on the request type of the target test request, extracting the request parameters in the target test request for determining the target service instance; based on the routing rules, determining the service instance corresponding to the request parameters as the target service instance, and determining the target instance information of the target service instance based on the production-side service list and metadata obtained from the registration platform.
[0043] The request parameters include at least one of the request header parameters, session parameters and query strings. It should be noted that when the simulated client generates a target test request, in order to facilitate the determination of the target service instance corresponding to the target test request, a request tag may be added to the request parameters of the generated target test request, and the routing rule may be the correspondence between the request tag and the service instance.
[0044] In this embodiment, based on the different request types, a request tag can be added to at least one of the request header parameters, session parameters, and query strings when generating a test request. In order to quickly and accurately determine the request tag corresponding to the target test request, the request type of the target test request can be determined, and based on the request type, the request parameters to which the request tag is added can be determined. Exemplarily, if the request type is a delete type, the request header parameters of the target test request can be extracted to determine the request tag based on the request header parameters.
[0045] In a specific implementation, the request tag is determined based on the extracted request parameters, and the service instance corresponding to the request tag in the routing rule is determined as the target service instance. After the target service instance is determined, a request for obtaining the production-side service list and metadata can be sent to the registration platform, and the production-side service list and metadata sent by the registration center are received. The target instance information of the target service instance is determined through the production-side service list. The target service tag of the target service instance is determined through the metadata, and it is determined whether the target service tag in the metadata corresponds to the determined target service instance. If so, it means that the determined target instance information is correct. If not, an alarm message can be generated and sent to the R&D terminal.
[0046] This embodiment uses the request type to quickly extract request parameters to improve the efficiency and convenience of determining the target instance information. In addition, by using the idea of service labels, by labeling any service instance of at least one microservice, the traffic is transferred to the service instance of the service label used to execute the test request, thereby achieving logical environment isolation, adding multiple development and testing environments without increasing costs, thereby facilitating rapid debugging and improving resource utilization.
[0047] S130. Based on the target instance information, route the target test request to the target service instance of the target microservice to call the target service instance to perform a test operation corresponding to the target test request.
[0048] The target instance information includes the Internet Protocol address and interface information of the target service instance, and may also include information such as the name and code of the target service instance.
[0049] Optionally, routing the target test request to the target service instance of the target microservice based on the target instance information includes: routing the target test request to the target service instance of the target microservice according to the Internet Protocol address and interface information of the target service instance.
[0050] In a specific implementation, for each target service instance, the target test request can be routed to the target service instance through the interface information and the Internet Protocol address. After the target service instance at the production end receives the target test request, the test operation corresponding to the target test request is performed based on the target test request. This embodiment can quickly and accurately route the target test request to the target service instance through the Internet Protocol address and the interface information.
[0051] In actual application, the method further includes: updating routing rules based on the received update information sent by the management platform.
[0052] It should be noted that, as the microservice architecture is constantly updated and changed, in order to accurately test the microservices, the routing rules need to be updated. Specifically, the management platform may periodically or randomly send routing update requests to the R&D terminal to update the routing rules based on the feedback information corresponding to the update request fed back by the R&D terminal. The feedback information may reflect at least one of the addition, deletion and modification of the service instance on the production side. The feedback information may also reflect the adjustment of the label of the service instance on the production side.
[0053] In a specific implementation, after the management platform updates the routing rules based on the feedback information, it generates update information based on the latest routing rules and sends the update information to the consumer end. The update information includes instance update information and / or label update information. Instance update information includes the addition, deletion and modification of service instances on the production end; label update information is the modification of the service label of the service instance. Based on the instance update information, the consumer end adds, deletes and adjusts the service instances in the routing rules. Based on the label update information, the consumer end adjusts the correspondence between the test request and the service instance in the routing rules.
[0054] This embodiment updates the routing rules by receiving update information, thereby facilitating improving the accuracy and effectiveness of determining the target service instance.
[0055] The technical solution of the embodiment of the present invention, in the case of receiving the target test request sent by the simulated client, determines at least one target microservice corresponding to the target test request on the production side based on the target test request; determines the target instance information of the target service instance in the target microservice based on the routing rules sent by the management platform received in advance; wherein, the target microservice corresponds to at least one service instance, and since the routing rules are used to reflect the correspondence between the test request and the service instance that executes the test request, the target instance information corresponding to the target test request can be determined without hard coding; finally, based on the target instance information, the target test request is routed to the target service instance of the target microservice to call the target service instance to execute the test operation corresponding to the target test request. This embodiment reflects the correspondence between the test request and the service instance through the routing rules, and can quickly determine the target instance information corresponding to the target test request without modifying the source code, thereby improving the flexibility and convenience of testing the microservice.
[0056] Figure 2 1 is a schematic diagram of the structure of a microservice testing device provided according to an embodiment of the present invention, and the device is used to execute the microservice testing method provided by any of the above embodiments. The device and the microservice testing method of the above embodiments belong to the same inventive concept, and the details not described in detail in the embodiment of the microservice testing device can refer to the embodiment of the above microservice testing method. Figure 2 As shown, the device is arranged at the consumer end and includes:
[0057] The target microservice determination module 10 is used to determine at least one target microservice corresponding to the target test request on the production side based on the target test request when receiving the target test request sent by the simulated client;
[0058] The target instance information determination module 11 is used to determine the target instance information of the target service instance in the target microservice based on the routing rules sent by the management platform received in advance; wherein the target microservice corresponds to at least one service instance, and the routing rules are used to reflect the corresponding relationship between the test request and the service instance that executes the test request;
[0059] The request routing module 12 is used to route the target test request to the target service instance of the target microservice based on the target instance information, so as to call the target service instance to perform the test operation corresponding to the target test request.
[0060] Based on any optional technical solution in the embodiments of the present invention, optionally, the method further includes:
[0061] A routing rule receiving module, used to receive the routing rule sent by the management platform before determining the target instance information of the target service instance in the target microservice based on the routing rule sent by the management platform received in advance;
[0062] The routing rules are generated based on the configuration file of the microservice on the production side, and the configuration file includes the instance information and service label of the service instance corresponding to the microservice.
[0063] Based on any optional technical solution in the embodiments of the present invention, optionally, the method further includes:
[0064] The list generation module is used to generate a production-side service list for recording the service instances of each microservice provided by the production side before receiving the routing rules sent by the management platform, upload the production-side service list to the registration center to perform registration operations on the service instances, and synchronize the service tags corresponding to the service instances to the service metadata of the registration center.
[0065] Based on any optional technical solution in the embodiments of the present invention, optionally, the target instance information determination module 11 includes:
[0066] A request parameter extraction module, used to extract a request parameter used to determine a target service instance in a target test request based on a request type of the target test request; wherein the request parameter includes at least one of a request header parameter, a session parameter, and a query string;
[0067] The target service instance determination module is used to determine the service instance corresponding to the request parameters as the target service instance based on the routing rules, and determine the target instance information of the target service instance based on the production-side service list and metadata obtained from the registration platform.
[0068] On the basis of any optional technical solution in the embodiment of the present invention, optionally, the target instance information includes an Internet Protocol address and interface information of the target service instance;
[0069] The request routing module 12 includes:
[0070] The request routing unit is used to route the target test request to the target service instance of the target microservice according to the Internet Protocol address and interface information of the target service instance.
[0071] Based on any optional technical solution in the embodiments of the present invention, optionally, the device further includes:
[0072] A routing rule updating module, used to update routing rules based on the update information received from the management platform;
[0073] The update information includes instance update information and / or label update information.
[0074] The technical solution of the embodiment of the present invention, in the case of receiving the target test request sent by the simulated client, determines at least one target microservice corresponding to the target test request on the production side based on the target test request; determines the target instance information of the target service instance in the target microservice based on the routing rules sent by the management platform received in advance; wherein, the target microservice corresponds to at least one service instance, and since the routing rules are used to reflect the correspondence between the test request and the service instance that executes the test request, the target instance information corresponding to the target test request can be determined without hard coding; finally, based on the target instance information, the target test request is routed to the target service instance of the target microservice to call the target service instance to execute the test operation corresponding to the target test request. This embodiment reflects the correspondence between the test request and the service instance through the routing rules, and can quickly determine the target instance information corresponding to the target test request without modifying the source code, thereby improving the flexibility and convenience of testing the microservice.
[0075] It is worth noting that in the embodiment of the above-mentioned microservice testing device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0076] Figure 3 It is a structural schematic diagram of an electronic device that implements the microservice testing method of an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0077] like Figure 3As shown, the electronic device 20 includes at least one processor 21, and a memory connected to the at least one processor 21, such as a read-only memory (ROM) 22, a random access memory (RAM) 23, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 21 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 22 or the computer program loaded from the storage unit 28 to the random access memory (RAM) 23. In RAM23, various programs and data required for the operation of the electronic device 20 can also be stored. The processor 21, ROM22 and RAM23 are connected to each other through a bus 24. An input / output (I / O) interface 25 is also connected to the bus 24.
[0078] A number of components in the electronic device 20 are connected to the I / O interface 25, including: an input unit 26, such as a keyboard, a mouse, etc.; an output unit 27, such as various types of displays, speakers, etc.; a storage unit 28, such as a disk, an optical disk, etc.; and a communication unit 29, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 29 allows the electronic device 20 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0079] The processor 21 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 21 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 21 executes the various methods and processes described above, such as the microservice testing method.
[0080] In some embodiments, the microservice testing method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 28. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 20 via the ROM 22 and / or the communication unit 29. When the computer program is loaded into the RAM 23 and executed by the processor 21, one or more steps of the microservice testing method described above may be performed. Alternatively, in other embodiments, the processor 21 may be configured to execute the microservice testing method in any other appropriate manner (e.g., by means of firmware).
[0081] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0082] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0083] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0084] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0085] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0086] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0087] This embodiment also provides a computer program product, including a computer program, which, when executed by a processor, implements the microservice testing method provided in any embodiment of the present application.
[0088] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0089] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0090] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A microservice testing method, characterized in that: Applied to the consumer side, including: In the case of receiving a target test request sent by a simulated client, determining at least one target microservice on a production side corresponding to the target test request based on the target test request; Determine the target instance information of the target service instance in the target microservice based on the routing rules sent by the management platform received in advance; wherein the target microservice corresponds to at least one service instance, and the routing rules are used to reflect the corresponding relationship between the test request and the service instance that executes the test request; Based on the target instance information, the target test request is routed to the target service instance of the target microservice, so as to call the target service instance to perform a test operation corresponding to the target test request.
2. The method according to claim 1, characterized in that Before determining the target instance information of the target service instance in the target microservice based on the routing rule sent by the management platform received in advance, the method further includes: Receive routing rules sent by the management platform; The routing rules are generated based on a configuration file of a microservice at the production end, and the configuration file includes instance information and a service label of a service instance corresponding to the microservice.
3. The method according to claim 2, characterized in that Before receiving the routing rules sent by the management platform, it also includes: Generate a production-side service list for recording the service instances of each microservice provided by the production end, upload the production-side service list to the registration center to perform a registration operation on the service instance, and synchronize the service tag corresponding to the service instance to the service metadata of the registration center.
4. The method according to claim 1, characterized in that: The determining the target instance information of the target service instance in the target microservice based on the routing rule sent by the management platform received in advance includes: Based on the request type of the target test request, extracting a request parameter in the target test request for determining a target service instance; wherein the request parameter includes at least one of a request header parameter, a session parameter, and a query string; Based on the routing rule, a service instance corresponding to the request parameter is determined as a target service instance, and based on a production-side service list and metadata obtained from a registration platform, target instance information of the target service instance is determined.
5. The method according to claim 1, characterized in that The target instance information includes the Internet Protocol address and interface information of the target service instance; The step of routing the target test request to the target service instance of the target microservice based on the target instance information includes: The target test request is routed to the target service instance of the target microservice according to the Internet Protocol address of the target service instance and the interface information.
6. The method according to claim 1, characterized in that Also includes: Updating the routing rules based on the received update information sent by the management platform; The update information includes instance update information and / or label update information.
7. A microservice testing device, characterized in that: Set up on the consumer side, including: A target microservice determination module is used to determine at least one target microservice on the production side corresponding to the target test request based on the target test request when receiving the target test request sent by the simulated client; A target instance information determination module, used to determine the target instance information of the target service instance in the target microservice based on the routing rules sent by the management platform received in advance; wherein the target microservice corresponds to at least one service instance, and the routing rules are used to reflect the corresponding relationship between the test request and the service instance that executes the test request; A request routing module is used to route the target test request to the target service instance of the target microservice based on the target instance information, so as to call the target service instance to perform a test operation corresponding to the target test request.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the microservice testing method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the microservice testing method according to any one of claims 1 to 6 when executed.
10. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the microservice testing method according to any one of claims 1 to 6.