Method and device for randomly testing life cycle of virtual machine
Through the random testing method of the virtual machine life cycle, operation sequences are automatically generated and test cases are executed, which solves the problem of low efficiency of manually written test cases and achieves more efficient virtual machine test coverage.
Patent Information
- Application Number
- CN202410847983.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-01
AI Technical Summary
Existing virtual machine testing mainly relies on manually written test cases, resulting in low testing efficiency and inability to fully cover various complex operation sequences of the virtual machine. In addition, use cases written by different testers are prone to duplication and omissions.
A random testing method for the virtual machine life cycle is proposed. By determining the virtualization operation and constraint relationship of the virtual machine, an initial weight matrix is established and normalized into a Markov matrix, and an operation sequence is automatically generated until the target length or number of use cases is reached. , and then execute and display the execution results of the use case collection.
It effectively improves the efficiency of testing work, can intelligently combine operation sequences, fully covers the operation of virtual machines, reduces duplication and omissions in use case generation, and improves test coverage and use case quality.
Smart Images

Figure CN118733462A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of testing technology, and in particular relates to a random testing method and device for a virtual machine life cycle. Background Art
[0002] In the related technology, virtual machine testing currently mainly relies on the method of manually writing test cases. Testers need to design various operation sequences based on experience to fully verify the functions and performance of the virtual machine. However, the method of manually writing test cases will lead to problems such as low testing efficiency. Therefore, how to better implement virtual machine testing has become an urgent problem to be solved. Summary of the invention
[0003] In view of the above deficiencies in the prior art, the purpose of the invention is to provide a random testing method and device for a virtual machine life cycle, which can effectively and automatically generate an operation sequence and can intelligently combine operation sequences, thereby improving the efficiency of the testing work.
[0004] In a first aspect of the present invention, a random testing method for a virtual machine life cycle is proposed, comprising: S1, determining the virtualization operation of the virtual machine and the constraint relationship between the virtualization operations; S2, determining that the initial virtualization operation of the virtual machine is a shutdown operation, establishing an initial weight matrix according to the constraint relationship between the virtualization operations, and normalizing the initial weight matrix to obtain a Markov matrix; S3, traversing the operation sequence under the Markov matrix and the shutdown operation of the virtual machine until the length of the operation sequence is a target length and / or the generated use cases of the operation sequence are a target number, terminating the traversal; S4, obtaining a use case set, executing the use cases in the use case set and displaying the summarized execution results.
[0005] Furthermore, the virtualization operation includes a power-on operation, a restart operation, the power-off operation, a stop operation, a recovery operation, a hot migration operation, and a deletion operation.
[0006] Furthermore, the constraint relationship between the virtualization operations includes: the power-on operation executes any operation except the power-on operation and the recovery operation in the next step, the restart operation executes any operation except the power-on operation and the deletion operation in the next step, the shutdown operation can only execute the power-on operation or the deletion operation in the next step, the stop operation can only execute the recovery operation or the deletion operation in the next step, the recovery operation executes any operation except the power-on operation and the recovery operation in the next step, the hot migration operation executes any operation except the power-on operation and the recovery operation in the next step, and the deletion operation does not execute any operation in the next step.
[0007] Furthermore, the method further includes: when it is determined that the initial virtualization operation of the virtual machine is a shutdown operation, setting targets for the virtualization operations to be executed and the virtualization operations that cannot be executed.
[0008] Furthermore, under the Markov matrix and the shutdown operation of the virtual machine, the operation sequence is traversed until the length of the operation sequence is a target length and / or the generation use cases of the operation sequence are a target number, and the traversal is terminated, including: under the Markov matrix and the shutdown operation of the virtual machine, the operation sequence is traversed until the length of the operation sequence is a target length, and the traversal is stopped; when the traversal is stopped, the virtualization operation of the virtual machine is returned to the shutdown operation, the initial weight matrix and the Markov matrix are updated, and under the updated Markov matrix and the shutdown operation of the virtual machine, the operation sequence is traversed until the generation use cases of the operation sequence are the target number, and the traversal is terminated.
[0009] Furthermore, updating the initial weight matrix and updating the Markov matrix include: determining whether the weight of the virtualization operation has changed; if the weight of the virtualization operation has changed, updating the initial weight matrix; and normalizing the updated initial weight matrix to obtain the updated Markov matrix.
[0010] Furthermore, a use case set is obtained, and the use cases in the use case set are executed and the summarized execution results are displayed, including: obtaining the operation sequence after traversal; translating the operation sequence after traversal into the use case set, and executing the use cases in the use case set; obtaining the successful and failed use cases and displaying them.
[0011] In a second aspect of the present invention, a random testing device for a virtual machine life cycle is proposed, comprising: a determination module, used to determine the virtualization operation of the virtual machine and the constraint relationship between the virtualization operations; an acquisition module, used to determine that the initial virtualization operation of the virtual machine is a shutdown operation, establish an initial weight matrix according to the constraint relationship between the virtualization operations, and normalize the initial weight matrix to obtain a Markov matrix; a traversal module, used to traverse the operation sequence under the Markov matrix and the shutdown operation of the virtual machine until the length of the operation sequence is the target length and / or the generated use cases of the operation sequence are the target number, and then terminate the traversal; an execution module, used to obtain a use case set, execute the use cases in the use case set and display the summarized execution results.
[0012] According to a third aspect of the present invention, an electronic device is proposed, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the methods described in the first aspect of the present invention.
[0013] According to a fourth aspect of the present invention, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any one of the methods according to the first aspect of the present invention.
[0014] The beneficial effects of the present invention are as follows:
[0015] The random testing method and device of the virtual machine life cycle of the present invention determine the virtualization operation of the virtual machine and the constraint relationship between the virtualization operations; when it is determined that the initial virtualization operation of the virtual machine is a shutdown operation, an initial weight matrix is established according to the constraint relationship between the virtualization operations, and the initial weight matrix is normalized to obtain a Markov matrix; under the Markov matrix and the shutdown operation of the virtual machine, the operation sequence is traversed until the length of the operation sequence is the target length and / or the generated use cases of the operation sequence are the target number, the traversal is terminated; a use case set is obtained, and the use cases in the use case set are executed and the summarized execution results are displayed. The method can effectively and automatically generate an operation sequence and can intelligently combine operation sequences, thereby improving the efficiency of testing work. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings are only used to illustrate specific embodiments and are not considered to limit the present invention. In the entire drawings, the same reference symbols represent the same components. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings.
[0017] Figure 1 is a flow chart of a random testing method for a virtual machine life cycle according to an embodiment of the present invention;
[0018] Figure 2 is a flow chart of a method for implementing termination of traversal according to an embodiment of the present invention;
[0019] Figure 3 is a structural block diagram of a random testing device for a virtual machine life cycle according to an embodiment of the present invention;
[0020] Figure 4 It is a structural block diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work should fall within the scope of protection of the present invention.
[0022] Furthermore, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts disclosed in the present invention.
[0023] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the orientation or position relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside", etc. is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. The terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0024] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of methods and systems consistent with some aspects of the present invention as detailed in the appended claims.
[0025] In the prior art, virtual machine testing currently relies mainly on the method of manually writing test cases. Testers need to design various operation sequences based on experience to fully verify the functions and performance of the virtual machine. However, this method has many problems: the workload of writing test cases is large, and test cases written by different testers are prone to duplication and omission; it cannot fully cover various complex operation sequences of the virtual machine; the test intensity for key functions is not enough, etc.
[0026] To this end, the present invention proposes a random testing method, device and related equipment for the life cycle of a virtual machine. Specifically, the random testing method, device and related equipment for the life cycle of a virtual machine according to an embodiment of the present invention are described below with reference to the accompanying drawings.
[0027] Figure 1 This is a flow chart of a random testing method for a virtual machine life cycle according to an embodiment of the present invention. It should be noted that the random testing method for a virtual machine life cycle according to an embodiment of the present invention can be applied to a random testing device for a virtual machine life cycle according to an embodiment of the present invention. The random testing device for a virtual machine life cycle can be configured on an electronic device or in a server. This embodiment of the present application does not limit this.
[0028] like Figure 1 As shown in the figure, the random testing method of the virtual machine life cycle includes:
[0029] S110: Determine virtualization operations of the virtual machine and constraint relationships between virtualization operations.
[0030] In an embodiment of the present invention, the virtualization operation includes a power-on operation, a restart operation, a power-off operation, a stop operation, a recovery operation, a hot migration operation, and a deletion operation.
[0031] In an embodiment of the present invention, the constraint relationship between virtualization operations includes: the next step of the power-on operation is to execute any operation except the power-on operation and the recovery operation; the next step of the restart operation is to execute any operation except the power-on operation and the deletion operation; the next step of the shutdown operation can only execute the power-on operation or the deletion operation; the next step of the stop operation can only execute the recovery operation or the deletion operation; the next step of the recovery operation is to execute any operation except the power-on operation and the recovery operation; the next step of the hot migration operation is to execute any operation except the power-on operation and the recovery operation; and the next step of the deletion operation is not to execute any operation.
[0032] S120, when it is determined that the initial virtualization operation of the virtual machine is a shutdown operation, an initial weight matrix is established according to the constraint relationship between the virtualization operations, and the initial weight matrix is normalized to obtain a Markov matrix.
[0033] In an embodiment of the present invention, when it is determined that the initial virtualization operation of the virtual machine is a shutdown operation, the virtualization operations to be executed and the virtualization operations that cannot be executed are set as targets. Then, an initial weight matrix can be established according to the constraint relationship between the virtualization operations, and the initial weight matrix is normalized to obtain a Markov matrix.
[0034] That is to say, the initial virtualization operation of the virtual machine can be set as the shutdown operation, that is, the virtual machine is in the shutdown state, the virtualization operation that can be executed in the next step of the shutdown operation is set to 1, and the virtualization operation that cannot be executed in the next step of the shutdown operation is set to 0. Then, the initial weight matrix can be established according to the constraint relationship between the virtualization operations, and the initial weight matrix is normalized to obtain a Markov matrix.
[0035] For example, a matrix is initialized in which the rows represent the current virtualization operation and the columns represent the possible virtualization operations to be transferred to, and the matrix is filled according to the constraint relationship between the virtualization operations. For example: if the shutdown operation can be transferred to the startup operation or the deletion operation, then the startup and deletion columns in the shutdown row are marked as 1, and the rest are marked as 0. The initial weight matrix is normalized, that is, for each state (i.e., virtualization operation), its corresponding row is divided by the sum of all elements in the row, so that the sum of each row is 1. In this way, the sum of the probabilities of each state transition is 1. The normalized matrix is the Markov matrix, which represents the probability of transition from one state to another.
[0036] Therefore, the obtained Markov matrix can fully consider the order dependency of virtual machine operations by representing the constraint relationship between the order of virtualization operations, making the generated test case sequence more realistic and better than simple random generation.
[0037] S130, traversing the operation sequence under the shutdown operation of the Markov matrix and the virtual machine until the length of the operation sequence reaches the target length and / or the number of generated use cases of the operation sequence reaches the target number, and then terminating the traversal.
[0038] In an embodiment of the present invention, a Markov matrix is obtained, and the operation sequence is traversed under the shutdown operation based on the Markov matrix and the virtual machine until the operation sequence reaches the target condition, and the traversal is terminated. Figure 2 As shown, the method for implementing the termination traversal includes:
[0039] S210, traversing the operation sequence under the shutdown operation of the Markov matrix and the virtual machine until the length of the operation sequence reaches the target length, and then stopping the traversal.
[0040] In one embodiment of the present invention, it is detected whether the length of the current operation sequence reaches the target length, and if not, the operation sequence is discarded.
[0041] In one embodiment of the present invention, when traversing the operation sequence, when reaching the deletion operation, the traversal is stopped.
[0042] S220, when the traversal is stopped, the virtualization operation of the virtual machine is returned to the shutdown operation, the initial weight matrix and the Markov matrix are updated, and the operation sequence is traversed under the updated Markov matrix and the shutdown operation of the virtual machine until the generated use cases of the operation sequence reach the target number, and the traversal is terminated.
[0043] In an embodiment of the present invention, updating the initial weight matrix and updating the Markov matrix include: determining whether the weight of the virtualization operation has changed; if the weight of the virtualization operation has changed, updating the initial weight matrix; normalizing the updated initial weight matrix to obtain an updated Markov matrix.
[0044] That is, when the traversal is stopped, the virtualization operation of the virtual machine is returned to the shutdown operation to determine whether the weight of the virtualization operation has changed; when the weight of the virtualization operation has changed, the initial weight matrix and the Markov matrix are updated.
[0045] In one embodiment of the present invention, when the virtualization operation of the virtual machine is returned to the shutdown operation, the weight matrix is modified to increase the weight of one operation to another operation, thereby determining whether the weight of the virtualization operation has changed. In this way, the probability of a certain operation sequence occurring is increased, and artificial control is achieved.
[0046] In another embodiment of the present invention, when the traversal is stopped, the weight of the traversed operation is attenuated, and then it can be determined whether the weight of the virtualized operation has changed, so as to increase the probability of occurrence of other uncovered operations, thereby making the generated sequence coverage higher and the test coverage wider.
[0047] For example, the initial weight matrix is A: 1 1 1 1
[0050] Converted to Markov matrix: 0.5 0.5 0.5 0.5
[0053] At this time, the weight A(0, 1) decays by a=a*0.1, and the updated weight matrix becomes: 1 0.1 1 1
[0056] Converted to Markov matrix:
[0057] 1 / (1+0.1)0.1 / (1+0.1)
[0058] 0.5 0.5.
[0059] It can be seen that the automatic generation of operation sequences by dynamically adjusting the traversal algorithm of the transition probability not only solves the problem of low efficiency of use case generation, but also enhances the test coverage and use case quality through the control of transition probability. It also ensures that the operation sequence can still be effectively generated in the new state, which greatly improves the test efficiency and effect of the virtual machine.
[0060] In one embodiment of the present invention, the operation sequence is traversed under the shutdown operation of the Markov matrix and the virtual machine until the length of the operation sequence reaches the target length and / or the number of generated cases of the operation sequence reaches the target number, and then the traversal is terminated.
[0061] S140, obtaining a use case set, executing the use cases in the use case set and displaying the summarized execution results.
[0062] In an embodiment of the present invention, the traversed operation sequence is obtained; the traversed operation sequence is translated into a use case set, and the use cases in the use case set are executed; the successful use cases and failed use cases are obtained and displayed.
[0063] For example, the traversed operation sequence is translated into a use case set. For example, if the c4-c5-c3-c1-c7 sequence is obtained, then the translation into the use case set is: stop-restore-shutdown-startup-delete.
[0064] It should be noted that the life cycle of a virtual machine can be understood as the complete process from the creation to the termination of the virtual machine, which usually includes stages such as definition, startup, operation, migration, stop, and deletion. Random testing can be understood as using randomly generated input data to activate different code paths and conditions of the program. Since the input data is unpredictable, the probability of discovering program defects can be increased.
[0065] According to the random testing method of the virtual machine life cycle of the embodiment of the present invention, the virtualization operation of the virtual machine and the constraint relationship between the virtualization operations are determined; when it is determined that the initial virtualization operation of the virtual machine is a shutdown operation, an initial weight matrix is established according to the constraint relationship between the virtualization operations, and the initial weight matrix is normalized to obtain a Markov matrix; under the Markov matrix and the shutdown operation of the virtual machine, the operation sequence is traversed until the length of the operation sequence is the target length and / or the generated use cases of the operation sequence are the target number, the traversal is terminated; a use case set is obtained, and the use cases in the use case set are executed and the summarized execution results are displayed. This method can effectively and automatically generate an operation sequence and can intelligently combine operation sequences, thereby improving the efficiency of testing work.
[0066] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment 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, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0067] According to one aspect of an embodiment of the present invention, a random testing device for a virtual machine life cycle is also provided. Figure 3 is a structural block diagram of a random testing device for a virtual machine life cycle according to an embodiment of the present invention; Figure 3 As shown, including:
[0068] A determination module 310, configured to determine virtualization operations of a virtual machine and constraint relationships between the virtualization operations;
[0069] Obtaining module 320, for determining that the initial virtualization operation of the virtual machine is a shutdown operation, establishing an initial weight matrix according to the constraint relationship between the virtualization operations, and normalizing the initial weight matrix to obtain a Markov matrix;
[0070] A traversal module 330 is used to traverse the operation sequence under the Markov matrix and the shutdown operation of the virtual machine until the length of the operation sequence reaches a target length and / or the number of generated use cases of the operation sequence reaches a target number, and then terminate the traversal;
[0071] The execution module 340 is used to obtain a use case set, execute the use cases in the use case set, and display the summarized execution results.
[0072] According to the random testing device of the life cycle of a virtual machine of an embodiment of the present invention, the virtualization operation of the virtual machine and the constraint relationship between the virtualization operations are determined; when it is determined that the initial virtualization operation of the virtual machine is a shutdown operation, an initial weight matrix is established according to the constraint relationship between the virtualization operations, and the initial weight matrix is normalized to obtain a Markov matrix; under the Markov matrix and the shutdown operation of the virtual machine, the operation sequence is traversed until the length of the operation sequence is the target length and / or the generated use cases of the operation sequence are the target number, the traversal is terminated; a use case set is obtained, and the use cases in the use case set are executed and the summarized execution results are displayed. In this way, the operation sequence can be effectively and automatically generated and the combined operation sequence can be intelligently and efficiently generated, thereby improving the efficiency of the test work.
[0073] Optionally, the virtualization operation includes a power-on operation, a restart operation, the power-off operation, a stop operation, a recovery operation, a hot migration operation, and a deletion operation.
[0074] Optionally, the constraint relationship between the virtualization operations includes: the power-on operation executes any operation except the power-on operation and the recovery operation in the next step, the restart operation executes any operation except the power-on operation and the deletion operation in the next step, the shutdown operation can only execute the power-on operation or the deletion operation in the next step, the stop operation can only execute the recovery operation or the deletion operation in the next step, the recovery operation executes any operation except the power-on operation and the recovery operation in the next step, the hot migration operation executes any operation except the power-on operation and the recovery operation in the next step, and the deletion operation does not execute any operation in the next step.
[0075] Optionally, the device further comprises a setting module, and the setting module is used to perform target setting on the virtualization operation to be executed and the virtualization operation that cannot be executed when it is determined that the initial virtualization operation of the virtual machine is a shutdown operation.
[0076] Optionally, the traversal module 330 is specifically used to traverse the operation sequence under the Markov matrix and the shutdown operation of the virtual machine until the length of the operation sequence reaches the target length, and then stop the traversal; when the traversal is stopped, return the virtualization operation of the virtual machine to the shutdown operation, update the initial weight matrix and the Markov matrix, and traverse the operation sequence under the updated Markov matrix and the shutdown operation of the virtual machine until the generated use cases of the operation sequence reach the target number, and then terminate the traversal.
[0077] Optionally, the traversal module 330 is specifically used to determine whether the weight of the virtualization operation has changed; if the weight of the virtualization operation has changed, update the initial weight matrix; normalize the updated initial weight matrix to obtain the updated Markov matrix.
[0078] Optionally, the execution module 340 is specifically used to obtain the operation sequence after traversal; translate the operation sequence after traversal into the use case set, and execute the use cases in the use case set; obtain the successful use cases and failed use cases and display them.
[0079] According to one aspect of an embodiment of the present invention, an electronic device is provided.
[0080] Figure 4 Schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Figure 4 As shown, the electronic device may include one or more ( Figure 4 Only one is shown in the figure) processor 102 (processor 102 may include but is not limited to a microprocessor (Microprocessor Unit, referred to as MPU) or a programmable logic device (Programmable logic device, referred to as PLD)) and a memory 104 for storing data. In an exemplary embodiment, the electronic device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 4 The structure shown is for illustration only and does not limit the structure of the above terminal device. Figure 4 More or fewer components as shown, or with Figure 4 Equivalent functions or comparisons shown Figure 4 A different configuration with more features is shown.
[0081] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the level determination method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal device via a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0082] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the switching device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0083] The present invention proposes a computer-readable storage medium having a computer program stored thereon, wherein the computer program can be loaded and executed by a processor to implement the random testing method for the life cycle of a virtual machine described in the first aspect.
[0084] The applicant of the present invention has made a detailed explanation and description of the implementation examples of the present invention in conjunction with the drawings in the specification. However, those skilled in the art should understand that the above implementation examples are only preferred implementation schemes of the present invention, and the detailed description is only to help readers better understand the spirit of the present invention, but not to limit the scope of protection of the present invention. On the contrary, any improvements or modifications based on the inventive spirit of the present invention should fall within the scope of protection of the present invention.
[0085] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0086] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.
[0087] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the above embodiments, or replace some of the technical features therein by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. Any changes or replacements that can be easily thought of by those skilled in the art within the technical scope disclosed in the present invention should be covered within the protection scope of the present invention.
Claims
1. A random testing method for a virtual machine life cycle, characterized in that: include: S1, determining virtualization operations of a virtual machine and constraint relationships between the virtualization operations; S2, when it is determined that the initial virtualization operation of the virtual machine is a shutdown operation, an initial weight matrix is established according to the constraint relationship between the virtualization operations, and the initial weight matrix is normalized to obtain a Markov matrix; S3, traversing the operation sequence under the Markov matrix and the shutdown operation of the virtual machine until the length of the operation sequence reaches a target length and / or the number of generated use cases of the operation sequence reaches a target number, and then terminating the traversal; S4, obtain a use case set, execute the use cases in the use case set and display the summarized execution results.
2. The random testing method for a virtual machine life cycle according to claim 1, characterized in that: The virtualization operation includes a power-on operation, a restart operation, the power-off operation, a stop operation, a recovery operation, a hot migration operation, and a deletion operation.
3. The random testing method for a virtual machine life cycle according to claim 2, characterized in that: The constraint relationship between the virtualization operations includes: the power-on operation executes any operation except the power-on operation and the recovery operation in the next step, the restart operation executes any operation except the power-on operation and the deletion operation in the next step, the shutdown operation can only execute the power-on operation or the deletion operation in the next step, the stop operation can only execute the recovery operation or the deletion operation in the next step, the recovery operation executes any operation except the power-on operation and the recovery operation in the next step, the hot migration operation executes any operation except the power-on operation and the recovery operation in the next step, and the deletion operation does not execute any operation in the next step.
4. The random testing method for a virtual machine life cycle according to claim 1, characterized in that: The method further includes: when it is determined that the initial virtualization operation of the virtual machine is a shutdown operation, setting targets for the virtualization operations to be executed and the virtualization operations that cannot be executed.
5. The random testing method for a virtual machine life cycle according to claim 1, characterized in that: Under the Markov matrix and the shutdown operation of the virtual machine, traversing the operation sequence until the length of the operation sequence reaches a target length and / or the number of generated use cases of the operation sequence reaches a target number, terminating the traversal, including: Under the Markov matrix and the shutdown operation of the virtual machine, traverse the operation sequence until the length of the operation sequence reaches a target length, and then stop traversing; When the traversal is stopped, the virtualization operation of the virtual machine is returned to the shutdown operation, the initial weight matrix and the Markov matrix are updated, and the operation sequence is traversed under the updated Markov matrix and the shutdown operation of the virtual machine until the generated use cases of the operation sequence reach the target number, and the traversal is terminated.
6. The random testing method for a virtual machine life cycle according to claim 5, characterized in that: Updating the initial weight matrix and updating the Markov matrix include: Determining whether the weight of the virtualization operation changes; When the weight of the virtualization operation changes, updating the initial weight matrix; The updated initial weight matrix is normalized to obtain the updated Markov matrix.
7. The random testing method for a virtual machine life cycle according to claim 1, characterized in that: Obtain a use case set, execute the use cases in the use case set and display the summary of the execution results, including: Obtaining the operation sequence after traversal; Translate the traversed operation sequence into the use case set, and execute the use cases in the use case set; Get the successful and failed cases and display them.
8. A random testing device for a virtual machine life cycle, characterized in that: include: A determination module, used to determine the virtualization operations of the virtual machine and the constraint relationships between the virtualization operations; An obtaining module is used to determine that when the initial virtualization operation of the virtual machine is a shutdown operation, establish an initial weight matrix according to the constraint relationship between the virtualization operations, and normalize the initial weight matrix to obtain a Markov matrix; A traversal module, used for traversing the operation sequence under the Markov matrix and the shutdown operation of the virtual machine until the length of the operation sequence reaches a target length and / or the number of generated use cases of the operation sequence reaches a target number, and then terminating the traversal; The execution module is used to obtain a use case set, execute the use cases in the use case set and display the summarized execution results.
9. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 7.
