Impotent test method and device, electronic equipment and storage medium

By configuring pile services in the business service system and generating interrupt reentry rules, and automatically analyzing the call links, the problems of low efficiency and incomplete coverage in the existing technology are solved, and efficient idempotence testing within the system is realized.

CN120540967APending Publication Date: 2025-08-26TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410199500.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-21
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

When conducting idempotence testing in the prior art, automated test cases only reenter at the entrance of the system, and cannot verify the idempotence problems caused by internal jitter in the system. The manual analysis interrupt reentry point is incomplete, inefficient and may damage the test environment.

Method used

By creating a pile service, each business service in the business service system is configured as a business message forwarding, an interrupt reentry rule is generated, and a business message is used to perform interrupt reentry operations, and the call link is automatically analyzed to judge idempotence.

Benefits of technology

It realizes comprehensive idempotence testing within the business service system, improves testing efficiency, avoids the damage to the test environment by manual operations, and can be carried out normally.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120540967A_ABST
    Figure CN120540967A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an idempotence testing method and device, electronic equipment and a computer readable storage medium, and relates to the field of software testing. The method comprises the steps of creating a pile service, and configuring a business message transmitted by a business service to be forwarded through the pile service; obtaining a calling link after the test case triggers the business scene in the business service system; generating an interrupt reentry rule according to the calling link, and indicating the pile service to read the interrupt reentry rule; triggering the test case to send a test request to the first business service, and indicating the pile service to perform an interrupt reentry operation according to an interrupt reentry rule; and obtaining a sensing result and a test response, and judging whether the business scene passes the idempotent test under the interruption reentry operation. According to the embodiment of the invention, the problem that the internal jitter of the system cannot be verified can be effectively solved, and the problems that the testing environment is damaged, the influence range is large and normal operation cannot be carried out in a mode of manually suspending business service are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology. Specifically, the present application relates to an idempotence method, device, electronic device, computer-readable storage medium, and computer program product. Background Art

[0002] Idempotence testing verifies that executing the same operation multiple times produces the same results as executing it only once. Idempotence is crucial in payment and settlement systems. By simulating repeated operations, we verify that the system can avoid issues like duplicate payments, duplicate deductions, and duplicate shipments.

[0003] The relevant technology mainly uses automated test cases to perform reentrant operations at the entrance of the business service system to verify idempotence. If you want to construct interrupt reentrant operations between business services within the system, you need to rely on manual operations, such as stopping some services, intercepting them through tools such as iptables (also called interruption), and repeatedly sending them through packet sending tools, which affects test efficiency. Summary of the Invention

[0004] The embodiments of the present application provide an idempotency testing method, apparatus, electronic device, computer-readable storage medium, and computer program product that can solve the above-mentioned problems of the prior art. The technical solution is as follows:

[0005] According to one aspect of an embodiment of the present application, a method for testing idempotence is provided, the method comprising:

[0006] Create a stub service, and for each business service in the business service system, configure the business message transmitted by the business service to be forwarded through the stub service;

[0007] Obtaining a call link after a test case triggers a business scenario in the business service system, wherein the test case is used to send a test request for the business scenario to the first business service in the call link; the call link is used to describe the call sequence of each business service that executes the business scenario;

[0008] Generate an interruption reentry rule according to the call link, and instruct the stub service to read the interruption reentry rule;

[0009] Triggering the test case to send the test request to the first business service, instructing the stub service to perform an interruption and reentry operation on the business messages transmitted by each business service according to the interruption and reentry rule;

[0010] Obtain the perception result of the business scenario returned by the test case and the test response of the business scenario returned by the first business service, and determine whether the business scenario passes the idempotence test under the interruption reentry operation based on the perception result and the test response.

[0011] According to another aspect of an embodiment of the present application, an idempotence testing device is provided, the device comprising:

[0012] A configuration module, configured to create a stub service, and for each business service in the business service system, configure the business message transmitted by the business service to be forwarded via the stub service;

[0013] A link acquisition module is used to obtain a call link after a test case triggers a business scenario in the business service system. The test case is used to send a test request for the business scenario to the first business service in the call link. The call link is used to describe the call sequence of each business service that executes the business scenario.

[0014] A reading instruction module, configured to generate an interruption reentry rule according to the call link, and instruct the stub service to read the interruption reentry rule;

[0015] An operation instruction module is used to trigger the test case to send the test request to the first business service, and instruct the stub service to perform an interruption and reentry operation on the business message transmitted by each business service according to the interruption and reentry rule;

[0016] A judgment module is used to obtain the perception result of the business scenario returned by the test case and the test response of the business scenario returned by the first business service, and judge whether the business scenario passes the idempotence test under the interruption reentry operation based on the perception result and the test response.

[0017] As an optional implementation, the interrupt reentry rule includes a condition rule and an operation rule;

[0018] The conditional rule is used to describe the characteristics of the service message for the interrupt re-entry operation, and the type of the characteristic includes at least one of a source service identifier, a destination service identifier, coloring information, a message type, a message packet, and structured data;

[0019] The operation rule is used to describe the method of interrupting the re-entry operation, and the method includes at least one of intercepting operation, tampering operation, re-entry of the original message, and re-entry after tampering.

[0020] As an optional implementation manner, the message type is at least one of a test request and the test response;

[0021] If the feature of the service message for the interruption re-entry operation described in the conditional rule is coloring information, the reading instruction module instructs the stub service to read the interruption re-entry rule, which is also used before:

[0022] Instruct the stub service to use the test requests sent by each business service in the call chain as re-entry points. For each re-entry point, use the business service corresponding to the re-entry point as the target business service, and use the test responses sent by the business services located after the target business service in the call chain as the interruption points corresponding to the re-entry point.

[0023] The re-entry point refers to a service message for performing a re-entry operation, and the interruption point refers to a service message for performing an interruption operation.

[0024] As an optional implementation, each service message includes a destination service identifier;

[0025] The stub service is used to receive a business message to be forwarded, determine an address corresponding to a destination service identifier in the business message based on a pre-established correspondence between a service identifier and a business service address, and forward the business message to the address.

[0026] As an optional implementation manner, the business message includes the coloring information of the business scenario, the source business service identifier and the destination service identifier;

[0027] The link acquisition module is used to:

[0028] Triggering the test case to send a test request to the first business service of the business scenario, instructing the stub service to record the forwarded business message;

[0029] After the test case receives the test response sent by the first business service, query the test request forwarded by the stub service according to the coloring information, and use each test request including the coloring information as a target test request;

[0030] The call link is determined according to the source service identifier and the destination service identifier in each target test request.

[0031] As an optional implementation, a perception result of passing means that the business service completes the business scenario and there is only one correct result;

[0032] A failed perception result means that the business service did not complete the business scenario, the business service completed the business scenario but did not produce a correct result, or the business service completed the business scenario but produced multiple correct results.

[0033] As an optional implementation manner, the judgment module is used to:

[0034] If the perception result is passed, and it is determined based on the test response that the business service correctly handles the reentry request, then it is determined that the idempotence test has passed;

[0035] If the perception result is passed and it is determined based on the test response that the business service does not correctly handle the reentry request, it is determined that the idempotence test has failed;

[0036] If the perception result is failure and the test response determines that the business service correctly handles the reentry request, it is determined that the idempotence test has failed;

[0037] If the perception result is failure and the test response determines that the business service does not correctly handle the reentry request, it is determined that the idempotence test has failed.

[0038] As an optional implementation, the reading indication module is specifically configured to:

[0039] Generate an interruption reentry rule according to the call link;

[0040] Instructing a pre-created use case management service to store the test case and the interruption re-entry rule into a use case database, instructing a pre-created use case execution service to read the interruption re-entry rule, write the interruption re-entry rule into a stub rule library, and instructing the stub service to read the interruption re-entry rule from the stub rule library;

[0041] The operation instruction module is specifically used to: instruct the use case execution service in the use case database, triggering the test case to send the test request to the first configured business service.

[0042] As an optional implementation, the judgment module is used to: instruct the use case execution service to receive the perception result returned by the test case and the test response returned by the first business service, and to determine whether the idempotence test is passed based on the perception result and the test response.

[0043] According to another aspect of an embodiment of the present application, an electronic device is provided. The electronic device includes a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of the above method.

[0044] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.

[0045] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, which implements the steps of the above method when executed by a processor.

[0046] The beneficial effects of the technical solution provided by the embodiments of the present application are:

[0047] First, for each business service in the business service system, the business messages transmitted by the business service are configured to be forwarded through the stub service, so that all business messages in the business scenario will pass through the stub service, and further obtain the call link after the test case triggers the business scenario in the business service system, generate an interruption and re-entry rule based on the call link, and have the possibility of performing an interruption and re-entry operation on all business messages involved in the call link, further instruct the stub service to read the interruption and re-entry rule, trigger the test case to send the test request to the first business service, instruct the stub service to perform an interruption and re-entry operation on the business messages transmitted by each business service according to the interruption and re-entry rule, and further obtain the perception result of the business scenario returned by the test case and the first business service The test response of the returned business scenario is used to determine whether the business scenario passes the idempotence test under the interruption and re-entry operation based on the perception results and the test response. The embodiment of the present application disassembles and encapsulates the execution of the business scenario into a call link, and automatically analyzes the interruption and re-entry rules through the call link, which is more comprehensive and more efficient than manual analysis. The ability of the pile service to forward all business messages is utilized to instruct the pile service to perform interruption and re-entry operations on each business message according to the interruption and re-entry rules. This can effectively solve the problem that the related technology is easily intercepted and cannot verify the internal jitter of the system due to re-entry only at the entrance of the business service system. It also overcomes the problem that the manual suspension of business services destroys the test environment, has a large impact range, and cannot be carried out normally. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments of the present application.

[0049] Figure 1 A schematic diagram of the system architecture for implementing idempotence testing provided in an embodiment of the present application;

[0050] Figure 2 A flowchart of an idempotence testing method provided in an embodiment of the present application;

[0051] Figure 3A A schematic diagram of a business service topology designed for a business scenario of executing a test case provided in an embodiment of the present application;

[0052] Figure 3B A schematic diagram of a business service topology configured to forward business messages by a stub service provided in an embodiment of the present application;

[0053] Figure 4 A schematic diagram of determining whether an idempotence test has been passed based on different perception results and test results provided in an embodiment of the present application;

[0054] Figure 5 A schematic diagram of a system structure for idempotence testing provided in an embodiment of the present application;

[0055] Figure 6 An interactive diagram of an idempotency test based on a use case management service, a use case execution service, and a stub service provided in an embodiment of the present application;

[0056] Figure 7 A schematic diagram of a process flow for idempotence testing provided in an embodiment of the present application;

[0057] Figure 8 A schematic diagram of the structure of an idempotence testing device provided in an embodiment of the present application;

[0058] Figure 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] The following describes the embodiments of the present application in conjunction with the accompanying drawings. It should be understood that the embodiments described below in conjunction with the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.

[0060] Those skilled in the art will understand that, unless otherwise stated, the singular forms "a", "an" and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude implementation as other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the present technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the element can be directly connected or coupled to the other element, or it can refer to that the element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used here can include wireless connection or wireless coupling. The term "and / or" used here indicates at least one of the items defined by the term, for example, "A and / or B" can be implemented as "A", or as "B", or as "A and B".

[0061] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0062] First, several terms involved in this application are introduced and explained:

[0063] Idempotence testing verifies that executing the same operation multiple times produces the same result as executing it only once.

[0064] Interruption and reentry: Business services execute business processes through requests and responses. Interruption and reentry refer to two operations: interruption refers to intercepting a request or response, and reentry refers to repeating an already sent request or response. This embodiment of the application combines these two operations to verify whether an internal system interruption and reentry can continue the interrupted business or intercept the reentry. This makes it easier to detect idempotence issues than simply reentry.

[0065] In software engineering or systems engineering, a use case describes how a system responds to external requests. It also defines and describes a coherent functional unit of a system or subsystem without revealing its internal structure. Use cases are a technique for capturing requirements through user scenarios. Each use case provides one or more scenarios that illustrate how a system interacts with end users or other systems—specifically, who can use the system and what it can do—to achieve a clear business goal.

[0066] Microservices (or microservices architecture) is a cloud-native architectural approach that includes many small, loosely coupled, and independently deployable components or services within a single application. These services typically have their own technology stack, including a database and data management model; communicate with each other through a combination of REST APIs, event streams, and message brokers; and are organized according to business capabilities, with service demarcation lines often called bounded contexts.

[0067] With the rapid development of information, cloud technology has gradually become part of every aspect of our lives. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form a resource pool that can be used flexibly and conveniently on demand. Cloud computing technology will become a key support. The backend services of technical network systems, such as video websites, image websites, and more portals, require extensive computing and storage resources. With the rapid development and application of the internet industry, every item will likely have its own unique identification mark, which will need to be transmitted to the backend system for logical processing. Different levels of data will be processed separately. All types of industry data require a strong system support, which can be achieved through cloud computing.

[0068] When conducting idempotency testing in related technologies, on the one hand, automated test cases only re-enter the system at the entrance, that is, only the first business service in the business scenario is re-entered. This is easily intercepted by the anti-re-entry logic of the entrance, and the idempotency problem caused by internal jitter in the system cannot be verified. On the other hand, manual analysis of interruption re-entry points may not cover all aspects. On the other hand, manual operation of interruption re-entry is cumbersome and inefficient. Moreover, manual suspension of business services and other operations may damage the test environment, have a wide impact, and cannot be performed on a regular basis.

[0069] The idempotence testing method, device, electronic device, computer-readable storage medium, and computer program product provided in this application are intended to solve the above technical problems in the prior art.

[0070] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application. It should be noted that the following embodiments can refer to, draw on, or combine with each other, and the same terms, similar features, and similar implementation steps in different embodiments will not be repeated.

[0071] Figure 1 A schematic diagram of a system architecture for implementing idempotency testing provided in an embodiment of the present application, wherein a terminal 102 communicates with a server 104, the terminal runs a business scenario to be tested, the server 104 is a server for the application to be tested, the test application of the terminal 102 runs a test method, generates a test case, and tests the business scenario to be tested by calling the server 104. Specifically, the testing method includes: creating a pile service, for each business service in the business service system, configuring the business message transmitted by the business service to be forwarded through the pile service; obtaining a call link after the test case triggers the business scenario in the business service system, generating an interruption reentry rule according to the call link, and instructing the pile service to read the interruption reentry rule; triggering the test case to send the test request to the first business service, instructing the pile service to perform an interruption reentry operation on the business message transmitted by each business service according to the interruption reentry rule; obtaining the perception result of the business scenario returned by the test case and the test response of the business scenario returned by the first business service, and judging whether the business scenario passes the idempotency test under the interruption reentry operation according to the perception result and the test response.

[0072] Among them, the server 104 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal 102 can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, smart voice interaction device, smart home appliance, vehicle terminal, aircraft, etc., but is not limited to these. The terminal and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.

[0073] The present application provides an idempotency testing method, such as Figure 2 As shown, the method includes S101 to S105, specifically:

[0074] S101 , creating a stub service. For each business service in the business service system, configuring the business message transmitted by the business service to be forwarded through the stub service.

[0075] The pile service created in the embodiment of the present application can be one or more. In some embodiments, the pile service is a distributed architecture.

[0076] It should be understood that the business service system includes multiple business services, and different business services are used for linearly different business logics. Through the interaction of a certain number of business services, the business scenario requested by the test case can be completed. Each business service in the embodiment of the present application can be a microservice.

[0077] It should be noted that in the original business service system, if each business service wants to send a business message to other business services, it adopts a direct sending method. However, this application first configures each business service in the business service system, so that each business service must first send the business message to be transmitted to the pile service, and then the pile service forwards it. Then, when testing the business scenario, since all business messages will pass through the pile service during the test, the embodiment of the present application can provide the pile service with interruption and re-entry rules, and the pile service will interrupt and re-enter the business message according to the interruption and re-entry rules, thereby completing the idempotence test. Compared with the existing technology that can only perform re-entry operations at the entrance of the business service system, this application can interrupt and re-enter any business message during the business scenario, which significantly improves the scope and flexibility of interruption and re-entry operations.

[0078] S102: Obtain a call link after the test case triggers a business scenario in the business service system.

[0079] It should be noted that the embodiments of the present application can pre-generate different test cases for different business scenarios. The embodiments of the present application do not specifically limit the business scenarios. Taking the mobile payment field as an example, it can be transfer, payment, sending red envelopes, paying fees, etc.

[0080] The test case of the embodiment of the present application is used to send a test request to the first business service of the call link and output the perception result of whether the test passes. It should be understood that the test case only knows which business service (that is, the first business service) the test request needs to be sent to, how the first business service handles the test request, and to which business service the test request is further sent. The test case does not need to know. The test case only needs to receive the test response returned by the first business service and output the perception result of whether the test passes based on the test response.

[0081] It should be understood that the test response returned by the first business service to the test case is the last test response to the test request. Figure 3A , which exemplarily shows a schematic diagram of a business service topology designed for a business scenario executed by a test case. As shown in the figure, this embodiment involves business service 1, business service 2, and business service 3. The test case sends test request 1 to business service 1. Business service 1 processes the test request and generates test request 2, which is sent to business service 2. Business service 2 then processes the test request 2 and further generates test request 3, which is sent to business service 3. After business service 3 processes the test request 3, it generates test response 1 and returns it to business service 2. Business service 2 generates test response 2 based on the received test response 1 and sends it to business service 1. Business service 1 generates test response 1 based on the received test response 2 and sends it to the test case. It should be noted that in this embodiment, test requests 1 to 3 can be the same test request or different test requests, and test responses 1 to 3 can be the same test response or different test responses. As can be seen from this embodiment, when the test case receives the test response, it means that the execution of the corresponding business scenario has ended.

[0082] See Figure 3B , which exemplarily shows that Figure 3A A schematic diagram of the business service topology configured in the basic business service system in which the stub service forwards business messages. It can be seen from the figure that when each business service sends a business message, it does not send the business message directly to the next business service. Instead, the business message is first sent to the stub service, and then the stub service forwards it to the next business service. It should be understood that when the stub service does not execute the interrupt reentry rule, the stub service can directly forward the received business message.

[0083] In actual applications, multiple test cases may be executed at the same time. From the perspective of business services, in order to distinguish which use case the received and sent messages belong to, the business service will add an identification information to the sent messages, also known as the coloring information. The coloring information can be a string of hash values. The business service will use the same coloring information when processing related messages (for example, for a request sent for a transaction, the related messages all use the same coloring information, and when performing the next transaction, another coloring information will be used), thereby distinguishing different executions of different test cases.

[0084] From the perspective of test cases, in order to distinguish different test cases and different executions, each test case execution is sent to the business service with different coloring information. Therefore, the coloring information in the message transmitted by different executions of different test cases is different, thereby distinguishing different executions of different test cases.

[0085] In an embodiment of the present application, when the test case sends a test request to the first business service, it carries the coloring information. When the first business service sends information related to the test case to other business services, it carries the coloring information in the message.

[0086] When executing step S102 in the embodiment of the present application, the pile service has not yet obtained the interruption and reentry rules, so the pile service is only responsible for forwarding the received business messages and will not perform interruption and reentry operations on the business messages. However, when forwarding the business messages, the pile service can generate a call link for the business scenario based on the sender and receiver of each business message in a business scenario.

[0087] The call link in the embodiment of the present application is used to describe the call sequence of each business service to execute the business scenario. Figure 3A For example, the call link of this embodiment can be expressed as: business service 1 sends business request 2 to business service 2, business service 2 sends business request 3 to business service 3, business service 3 sends business response 3 to business service 2, and business service 2 sends a business response to business service 1. It can be seen that the call link specifically describes the calling order of each business service through the order of business messages sent between business services.

[0088] S103: Generate an interruption reentry rule according to the call link, and instruct the stub service to read the interruption reentry rule.

[0089] After obtaining a call link, embodiments of the present application can generate interruption and reentry rules based on the call link. It can be understood that the interruption and reentry rules are rules for performing interruption and reentry operations on business messages transmitted by each business in the call link. Specifically, they can indicate which business messages to interrupt, which business messages to reenter, the method of interruption, the method of reentry, and so on. By generating interruption and reentry rules and instructing the stub service to exclusively interrupt and reenter the rules, the present application realizes the automated construction of interruption and reentry scenarios between business services within the business service system.

[0090] It should be noted that the stub service can perform interrupt and re-entry operations on business messages with certain coloring information based on the coloring information. The interrupt and re-entry rules of the embodiment of the present application can be effective for a business message once or multiple times, and can also be specified to be processed after receiving a specific number of times, thereby improving the flexibility of idempotence testing.

[0091] The embodiment of the present application lays the foundation for idempotence testing of business scenarios after the test case is triggered again in the future by indicating the service reading interrupt re-entry rule.

[0092] S104: Trigger the test case to send a test request to the first business service, and instruct the stub service to perform an interruption and reentry operation on the business messages transmitted by each business service according to the interruption and reentry rule.

[0093] By triggering the test case to send the test request to the first business service, each business service involved in the call link will start to execute the business scenario and send business messages. The stub service is instructed to perform terminal reentry operations on the business messages transmitted by each business service in the call link according to the interruption and reentry rules, laying the foundation for subsequent judgment of whether the idempotence test has passed.

[0094] S105. Obtain the perception result of the business scenario returned by the test case and the test response of the business scenario returned by the first business service, and determine whether the business scenario passes the idempotence test under the interruption reentry operation based on the perception result and the test response.

[0095] As can be seen from the above embodiment, the test case will finally receive the test response returned by the first business service, and judge the perception result of the business scenario based on the test response. The perception results of the embodiment of the present application include two situations: pass and fail. Pass means that the business service completes the business scenario and there is only one correct result. Failure has the following three situations:

[0096] Case 1: Business service does not complete the business scenario;

[0097] Case 2: The business service completes the business scenario but does not produce the correct result;

[0098] Case 3: The business service completes the business scenario but has multiple correct results

[0099] Taking the transfer business scenario as an example, if the business service fails to complete the business scenario, it means that the transfer is not completed; if the business service completes the business scenario but has no correct result, it means that although the transfer is completed, the transfer amount is incorrect; if the business service completes the business scenario but has multiple correct results, it means that although the transfer is completed, the number of times it is completed exceeds one, resulting in duplicate transfers.

[0100] The embodiment of the present application determines whether the business scenario passes the idempotence test under the interrupt reentry operation based on information from two dimensions: perception results and test response, thereby improving the accuracy of obtaining the idempotence test results.

[0101] In the embodiment of the present application, for each business service in the business service system, the business messages transmitted by the business service are configured to be forwarded through the pile service, so that all business messages in the business scenario will pass through the pile service, and further obtain the call link after the test case triggers the business scenario in the business service system, generate an interruption and re-entry rule according to the call link, and have the possibility of performing an interruption and re-entry operation on all business messages involved in the call link, further instruct the pile service to read the interruption and re-entry rule, trigger the test case to send the test request to the first business service, instruct the pile service to perform an interruption and re-entry operation on the business messages transmitted by each business service according to the interruption and re-entry rule, and further obtain the perception result of the business scenario returned by the test case and the first business The service service returns a test response to the business scenario, and judges whether the business scenario passes the idempotence test under the interruption and re-entry operation based on the perception result and the test response. The embodiment of the present application disassembles and encapsulates the execution of the business scenario into a call link, and automatically analyzes the interruption and re-entry rules through the call link, which is more comprehensive and more efficient than manual analysis. The ability of the pile service to forward all business messages is utilized to instruct the pile service to perform interruption and re-entry operations on each business message according to the interruption and re-entry rules. This can effectively solve the problem that the related technology is easy to be intercepted and the internal jitter of the system cannot be verified due to re-entry only at the entrance of the business service system. It also overcomes the problem that the manual suspension of business services destroys the test environment, has a large impact range, and cannot be carried out normally.

[0102] The business message of the embodiment of the present application may include a source service identifier, a destination service identifier, coloring information, a message type, a message message and message structured data, wherein the source service identifier refers to the identifier of the business service that sends the business message; correspondingly, the destination service identifier refers to the identifier of the business service that receives the business message; there are two message types, namely test request and test response; the message message is the specific content of the business message, and the message structured data is the structured representation of the message message.

[0103] For example, a service message is {"src":"A","dst":"B","dna":"11111","type":"req","message":"x=1&y=2","map":{"x":1,"y":2}}. In this service message, src is the source service identifier, dst is the destination service identifier, dna is the dyeing information, type is the message type, req is the test response, message is the message message, and map is the message structured data.

[0104] The interruption and re-entry rules of the embodiment of the present application include conditional rules and operation rules, wherein the conditional rules describe the conditions that the business message for performing the interruption and re-entry operation must meet, that is, the characteristics it must possess. The type of characteristics of the present application may refer to at least one of the source service identifier, destination service identifier, coloring information, message type, message packet, and structured data.

[0105] Taking the feature type of coloring information as an example, after receiving any business message, the pile service parses the business message, obtains the coloring information in the business message, and matches the coloring information with the conditional rules in the interruption and re-entry rules. If it is found that the coloring information is the coloring information of the business message for the interruption and re-entry operation described by the conditional rules, then the business message will be interrupted and re-entered according to the operation rules.

[0106] The operation rules of the embodiment of the present application are used to describe the method of interrupting the re-entry operation, which includes at least one of intercepting operation, tampering operation, re-entry of the original message, and re-entry after tampering.

[0107] It should be noted that interception and reentry operations are not effective for the same conditional rule. The stub service can configure both interception and reentry rules at the same time. For example, Figure 3B Taking the embodiment as an example, for test response 2, the operation rule can be an interception operation, such as intercepting business service 2 to return test response 2 of business service 1 once. For test request 2, the operation rule can be re-entry of the original message once, that is, re-entering business service 1 to request test request 2 of business service 2 once.

[0108] Reentry after tampering means tampering with the reentry message. There are also cases where the message is not reentered but only tampered. For example, Figure 3B Taking the embodiment as an example, if the operation rule of the test request 3 is re-entry after tampering, the pile service tampered with the test request 3 according to the operation rule. For example, the rule can carry the tampered message, and the pile service forwards the tampered test request 3 to the business service 3.

[0109] It should be noted that in the case of tampering, the rules also need to provide a map of the tampered field values ​​of the business message. The stub service repackages the tampered field values ​​according to the rules. The following pseudo code illustrates the case of constructing a business service B calling a business service C and returning an interception:

[0110]

[0111] In the above pseudocode, "condition" represents the conditional rule, which describes the interrupt reentry operation for the business message with the destination service identifier C, the message type as a test request, and the coloring information as "11111". "Operation" represents the operation rule, and the operation type is "drop", which means interception. Then, the stub service needs to intercept the test request that meets the above conditional rules.

[0112] Based on the above embodiments, as an optional embodiment, the message type is at least one of a test request and the test response.

[0113] If the feature of the business message for the interruption and reentry operation described in the conditional rule is coloring information, that is, the conditional rule only limits the coloring information, it means that the stub service needs to perform the interruption and reentry operation on all business messages with the corresponding coloring information. The stub service also needs to further determine the reentry point and the interruption point. Specifically,

[0114] Using the test request sent by each business service in the call link as a re-entry point, wherein the re-entry point refers to the business message for the re-entry operation;

[0115] For each re-entry point, the business service corresponding to the re-entry point is used as the target business service, and the test response sent by the business service located after the target business service in the call link is used as the interruption point corresponding to the re-entry point. The interruption point refers to the business message for performing an interruption operation.

[0116] That is to say, the stub service of the embodiment of the present application needs to perform a re-entry operation for each test request on the call link and needs to perform an interrupt operation for all test responses.

[0117] The following example illustrates this. Assuming the business scenario of the test case is a refund, after executing the test case, all test requests and test responses passing through the stub service can be queried based on the test case's coloring information. The source src and destination dst of each business message can be obtained. The pseudo code of the call link can be expressed as follows:

[0118]

[0119] In the above pseudo code, A to G represent different business services. According to the destination service identifier of each business message, it can be known that the re-entry point is a business message with dst = A, B, C, D, E, F, G, and type = req. For each re-entry point, the interruption point is searched for downstream of the link. For example, taking the business message with src = B and type = req as an example, its subsequent interruption point is a business message with dst = C, D, E, F, G, and type = rsp. The pseudo code for determining the re-entry point and interruption point in the embodiment of the present application can be expressed as:

[0120] init downstreammap = {interface: downstreaminterface[]}

[0121] For calling the data list of the call link:

[0122] Get call link data src dst

[0123] dst is inserted into the downstream map[src]

[0124] for k,v:=range downstream map:

[0125] Call func to get the downstream interface (k) and return the updated v

[0126] func takes the downstream interface (interface x):

[0127] Interface list: = downstream map [interface x]

[0128] for i,interface:=range interface list:

[0129] If interface i is in the downstream map:

[0130] Call func to get the downstream interface (interface i) and return the updated interface list

[0131] Return a list of duplicate interfaces

[0132] Simply put, the logic of the above pseudocode involves first traversing the call chain to anchor the reentry point, then traversing the subsequent call chains based on the reentry point to exhaustively search for breakpoints. This involves recursively searching for downstream interfaces and updating the interface list. The final interface list is the list of breakpoints. The interface in the pseudocode strictly refers to the interface name of the business service. The call chain records which business service (interface) is called from which business service (interface). It can also be simply understood as the source service identifier and the destination service identifier. "Map" refers to "mapping." By obtaining the source service identifier src and the destination service identifier dst from the call chain, for the downstream map (i.e., the mapping from a certain interface to a list of downstream interfaces), src is used as the key to find the list of mapped values ​​and insert dst at the end of the list. k and v are local variables defined in the for loop. The pseudocode for the for loop is written in a Golang-like manner. It ranges the downstream map (i.e., the mapping from a certain interface to a list of downstream interfaces). For each interface k, the corresponding interface list is v. In the pseudocode, "call func to get downstream interface (k)" means calling the function func defined below, which gets the downstream interface (interface x). The parameter k is passed as the traversed interface. This function returns a list of interfaces without duplicates. Based on the result of the function, v is updated, which is the list of downstream interfaces corresponding to k. It should be understood that x is a formal parameter and k is an actual parameter in the pseudocode.

[0133] The embodiment of the present application obtains the call link after the test case triggers the business scenario, including:

[0134] S201, triggering the test case to send a test request to the first business service of the business scenario, instructing the stub service to record the forwarded business message;

[0135] S202: After the test case receives the test response sent by the first business service, query the test requests forwarded by the stub service according to the coloring information, and use each test request including the coloring information as a target test request;

[0136] S203: Determine the call link according to the source service identifier and the destination service identifier in each target test request.

[0137] The embodiment of the present application sends a test request to the first business service of the business scenario by triggering a test case, and instructs the pile service to record the forwarded business message. In some embodiments, the forwarding service can only record part of the business message information, such as coloring information, source service identifier and destination service identifier. When the test case receives the test response sent by the first business service, it indicates that the execution of the business scenario is completed. At this time, the pile service can be instructed to determine the call link. Since in actual application, the pile service will receive a large number of business messages sent by business services, it is necessary to query whether the various test requests forwarded by the pile service include coloring information based on the coloring information. Each test request including the coloring information is used as a target test request, and then a call link is constructed according to the order of the source service identifier and the destination service identifier in each target test request.

[0138] Based on the above embodiments, as an optional embodiment, each business message includes a destination service identifier, that is, the service identifier of the business service that receives the business message. The pile service of the embodiment of the present application has a service discovery capability, that is, the ability to discover the address of the business service or the addresses of other related business services through the service identifier (such as the name) of the business service, so as to effectively forward the business message.

[0139] The pile service of the embodiment of the present application pre-stores the correspondence between the service identifier and the address of the business service. Therefore, after receiving the business message, the corresponding relationship is queried based on the destination service identifier included in the business message, the address corresponding to the destination service identifier is determined, and the business message is forwarded to the address to realize the forwarding of the business message.

[0140] Based on the above embodiments, the perception result of pass means that the business service completes the business scenario, and there is only one correct result. Taking transfer as an example, the perception result of pass means that the transfer is completed, and the transfer amount, transfer object, etc. are all correct.

[0141] The perception result of failure means that the business service has not completed the business scenario, the business service has completed the business scenario but has no correct result, or the business service has completed the business scenario but has multiple correct results. Taking transfer as an example, the perception result of failure may be a transfer failure, or a transfer success but the transfer amount or transfer object is incorrect, or a transfer success but the number of transfers is incorrect.

[0142] In this embodiment of the application, judging whether the idempotence test is passed based on the perception result and the test response includes:

[0143] If the perception result is passed, and it is determined based on the test response that the business service correctly handles the reentry request, then it is determined that the idempotence test has passed;

[0144] If the perception result is passed and it is determined based on the test response that the business service does not correctly handle the reentry request, it is determined that the idempotence test has failed;

[0145] If the perception result is failure and the test response determines that the business service correctly handles the reentry request, it is determined that the idempotence test has failed.

[0146] If the perception result is failure and the test response determines that the business service does not correctly handle the reentry request, it is determined that the idempotence test has failed.

[0147] The following example shows user A transferring 1 cent to user B. Under normal circumstances:

[0148] The request interface is transfer, the request parameters are: payee = A, payee = B, amount = 1 cent. The business system processes the request to execute payee A minus 1 cent and payee B plus 1 cent. After the processing is completed, it returns the test response: transfer successful (error code = 0).

[0149] Here are some examples of errors:

[0150] 1. Business service execution: Payee A deducts 1 cent, payee B adds 2 cents;

[0151] 2. Business service execution: Payee A deducts 1 cent, payee B deducts 1 cent;

[0152] In both cases, after the processing is completed, the test response is returned: Transfer successful (error code = 0)

[0153] If interrupt reentry is not performed, the test case is executed:

[0154] Construct request parameters: payee = A, payee = B, amount = 1 cent, and send to the transfer interface;

[0155] Check the test response, expected: transfer successful (error code > 0)

[0156] Check the database, as expected: payee A deducts 1 cent, payee B deducts 1 cent (ensuring that the test response meets expectations and the transaction results are correct)

[0157] When performing an interruption and reentry operation, if the interruption occurs after the payee A subtracts 1 point (the payee B has not added it yet), the request will be resent.

[0158] See Figure 4 , which exemplarily shows a schematic diagram of judging whether the idempotence test is passed based on different perception results and test conditions provided by an embodiment of the present application.

[0159] Several manifestations of business systems:

[0160] The test case perceives that the payee A has deducted 1 point and continues to add 1 point to the payee B. The test response is: transfer successful (error code = 0). In this case, the perception result is passed and the business service is determined to have correctly completed the re-entry request based on the test response, then the idempotence test is determined to have passed.

[0161] The test case detects that the payee A has subtracted 1 cent and continues to add 1 cent to the payee B. The test response is: transfer failed (error code = 1). In this case, the perception result is passed, and according to the test response, it is determined that the business service did not correctly complete the reentry request, and it is determined that the idempotence test has failed. It should be noted that the probability of this situation occurring is almost 0. It may be that the test case did not correctly check the response and the response was not expected (-1).

[0162] The test case does not perceive that the payee A has already subtracted 1 cent, and then completes the payee A subtracting 1 cent again (that is, subtracting 2 cents), and the payee B adding 1 cent. The test response is: transfer successful (error code = 0). In this case, the perception result is failure, and according to the test response, it is determined that the business service correctly completes the reentry request, which means that the idempotence test has failed.

[0163] The test case detects that the payee A has deducted 1 cent, but the payee B has not added 1 cent. The test response is: transfer successful (error code = 0). In this case, the perception result is failure. According to the test response, it is determined that the business service correctly completes the reentry request, and the idempotence test is determined to have failed.

[0164] The test case detects that the payee A has subtracted 1 cent and the payee B has added 1 cent, but the rollback adds 1 cent back to the payee. The test response is: transfer successful (error code = 0). In this case, the perception result is failure, and based on the test response, it is determined that the business service correctly completes the re-entry request, then it is determined that the idempotence test has failed (this situation is not within the definition of idempotence, the funds are not miscalculated, but the response does not match the action of the business system).

[0165] The test case perceives that the payee A has subtracted 1 cent and the payee B has added 1 cent. The test response is: transfer failed (error code = -1). In this case, the perception result is failure, and according to the test response, it is determined that the business service did not correctly complete the reentry request, and it is determined that the idempotence test has failed.

[0166] The test case detects that the payee A deducted 1 cent from the balance, but did not subsequently add 1 cent to the payee B. The test response is: transfer failed (error code = -1). In this case, the perception result is failure, and based on the test response, it is determined that the business service did not correctly complete the reentry request, and thus the idempotence test is determined to have failed.

[0167] The test case detects that the payment to payee A has been deducted by 1 cent, and the payment is rolled back to add 1 cent to the payee. The test response is: transfer failed (error code = -1). In this case, the perception result is failure, and according to the test response, it is determined that the business service did not correctly complete the reentry request, and thus the idempotence test is determined to have failed (this case is not within the definition of idempotence, but since the funds were not miscalculated, the business accepts it).

[0168] Based on the above embodiments, as an optional embodiment, the embodiment of the present application also includes creating a use case management service and a use case execution service, see Figure 5 , which exemplarily shows a schematic diagram of the system structure of the idempotence test provided by an embodiment of the present application. As shown in the figure, the use case management service is used to store test cases and interruption and reentry rules in the use case database. In some embodiments, the interruption and reentry rules can be generated by the use case management service, or generated by the execution entity of the embodiment of the present application and sent to the use case management service.

[0169] The use case execution service is used to read test cases and interruption and re-entry rules from the use case database. The use case execution service first writes the interruption and re-entry rules into the stub rule library, and instructs the stub service to read the interruption and re-entry rules in the stub rule library. The stub service sends a response to the use case execution service after reading the interruption and re-entry rules. After receiving the response, the use case execution service instructs the test case to send a test request to the business service. Each business service sends the business message to the stub service, which forwards it and instructs the stub service to perform interruption and re-entry operations on the business messages transmitted by each business service according to the interruption and re-entry rules.

[0170] On the basis of the above embodiments, the embodiment of the present application generates an interruption reentry rule according to the call link and instructs the stub service to read the interruption reentry rule, including:

[0171] Generate an interruption reentry rule according to the call link;

[0172] Instructing the use case management service to store the test case and the interruption reentry rule in the use case database;

[0173] Instructing the use case execution service to read the interruption reentry rule and write the interruption reentry rule into a stub rule library;

[0174] The stub service is instructed to read the interrupt re-entry rule from the stub rule library.

[0175] Triggering the test case to send the test request to the first configured business service includes:

[0176] Instruct the use case execution service in the use case database to trigger the test case to send the test request to the first configured business service.

[0177] Based on the above embodiments, as an optional embodiment, obtaining the perception result returned by the test case and the test response returned by the first business service, and judging whether the business scenario passes the test under the interruption reentry operation according to the perception result and the test response, includes:

[0178] Instruct the use case execution service to receive the perception result returned by the test case and the test response returned by the first business service, and determine whether the idempotence test is passed based on the perception result and the test response.

[0179] The embodiment of the present application instructs the use case execution service to receive the perception results and test responses, and determines whether the idempotence test is passed. Each process of the idempotence test process is executed by different services, so that the responsibilities and boundaries of each service are clearly defined.

[0180] See Figure 6 , which exemplarily shows an interaction diagram of idempotence testing based on the use case management service, use case execution service, and stub service provided in an embodiment of the present application, as shown in the figure, including:

[0181] S301. The use case management service stores the test cases and interruption reentry rules in the use case database;

[0182] S302, the use case execution service reads the test case and interrupt reentry rules from the use case server;

[0183] S303, the use case execution service writes the interruption reentry rule into the stub rule library;

[0184] S304, the stub service reads the interrupt reentry rule from the stub rule library and sends a response message to the use case execution service;

[0185] S305: The use case execution service triggers the test case to send a test request to the business service;

[0186] S306, the pile service receives the business message sent by the business service and performs an interruption and reentry operation on the business message transmitted by each business service according to the interruption and reentry rule;

[0187] S307: The use case execution service receives the perception result returned by the test case and the test response returned by the first business service, and determines whether the idempotence test is passed based on the perception result and the test response.

[0188] See Figure 7 , which exemplarily shows a flow chart of the idempotence test provided in an embodiment of the present application, as shown in the figure, including:

[0189] S401, create use case management service, use case execution service and stub service;

[0190] S402: For each business service in the business service system, configure the business message transmitted by the business service to be forwarded through the stub service;

[0191] S403, instructing the test case to trigger a business scenario in the business service system, instructing the stub service to record the forwarded business message, and generating a call link according to the forwarded business message;

[0192] S404: Generate an interruption and reentry rule according to the call link, and instruct the use case management service to store the test case and the interruption and reentry rule in a use case database;

[0193] S405, instructing the use case execution service to read the interruption reentry rule, writing the interruption reentry rule into a pile rule base, and instructing the pile service to read the interruption reentry rule from the pile rule base;

[0194] S406, triggering the test case to send the test request to the first business service, instructing the stub service to perform an interruption and reentry operation on the business messages transmitted by each business service according to the interruption and reentry rule;

[0195] S407: Instruct the use case execution service to receive the perception result returned by the test case and the test response returned by the first business service, and determine whether the idempotence test is passed based on the perception result and the test response.

[0196] The embodiment of the present application provides an idempotence testing device, such as Figure 8 As shown, the device may include: a configuration module 801, a link acquisition module 802, a reading instruction module 803, an operation instruction module 804 and a judgment module 805, wherein:

[0197] Configuration module 801, used to create a stub service, for each business service in the business service system, configured to forward business messages transmitted by the business service through the stub service;

[0198] Link acquisition module 802 is used to obtain a call link after a test case triggers a business scenario in the business service system. The test case is used to send a test request for the business scenario to the first business service in the call link; the call link is used to describe the call sequence of each business service that executes the business scenario;

[0199] A reading instruction module 803 is used to generate an interruption reentry rule according to the call link and instruct the stub service to read the interruption reentry rule;

[0200] An operation instruction module 804 is used to trigger the test case to send the test request to the first business service, and instruct the stub service to perform an interruption and reentry operation on the business message transmitted by each business service according to the interruption and reentry rule;

[0201] The judgment module 805 is used to obtain the perception result of the business scenario returned by the test case and the test response of the business scenario returned by the first business service, and judge whether the business scenario passes the idempotence test under the interruption reentry operation based on the perception result and the test response.

[0202] As an optional implementation, the interrupt reentry rule includes a condition rule and an operation rule;

[0203] The conditional rule is used to describe the characteristics of the service message for the interrupt re-entry operation, and the type of the characteristic includes at least one of a source service identifier, a destination service identifier, coloring information, a message type, a message packet, and structured data;

[0204] The operation rule is used to describe the method of interrupting the re-entry operation, and the method includes at least one of intercepting operation, tampering operation, re-entry of the original message, and re-entry after tampering.

[0205] As an optional implementation manner, the message type is at least one of a test request and the test response;

[0206] If the feature of the service message for the interruption re-entry operation described in the conditional rule is coloring information, the reading instruction module instructs the stub service to read the interruption re-entry rule, which is also used before:

[0207] Instruct the stub service to use the test requests sent by each business service in the call chain as re-entry points. For each re-entry point, use the business service corresponding to the re-entry point as the target business service, and use the test responses sent by the business services located after the target business service in the call chain as the interruption points corresponding to the re-entry point.

[0208] The re-entry point refers to a service message for performing a re-entry operation, and the interruption point refers to a service message for performing an interruption operation.

[0209] As an optional implementation, each service message includes a destination service identifier;

[0210] The stub service is used to receive a business message to be forwarded, determine an address corresponding to a destination service identifier in the business message based on a pre-established correspondence between a service identifier and a business service address, and forward the business message to the address.

[0211] As an optional implementation manner, the business message includes the coloring information of the business scenario, the source business service identifier and the destination service identifier;

[0212] The link acquisition module is used to:

[0213] Triggering the test case to send a test request to the first business service of the business scenario, instructing the stub service to record the forwarded business message;

[0214] After the test case receives the test response sent by the first business service, query the test request forwarded by the stub service according to the coloring information, and use each test request including the coloring information as a target test request;

[0215] The call link is determined according to the source service identifier and the destination service identifier in each target test request.

[0216] As an optional implementation, a perception result of passing means that the business service completes the business scenario and there is only one correct result;

[0217] A failed perception result means that the business service did not complete the business scenario, the business service completed the business scenario but did not produce a correct result, or the business service completed the business scenario but produced multiple correct results.

[0218] As an optional implementation manner, the judgment module is used to:

[0219] If the perception result is passed, and it is determined based on the test response that the business service correctly handles the reentry request, then it is determined that the idempotence test has passed;

[0220] If the perception result is passed and it is determined based on the test response that the business service does not correctly handle the reentry request, it is determined that the idempotence test has failed;

[0221] If the perception result is failure and the test response determines that the business service correctly handles the reentry request, it is determined that the idempotence test has failed.

[0222] If the perception result is failure and the test response determines that the business service does not correctly handle the reentry request, it is determined that the idempotence test has failed.

[0223] As an optional implementation, the reading indication module is specifically configured to:

[0224] Generate an interruption reentry rule according to the call link;

[0225] Instructing a pre-created use case management service to store the test case and the interruption re-entry rule into a use case database, instructing a pre-created use case execution service to read the interruption re-entry rule, write the interruption re-entry rule into a stub rule library, and instructing the stub service to read the interruption re-entry rule from the stub rule library;

[0226] The operation instruction module is specifically used to: instruct the use case execution service in the use case database, triggering the test case to send the test request to the first configured business service.

[0227] The device of the embodiment of the present application can execute the method provided by the embodiment of the present application, and its implementation principle is similar. The actions performed by each module in the device of each embodiment of the present application correspond to the steps in the method of each embodiment of the present application. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, and will not be repeated here.

[0228] In an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored on the memory. The processor executes the above-mentioned computer program to implement the steps of the idempotence testing method. Compared with the relevant technology, it can be achieved: first, for each business service in the business service system, the business message transmitted by the business service is configured to be forwarded through the pile service, so that all business messages in the business scenario will pass through the pile service, and further obtain the call link after the test case triggers the business scenario in the business service system, generate an interruption and re-entry rule according to the call link, and have the possibility of interruption and re-entry operations on all business messages involved in the call link, further instruct the pile service to read the interruption and re-entry rule, trigger the test case to send the test request to the first business service, and instruct the pile service to interrupt the business messages transmitted by each business service according to the interruption and re-entry rule. Re-entry operation, further obtaining the perception result of the business scenario returned by the test case and the test response of the business scenario returned by the first business service, and judging whether the business scenario passes the idempotence test under the interruption re-entry operation according to the perception result and the test response. The embodiment of the present application disassembles and encapsulates the execution of the business scenario into a call link, and automatically analyzes the interruption re-entry rules through the call link, which is more comprehensive and more efficient than manual analysis. The ability of the pile service to forward all business messages is utilized to instruct the pile service to perform interruption re-entry operations on each business message according to the interruption re-entry rules. This can effectively solve the problem that the related technology is easily intercepted and cannot verify the internal jitter of the system due to re-entry only at the entrance of the business service system, and also overcomes the problem that the manual suspension of business services destroys the test environment, has a large impact range, and cannot be carried out normally.

[0229] In an alternative embodiment, an electronic device is provided, such as Figure 9As shown, Figure 9 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which may be used for data exchange between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the number of transceivers 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.

[0230] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

[0231] Bus 4002 may include a path for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, for example. Bus 4002 may be divided into an address bus, a data bus, a control bus, and so on. For ease of illustration, bus 4002 is represented by a single thick line in the figure, but this does not indicate that there is only one bus or only one type of bus.

[0232] The memory 4003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation here.

[0233] The memory 4003 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the above method embodiment.

[0234] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.

[0235] An embodiment of the present application also provides a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiment when executed by a processor.

[0236] The terms "first," "second," "third," "fourth," "1," "2," and the like (if any) in the specification and claims of this application and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or sequential sequence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the application described herein can be implemented in an order other than that shown or described in the drawings.

[0237] It should be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the order of implementation of these steps is not limited to the order indicated by the arrows. Unless otherwise clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart can include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage in these sub-steps or stages can also be executed at different times respectively. Under different scenarios at the execution time, the execution order of these sub-steps or stages can be flexibly configured according to demand, and the embodiment of the present application does not limit this.

[0238] The above description is only an optional implementation method for some implementation scenarios of this application. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the solution of this application, the use of other similar implementation methods based on the technical ideas of this application also falls within the protection scope of the embodiments of this application.

Claims

1. A method for testing idempotence, characterized in that: include: Create a stub service, and for each business service in the business service system, configure the business message transmitted by the business service to be forwarded through the stub service; Obtaining a call link after a test case triggers a business scenario in the business service system, wherein the test case is used to send a test request for the business scenario to the first business service in the call link; the call link is used to describe the call sequence of each business service that executes the business scenario; Generate an interruption reentry rule according to the call link, and instruct the stub service to read the interruption reentry rule; Triggering the test case to send the test request to the first business service, instructing the stub service to perform an interruption and reentry operation on the business messages transmitted by each business service according to the interruption and reentry rule; Obtain the perception result of the business scenario returned by the test case and the test response of the business scenario returned by the first business service, and determine whether the business scenario passes the idempotence test under the interruption reentry operation based on the perception result and the test response.

2. The method according to claim 1, characterized in that The interrupt re-entry rule includes condition rules and operation rules; The conditional rule is used to describe the characteristics of the service message for the interrupt re-entry operation, and the type of the characteristic includes at least one of a source service identifier, a destination service identifier, coloring information, a message type, a message packet, and structured data; The operation rule is used to describe the method of interrupting the re-entry operation, and the method includes at least one of intercepting operation, tampering operation, re-entry of the original message, and re-entry after tampering.

3. The method according to claim 2, characterized in that The message type is at least one of a test request and a test response; If the service message for the interruption re-entry operation described in the conditional rule has the characteristic of coloring information, instructing the stub service to read the interruption re-entry rule, the method further includes: Instruct the stub service to use the test requests sent by each business service in the call link as re-entry points, and for each re-entry point, use the business service corresponding to the re-entry point as the target business service, and use the test responses sent by the business services located after the target business service in the call link as the interruption points corresponding to the re-entry point; The re-entry point refers to a service message for performing a re-entry operation, and the interruption point refers to a service message for performing an interruption operation.

4. The method according to claim 1, wherein Each business message includes a destination service identifier; The stub service is used to receive a business message to be forwarded, determine an address corresponding to a destination service identifier in the business message based on a pre-established correspondence between a service identifier and a business service address, and forward the business message to the address.

5. The method according to claim 1, characterized in that The service message includes the coloring information of the service scenario, the source service identifier and the destination service identifier; The obtaining of the call link after the test case triggers the business scenario in the business service system includes: Triggering the test case to send a test request to the first business service of the business scenario, instructing the stub service to record the forwarded business message; After the test case receives the test response sent by the first business service, query the test request forwarded by the stub service according to the coloring information, and use each test request including the coloring information as a target test request; The call link is determined according to the order of the source service identifier and the destination service identifier in each target test request.

6. The method according to claim 1, characterized in that The perception result of "pass" means that the business service completes the business scenario and there is only one correct result; The perception result of "failed" means that the business service does not complete the business scenario, the business service completes the business scenario but has no correct result, or the business service completes the business scenario but has multiple correct results.

7. The method according to claim 6, characterized in that Based on the perception results and the test response, determine whether the idempotence test is passed, including: If the perception result is passed, and it is determined based on the test response that the business service correctly handles the reentry request, then it is determined that the idempotence test has passed; If the perception result is passed and it is determined based on the test response that the business service does not correctly handle the reentry request, it is determined that the idempotence test has failed; If the perception result is failure and the test response determines that the business service correctly handles the reentry request, it is determined that the idempotence test has failed; If the perception result is failure and the test response determines that the business service does not correctly handle the reentry request, it is determined that the idempotence test has failed.

8. The method according to any one of claims 1 to 7, characterized in that Generating an interruption reentry rule according to the call link and instructing the stub service to read the interruption reentry rule includes: Generate an interruption reentry rule according to the call link; Instructing a pre-created use case management service to store the test case and the interruption re-entry rule into a use case database, instructing a pre-created use case execution service to read the interruption re-entry rule, write the interruption re-entry rule into a stub rule library, and instructing the stub service to read the interruption re-entry rule from the stub rule library; Triggering the test case to send the test request to the first configured business service includes: Instruct the use case execution service in the use case database to trigger the test case to send the test request to the first configured business service.

9. The method according to claim 8, characterized in that The obtaining of the perception result returned by the test case and the test response returned by the first business service, and determining whether the business scenario passes the test under the interruption reentry operation according to the perception result and the test response, includes: Instruct the use case execution service to receive the perception result returned by the test case and the test response returned by the first business service, and determine whether the idempotence test is passed based on the perception result and the test response.

10. An idempotence testing device, characterized in that: include: A configuration module, configured to create a stub service, and for each business service in the business service system, configure the business message transmitted by the business service to be forwarded via the stub service; A link acquisition module is used to obtain a call link after a test case triggers a business scenario in the business service system. The test case is used to send a test request for the business scenario to the first business service in the call link. The call link is used to describe the call sequence of each business service that executes the business scenario. A reading instruction module, configured to generate an interruption reentry rule according to the call link, and instruct the stub service to read the interruption reentry rule; An operation instruction module is used to trigger the test case to send the test request to the first business service, and instruct the stub service to perform an interruption and reentry operation on the business message transmitted by each business service according to the interruption and reentry rule; A judgment module is used to obtain the perception result of the business scenario returned by the test case and the test response of the business scenario returned by the first business service, and judge whether the business scenario passes the idempotence test under the interruption reentry operation based on the perception result and the test response.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the idempotence testing method according to any one of claims 1 to 9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the idempotence testing method according to any one of claims 1 to 9 is implemented.

13. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the idempotence testing method according to any one of claims 1 to 9 is implemented.