Test method and device based on Mock service
By receiving service requests from the user terminal and determining whether the Mock service needs to be started, the problem of fixed return value of the existing Mock service is solved, and the real-time simulation of the underlying component behavior of the Mock service is achieved, and testing efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202411761772.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-04-25
Smart Images

Figure CN119883496A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a testing method and device based on Mock service. Background Art
[0002] In this field, the existing technical solutions mainly provide a service Mock platform. Users can manually set the return value of each service on the Mock service system. At the same time, they can also set it to be a proxy to call the real service, that is, first call the real service, and then save the data. The next time the application visits, it directly returns the saved data.
[0003] In the existing technical solutions, the Mock service is mainly performed by manually writing Mock data, or sampling the return results through the real service as the return value of the Mock service.
[0004] The technical problems existing in the existing technical solutions are mainly that the return value of Mock is relatively fixed and lacks context change relationship. In the cloud resource management platform business scenario, the relatively fixed return value cannot meet the complex business scenario testing and verification. For example, in the creation of a cloud desktop business scenario, the desktop status will undergo multiple status changes and a new desktop uuid will be generated. The business system needs to read the response information of multiple status changes in the same test scenario. Manually writing Mock data to match rules is labor-intensive, difficult to reuse, and difficult to maintain. How to solve the problem of large workload in dynamic Mock service data preparation and difficult reuse of Mock interfaces is an urgent problem that needs to be solved. Summary of the invention
[0005] The present application shows a testing method and device based on Mock service.
[0006] In a first aspect, the present application shows a testing method based on a Mock service, the method comprising:
[0007] Receiving a service request sent by a user terminal;
[0008] According to the business request and the pre-established virtual machine, determine whether it is necessary to start the Mock service;
[0009] In the case where the Mock service needs to be started, a virtual machine corresponding to the Mock service is determined, so that the virtual machine executes an operation corresponding to the business request to obtain a response result.
[0010] Optionally, in the case where the Mock service needs to be started, determining a virtual machine corresponding to the Mock service so that the virtual machine performs an operation corresponding to the business request to obtain a response result includes:
[0011] Determine whether the virtual machine is in shutdown state through the Mock service;
[0012] If the virtual machine is in a shutdown state, the state of the virtual machine is changed to a startup state, and a successful operation response is returned.
[0013] Optionally, in the case where the Mock service needs to be started, determining a virtual machine corresponding to the Mock service so that the virtual machine performs an operation corresponding to the business request to obtain a response result includes:
[0014] If the virtual machine is in a powered-on state, the virtual machine is used to execute an operation corresponding to the service request.
[0015] Optionally, the method further comprises:
[0016] Receive a request to create a virtual machine;
[0017] Determine, according to the creation request and the configuration table, the service address information corresponding to the creation request;
[0018] Use a pre-established proxy program to determine whether to proxy traffic to the Mock service based on the context information of the current request;
[0019] If the current environment is a Mock environment, the service address information is changed to the address information corresponding to the Mock service.
[0020] Optionally, the method further comprises:
[0021] Initiate an HTTP request to the management computing resource unit to simulate the creation of a virtual machine;
[0022] The management computing resource unit requests the simulation unit of the image resource through HTTP to obtain the image required to create the virtual machine;
[0023] The management computing resource unit requests the simulation unit of the network resource through HTTP to obtain the network information required to create the virtual machine;
[0024] The computing resource management unit requests the storage resource simulation unit through HTTP to obtain the persistent storage information required to create a virtual machine;
[0025] The management computing resource unit generates a database record of the newly created virtual machine according to the image required for creating the virtual machine, the network information required for creating the virtual machine, and the persistent storage information required for creating the virtual machine.
[0026] In a second aspect, the present application shows a testing device based on a Mock service, the device comprising:
[0027] A receiving module, used for receiving a service request sent by a user terminal;
[0028] A judgment module, used to judge whether it is necessary to start the Mock service according to the business request and the pre-established virtual machine;
[0029] The execution module is used to determine the virtual machine corresponding to the Mock service when the Mock service needs to be started, so that the virtual machine executes the operation corresponding to the business request and obtains a response result.
[0030] Optionally, the execution module is used to:
[0031] Determine whether the virtual machine is in shutdown state through the Mock service;
[0032] If the virtual machine is in a shutdown state, the state of the virtual machine is changed to a startup state, and a successful operation response is returned.
[0033] Optionally, the execution module is used to:
[0034] If the virtual machine is in a powered-on state, the virtual machine is used to execute an operation corresponding to the service request.
[0035] Optionally, the device further comprises an establishing module, wherein the establishing module is configured to:
[0036] Receive a request to create a virtual machine;
[0037] Determine, according to the creation request and the configuration table, the service address information corresponding to the creation request;
[0038] Use a pre-established proxy program to determine whether to proxy traffic to the Mock service based on the context information of the current request;
[0039] If the current environment is a Mock environment, the service address information is changed to the address information corresponding to the Mock service.
[0040] Optionally, the establishing module is used to:
[0041] Initiate an HTTP request to the management computing resource unit to simulate the creation of a virtual machine;
[0042] The management computing resource unit requests the simulation unit of the image resource through HTTP to obtain the image required to create the virtual machine;
[0043] The management computing resource unit requests the simulation unit of the network resource through HTTP to obtain the network information required to create the virtual machine;
[0044] The computing resource management unit requests the storage resource simulation unit through HTTP to obtain the persistent storage information required to create a virtual machine;
[0045] The management computing resource unit generates a database record of the newly created virtual machine according to the image required for creating the virtual machine, the network information required for creating the virtual machine, and the persistent storage information required for creating the virtual machine.
[0046] In a third aspect, the present application shows an electronic device, which includes: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the method described in any of the above aspects.
[0047] In a fourth aspect, the present application illustrates a non-temporary computer-readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute a method as described in any of the above aspects.
[0048] In a fifth aspect, the present application illustrates a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to execute the method described in any of the above aspects.
[0049] The technical solution provided by the present application may include the following beneficial effects: an embodiment of the present application provides a testing method and device based on a Mock service, the method comprising: receiving a business request sent by a user terminal; judging whether it is necessary to start a Mock service according to the business request and a pre-established virtual machine; if it is necessary to start the Mock service, determining a virtual machine corresponding to the Mock service so that the virtual machine performs an operation corresponding to the business request and obtains a response result. The Mock service in the embodiment of the present application has the ability to simulate the behavior of the underlying components of cloud resources in real time. It can receive requests from a management console system and immediately respond to a response package that is consistent with the response of a real cloud resource interface. This real-time simulation technology ensures that the relevant business system can obtain accurate and reliable simulation results when testing without manually configuring Mock data rules. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 This is a flowchart of the steps of a testing method based on Mock service in this application;
[0051] Figure 2 This is a schematic diagram of the osMock process of this application;
[0052] Figure 3 This is a schematic diagram of a Mock service simulation process for creating a virtual machine in this application;
[0053] Figure 4This is a schematic diagram of an Agent process flow of this application;
[0054] Figure 5 It is a structural block diagram of a test device based on Mock service in this application;
[0055] Figure 6 is a block diagram of an electronic device of the present application;
[0056] Figure 7 It is a block diagram of an electronic device of the present application. DETAILED DESCRIPTION
[0057] 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 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.
[0058] Reference Figure 1 , shows a flowchart of a test method based on a Mock service of the present application, which can be applied to electronic devices, wherein the method specifically may include the following steps:
[0059] S101, receiving a service request sent by a user terminal;
[0060] S102: Determine whether to start the Mock service according to the business request and the pre-established virtual machine;
[0061] S103: When the Mock service needs to be started, determine a virtual machine corresponding to the Mock service, so that the virtual machine executes an operation corresponding to the business request and obtains a response result.
[0062] The embodiment of the present application provides a set of Mock solutions, which determines whether it is necessary to start the Mock service according to the business request sent by the user and the pre-established virtual machine; if the Mock service needs to be started, the virtual machine corresponding to the Mock service is found, so that the virtual machine executes the operation corresponding to the business request, and the response result obtained can be used as an agent to request the cloud resource interface without the relevant business system being aware of it, simulate the creation, shutdown, startup, shutdown and other actions of the underlying resources, and provide real-time status change query, so as to facilitate the relevant business system to efficiently perform complex scenario testing.
[0063] The system that relies on the cloud resource interface in the embodiment of the present application provides a set of Mock solutions, which can proxy the request for the cloud resource interface without the relevant system being aware of it, simulate the creation, shutdown, startup, shutdown and other actions of the underlying resources, and provide real-time status change query, without occupying the underlying virtual machine resources, and without manually preparing simulation data, so as to facilitate the relevant business systems to efficiently perform complex scenario testing.
[0064] The embodiment of the present application provides a testing method based on a Mock service, the method comprising: receiving a business request sent by a user terminal; judging whether it is necessary to start the Mock service according to the business request and a pre-established virtual machine; if it is necessary to start the Mock service, determining a virtual machine corresponding to the Mock service, so that the virtual machine performs an operation corresponding to the business request and obtains a response result. The Mock service in the embodiment of the present application has the ability to simulate the behavior of the underlying components of cloud resources in real time, it can receive requests from the management console system, and immediately respond to a response packet that is consistent with the response of the real cloud resource interface. This real-time simulation technology ensures that when the relevant business system is tested, accurate and reliable simulation results can be obtained without manually configuring the Mock data rules.
[0065] Another embodiment of the present application further supplements the testing method based on the Mock service provided in the above embodiment.
[0066] In one embodiment of the present application, when a Mock service needs to be started, a virtual machine corresponding to the Mock service is determined so that the virtual machine performs an operation corresponding to the business request to obtain a response result, including:
[0067] Use the Mock service to determine whether the virtual machine is in shutdown state;
[0068] If the virtual machine is in a powered-off state, the state of the virtual machine is changed to a powered-on state, and a successful operation response is returned.
[0069] In another embodiment of the present application, when a Mock service needs to be started, determining a virtual machine corresponding to the Mock service so that the virtual machine performs an operation corresponding to the business request and obtains a response result includes:
[0070] If the virtual machine is in the powered-on state, the virtual machine is used to execute the operation corresponding to the service request.
[0071] Another embodiment of the present application also includes:
[0072] Receive a request to create a virtual machine;
[0073] Determine the service address information corresponding to the creation request according to the creation request and the configuration table;
[0074] Use a pre-established proxy program to determine whether to proxy traffic to the Mock service based on the context information of the current request;
[0075] If the current environment is a Mock environment, the service address information is changed to the address information of the corresponding Mock service.
[0076] like Figure 2 As shown, the present invention is managed and controlled according to the following steps.
[0077] 1. The user first fully copies the database table that the underlying components of the cloud resources depend on as the data source of the Mock service.
[0078] 2. Implement cloud resource operation related interfaces in the Mock service, such as creating virtual machines, powering on, shutting down, etc. In the interface implementation, add, delete, and modify related resources in the data table.
[0079] 3. Provide a Java proxy program to dynamically proxy the Mock request initiator and determine whether to proxy traffic to the Mock service based on the context information of the current request.
[0080] 4. The Mock service receives the request and responds with a response package consistent with the real OS interface. At the same time, it changes the status of the corresponding resources in the Mock database to achieve full life cycle Mock management of cloud resources.
[0081] like Figure 4 As shown, the Java agent program dynamically proxying the Mock request initiator program referred to in the embodiment of the present application is managed and controlled according to the following steps:
[0082] 1) The requester initiates a request to create a virtual machine.
[0083] 2) After receiving the request, the service provider goes to the configuration table to obtain the request URL address of the corresponding service;
[0084] 3) When the address is returned, enter the Java agent program logic.
[0085] 4) The agent first determines whether the current environment and the current request path are Mock environments based on the environment variables and configuration information.
[0086] 5) If it is a mock environment, find the method that needs to proxy the request URL, and modify the request address returned by the method to the address of the corresponding mock service. If it is a non-mock environment, directly return the information returned by the original method.
[0087] Optionally, the method further comprises:
[0088] Initiate an HTTP request to the management computing resource unit to simulate the creation of a virtual machine;
[0089] The management computing resource unit requests the simulation unit of the image resource through HTTP to obtain the image required to create the virtual machine;
[0090] The management computing resource unit requests the simulation unit of the network resource through HTTP to obtain the network information required to create the virtual machine;
[0091] The computing resource management unit requests the storage resource simulation unit through HTTP to obtain the persistent storage information required to create a virtual machine;
[0092] The management computing resource unit generates a database record of the newly created virtual machine according to the image required for creating the virtual machine, the network information required for creating the virtual machine, and the persistent storage information required for creating the virtual machine.
[0093] like Figure 3 As shown, the overall process of the Mock service in the embodiment of the present application to simulate the underlying components of cloud resources in real time to create a virtual machine is managed and controlled according to the following steps. Among them, the computing Mock service module is responsible for managing the simulation of computing resources, the mirror Mock service module is responsible for the simulation of mirror resources, the network Mock service module is responsible for the simulation of network resources, and the storage Mock service module is responsible for the simulation of storage resources.
[0094] a) Request the Mock service to initiate an HTTP request to the Mock service module to simulate the creation of a virtual machine.
[0095] b) The calculation Mock service module obtains the image required to create a virtual machine through an HTTP request to the image Mock service module.
[0096] c) The calculation Mock service module requests the network Mock service module through HTTP to obtain the network information required to create a virtual machine.
[0097] d) The calculation Mock service module requests the storage Mock service module through HTTP to obtain the persistent storage information required to create a virtual machine.
[0098] e) The calculation Mock service module generates a database record of the newly created virtual machine based on the above information.
[0099] d) The Mock service module calculates the creation completion information and returns a successful creation response package to the Mock service requester.
[0100] The embodiment of the present application provides a testing method based on a Mock service, the method comprising: receiving a business request sent by a user terminal; judging whether it is necessary to start the Mock service according to the business request and a pre-established virtual machine; if it is necessary to start the Mock service, determining a virtual machine corresponding to the Mock service, so that the virtual machine performs an operation corresponding to the business request and obtains a response result. The Mock service in the embodiment of the present application has the ability to simulate the behavior of the underlying components of cloud resources in real time, it can receive requests from the management console system, and immediately respond to a response packet that is consistent with the response of the real cloud resource interface. This real-time simulation technology ensures that when the relevant business system is tested, accurate and reliable simulation results can be obtained without manually configuring the Mock data rules.
[0101] Example 1: Creating a virtual machine
[0102] In this embodiment, the user needs to create a large number of virtual machines in the management console system in order to perform stress testing. Using the Mock device and equipment of the present invention, the user can initiate a request to create a virtual machine through the management console system. The Java agent program will dynamically proxy these requests and redirect them to the Mock service.
[0103] After receiving the request to create a virtual machine, the Mock service simulates the behavior of the underlying components of the cloud resources. It creates a record of the virtual machine in the Mock data source and returns a response package consistent with the real cloud resource interface response to the management console system. Users do not need to manually configure complex Mock data rules.
[0104] Example 2: Power on
[0105] In this embodiment, the user needs to test the performance of the system in the boot scenario. Using the Mock device and equipment of the present invention, the user can initiate boot and shutdown requests through the management console system.
[0106] The proxy program determines whether these requests need to proxy traffic to the Mock service. If necessary, it redirects the request to the Mock service. The Mock service simulates the behavior of the underlying components of the cloud resources. First, it determines whether the requested virtual machine is in a shutdown state. If the virtual machine is in a shutdown state, it changes its state to a startup state and returns a successful operation response. If the virtual machine is in a startup state, it returns a response that the desktop that has already been powered on cannot be powered on, thus achieving a full simulation of the virtual machine's startup process.
[0107] Through this embodiment, the user can test the performance of the system in a completely realistic scenario without having to manually configure various rules to adapt to different test cases.
[0108] The Mock service of the present invention has the ability to simulate the behavior of the underlying components of cloud resources in real time. It can receive requests from the management console system and respond immediately with a response packet that is consistent with the response of the real cloud resource interface. This real-time simulation technology ensures that when the relevant business system is tested, accurate and reliable simulation results can be obtained without manually configuring the Mock data rules.
[0109] The embodiments of the present application solve the problems of large workload in dynamic Mock service data preparation and difficulty in reusing Mock interfaces, and provide a Mock solution for systems that rely on cloud resource interfaces. It can proxy requests for cloud resource interfaces without the relevant business systems being aware of them, simulate the creation, shutdown, startup, shutdown and other actions of the underlying resources, and provide real-time status change query, so as to facilitate the relevant business systems to efficiently perform complex scenario testing.
[0110] It should be noted that each implementable method in this embodiment may be implemented separately, or may be implemented in combination in any combination without conflict, and this application is not limited thereto.
[0111] Another embodiment of the present application provides a testing device based on a Mock service, which is used to execute the testing method based on a Mock service provided in the above embodiment.
[0112] like Figure 5 , which is a schematic diagram of the structure of a test device based on a Mock service provided in an embodiment of the present application. The test device based on a Mock service includes a receiving module 501, a judging module 502 and an executing module 503, wherein:
[0113] The receiving module 501 is used to receive a service request sent by a user terminal;
[0114] The judgment module 502 is used to judge whether the Mock service needs to be started according to the business request and the pre-established virtual machine;
[0115] The execution module 503 is used to determine the virtual machine corresponding to the Mock service when the Mock service needs to be started, so that the virtual machine executes the operation corresponding to the business request and obtains a response result.
[0116] Regarding the device in this embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0117] The embodiment of the present application provides a testing device based on a Mock service, the method comprising: receiving a business request sent by a user terminal; judging whether it is necessary to start the Mock service according to the business request and a pre-established virtual machine; if it is necessary to start the Mock service, determining the virtual machine corresponding to the Mock service, so that the virtual machine performs an operation corresponding to the business request and obtains a response result. The Mock service in the embodiment of the present application has the ability to simulate the behavior of the underlying components of cloud resources in real time, it can receive requests from the management console system, and immediately respond to a response package that is consistent with the response of the real cloud resource interface. This real-time simulation technology ensures that the relevant business system can obtain accurate and reliable simulation results when testing, without the need to manually configure the Mock data rules.
[0118] Another embodiment of the present application further supplements the test device based on the Mock service provided in the above embodiment.
[0119] Optionally, an execution module is used to:
[0120] Use the Mock service to determine whether the virtual machine is in shutdown state;
[0121] If the virtual machine is in a powered-off state, the state of the virtual machine is changed to a powered-on state, and a successful operation response is returned.
[0122] Optionally, an execution module is used to:
[0123] If the virtual machine is in a powered-on state, the virtual machine is used to execute an operation corresponding to the service request.
[0124] Optionally, the device further comprises an establishing module, the establishing module being configured to:
[0125] Receive a request to create a virtual machine;
[0126] Determine the service address information corresponding to the creation request according to the creation request and the configuration table;
[0127] Use a pre-established proxy program to determine whether to proxy traffic to the Mock service based on the context information of the current request;
[0128] If the current environment is a Mock environment, the service address information is changed to the address information of the corresponding Mock service.
[0129] Optionally, build modules for:
[0130] Initiate an HTTP request to the management computing resource unit to simulate the creation of a virtual machine;
[0131] The management computing resource unit requests the simulation unit of the image resource through HTTP to obtain the image required to create the virtual machine;
[0132] The management computing resource unit requests the simulation unit of the network resource through HTTP to obtain the network information required to create the virtual machine;
[0133] The computing resource management unit requests the storage resource simulation unit through HTTP to obtain the persistent storage information required to create a virtual machine;
[0134] The management computing resource unit generates a database record of the newly created virtual machine according to the image required for creating the virtual machine, the network information required for creating the virtual machine, and the persistent storage information required for creating the virtual machine.
[0135] The embodiment of the present application provides a testing device based on a Mock service, the method comprising: receiving a business request sent by a user terminal; judging whether it is necessary to start the Mock service according to the business request and a pre-established virtual machine; if it is necessary to start the Mock service, determining the virtual machine corresponding to the Mock service, so that the virtual machine performs an operation corresponding to the business request and obtains a response result. The Mock service in the embodiment of the present application has the ability to simulate the behavior of the underlying components of cloud resources in real time, it can receive requests from the management console system, and immediately respond to a response package that is consistent with the response of the real cloud resource interface. This real-time simulation technology ensures that the relevant business system can obtain accurate and reliable simulation results when testing, without the need to manually configure the Mock data rules.
[0136] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions involved are not necessarily required by the present application.
[0137] Optionally, an embodiment of the present application further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0138] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0139] FIG6 is a block diagram of an electronic device 800 shown in the present application. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0140] Reference Figure 6 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0141] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0142] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, images, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0143] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.
[0144] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0145] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0146] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0147] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0148] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast operation information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0149] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0150] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0151] Figure 71 is a block diagram of an electronic device 1900 shown in the present application. For example, the electronic device 1900 may be provided as a server.
[0152] Reference Figure 7 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
[0153] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output (I / O) interface 1958. The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.
[0154] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0155] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0156] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0157] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0158] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0159] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0160] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0161] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0162] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0163] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A testing method based on Mock service, characterized in that: The method comprises: Receiving a service request sent by a user terminal; According to the business request and the pre-established virtual machine, determine whether it is necessary to start the Mock service; In the case where the Mock service needs to be started, a virtual machine corresponding to the Mock service is determined, so that the virtual machine executes an operation corresponding to the business request to obtain a response result.
2. The testing method based on Mock service according to claim 1, characterized in that: In the case where the Mock service needs to be started, determining a virtual machine corresponding to the Mock service so that the virtual machine performs an operation corresponding to the business request and obtains a response result, including: Determine whether the virtual machine is in shutdown state through the Mock service; If the virtual machine is in a shutdown state, the state of the virtual machine is changed to a startup state, and a successful operation response is returned.
3. The testing method based on Mock service according to claim 2, characterized in that: In the case where the Mock service needs to be started, determining a virtual machine corresponding to the Mock service so that the virtual machine performs an operation corresponding to the business request and obtains a response result, including: If the virtual machine is in a powered-on state, the virtual machine is used to execute an operation corresponding to the service request.
4. The testing method based on Mock service according to claim 1, characterized in that: The method further comprises: Receive a request to create a virtual machine; Determine, according to the creation request and the configuration table, the service address information corresponding to the creation request; Use a pre-established proxy program to determine whether to proxy traffic to the Mock service based on the context information of the current request; If the current environment is a Mock environment, the service address information is changed to the address information corresponding to the Mock service.
5. The testing method based on Mock service according to claim 1, characterized in that: The method further comprises: Initiate an HTTP request to the management computing resource unit to simulate the creation of a virtual machine; The management computing resource unit requests the simulation unit of the image resource through HTTP to obtain the image required to create the virtual machine; The management computing resource unit requests the simulation unit of the network resource through HTTP to obtain the network information required to create the virtual machine; The computing resource management unit requests the storage resource simulation unit through HTTP to obtain the persistent storage information required to create a virtual machine; The management computing resource unit generates a database record of the newly created virtual machine according to the image required for creating the virtual machine, the network information required for creating the virtual machine, and the persistent storage information required for creating the virtual machine.
6. A testing device based on Mock service, characterized in that: The device comprises: A receiving module, used for receiving a service request sent by a user terminal; A judgment module, used to judge whether it is necessary to start the Mock service according to the business request and the pre-established virtual machine; The execution module is used to determine the virtual machine corresponding to the Mock service when the Mock service needs to be started, so that the virtual machine executes the operation corresponding to the business request and obtains a response result.
7. The testing device based on Mock service according to claim 6, characterized in that: The execution module is used to: Determine whether the virtual machine is in shutdown state through the Mock service; If the virtual machine is in a shutdown state, the state of the virtual machine is changed to a startup state, and a successful operation response is returned.
8. The test device based on Mock service according to claim 7, characterized in that: The execution module is used to: If the virtual machine is in a powered-on state, the virtual machine is used to execute an operation corresponding to the service request.
9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method according to any one of claims 1 to 5 when executed by the processor.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.