A method, device and electronic device for providing mock services

By synchronizing the mock configuration to the database and automatically checking and setting the configuration on the mock platform, the existing mock services are solved, and the stability and accuracy of automated testing are achieved.

CN114064455BActive Publication Date: 2025-05-27KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111202316.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-15
Publication Date
2025-05-27
Estimated Expiration
2041-10-15

AI Technical Summary

Technical Problem

The mock services in the existing automated testing framework are unstable and not universal, cannot adapt to the testing needs of multiple systems, and require manual repair of configuration when there is a error in mock data.

Method used

Automatic mock configuration management and repair by synchronizing the mock configuration, system ID to be tested and interface ID to the database. The specific steps include parsing the mock ID required by the system to be tested, traversing the mock ID to obtain the system ID and interface ID to be tested from the database, and checking and setting up advanced mock configurations on the mock platform.

Benefits of technology

It realizes the stability and universality of mock services, can automatically repair mock configuration, reduce manual intervention, and improve the stability and accuracy of automated testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064455B_ABST
    Figure CN114064455B_ABST
Patent Text Reader

Abstract

The present application discloses a method for providing mock services, including: synchronizing the mock configuration of the system to be tested in the automated test on the mock platform, the system ID to be tested, and the interface ID to be tested into a database; parsing the mock IDs of all mocks that need to be pre-configured for the first system to be tested; traversing all mock IDs, parsing the system ID to be tested and the interface ID corresponding to the current mock ID; in response to the current mock ID corresponding to the advanced mock configuration, according to the system ID to be tested and the interface ID and the current mock ID, checking whether there is a corresponding advanced mock configuration on the mock platform, if not, then setting the advanced mock configuration corresponding to the current mock ID stored in the database to the mock platform, for providing data feedback for the automated test. By applying the present application, the mock configuration can be synchronized in the database, and the mock configuration on the mock platform can be automatically repaired.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automatic testing technology, and in particular to a method and device for providing mock services, a computer-readable storage medium, and an electronic device. Background Art

[0002] In the existing systems, businesses may overlap, so when a system is running, it may be necessary to obtain relevant data and information from other third-party systems. For the testing of such systems, the input or interaction of third-party systems is also required to complete the test. For example, the loan service of the trading platform needs to interact with the external bank system. When triggering certain requests to the bank, it relies on the specific return content of the bank system to carry out subsequent business processing; then when testing the loan service of the trading platform, in some cases, the bank may need to feedback information to help complete the test. However, for such services that require interaction or information transmission of third-party systems to complete the test, during the testing process, automated test execution errors often occur due to the return data of the third-party system not meeting expectations. Therefore, it is necessary to ensure the stability of the third-party system and the accuracy of the data, otherwise it will affect the test stability of the test service and the accuracy of the test results.

[0003] Mocking is a common solution for the system under test to interact with third-party systems that it depends on.

[0004] However, the mocking capabilities of the current automated testing framework have two disadvantages: instability and non-universality. The existing mock service is nested in the system under test. For example, the test of the loan service only supports the loan service, and other systems cannot use the mock service. At the same time, the mock solution used by the loan service is also unstable. The mock configuration is hard-coded in the mock platform. Once the test data on the mock platform is tampered with, the automated test cannot perceive the mock error in the first place. Then, when the test is executed, it will definitely fail due to the error in the mock return content. When the test fails, it is necessary to rely on manual repair of the relevant configuration on the mock platform. It can be seen that the current mock service cannot be universal for multiple systems on the one hand, and the test system cannot perceive the error of the mock data on the other hand. When a problem occurs, the mock configuration needs to be manually repaired. Summary of the invention

[0005] In view of the above-mentioned prior art, an embodiment of the present application discloses a method for providing mock services, synchronizing mock configurations in a database, and being able to automatically repair mock configurations on a mock platform.

[0006] A method for providing a mock service, optionally comprising:

[0007] Synchronize the mock configuration of the system under test in the automated test on the mock platform, the system under test ID and the interface ID to the database; wherein the mock configuration is the configuration information of the mock used to test the system under test, the system under test ID is the identification of the system under test on the mock platform, and the interface ID is the identification of the interface under test of the system under test;

[0008] In response to determining that a first system to be tested to be subjected to an automated test needs to configure a mock before the automated test is performed, parsing out mock IDs of all mocks that need to be pre-configured for the first system to be tested; wherein the mock IDs are used to identify the mocks;

[0009] Traverse the mock IDs and parse the system ID and interface ID to be tested corresponding to the current mock ID from the database;

[0010] In response to the current mock ID corresponding to the advanced mock configuration, according to the parsed system ID and interface ID to be tested and the current mock ID, it is checked on the mock platform whether there is an advanced mock configuration corresponding to the same system ID and interface ID to be tested; if not, the advanced mock configuration corresponding to the current mock ID stored in the database is set on the mock platform according to the corresponding system ID and interface ID to be tested.

[0011] Optionally, the method further includes: judging whether the system under test requires a gateway cache refresh based on the information stored in the database; if a gateway cache refresh is required, determining the gateway service configuration of the system under test from the database, and determining whether the gateway has started the corresponding mock based on the gateway service configuration; if not, instructing the gateway to start the corresponding mock.

[0012] Optionally, synchronizing the mock configuration of the system under test on the mock platform and the ID of the system under test and the interface ID into the database includes:

[0013] Receive a command input by a user for requesting synchronization of mock configuration; the command includes a mock configuration synchronization keyword for synchronization operation, the system ID to be tested, and the interface ID;

[0014] After the mock configuration synchronization keyword is detected in the command, a specific interface related to the system under test in the mock platform is determined according to the system under test ID and the interface ID in the command, and the mock configuration is obtained from the specific interface and saved in the database.

[0015] Optionally, acquiring the mock configuration from the specific interface and saving it in the database includes:

[0016] In response to determining that the acquired mock configuration is an advanced mock configuration and the command includes a mock configuration index, acquiring a configuration item indicated by the mock configuration index from all configuration items of the advanced mock configuration; wherein each configuration item includes mock data that needs to be fed back during testing and its corresponding trigger condition;

[0017] and / or,

[0018] In response to determining that the acquired mock configuration is an advanced mock configuration and the command does not include a mock configuration index, storing all configuration items of the advanced mock configuration in the database;

[0019] and / or,

[0020] In response to determining that the acquired mock configuration is a common mock configuration, all contents in the common mock configuration are stored in the database.

[0021] Optionally, if the command for requesting synchronization of the mock configuration fails, or if acquisition of the mock configuration from the specific interface fails, the method further includes: issuing an alarm message of synchronization failure.

[0022] Optionally, after setting the extracted advanced mock configuration on the mock platform, the method further comprises: if the setting is successful, updating the advanced mock ID returned by the setting interface to the corresponding mock configuration in the database; if the setting fails, the system prompts an advanced mock setting error message.

[0023] Optionally, the method further comprises: if the traversed current mock ID corresponds to a common mock configuration, after parsing to obtain the ID of the system to be tested and the interface ID corresponding to the mock ID, setting the common mock configuration corresponding to the current mock ID stored in the database into the mock platform;

[0024] Optionally, after setting the common mock configuration corresponding to the current mock ID stored in the database into the mock platform, the method further comprises: if the setting fails, the system prompts a common mock setting error message.

[0025] A device for providing mock services, comprising: a configuration synchronization unit, a self-checking unit and a repairing unit;

[0026] The configuration synchronization unit is used to synchronize the mock configuration of the system to be tested in the automated test on the mock platform, the system ID and the interface ID to the database; wherein the mock configuration is the configuration information of the mock used to test the system to be tested, the system ID is the identifier of the system to be tested on the mock platform, and the interface ID is the identifier of the interface to be tested of the system to be tested;

[0027] The self-checking unit is used for, in response to determining that a first system to be tested to be subjected to an automated test needs to configure a mock before the automated test is performed, parsing out the mock IDs of all mocks that need to be pre-configured for the first system to be tested; traversing the mock IDs, parsing the system ID to be tested and the interface ID corresponding to the current mock ID from the database; in response to the current mock ID corresponding to a high-level mock configuration, checking on the mock platform whether there is a high-level mock configuration corresponding to the same system ID to be tested and interface ID according to the parsed system ID to be tested and the current mock ID, and if not, notifying the repair unit to repair the configuration of the mock platform;

[0028] The repair unit is used to set the advanced mock configuration corresponding to the current mock ID stored in the database to the mock platform according to the corresponding system ID and interface ID to be tested after receiving the notification from the self-test unit.

[0029] Optionally, the device also includes a gateway detection unit, which is used to determine whether the system under test requires a gateway cache refresh based on the information stored in the database; if a gateway cache refresh is required, the gateway service configuration of the system under test is determined from the database, and whether the gateway has started the corresponding mock based on the gateway service configuration; if not, the gateway is instructing to start the corresponding mock.

[0030] A computer-readable storage medium stores computer instructions, which can implement the mock-based automated testing method when executed by a processor.

[0031] An electronic device, the electronic device comprising at least the computer-readable storage medium and a processor;

[0032] The processor is used to read the executable instructions from the computer-readable storage medium and execute the instructions to implement the mock-based automated testing method.

[0033] In summary, the embodiments of the present application disclose a method, device and storage medium for automated testing based on mock. In the embodiments of the present application, the mock configuration on the mock platform and the corresponding system ID and interface ID are synchronously saved in the database; then, when the system is automated and the mock needs to be configured in advance, the mockIDs of all mocks that need to be pre-configured are parsed; when the mock ID corresponds to an advanced mock configuration, the system ID and interface ID corresponding to the mock ID are parsed in the database, and the advanced mock configuration is checked on the mock platform to see if it exists on the same system and interface. If not, the advanced mock configuration saved in the database is set to the mock platform according to the same system and interface; finally, the automated testing of the system is performed based on the mock settings on the mock platform. In the above manner, the mock configuration can be automatically synchronized in the database, and the mock configuration on the mock platform can be automatically repaired. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0035] Figure 1 This is a flowchart of the method for providing mock services in this application;

[0036] Figure 2 This is a diagram of the meaning of index in advanced mock configuration;

[0037] Figure 3 The table structure of weapons_mock table is shown below;

[0038] Figure 4 Example of mock configuration stored in the weapons_mock table;

[0039] Figure 5 After the mock configuration synchronization is completed, a schematic diagram of the synchronization result will be displayed on the system display interface;

[0040] Figure 6 This is a schematic diagram of the pre_step column in the test case table case_info;

[0041] Figure 7 This is a schematic diagram of the mock configuration example in the case_info table;

[0042] Figure 8Configure the mock diagram in the pre_step column of the case_info table;

[0043] Fig. 9 A diagram for resetting mock configuration to the mock platform;

[0044] Fig.10 A schematic diagram of the basic structure of the device that provides mock services in this application;

[0045] Fig.11 A schematic diagram of the structure of the electronic device provided in this application. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0047] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.

[0048] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0049] The present application discloses a method and device for providing mock services, which can be independent of the system under test and provide a unified mock service for automated testing of multiple systems.

[0050] Figure 1 This is a flow chart of the method for providing mock services in this application. Figure 1 As shown, the method includes:

[0051] Step 101: synchronize the mock configuration of the system under test in the automated test on the mock platform, the system under test ID and the interface ID into the database.

[0052] In this step, each mock configuration and the system ID and interface ID to which the mock configuration belongs are correspondingly saved in the database. Among them, the mock configuration is the configuration information of the mock for testing the system to be tested, the system ID to be tested is the ID of the system to be tested on the mock platform, and the interface ID is the tested interface identifier of the system to be tested. The specific method of pulling data from the mock platform and saving it to the database can adopt the existing method, which is usually a manual entry method. Taking into account the accuracy and efficiency of data entry, this application provides a method for automatically pulling mock configurations from the mock platform and saving them to the database. Specifically, a preset command can be used to input the system that provides mock services. The following takes the php artisan command for mock configuration synchronization as an example for explanation, and the processing steps are as follows:

[0053] Receive a php artisan command input by a user to request synchronization of mock configuration; the command includes a mock configuration synchronization keyword, which is used to indicate that the command is a request message for synchronization of mock configuration; the php artisan command also includes the ID of the system to be tested in the mock platform (i.e., the system ID to be tested) and the ID of the tested interface of the system to be tested in the mock platform (i.e., the interface ID). After detecting the mock configuration synchronization keyword in the php artisan command, the system providing mock services determines a specific interface related to the system to be tested in the mock platform according to the ID of the system to be tested in the mock platform and the tested interface of the system to be tested included in the command, obtains the mock configuration from the specific interface, and saves it in the database. Among them, if the obtained mock configuration is a common mock configuration, all the contents in the common mock configuration can be stored in the database, including the mock ID, the mock data that needs to be fed back, and the corresponding system ID and interface ID to be tested; assuming that the phpartisan command also includes a mock configuration index (index), then if the obtained mock configuration is an advanced mock configuration, the configuration item indicated by the index is obtained from all the configuration items of the advanced mock configuration, and the obtained configuration item content is stored in the database corresponding to the system ID and interface ID to be tested; or, if the obtained mock configuration is an advanced mock configuration and the php artisan command does not include the mock configuration index index, all the configuration items of the advanced mock configuration can be directly stored in the database. Here, the configuration item refers to a trigger condition in the advanced mock configuration and the corresponding mock data needs to be fed back during the test. The following is an example of a php artisan command:

[0054] php artisan sync:mock--project=1238--interface=19066--index=0

[0055] In the above command, sync:mock is a keyword in the command line, indicating that the command is used to request the synchronization of the mock configuration; project refers to the code of the system under test in the mock platform; interface refers to the code of the interface under test in the mock platform. Through project and interface, the interface to be tested of a certain system can be locked from the mock platform. index indicates the number of data in the advanced mock. For example, when index = 0, it means obtaining the first data in the advanced mock, such as Figure 2 As shown; when index = 0, 2, it means obtaining the first and third data in the advanced mock.

[0056] When the system providing mock service parses the php artisan sync:mock command, it will first parse the values ​​of project, interface and index. The value of index is separated by English commas, and the separated numeric subscripts can be stored in an array. Next, the system will request the mock platform to obtain all advanced mock configurations of the interface in the mock platform through project and interface. If the request fails or no data is obtained, it is considered that the synchronization has failed, and the system can actively alarm. If the request is successful and the data is obtained, the corresponding mock configuration will be found according to the index in index, and the mock data and its corresponding trigger conditions will be stored in the database. For example, in an embodiment of the present application, these data can be stored in a table in the database and the table is named weapons_mock. Figure 3 The table structure of the weapons_mock table is shown below. Figure 4 Example of mock configuration stored in the weapons_mock table.

[0057] Through the above method, you can use the PHP command to synchronize the mock platform configuration with one click, no longer rely on manual input, and realize automatic backup of the mock configuration. After the synchronization is completed, the synchronization result prompt can be displayed on the system display interface as follows Figure 5 shown.

[0058] After the synchronization of mock configuration is realized, when the automated test of the system to be tested is performed, it will first be determined whether the test needs to configure the mock in advance. This can be maintained in the pre_step column of the test case table case_info. pre_step indicates the prerequisite steps that need to be executed before executing the test case. The specific supported parameter keys can be as follows Figure 6 When the mock keyword is configured in pre_step, it means that the mock configuration needs to be configured on the mock platform before executing this test case. The mock configuration example in the case_info table is as follows Figure 7 When you need to set up mock configuration for automated testing, perform the following steps to perform self-checks and repairs:

[0059] Step 102: parse out the mock IDs of all mocks that need to be configured in advance for the system under test.

[0060] Assume that the system to be tested that needs to set up mock configuration in advance is system A. Then, all mock IDs that need to be configured in advance for system A need to be parsed. Specifically, this can be done from the storage content that records whether the system to be tested needs to be configured with mocks in advance. For example, parse the mock configuration in the pre_step column of the case_info table and parse out the mock id. There may be multiple mockids, which can be separated by commas, such as Figure 8 shown.

[0061] Next, all the parsed mock IDs are traversed, and the following steps 103-105 are executed for each current mock ID:

[0062] Step 103: parse the system ID and interface ID to be tested corresponding to the current mock ID from the database.

[0063] Query the current mock ID in the mock configuration stored in the database. If it does not exist, an error message will be displayed, indicating that the mock configuration has not been synchronized successfully. If it does exist, find the mock configuration corresponding to the current mock ID from the database, and extract the corresponding system ID and interface ID to be tested from the mock configuration. The current mockID refers to the mockID currently traversed during the traversal process.

[0064] Step 104, determine whether the current mock ID is an advanced mock configuration or a common mock configuration, if it is an advanced mock configuration, execute step 105, otherwise execute step 106.

[0065] When saving mock configurations in the database, each mock configuration will be marked as an advanced mock configuration or a common mock configuration. For example, you can judge based on mock_type in the weapons_mock table. When mock_type = 2, it is an advanced mock configuration, and when mock_type = 1, it is a common mock configuration. If the queried mock configuration is neither a common mock configuration nor an advanced mock configuration, then the configuration is considered illegal and the system prompts a configuration error.

[0066] The specific processing for common mock configuration and advanced mock configuration is different. They are introduced below.

[0067] Step 105, based on the parsed system ID and interface ID to be tested, check on the mock platform whether there is an advanced mock configuration corresponding to the same system ID and interface ID to be tested. If not, the advanced mock configuration corresponding to the current mock ID stored in the database is set on the mock platform according to its corresponding system ID and interface ID to be tested.

[0068] For advanced mock configuration, you can query the mock platform according to the system ID and interface ID to be tested parsed in the database and the current mock ID, and query whether there is an advanced mock configuration with the same mock ID on the same system ID and interface ID of the mock platform. If it exists, it is considered that the mock setting on the mock platform is normal, and the mock setting on the mock platform can be directly used to perform the automated test of the subsequent system A, and this step does not need to be processed additionally. If it does not exist, it is considered that the mock setting on the mock platform is abnormal, may have been changed, and needs to be reset, then the advanced mock configuration corresponding to the current mock ID saved in the database is set to the mock platform, and corresponds to the same system ID to be tested and interface ID. After the reset is completed, the mock configuration newly set on the mock platform, its mock ID may change, so it is necessary to update the latest mock ID to the database. If the setting of the advanced mock configuration on the mock platform fails, the system needs to give a prompt that the mock platform setting failed. When re-setting the mock on the mock platform, optionally, a prompt message for automated testing can be added to the mock setting to instruct other systems or salespeople that the mock configuration is for automated testing and should not be changed or deleted at will.

[0069] Here is a simple example: You can first query whether the mock platform has the corresponding advanced mock configuration based on mock_id, project_id, and interface_ in the weapons_mock table. If it exists, the mock configuration is considered normal and does not need to be reset. If the interface returns that it does not exist, you need to reset the mock configuration to the mock platform, such as Fig. 9 As shown. At this time, the mock_data and desc (the Chinese description of the configuration, which can be automatically prefixed with "automation" to remind you not to modify or delete it at will) in the weapons_mock table will be set to the mock platform. If the interface returns success, it is considered that the setting is successful, and the high-level mock id returned by the interface will be updated to the mock_id column in the weapons_mock table. If the interface returns failure, it is considered that the setting has failed, false is returned, and the system prompts an error.

[0070] Step 106: For common mock configuration, the mock configuration is set on the mock platform.

[0071] For common mock configuration, you can directly set the mock configuration to the mock platform for subsequent automated testing. For example, set the mock_data in the weapons_mock table to the mock platform. If the interface returns success, the setting is considered successful. If the interface returns failure, the setting is considered failed, false is returned, and the system prompts an error.

[0072] Through the processing of the above steps 103-106, the self-checking and self-repairing capabilities of the mock configuration are realized on the mock platform. In addition, optionally, the method of the present application may further include the processing of the following steps 107-109, so as to check the gateway and perform necessary startup processing.

[0073] Step 107, judging whether the system under test needs a gateway cache refresh according to the information stored in the database, if so, executing step 108, otherwise terminating the process.

[0074] The mock capabilities of some services are implemented by relying on the gateway service of the trading platform. Usually, there is a column mock_type in the database table gate_provider of the gateway service to control whether to use the mock configuration of the mock platform. For example, when mock_type = 2, it can indicate the use of the mock platform. When the mock_type value changes, the gateway service needs to refresh the redis cache for the mock settings to take effect. Based on this, you can decide whether to refresh the gateway cache based on whether the mock configuration depends on the gateway mock. For example, you can determine whether you need to enter the gateway cache refresh logic based on the value in the hub_refresh column in the weapons_mock table. If hub_refresh = 1, then enter the gateway cache refresh logic. When hub_refresh = 1, you do not need to enter the gateway cache refresh logic.

[0075] Step 108, determining the gateway service configuration of the system to be tested from the database, and determining whether the gateway has started the corresponding mock according to the gateway service configuration, if so, ending this process, otherwise, executing step 109.

[0076] First, parse the gate_provide_id and gate_provider_name in the weapons_mock table. Based on these two columns, the specific configuration of the gateway service can be located, and then the mock_type of the configuration of the gateway service can be parsed. If the corresponding gateway configuration is not found, it is considered illegal and the system prompts an error. If the gateway configuration is found, determine whether mock_type is 2. If mock_type = 2, it is considered that the gateway has started mock, and no other processing is required. Return true directly, success. If mock_type! = 2, it is necessary to execute the gateway enablement process. Specifically, first set the mock_type in the gate_provider table of the gateway service database to 2, then call the gateway cache refresh interface, refresh the redis cache, and the interface returns success, then the gateway service mock is considered to be enabled successfully, otherwise it is considered to have failed.

[0077] At this point, the method flow in this application ends.

[0078] The above is a specific implementation of the method for providing mock services in this application. In the above method, the ability to automatically repair the mock configuration is achieved by real-time synchronization and detection of the accuracy of the mock configuration on the mock platform. By supporting both ordinary mock and advanced mock, specific return results can be obtained under specific parameters of specific requests. The demands of some services for relying on the mock capabilities of the gateway service are met by configuring whether to resolve the dependency on the gateway and automatically opening the gateway mock. Finally, a set of general mock capabilities applicable to all business accesses is realized, which has the advantages of being applicable to all businesses and having the ability to automatically repair errors, so as to ensure the stability of automated execution and the accuracy of the results.

[0079] The present application also provides a device for providing mock services, which can be used to implement the above method. Fig.10 This is a basic structural diagram of the device that provides mock services in this application. Fig.10 As shown, the device includes: a configuration synchronization unit, a self-checking unit and a repairing unit.

[0080] Among them, the configuration synchronization unit is used to synchronize the mock configuration, the system ID and the interface ID of the system to be tested in the automated test on the mock platform in advance to the database. The self-check unit is used to parse out all the mockIDs that need to be configured in advance for the first system to be tested when it is determined that the first system to be tested for automated testing needs to be configured with mocks in advance; traverse all the mock IDs and parse the system ID and interface ID corresponding to the current mock ID from the database; when the current mock ID corresponds to an advanced mock configuration, check on the mock platform whether there is an advanced mock configuration corresponding to the same system ID and interface ID according to the parsed system ID and interface ID to be tested, if not, notify the repair unit to repair the configuration of the mock platform. The repair unit is used to set the advanced mock configuration corresponding to the current mock ID stored in the database to the mock platform according to its corresponding system ID and interface ID to be tested after receiving the notification from the self-check unit, so as to provide data feedback for automated testing.

[0081] Optionally, to implement gateway monitoring, Fig.10 The device shown may also include a gateway detection unit, which is used to determine whether the system under test requires a gateway cache refresh based on the information stored in the database; if a gateway cache refresh is required, the gateway service configuration of the system under test is determined from the database, and whether the gateway has started the corresponding mock based on the gateway service configuration; if not, the gateway is instructing the gateway to start the corresponding mock.

[0082] The embodiment of the present application also provides a computer-readable storage medium, which stores instructions, and the instructions, when executed by a processor, can execute the steps in the method for providing mock services as described above. In practical applications, the computer-readable medium can be included in each device / apparatus / system in the above embodiments, or it can exist independently without being assembled into the device / apparatus / system. Among them, instructions are stored in a computer-readable storage medium, and the instructions stored therein can execute the steps in the method for implementing GPU virtualization as described above when executed by a processor.

[0083] According to the embodiments disclosed in the present application, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof, but it is not used to limit the scope of protection of the present application. In the embodiments disclosed in the present application, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.

[0084] like Fig.11 As shown, an embodiment of the present invention also provides an electronic device. Fig.11 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present invention, specifically:

[0085] The electronic device may include a processor 1101 with one or more processing cores, a memory 1102 with one or more computer-readable storage media, and a computer program stored in the memory and executable on the processor. When executing the program in the memory 1102, a GPU virtualization method may be implemented.

[0086] Specifically, in practical applications, the electronic device may further include components such as a power supply 1103, an input / output unit 1104, etc. Those skilled in the art may understand that Fig.11 The structure of the electronic device shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0087] Processor 1101 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the server and processes data by running or executing software programs and / or modules stored in memory 1102 and calling data stored in memory 1102, thereby monitoring the electronic device as a whole.

[0088] The memory 1102 can be used to store software programs and modules, that is, the above-mentioned computer-readable storage medium. The processor 1101 executes various functional applications and data processing by running the software programs and modules stored in the memory 1102. The memory 1102 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the server, etc. In addition, the memory 1102 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 1102 may also include a memory controller to provide the processor 1101 with access to the memory 1102.

[0089] The electronic device also includes a power supply 1103 for supplying power to various components, which can be logically connected to the processor 1101 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 1103 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0090] The electronic device may also include an input and output unit 1104, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. The input unit output 1104 may also be used to display information input by the user or information provided to the user and various graphical user interfaces, which may be composed of graphics, text, icons, videos and any combination thereof.

[0091] The flow chart and block diagram in the accompanying drawings of the present application show the possible architecture, function and operation of the system, method and computer program product according to the various embodiments disclosed in the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in the order of the standards in different figures. For example, the boxes represented by two connections can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0092] Those skilled in the art will appreciate that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present application. In particular, without departing from the spirit and teachings of the present application, the features described in the various embodiments and / or claims of the present application may be combined and / or combined in a variety of ways, and all of these combinations and / or combinations fall within the scope disclosed in the present application.

[0093] Specific embodiments are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas, and is not used to limit the present application. For those skilled in the art, changes can be made in the specific implementation methods and application scopes according to the ideas, spirits and principles of the present invention, and any modifications, equivalent substitutions, improvements, etc. made therein should be included in the scope of protection of this application.

Claims

1. A method for providing a mock service, characterized in that, the method includes: Synchronizing the mock configuration, the ID of the system under test, and the interface ID of the system under test in the automated test on the mock platform to the database; wherein, the mock configuration is the configuration information of the mock used to test the system under test, the ID of the system under test is the identifier of the system under test on the mock platform, and the interface ID is the identifier of the interface under test of the system under test; In response to determining that a first system under test to be subjected to an automated test needs to be configured with a mock before the automated test, parsing out all the mock IDs of the mocks that the first system under test needs to be pre-configured from the stored content recording whether the first system under test needs to be mock-set up in advance; wherein, the mock ID is used to identify the mock; Traversing the parsed mock IDs, parsing out the ID of the system under test and the interface ID corresponding to the current mock ID from the database, where the current mock ID refers to the mock ID currently traversed during the traversal process; In response to the current mock ID corresponding to an advanced mock configuration, checking whether there is an advanced mock configuration corresponding to the same ID of the system under test and the interface ID on the mock platform according to the parsed ID of the system under test, the interface ID, and the current mock ID. If not, setting the advanced mock configuration corresponding to the current mock ID saved in the database to the mock platform according to the corresponding ID of the system under test and the interface ID.

2. The method according to claim 1, characterized in that, the method further includes: judging whether the system under test needs to refresh the gateway cache according to the information saved in the database; if it is necessary to refresh the gateway cache, determining the gateway service configuration of the system under test from the database, and determining whether the gateway has started the corresponding mock according to the gateway service configuration. If not, instructing the gateway to start the corresponding mock.

3. The method according to claim 1 or 2, characterized in that, the step of synchronizing the mock configuration, the ID of the system under test, and the interface ID of the system under test in the automated test on the mock platform to the database includes: Receiving a command input by a user for requesting to synchronize the mock configuration; the command includes a mock configuration synchronization keyword, the ID of the system under test, and the interface ID, and the mock configuration synchronization keyword is used to indicate that the command is a request message for synchronizing the mock configuration; After detecting the mock configuration synchronization keyword in the command, determining a specific interface related to the system under test in the mock platform according to the ID of the system under test and the interface ID in the command, and obtaining the mock configuration from the specific interface and saving it to the database.

4. The method according to claim 3, characterized in that, the step of obtaining the mock configuration from the specific interface and saving it to the database includes: In response to determining that the obtained mock configuration is an advanced mock configuration and the command includes a mock configuration index, obtain the configuration item indicated by the mock configuration index from all the configuration items of the advanced mock configuration; wherein each configuration item includes the mock data to be fed back during testing and its corresponding triggering condition; and / or, In response to determining that the obtained mock configuration is an advanced mock configuration and the command does not include a mock configuration index, store all the configuration items of the advanced mock configuration in the database; and / or, In response to determining that the obtained mock configuration is a normal mock configuration, store all the contents of the normal mock configuration in the database.

5. The method according to claim 3, wherein, if the command for requesting to synchronize the mock configuration fails, or if the mock configuration cannot be obtained from the specific interface, the method further includes: sending an alarm message indicating synchronization failure.

6. The method according to claim 1, wherein, after setting the extracted advanced mock configuration to the mock platform, the method further includes: if the setting is successful, update the advanced mock ID returned by the setting interface to the corresponding mock configuration in the database; if the setting fails, the system prompts an error message for advanced mock setting.

7. The method according to claim 1, wherein, the method further includes: if the currently traversed mock ID corresponds to a normal mock configuration, after parsing to obtain the ID of the system under test and the interface ID corresponding to the mock ID, set the normal mock configuration corresponding to the current mock ID saved in the database to the mock platform.

8. The method according to claim 7, wherein, after setting the normal mock configuration corresponding to the current mock ID saved in the database to the mock platform, the method further includes: if the setting fails, the system prompts an error message for normal mock setting.

9. A computer-readable storage medium, on which computer instructions are stored, wherein, when the instructions are executed by a processor, the automated testing method based on mock according to any one of claims 1 to 8 can be implemented.

10. An electronic device, which at least includes the computer-readable storage medium according to claim 9, and further includes a processor; the processor is used to read the executable instructions from the computer-readable storage medium and execute the instructions to implement the automated testing method based on mock according to any one of claims 1 to 8 above.

Citation Information

Patent Citations

  • Mock service system and processing method of Mock service

    CN103297475A

  • Dubbo service test method, device and equipment

    CN111966591A