CN117056198A - Mock test method, mock test device, medium and computer equipment - Google Patents

Mock test method, mock test device, medium and computer equipment Download PDF

Info

Publication number
CN117056198A
CN117056198A CN202310358731.2A CN202310358731A CN117056198A CN 117056198 A CN117056198 A CN 117056198A CN 202310358731 A CN202310358731 A CN 202310358731A CN 117056198 A CN117056198 A CN 117056198A
Authority
CN
China
Prior art keywords
service
mock
cluster
strategy
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310358731.2A
Other languages
Chinese (zh)
Inventor
周小亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202310358731.2A priority Critical patent/CN117056198A/en
Publication of CN117056198A publication Critical patent/CN117056198A/en
Pending legal-status Critical Current

Links

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The application discloses a mock testing method, a device, a medium and computer equipment, wherein the method comprises the steps of obtaining a self-defined cluster strategy of a service requester, wherein the cluster strategy is used for matching mock testing service for the service requester, and the cluster strategy is obtained based on external interface expansion of a Dubbo framework; adding the cluster strategy to the inheritable abstract execution class to obtain an executable cluster strategy execution class; adding the cluster policy enforcement class to the configuration of the Dubbo framework; and responding to the service request initiated by the service request party to a service provider, and judging whether the service request party matches the mock test service of the Dubbo framework or not based on the cluster policy execution class. The method and the device can quickly set the logic for matching the mock service on the premise of not changing the original configuration of the Dubbo frame, and overcome various limitations of the mock service of the Dubbo frame.

Description

Mock test method, mock test device, medium and computer equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a mock testing method, a mock testing device, a medium, and a computer device.
Background
Currently, in the process of project development, testing and joint debugging, some situations that downstream service call is not feasible are often encountered, and in order to not depend on downstream systems, most of applications are currently native mock testing services based on a Dubbo framework, or service requests are drained to the mock testing services through a filter to solve the problem.
However, the native mock test service of the Dubbo framework focuses on the degradation requirements of the production level, requiring modification of the original Dubbo configuration in the project at execution time, which is complex. If the service request is drained to the mock service based on the filter, the service provider needs to be online, otherwise, an exception is thrown, so that the limit of enabling the mock test service through the filter is larger.
Disclosure of Invention
The embodiment of the application provides a mock testing method, a mock testing device, a medium and computer equipment, which can be used for testing the computer equipment
The embodiment of the application provides a mock testing method, which comprises the following steps:
acquiring a self-defined cluster strategy of a service requester, wherein the cluster strategy is used for matching mock test service for the service requester, and the cluster strategy is obtained based on external interface expansion of a Dubbo framework;
adding the cluster strategy to the inheritable abstract execution class to obtain an executable cluster strategy execution class;
adding the cluster policy enforcement class to the configuration of the Dubbo framework;
and responding to the service request initiated by the service request party to a service provider, and judging whether the service request party matches the mock test service of the Dubbo framework or not based on the cluster policy execution class.
The embodiment of the application also provides a mock testing device, which comprises:
the cluster strategy acquisition module is used for acquiring a cluster strategy customized by a service requester, wherein the cluster strategy is used for matching a mock test service for the service requester, and the cluster strategy is obtained based on external interface expansion of a Dubbo framework;
the cluster policy executable class acquisition module is used for adding the cluster policy to the inheritable abstract execution class to obtain an executable cluster policy execution class;
a class adding module, configured to add the cluster policy execution class to the configuration of the Dubbo framework;
and the service matching module is used for responding to the service request initiated by the service request party to the service provider, and judging whether the service request party matches the mock test service of the Dubbo framework or not based on the cluster policy execution class.
Optionally, the service matching module further includes:
an on state obtaining sub-module, configured to obtain an on state of a mock service switch in a target application of the service provider;
the first logic execution sub-module is used for continuing to execute the first logic if the target application opens the mock service switch;
and the first request result return sub-module is used for requesting to call the real interface of the service provider and returning the first request result to the service requester if the mock service switch is not opened by the target application.
Optionally, the first logic execution submodule includes:
the interface information acquisition sub-module is used for acquiring interface information of a mock interface corresponding to the target application, wherein the interface information comprises at least one of an interface address, a parameter entering number, a parameter entering type and a parameter entering value;
a mock service calling sub-module for calling the mock service of the target application according to the interface information;
a mock policy matching sub-module, configured to match, according to the mock service, a corresponding mock policy for the service requester;
the second request result returning sub-module is used for executing the mock strategy if the mock strategy is successfully matched, and returning a second request result to the service requester according to the mock strategy;
and the second logic execution sub-module is used for continuing to execute the second logic if the matching fails.
Optionally, the second logic execution submodule is specifically configured to:
returning a matching failure message to the service request party, and judging whether to transfer the service request to the real interface;
if yes, requesting to call the real interface, and returning a first request result to the service requester;
and if not, returning a third request result to the service requester.
Optionally, the apparatus further comprises:
the first configuration file acquisition sub-module acquires a first configuration file of the mock service switch;
and the Mock service switch supporting sub-module is used for configuring the first configuration file to a message agency tool so that the message agency tool supports the Mock service switch.
Optionally, the class adding module further includes:
a configuration path acquisition sub-module for acquiring a configuration path;
a configuration file new building sub-module for newly building a configuration file of the cluster strategy under the configuration path;
and the class adding sub-module is used for adding the cluster strategy execution class into the configuration file.
In some embodiments of the present application, a computer device may also be provided, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method as described above when executing the computer program.
In some embodiments of the application, a computer-readable storage medium may also be provided, on which a computer program is stored which, when run on a computer, causes the computer to perform the steps of the method as described above.
From the above, the application can realize a cluster policy execution class by self-defining based on the Dubbo SPI mode, and can also realize logic of mock service matched with the Dubbo framework for the service requester under the condition that the service provider is offline. The logic for matching the mock service for the service request can be quickly set on the premise of not changing the original configuration of the Dubbo framework, so that various limitations of matching the mock service of the Dubbo framework can be effectively overcome.
Moreover, the configured cluster strategy execution class has strong suitability, and can self-research and use the mock service of an open source third party depending on the mock service of the third party, so that the configuration is simpler and more flexible. The tester does not need to write test codes, can complete the configuration of the cluster strategy execution class generally in a page configuration mode, does not need to deploy and issue the cluster strategy execution class, and immediately meets the condition of modifying the cluster strategy execution class, and does not need to reissue at an application end after modification, so that the whole configuration and subsequent maintenance process is flexible and simple.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a mock testing method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a cluster policy enforcement class provided by an embodiment of the present application;
fig. 3 is a schematic structural diagram of a mock testing device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to fall within the scope of the application.
The terms "first," "second," "third," and the like in this disclosure are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first", "a second", and "a third" may explicitly or implicitly include at least one such feature. In the description of the present application, the meaning of "plurality" means at least two, for example, two, three, etc., unless specifically defined otherwise. All directional indications (such as up, down, left, right, front, back … …) in embodiments of the present application are merely used to explain the relative positional relationship, movement, etc. between the components in a particular gesture (as shown in the drawings), and if the particular gesture changes, the directional indication changes accordingly. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
The embodiment of the application provides a mock testing method, a mock testing device, computer equipment and a storage medium.
The computer equipment can be terminal equipment such as a mobile phone, a tablet personal computer, a notebook computer and the like, and can also be wearable equipment, an intelligent television or other intelligent terminals.
The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, basic cloud computing services such as big data and artificial intelligence platforms, but is not limited thereto.
Taking the integration of the mock testing device in a server as an example, the server can acquire a cluster strategy customized by a service requester, wherein the cluster strategy is used for matching a mock testing service for the service requester, and the cluster strategy is obtained based on external interface expansion of a Dubbo framework; adding the cluster strategy to the inheritable abstract execution class to obtain an executable cluster strategy execution class; adding the cluster policy enforcement class to the configuration of the Dubbo framework; and responding to the service request initiated by the service request party to a service provider, and judging whether the service request party matches the mock test service of the Dubbo framework or not based on the cluster policy execution class.
From the above, the application can realize a cluster policy execution class by self-defining based on the Dubbo SPI mode, and can also realize logic of mock service matched with the Dubbo framework for the service requester under the condition that the service provider is offline. The logic for matching the mock service for the service request can be quickly set on the premise of not changing the original configuration of the Dubbo framework, so that various limitations of matching the mock service of the Dubbo framework can be effectively overcome.
Moreover, the configured cluster strategy execution class has strong suitability, and can self-research and use the mock service of an open source third party depending on the mock service of the third party, so that the configuration is simpler and more flexible. The tester does not need to write test codes, can complete the configuration of the cluster strategy execution class generally in a page configuration mode, does not need to deploy and issue the cluster strategy execution class, and immediately meets the condition of modifying the cluster strategy execution class, and does not need to reissue at an application end after modification, so that the whole configuration and subsequent maintenance process is flexible and simple.
The following will describe in detail. The following description of the embodiments is not intended to limit the preferred embodiments.
Referring to fig. 1 and fig. 2, fig. 1 is a flow chart of a mock testing method according to an embodiment of the present application, and fig. 2 is a technical architecture diagram of the mock testing method according to an embodiment of the present application. As shown in fig. 1, the flow of the mock testing method may be as follows:
step 201, obtaining a cluster policy customized by a service requester.
The cluster policy is used for matching mock test services for the service requesters, and can be obtained based on external interface expansion of the Dubbo framework.
In some embodiments, the external interface may be an SPI (Serial Peripheral Interface ), so that the Cluster policy may be a custom Cluster based on the Dubbo SPI extension, and thus the Cluster policy may be named mockcrouster. The Cluster module is an intermediate layer between the service provider and the service requester, and shields the service provider for the service requester, so that the service requester can concentrate on processing related matters of remote call. Such as sending a request, accepting data returned by the service provider, etc.
Step 202, adding the cluster policy to the inheritable abstract execution class to obtain an executable cluster policy execution class.
In some embodiments, an inheritable abstract execution class abstract Cluster Invter may be obtained, and a cluster policy MockCluster may be added to the abstract Cluster class to obtain a cluster policy execution class abstract Cluster Invter.
Step 203, adding the cluster policy execution class to the configuration of the Dubbo framework.
Optionally, step 203 may further include:
acquiring a configuration path;
newly building a configuration file of the cluster strategy under the configuration path;
and adding the cluster strategy execution class into the configuration file.
In some embodiments, a configuration path/reservates/META-INF/dubbo/, newly built com alibaba. Dubbo. Rpc. Cluster configuration file may be obtained to implement an internal configuration mockccluster, e.g., adding mockccluster to the configuration file.
Optionally, the method of the present application further comprises:
acquiring a first configuration file of the mock service switch;
the first configuration file is configured to a message broker tool, so that the message broker tool hosts the mock service switch.
In some embodiments, the first configuration file may be a properties configuration file, the message broker may be apollo, so that the properties configuration file is used to manage a mock switch of the interface, the configuration may be managed to the apollo for convenient management, and it is ensured that the service provider is offline and the operation of a mock mechanism is not affected.
And 204, responding to the service request initiated by the service request party to the service provider, and judging whether the service request party matches the mock test service of the Dubbo framework or not based on the cluster policy execution class.
Optionally, step 204 may further include:
acquiring the starting state of a mock service switch in a target application of the service provider;
if the target application opens the mock service switch, continuing to execute a first logic;
and if the target application does not open the mock service switch, requesting to call the real interface of the service provider, and returning a first request result to the service requester.
Referring to fig. 2, as shown in fig. 2, when executing the cluster policy execution class, the on state of the mock service switch in the target application may be determined first, if not, it may be understood that the mock test interface is not needed to be docked, the real interface of the service provider is directly requested to be invoked, and the first request result is returned to the service requester. Accordingly, if the target application opens the mock service switch, the first logic is continued to be executed.
Optionally, step "if the target application opens the mock service switch, continuing to execute the first logic" includes:
acquiring interface information of a mock interface corresponding to the target application, wherein the interface information comprises at least one of an interface address, a parameter entering number, a parameter entering type and a parameter entering value;
according to the interface information, a mock service of the target application is called;
matching a corresponding mock strategy for the service requester according to the mock service;
if the mock strategy is successfully matched, executing the mock strategy, and returning a second request result to the service requester according to the mock strategy;
if the match fails, the second logic continues to execute.
In some embodiments, the http protocol accesses the self-developed mock service interface to query whether related mock policies preset by the user exist, the mock service matches the mock policies preset by the user according to the interface information, the parameter entry number, the parameter entry type and other information, and if the matching is successful, the response information of the mock policies preset by the user is returned in json format, namely a second request result is returned. If the match fails, the second logic continues to execute.
Optionally, step "if the matching fails, continuing to execute the second logic" includes:
returning a matching failure message to the service request party, and judging whether to transfer the service request to the real interface;
if yes, requesting to call the real interface, and returning a first request result to the service requester;
and if not, returning a third request result to the service requester.
As shown in fig. 2, if the matching fails, i.e. the corresponding mock policy is not found, a message of the matching failure is returned to the service requester, i.e. there is no first request result of the mock test service, and whether there is a setting for transferring the service request to the real interface is continuously determined, if the setting is present, the real interface of the target application is called to return the first request result; if the setting does not exist, a third request result indicating an exception is returned.
From the above, the application can realize a cluster policy execution class by self-defining based on the Dubbo SPI mode, and can also realize logic of mock service matched with the Dubbo framework for the service requester under the condition that the service provider is offline. The logic for matching the mock service for the service request can be quickly set on the premise of not changing the original configuration of the Dubbo framework, so that various limitations of matching the mock service of the Dubbo framework can be effectively overcome.
Moreover, the configured cluster strategy execution class has strong suitability, and can self-research and use the mock service of an open source third party depending on the mock service of the third party, so that the configuration is simpler and more flexible. The tester does not need to write test codes, can complete the configuration of the cluster strategy execution class generally in a page configuration mode, does not need to deploy and issue the cluster strategy execution class, and immediately meets the condition of modifying the cluster strategy execution class, and does not need to reissue at an application end after modification, so that the whole configuration and subsequent maintenance process is flexible and simple.
In order to better implement the method, correspondingly, the embodiment of the application also provides a mock testing device which is specifically integrated in the terminal or the server.
Referring to fig. 3, the apparatus includes:
the cluster policy obtaining module 301 is configured to obtain a cluster policy customized by a service requester, where the cluster policy is used to match mock test service for the service requester, and the cluster policy is obtained based on external interface expansion of a Dubbo framework;
a cluster policy executable class obtaining module 302, configured to add the cluster policy to an inheritable abstract execution class, to obtain an executable cluster policy execution class;
a class adding module 303, configured to add the cluster policy execution class to the configuration of the Dubbo framework;
and the service matching module 304 is configured to determine, based on the cluster policy execution class, whether to match the mock test service of the Dubbo framework for the service requester in response to the service request initiated by the service requester.
Optionally, the service matching module 304 further includes:
an on state obtaining sub-module, configured to obtain an on state of a mock service switch in a target application of the service provider;
the first logic execution sub-module is used for continuing to execute the first logic if the target application opens the mock service switch;
and the first request result return sub-module is used for requesting to call the real interface of the service provider and returning the first request result to the service requester if the mock service switch is not opened by the target application.
Optionally, the first logic execution submodule includes:
the interface information acquisition sub-module is used for acquiring interface information of a mock interface corresponding to the target application, wherein the interface information comprises at least one of an interface address, a parameter entering number, a parameter entering type and a parameter entering value;
a mock service calling sub-module for calling the mock service of the target application according to the interface information;
a mock policy matching sub-module, configured to match, according to the mock service, a corresponding mock policy for the service requester;
the second request result returning sub-module is used for executing the mock strategy if the mock strategy is successfully matched, and returning a second request result to the service requester according to the mock strategy;
and the second logic execution sub-module is used for continuing to execute the second logic if the matching fails.
Optionally, the second logic execution submodule is specifically configured to:
returning a matching failure message to the service request party, and judging whether to transfer the service request to the real interface;
if yes, requesting to call the real interface, and returning a first request result to the service requester;
and if not, returning a third request result to the service requester.
Optionally, the apparatus further comprises:
the first configuration file acquisition sub-module acquires a first configuration file of the mock service switch;
and the Mock service switch supporting sub-module is used for configuring the first configuration file to a message agency tool so that the message agency tool supports the Mock service switch.
Optionally, the class adding module 303 further includes:
a configuration path acquisition sub-module for acquiring a configuration path;
a configuration file new building sub-module for newly building a configuration file of the cluster strategy under the configuration path;
and the class adding sub-module is used for adding the cluster strategy execution class into the configuration file.
From the above, the application can realize a cluster policy execution class by self-defining based on the Dubbo SPI mode, and can also realize logic of mock service matched with the Dubbo framework for the service requester under the condition that the service provider is offline. The logic for matching the mock service for the service request can be quickly set on the premise of not changing the original configuration of the Dubbo framework, so that various limitations of matching the mock service of the Dubbo framework can be effectively overcome.
Moreover, the configured cluster strategy execution class has strong suitability, and can self-research and use the mock service of an open source third party depending on the mock service of the third party, so that the configuration is simpler and more flexible. The tester does not need to write test codes, can complete the configuration of the cluster strategy execution class generally in a page configuration mode, does not need to deploy and issue the cluster strategy execution class, and immediately meets the condition of modifying the cluster strategy execution class, and does not need to reissue at an application end after modification, so that the whole configuration and subsequent maintenance process is flexible and simple.
In addition, the embodiment of the present application further provides a computer device, which may be a terminal or a server, as shown in fig. 4, which shows a schematic structural diagram of the computer device according to the embodiment of the present application, specifically:
the computer device may include one or more processors 401 of a processing core, memory 402 of one or more computer readable storage media, a power supply 403, and an input unit 404, among other components. Those skilled in the art will appreciate that the computer device structure shown in FIG. 4 is not limiting of the computer device and may include more or fewer components than shown, or may be combined with certain components, or a different arrangement of components. Wherein:
the processor 401 is a control center of the computer device, connects various parts of the entire computer device using various interfaces and lines, and performs various functions of the computer device and processes data by running or executing software programs and/or modules stored in the memory 402, and calling data stored in the memory 402, thereby performing overall monitoring of the computer device. Optionally, processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, an application program, etc., and the modem processor mainly processes wireless communication. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by executing the software programs and modules stored in the memory 402. The memory 402 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, application programs required for at least one function, and the like; the storage data area may store data created according to the use of the computer device, etc. In addition, memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
The computer device further comprises a power supply 403 for supplying power to the various components, preferably the power supply 403 may be logically connected to the processor 401 by a power management system, so that functions of charge, discharge, and power consumption management may be performed by the power management system. The power supply 403 may also include one or more of any of a direct current or alternating current power supply, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
The computer device may also include an input unit 404, which input unit 404 may be used to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the computer device may further include a display unit or the like, which is not described herein. In particular, in this embodiment, the processor 401 in the computer device loads executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 executes the application programs stored in the memory 402, so as to implement various functions as follows:
when the first database to be synchronized is monitored to be changed in data, binary log data generated by the first database are obtained;
analyzing the binary log data to obtain identifiable data corresponding to the binary log data;
pushing the identifiable data to a first node for cleaning and processing the identifiable data at a first preset time interval;
controlling the first node to load a cleaning processing template, and converting the identifiable data into incremental binary log data serving as target log data through the cleaning processing template;
and acquiring a database value which corresponds to the target log data and is operated by a user as incremental data at a second preset time interval, and synchronizing the incremental data to a second database of target storage.
The specific implementation of each operation above may be referred to the previous embodiments, and will not be described herein.
Those of ordinary skill in the art will appreciate that all or a portion of the steps of the various methods of the above embodiments may be performed by instructions, or by instructions controlling associated hardware, which may be stored in a computer-readable storage medium and loaded and executed by a processor.
To this end, embodiments of the present application also provide a computer readable storage medium having stored therein a plurality of instructions capable of being loaded by a processor to perform the methods provided in the various alternative implementations of embodiments of the present application.
According to one aspect of the present application, there is also provided a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the methods provided in the various alternative implementations of the above embodiments.
The specific implementation of each operation above may be referred to the previous embodiments, and will not be described herein.
Wherein the storage medium may include: read Only Memory (ROM), random access Memory (RAM, random Access Memory), magnetic or optical disk, and the like.
The steps in the method provided by the embodiment of the present application may be executed by the instructions stored in the storage medium, so that the beneficial effects that can be achieved by the method provided by the embodiment of the present application may be achieved, which are detailed in the previous embodiments and are not described herein.
The foregoing describes in detail a mock testing method, apparatus, computer device and storage medium provided by the embodiments of the present application, and specific examples are applied to illustrate the principles and embodiments of the present application, where the foregoing examples are only used to help understand the method and core idea of the present application; meanwhile, as those skilled in the art will vary in the specific embodiments and application scope according to the ideas of the present application, the present description should not be construed as limiting the present application in summary.

Claims (10)

1. A mock testing method, characterized by being applied to a target database, the method comprising:
acquiring a self-defined cluster strategy of a service requester, wherein the cluster strategy is used for matching mock test service for the service requester, and the cluster strategy is obtained based on external interface expansion of a Dubbo framework;
adding the cluster strategy to the inheritable abstract execution class to obtain an executable cluster strategy execution class;
adding the cluster policy enforcement class to the configuration of the Dubbo framework;
and responding to the service request initiated by the service request party to a service provider, and judging whether the service request party matches the mock test service of the Dubbo framework or not based on the cluster policy execution class.
2. The mock testing method of claim 1, wherein the determining whether to match the mock test service of the Dubbo framework for the service requester based on the cluster policy enforcement class comprises:
acquiring the starting state of a mock service switch in a target application of the service provider;
if the target application opens the mock service switch, continuing to execute a first logic;
and if the target application does not open the mock service switch, requesting to call the real interface of the service provider, and returning a first request result to the service requester.
3. The mock testing method of claim 2, wherein if the target application opens the mock service switch, continuing to execute the first logic comprises:
acquiring interface information of a mock interface corresponding to the target application, wherein the interface information comprises at least one of an interface address, a parameter entering number, a parameter entering type and a parameter entering value;
according to the interface information, a mock service of the target application is called;
matching a corresponding mock strategy for the service requester according to the mock service;
if the mock strategy is successfully matched, executing the mock strategy, and returning a second request result to the service requester according to the mock strategy;
if the match fails, the second logic continues to execute.
4. The mock testing method of claim 3 wherein if the match fails, continuing to execute the second logic comprises:
returning a matching failure message to the service request party, and judging whether to transfer the service request to the real interface;
if yes, requesting to call the real interface, and returning a first request result to the service requester;
and if not, returning a third request result to the service requester.
5. The mock testing method of any one of claims 2-4, further comprising:
acquiring a first configuration file of the mock service switch;
the first configuration file is configured to a message broker tool, so that the message broker tool hosts the mock service switch.
6. The mock testing method of claim 1, wherein the adding the cluster policy enforcement class to the configuration of the Dubbo framework comprises:
acquiring a configuration path;
newly building a configuration file of the cluster strategy under the configuration path;
and adding the cluster strategy execution class into the configuration file.
7. A mock testing device, comprising:
the cluster strategy acquisition module is used for acquiring a cluster strategy customized by a service requester, wherein the cluster strategy is used for matching a mock test service for the service requester, and the cluster strategy is obtained based on external interface expansion of a Dubbo framework;
the cluster policy executable class acquisition module is used for adding the cluster policy to the inheritable abstract execution class to obtain an executable cluster policy execution class;
a class adding module, configured to add the cluster policy execution class to the configuration of the Dubbo framework;
and the service matching module is used for responding to the service request initiated by the service request party to the service provider, and judging whether the service request party matches the mock test service of the Dubbo framework or not based on the cluster policy execution class.
8. The mock testing apparatus of claim 7 wherein the service matching module further comprises:
an on state obtaining sub-module, configured to obtain an on state of a mock service switch in a target application of the service provider;
the first logic execution sub-module is used for continuing to execute the first logic if the target application opens the mock service switch;
and the first request result return sub-module is used for requesting to call the real interface of the service provider and returning the first request result to the service requester if the mock service switch is not opened by the target application.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 6 when the computer program is executed by the processor.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when run on a computer, causes the computer to perform the steps of the method according to any one of claims 1 to 6.
CN202310358731.2A 2023-03-27 2023-03-27 Mock test method, mock test device, medium and computer equipment Pending CN117056198A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310358731.2A CN117056198A (en) 2023-03-27 2023-03-27 Mock test method, mock test device, medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310358731.2A CN117056198A (en) 2023-03-27 2023-03-27 Mock test method, mock test device, medium and computer equipment

Publications (1)

Publication Number Publication Date
CN117056198A true CN117056198A (en) 2023-11-14

Family

ID=88668051

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310358731.2A Pending CN117056198A (en) 2023-03-27 2023-03-27 Mock test method, mock test device, medium and computer equipment

Country Status (1)

Country Link
CN (1) CN117056198A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117251385A (en) * 2023-11-20 2023-12-19 深圳大道云科技有限公司 method and device for acquiring mock data, terminal equipment and readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117251385A (en) * 2023-11-20 2023-12-19 深圳大道云科技有限公司 method and device for acquiring mock data, terminal equipment and readable storage medium
CN117251385B (en) * 2023-11-20 2024-04-02 深圳大道云科技有限公司 method and device for acquiring mock data, terminal equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN111913818B (en) Method for determining dependency relationship between services and related device
US7831734B2 (en) Method and system for remote configuration of network devices
CN111064626B (en) Configuration updating method, device, server and readable storage medium
CN112860343B (en) Configuration changing method, system, device, electronic equipment and storage medium
WO2019223136A1 (en) Data acquisition method and apparatus, and computer device and storage medium
JP7161560B2 (en) Artificial intelligence development platform management method, device, medium
CN117056198A (en) Mock test method, mock test device, medium and computer equipment
CN113965543B (en) Access method, device and storage medium of application server
CN111770176B (en) Traffic scheduling method and device
CN109614271A (en) Control method, device, equipment and the storage medium of multiple company-data consistency
CN113849356B (en) Equipment testing method and device, electronic equipment and storage medium
CN116208487A (en) Method, device, equipment and medium for upgrading consensus algorithm in block chain system
CN112417402B (en) Authority control method, authority control device, authority control equipment and storage medium
CN108809763B (en) Network performance parameter acquisition method, terminal device and storage medium
CN113326052A (en) Method and device for upgrading service component, computer equipment and storage medium
WO2021134252A1 (en) Inter-device communication method and apparatus, and storage medium
CN113110846A (en) Method and device for acquiring environment variable
CN115801569B (en) Access rule deployment method, device, equipment, medium and cloud platform
CN116361187A (en) Annotation-based mock testing method, annotation-based mock testing device, medium and computer equipment
CN116225576B (en) Application program data environment switching method and device, electronic equipment and medium
CN115102924B (en) Cluster address switching method and device, computer equipment and storage medium
CN112379912B (en) Algorithm management method and device, electronic equipment and storage medium
CN115881116A (en) Interface control method and device, electronic equipment and computer readable storage medium
CN115237005A (en) Control method and device for powering on equipment and storage medium
CN115480819A (en) Development environment configuration method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination