A testing method and device, electronic equipment and storage medium

By automatically performing data backup and restore operations in the cloud host and performing consistency verification, the problem of low efficiency of manual operations in the existing technology is solved, the automated performance evaluation and data backup and restore process are realized, and efficiency and accuracy.

CN113849388BActive Publication Date: 2024-09-13BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111161859.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-30
Publication Date
2024-09-13
Estimated Expiration
2041-09-30

AI Technical Summary

Technical Problem

In the existing technology, the data backup and restoration process requires manual operation and observation, which is inefficient and lacks automated solutions.

Method used

Provide a testing method and device that automatically determines cloud host performance by receiving test commands to write original data in designated storage media, perform backup and restore operations, record backup duration, and perform data consistency verification.

Benefits of technology

It realizes the automated data backup and restoration process, improves testing efficiency, reduces the need for manual monitoring, and improves the accuracy of data backup and restoration performance evaluation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113849388B
    Figure CN113849388B
Patent Text Reader

Abstract

The present application relates to a testing method and device, an electronic device and a storage medium. The method includes: receiving a test command; performing a write operation in a designated storage medium according to the test command to write original data in the designated storage medium; performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, and recording the backup duration of the backup operation; obtaining the restored data located in the designated storage medium by performing a restore operation to restore the target backup data to the designated storage medium; performing a consistency check on the restored data and the original data to obtain a check result; determining the cloud host performance of the cloud host to be tested according to the check result and the backup duration. The present application can effectively avoid the problem of large amount of manpower consumption and low efficiency caused by manual monitoring when testing the performance of the cloud host to be tested in the related art, and can effectively improve the test efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of testing technology, and in particular to a testing method and device, an electronic device and a storage medium. Background Art

[0002] Data backup is the basis of disaster recovery. It refers to the process of copying all or part of the data set in the system from the hard disk or array of the application host to other storage media to prevent data loss due to system operation errors or system failures. Data restoration refers to the process of restoring the previously made target backup data to the hard disk or array of the host.

[0003] The time taken for data backup and data restoration is one of the main criteria for customers to compare and select data backup products. Currently, the verification method for data backup and data restoration requires logging into the virtual machine, first writing random data to the data disk mounted to the virtual machine, and then manually performing the backup operation. The backup time also requires manual observation of the backup status to give a rough time.

[0004] Currently, no effective solution has been provided for the technical problems in the related art that the backup operation needs to be performed manually and the time taken for the backup needs to be manually observed. Summary of the invention

[0005] In order to solve the above-mentioned technical problems that the backup operation needs to be performed manually and the time taken for the backup needs to be manually observed, the present application provides a testing method and device, an electronic device and a storage medium.

[0006] In a first aspect, an embodiment of the present application provides a testing method, comprising:

[0007] Receive test commands;

[0008] Performing a write operation in the designated storage medium according to the test command to write original data in the designated storage medium;

[0009] Performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, and recording a backup duration of the backup operation;

[0010] By performing a restore operation to restore the target backup data to the designated storage medium, the restored data located in the designated storage medium is obtained;

[0011] Performing a consistency check on the restored data and the original data to obtain a check result;

[0012] The cloud host performance of the cloud host to be tested is determined according to the verification result and the backup duration.

[0013] Optionally, as in the aforementioned method, the test command carries the virtual machine IP, virtual machine ID and virtual machine login password;

[0014] Writing the original data to the designated storage medium according to the test command includes:

[0015] According to the virtual machine IP, query the target virtual machine in the cloud host to be tested;

[0016] Perform a login operation on the target virtual machine using the virtual machine ID and the virtual machine login password;

[0017] The data disk mounted on the target virtual machine is used as a designated storage medium, and original data is written into the designated storage medium.

[0018] Optionally, as in the aforementioned method, the test command carries a target data volume, and the writing of the original data into the designated storage medium includes:

[0019] Calling a preset data generation tool to generate the original data of the target data volume;

[0020] The original data is written into a designated storage medium.

[0021] Optionally, as in the aforementioned method, the test command also carries a target number of backup times, and the method further includes:

[0022] After performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, recording a current number of backups;

[0023] If the current number of backups does not reach the target number of backups, the process returns to executing the process of writing the original data to the designated storage medium according to the test command until the current number of backups reaches the target number of backups.

[0024] Optionally, as in the aforementioned method, after performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, the method further includes:

[0025] Determine a target backup ID corresponding to the target backup data;

[0026] Before performing the restore operation of restoring the target backup data to the designated storage medium to obtain the restored data in the designated storage medium, the method further includes:

[0027] Get the backup ID to be restored;

[0028] When the ID of the backup to be restored is the target backup ID, the target backup data is obtained by selecting from all the backup data according to the ID of the backup to be restored.

[0029] Optionally, as in the aforementioned method, the restoring operation of restoring the target backup data to the designated storage medium includes:

[0030] Determine the restoration start time and the restoration end time of the restoration operation;

[0031] Determine the restoration duration according to the restoration start time and the restoration end time;

[0032] The determining the cloud host performance of the cloud host to be tested according to the verification result and the backup duration includes:

[0033] The cloud host performance of the cloud host to be tested is determined according to the verification result, the backup duration, and the restoration duration.

[0034] Optionally, as in the aforementioned method, after writing the original data to the designated storage medium according to the test command, the method further includes:

[0035] Performing a hash operation on the original data to obtain a first hash value of the original data;

[0036] The performing consistency check on the restored data and the original data to obtain a check result includes:

[0037] Calculate and obtain a second hash value of the restored data;

[0038] Comparing the first Hash value with the second Hash value, and generating the verification result indicating that the restored data is consistent with the original data when the first Hash value is found to be consistent with the second Hash value;

[0039] When the first Hash value is compared to the second Hash value and it is found that the first Hash value is inconsistent with the second Hash value, the verification result indicating that the restored data is inconsistent with the original data is generated.

[0040] Optionally, as in the aforementioned method, after performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, the method further includes:

[0041] Clean up the original data in the designated storage medium.

[0042] In a second aspect, an embodiment of the present application provides a testing device, including:

[0043] A receiving module, used for receiving a test command;

[0044] A writing module, used to perform a writing operation in a designated storage medium according to the test command, so as to write original data in the designated storage medium;

[0045] A backup module, used to perform a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, and record the backup duration of the backup operation;

[0046] A restoration module, configured to obtain restored data in the designated storage medium by performing a restoration operation on the target backup data to restore the target backup data to the designated storage medium;

[0047] A verification module, used to perform consistency verification on the restored data and the original data to obtain a verification result;

[0048] The performance determination module is used to determine the cloud host performance of the cloud host to be tested according to the verification result and the backup duration.

[0049] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0050] The memory is used to store computer programs;

[0051] The processor is used to implement any of the methods described above when executing the computer program.

[0052] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the storage medium includes a stored program, wherein the program executes a method as described in any of the preceding items when executed.

[0053] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:

[0054] The method provided in the embodiment of the present application can automatically perform a backup operation on the original data in the specified storage medium, and can obtain the backup duration of the backup operation. Furthermore, it can also automatically perform a consistency check on the original data and the restored data to obtain a check result; ultimately, the cloud host performance of the cloud host to be tested can be automatically determined based on the backup duration and the check result; the problem of a large amount of manpower consumption and low efficiency caused by manual monitoring when testing the performance of the cloud host to be tested in the related technology can be effectively avoided, and the test efficiency can be effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0056] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0057] Figure 1 A flow chart of a testing method provided in an embodiment of the present application;

[0058] Figure 2 A flow chart of a testing method provided in another embodiment of the present application;

[0059] Figure 3 A flow chart of a test method provided for an application example of this application;

[0060] Figure 4 A block diagram of a testing device provided in an embodiment of the present application;

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

[0062] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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 making creative work are within the scope of protection of this application.

[0063] According to one aspect of an embodiment of the present application, a test method is provided. Optionally, in this embodiment, the above test method can be applied to a hardware environment consisting of a terminal and a server. The server is connected to the terminal via a network, and can be used to provide services (such as data backup services, data restoration services, etc.) for the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server.

[0064] The above network may include but is not limited to at least one of the following: wired network, wireless network. The above wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the above wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal may not be limited to a PC, a mobile phone, a tablet computer, etc.

[0065] The test method of the embodiment of the present application can be executed by a server, a terminal, or a server and a terminal together. The terminal can also execute the test method of the embodiment of the present application by a client installed thereon.

[0066] Taking the test method in this embodiment executed by the server as an example, Figure 1 A testing method provided in an embodiment of the present application comprises the following steps:

[0067] Step S101, receiving a test command;

[0068] The test method in this embodiment can be applied to scenarios where the host performance of the cloud host to be tested needs to be determined, such as: scenarios where data backup performance needs to be determined, scenarios where data restoration performance needs to be determined, scenarios where data backup performance and data restoration performance need to be determined simultaneously, etc. It can also be a scenario where other performance of the cloud host needs to be determined. In the embodiment of this application, the above test method is described by taking the simultaneous determination of data backup performance and data restoration performance as an example. For scenarios of other types of host performance tests, the above test method is also applicable if there is no contradiction.

[0069] Taking the scenario of simultaneously determining data backup performance and data restoration performance by brushing as an example, the performance of the cloud host to be tested for data backup and data restoration is determined by restoring the backed-up data.

[0070] Before testing the cloud host to be tested, you need to obtain the test command for testing the cloud host to be tested.

[0071] The test command may be a command manually generated or uploaded, so that the script implementing this embodiment can trigger the execution of subsequent steps according to the test command.

[0072] Step S102: performing a write operation in a designated storage medium according to a test command to write original data in the designated storage medium.

[0073] After obtaining the test command, a write operation of writing the original data to the specified storage medium can be triggered.

[0074] The designated storage medium may be a data disk for writing original data, or a partition of a data disk.

[0075] The original data may be data written into a specified storage medium according to a test command, and the data volume of the original data may be the data volume specified in the test command, or may be data written according to a preset data volume as long as the test command is received.

[0076] For example, when the original data is data written according to the data amount specified in the test command, the information used to specify the data amount in the test command can be obtained, and then the original data of the corresponding data amount can be written according to the information; when the original data is data written according to the preset data amount as soon as the test command is received, the writing of the preset data amount of the original data to the specified storage medium can be triggered according to the obtained test command.

[0077] Step S103, performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, and recording the backup duration of the backup operation.

[0078] After the original data is written in the designated storage medium, a backup operation of backing up the original data to the cloud host to be tested can be performed.

[0079] The backup operation may be to back up the original data to the cloud host to be tested, so as to create target backup data corresponding to the original data in the cloud host to be tested.

[0080] The cloud host to be tested may be a cloud host capable of performing data backup and data restoration operations.

[0081] The target backup data may be data stored in the cloud host to be tested after being backed up according to the original data. If no abnormality occurs in the backup operation, the target backup data is consistent with the original data.

[0082] During the execution of the backup operation, the execution process of the backup operation can be timed to obtain the backup duration.

[0083] For example, after obtaining the original data, a backup operation can be triggered. The backup operation can be to back up the original data to any storage location of the cloud host to be tested. During the backup operation, the backup start time and backup end time of the backup operation are recorded, and the backup duration is calculated.

[0084] Step S104, by performing a restore operation to restore the target backup data to the designated storage medium, the restored data in the designated storage medium is obtained.

[0085] After backing up the original data to the cloud host to be tested and obtaining the target backup data, the target backup data can be used to restore the designated storage medium, so as to obtain the restored data by writing the target backup data to the designated storage medium, thereby achieving the purpose of restoring the original data to the designated storage medium.

[0086] Before performing the restore operation, you can clean up the existing data in the specified storage medium. When the remaining space in the specified storage medium is much larger than the target backup data, you can directly perform the restore operation without cleaning up.

[0087] Step S105, performing consistency check on the restored data and the original data to obtain a check result.

[0088] After obtaining the restored data, if there are no abnormalities during the backup operation and the restore operation, the restored data and the original data should be consistent. Conversely, if there are abnormalities during the backup operation and the restore operation, the restored data and the original data may be inconsistent. Therefore, in this case, it means that the cloud host under test cannot achieve the most basic purpose of maintaining data consistency.

[0089] The consistency check may be a verification process of comparing the restored data with the original data to determine whether the restored data is consistent with the original data; and after the consistency check, a verification result indicating whether the restored data is consistent with the original data may be obtained.

[0090] For example, the verification result can be obtained by comparing the data consistency of each byte in the restored data and the original data, or by comparing the consistency between the information encoded by the restored data according to the preset encoding method and the information encoded by the original data according to the preset encoding method.

[0091] Step S106, determining the cloud host performance of the cloud host to be tested according to the verification result and the backup duration.

[0092] After obtaining the verification result and the backup time, the cloud host performance of the cloud host to be tested can be determined based on the verification result and the backup time.

[0093] The cloud host performance may be an indicator for indicating the performance of the cloud host in performing data backup and data restoration.

[0094] Since there are multiple indicators used to calculate the performance of the cloud host, the performance of the cloud host can be determined by weighting each indicator.

[0095] For example, the weight corresponding to the verification result (for example, n1) and the weight corresponding to the backup duration (for example, n2) can be determined in advance. When the verification result is consistent, the verification result is 1, otherwise it is 0; and in order to more accurately evaluate the backup performance, the backup volume per unit time (for example, 18M / s) can be calculated based on the backup duration and the amount of original data, and then the score of the backup volume per unit time is determined based on the scores corresponding to different preset backup volumes per unit time (for example, less than 10M / s is 0.5, greater than 10M / s and less than 20M / s is 0.6, ..., greater than 100M / s is 1). When the verification result is consistent, the cloud host performance score can be calculated to be n1+0.6n2.

[0096] Through the method in this embodiment, the backup operation can be automatically performed on the original data in the specified storage medium, and the backup duration of the backup operation can be obtained. Furthermore, the consistency check can be automatically performed on the original data and the restored data to obtain the check result; finally, the cloud host performance of the cloud host to be tested can be automatically determined based on the backup duration and the check result; the problem of large amount of manpower consumption and low efficiency caused by manual monitoring when testing the performance of the cloud host to be tested in the related technology can be effectively avoided, and the test efficiency can be effectively improved.

[0097] As an optional implementation, as in the aforementioned method, the test command carries the virtual machine IP, virtual machine ID, and virtual machine login password;

[0098] The step S102 writes the original data to the specified storage medium according to the test command, including the following steps:

[0099] Step S201, querying the target virtual machine in the cloud host to be tested according to the virtual machine IP;

[0100] Step S202: Log in to the target virtual machine using the virtual machine ID and the virtual machine login password.

[0101] When testing by mounting on a virtual machine, the virtual machine IP, virtual machine ID and virtual machine login password can be written in the process of generating the test command; the target virtual machine can be queried in the cloud host to be tested through the virtual machine IP (i.e., the address of the virtual machine); and the target virtual machine can be logged in through the virtual machine ID and virtual machine login password. This makes it easier to perform data backup and data restoration operations through the target virtual machine later.

[0102] The target virtual machine can be a virtual machine set up in a cloud host or a virtual machine set up on a local end.

[0103] For example, you can use the paramiko module in Python to ssh into the target virtual machine based on the virtual machine IP, virtual machine ID, and virtual machine login password.

[0104] Step S203: Use the data disk mounted on the target virtual machine as the designated storage medium, and write the original data into the designated storage medium.

[0105] After logging into the target virtual machine, the data disk mounted under the target virtual machine can be determined, and the data disk is used as the specified storage medium, and the original data is written into the specified storage medium according to the test command.

[0106] In addition, different target virtual machines can be logged in at the same time to test multiple different cloud hosts to be tested, thereby achieving the purpose of parallel testing of each cloud host to be tested.

[0107] Through the method in this embodiment, a method for testing a cloud host to be tested through a virtual machine is provided, and multiple different cloud hosts to be tested can be tested separately through multiple target virtual machines, thereby achieving the purpose of parallel testing of each cloud host to be tested, so as to further improve the test efficiency.

[0108] As an optional implementation, as in the aforementioned method, the test command carries the target data volume, and the step S102 writes the original data to the specified storage medium according to the test command, including the following steps:

[0109] Step S301, calling a preset data generation tool to generate raw data of a target data volume.

[0110] Step S302: writing original data into a designated storage medium.

[0111] After obtaining the test command, the original data needs to be written into the specified storage medium to perform a backup operation based on the original data.

[0112] The target data volume is written in the process of generating the test command, so as to specify the data volume of the original data to be generated through the target data volume.

[0113] After obtaining the test command, the test command can be parsed to obtain the target data volume therein, and then the original data of the target data volume can be randomly generated through a data generation tool (for example, the fio tool), so that the original data of the target data volume can be written to the designated storage medium later. Optionally, each time a preset data volume is generated, the generated data volume is written to the designated storage medium until the complete original data is written to the designated storage medium; or, after all the original data is generated, the original data is uniformly written to the designated storage medium.

[0114] Through the method in this embodiment, the purpose of writing corresponding original data according to the target data volume can be achieved, and then data backup and data restoration tests can be performed using data of different data volumes.

[0115] like Figure 2 As shown, as an optional implementation, as in the aforementioned method, the test command also carries a target number of backup times, and the method further includes the following steps:

[0116] Step S401, after performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, the current number of backups is recorded.

[0117] For the same cloud host to be tested, multiple backup operations can be performed to obtain the corresponding backup duration of each backup operation.

[0118] The target number of backups is written during the generation of the test command, so that the target number of backups is performed on the cloud host to be tested.

[0119] In order to determine whether the target backup times have been performed, after creating the target backup data corresponding to the original data in the cloud host to be tested, the number of backup times performed so far (including the current backup operation) can be recorded.

[0120] For example, an independent variable corresponding to the number of backups may be preset (with an initial value of 1), so that the independent variable may be incremented by 1 after each backup operation, thereby achieving the purpose of counting the current number of backups.

[0121] Step S402, if the current number of backups does not reach the target number of backups, executing a first jump operation for jumping to a write operation in a designated storage medium according to a test command until the current number of backups reaches the target number of backups;

[0122] Step S403: if the current backup number reaches the target backup number, a second jump operation is executed to jump to a restore operation by restoring the target backup data to the designated storage medium to obtain the restored data in the designated storage medium.

[0123] If the current number of backups does not reach the target number of backups, it means that the backup operation needs to be performed again, that is, step S102 needs to be executed again to write the original data to the specified storage medium according to the test command, that is, new original data is written to the storage medium again according to the test command, and step S103 is performed again to perform the backup operation based on the new original data.

[0124] When the current backup times reaches the target backup times, a second jump operation may be performed to jump to step S104 to perform a restore operation to restore the target backup data to the designated storage medium to obtain the restored data in the designated storage medium.

[0125] Through the method in this embodiment, the backup operation of the target backup number can be performed according to the required number of backups, that is, the target backup number, so as to achieve the purpose of automatically performing multiple backups.

[0126] As an optional implementation, as in the aforementioned method, after performing a backup operation on the original data in the designated storage medium in step S103 to create target backup data corresponding to the original data in the cloud host to be tested, the method further includes the following steps:

[0127] Step S511, determining the target backup ID corresponding to the target backup data.

[0128] After obtaining the target backup data, in order to facilitate the later selection of the target backup data, the target backup data can be identified, that is, the target backup ID corresponding to the target backup data is obtained; and there is a unique corresponding relationship between the target backup data and the target backup ID.

[0129] The target backup ID may be generated according to the backup time of the target backup data, may be generated according to the backup order, or may be generated according to the identification information of the backed-up original data.

[0130] Optionally, after the target backup ID is generated, the index of the target backup data and the target backup ID may be correspondingly stored in a python data type dictionary.

[0131] Before obtaining the restored data in the designated storage medium by performing a restore operation to restore the target backup data to the designated storage medium, the method further includes the following steps:

[0132] Step S521, obtaining the backup ID to be restored;

[0133] Step S522: when the backup ID to be restored is the target backup ID, the target backup data is selected from all the backup data according to the backup ID to be restored.

[0134] Before performing a restore operation on a specified storage medium, data to be restored needs to be determined.

[0135] Therefore, you can first obtain the backup ID to be restored.

[0136] The backup ID to be restored may be a target backup ID of the backup data to be restored.

[0137] When the backup ID to be restored is the target backup ID, it means that the designated storage medium needs to be restored through the target backup data. Then, the target backup data can be selected from all the backup data according to the backup ID to be restored.

[0138] For example, when performing a restore operation, when the index of the backup data and the backup ID are stored correspondingly in the python data type dictionary, and the backup ID to be restored is the target backup ID, the matching backup ID corresponding to the backup ID to be restored can be queried among all backup IDs through the backup ID to be restored, and then the target index of the target backup data corresponding to the matching backup ID can be obtained, and then the target backup data can be obtained according to the target index.

[0139] By using the method of this embodiment, the backup data is identified by using the backup ID, so that the efficiency of obtaining the backup data can be effectively improved, and the efficiency of subsequent data restoration can be improved.

[0140] As an optional implementation, as in the above method, the step S104 includes the following steps by restoring the target backup data to the designated storage medium:

[0141] Step S601, determining the restoration start time and restoration end time of the restoration operation;

[0142] Step S602, determining the restoration duration according to the restoration start time and the restoration end time.

[0143] During the execution of the restore operation, the execution process of the restore operation can be timed. The restore start time is obtained by timing when the restore operation starts, and the restore end time is obtained when the restore operation ends. Finally, the restore duration can be determined by determining the time difference between the restore end time and the restore start time.

[0144] The step S106 determines the cloud host performance of the cloud host to be tested according to the verification result and the backup duration, including:

[0145] Determine the cloud host performance of the cloud host to be tested based on the verification results, backup duration, and restoration duration.

[0146] After obtaining the verification results, backup time and restore time, the backup performance of the cloud host to be tested can be determined according to the backup time, and the restore performance of the cloud host to be tested can be determined according to the restore time. Then, the cloud host performance of the cloud host to be tested can be determined according to the verification results, backup time and restore time.

[0147] For example, the weight corresponding to the verification result (for example, 0.2), the weight corresponding to the backup duration (for example, 0.4), and the weight corresponding to the restore duration (for example, 0.4) can be predetermined. When the verification result is consistent, the verification result is 1, otherwise it is 0; and in order to more accurately evaluate the backup performance, the backup volume per unit time (for example, 18M / s) can be calculated according to the backup duration and the amount of original data, and then the scores corresponding to different preset backup volumes per unit time (for example, less than 10M / s is 0.5, greater than 10M / s and less than 20M / s is 0.6, ..., greater than 100M / s) can be calculated. is 1), similarly, the backup volume per unit time (for example, 22M / s) can be calculated according to the restoration duration and the amount of target backup data, and then the score of the backup volume per unit time is determined according to the scores corresponding to different preset backup volumes per unit time (for example, less than 10M / s is 0.5, greater than 10M / s and less than 20M / s is 0.6, greater than 20M / s and less than 30M / s is 0.7, ..., greater than 100M / s is 1). When the verification result is consistent, the score for indicating the performance of the cloud host can be calculated as 0.2×0.2+0.4×0.6+0.4×0.7=0.56.

[0148] Through the method in this embodiment, the restoration time can be added on the basis of the verification result and the backup time to determine the cloud host performance of the cloud host to be tested, thereby improving the multi-dimensional evaluation of the cloud host to be tested and enhancing the comprehensiveness of the evaluation.

[0149] As an optional implementation, as in the above method, after writing the original data to the designated storage medium according to the test command in step S102, the method further includes the following steps:

[0150] Step S711, performing a hash operation on the original data to obtain a first hash value of the original data.

[0151] After the original data is written into the designated storage medium according to the test command, the complete original data in the designated storage medium can be determined, and then a hash operation can be performed on the original data to obtain a first hash value of the original data.

[0152] Furthermore, when the original data is written to the designated storage medium through the target virtual machine, since the original data is actually written to the cache when the virtual machine is used to write the data, after obtaining the first hash value of the original data, the data disk corresponding to the designated storage medium can be unloaded so that the original data is written from the cache to the target storage medium. In addition, when the current process is needed to perform subsequent data backup operations, it is necessary to log out of the target virtual machine to perform data backup operations through the process. When another process is used to perform subsequent data backup operations, it is not necessary to log out of the target virtual machine.

[0153] For example, the MD5 value (eg, X1) of the original data may be obtained through md5sum, and X1 may be used as the first hash value.

[0154] Perform consistency check on the restored data and the original data to obtain the check results, including:

[0155] Step S721, calculating and obtaining a second hash value of the restored data;

[0156] Step S722, comparing the first hash value with the second hash value, and generating a verification result indicating that the restored data is consistent with the original data when the first hash value and the second hash value are found to be consistent;

[0157] Step S723: when the first hash value is found to be inconsistent with the second hash value, a verification result indicating that the restored data is inconsistent with the original data is generated.

[0158] After the restored data is obtained, a hash calculation can be performed on the restored data to obtain a second hash value of the restored data. Moreover, the calculation method of performing a hash calculation on the restored data is consistent with the calculation method of performing a hash calculation on the original data.

[0159] After obtaining the second hash value, the first hash value can be compared with the second hash value. When the comparison shows that the first hash value and the second hash value are consistent, a verification result is generated to indicate that the restored data is consistent with the original data; when the comparison shows that the first hash value and the second hash value are inconsistent, a verification result is generated to indicate that the restored data is inconsistent with the original data.

[0160] For example, the MD5 value (eg, X2) of the restored data may be obtained through md5sum, and X2 may be used as the second hash value.

[0161] When X2=X1, a verification result is generated to indicate that the restored data is consistent with the original data; when X2≠X1, a verification result is generated to indicate that the restored data is inconsistent with the original data.

[0162] Through the method in this embodiment, the restored data and the original data can be compared based on the comparison between the second hash value of the restored data and the first hash value of the original data, and the purpose of verifying whether the restored data is consistent with the original data can be achieved.

[0163] As an optional implementation, as in the aforementioned method, after performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, the method further includes the following steps:

[0164] Step S801, clearing the original data in the designated storage medium.

[0165] After performing a backup operation on the original data in the specified storage medium, if another backup operation or a restore operation is required on the specified storage medium, it is necessary to continue writing data to the specified storage medium; in order to avoid the remaining storage space in the specified storage medium being insufficient to store the new original data or restore data required to be written for another backup operation, the original data in the specified storage medium can be cleaned up.

[0166] Through the method in this embodiment, it can be effectively ensured that the remaining storage space of the designated storage medium is sufficient to write new data.

[0167] like Figure 3 As shown, an application example of applying the method described in the above embodiment is also provided:

[0168] P1. In the script used to test the cloud host to be tested, enter the virtual machine IP, virtual machine ID, virtual machine login password, data size date, and the number of backups required count (i.e., the target number of backups);

[0169] P2. Use the paramiko module in Python to ssh into the target virtual machine through the virtual machine IP, virtual machine ID and virtual machine login password;

[0170] P3. Use the fio tool to perform random write operations on the disk (ie, the specified storage medium) according to the data size date to obtain the original data. After completion, use md5sum to obtain the MD5 value (ie, the first hash value) of the original data.

[0171] P4. Then unmount (umount) the disk, log out and connect to the target virtual machine;

[0172] P5. Perform a backup operation on the target virtual machine, back up the original data to the target cloud host, obtain the target backup ID, store it in a python data type dictionary, and calculate the backup duration by recording the start and end backup times of the backup operation;

[0173] P6. Log in to the target virtual machine again, mount the disk to the target virtual machine according to the drive letter of the disk, and clean up the data on the disk;

[0174] P7. Determine whether the current number of backups reaches the required number of backups count, and loop the above operations according to the required number of backups count;

[0175] P8. Finally, according to the needs, select the backup ID to be restored for the restore operation, query the backup index corresponding to the backup ID to be restored in the dictionary, calculate the restoration duration by recording the start time and end time of the restoration, and obtain the MD5 value of the restored data (i.e., the second hash value), compare it with the MD5 value of the original data, verify the data consistency, and then obtain the cloud host performance of the target cloud host.

[0176] like Figure 4 As shown, according to an embodiment of another aspect of the present application, a testing device is also provided, including:

[0177] Receiving module 1, used for receiving a test command;

[0178] A writing module 2, used for performing a writing operation in a designated storage medium according to a test command, so as to write original data in the designated storage medium;

[0179] The backup module 3 is used to perform a backup operation on the original data in the specified storage medium to create target backup data corresponding to the original data in the cloud host to be tested, and record the backup duration of the backup operation;

[0180] Restoration module 4, used for obtaining restored data in the designated storage medium by performing a restore operation to restore the target backup data to the designated storage medium;

[0181] Verification module 5, used to perform consistency verification on the restored data and the original data to obtain a verification result;

[0182] The performance determination module 6 is used to determine the cloud host performance of the cloud host to be tested according to the verification result and the backup duration.

[0183] Specifically, the specific process of each module in the device of the embodiment of the present invention realizing its function can be referred to the relevant description in the method embodiment, which will not be repeated here.

[0184] According to another embodiment of the present application, there is also provided an electronic device, including: Figure 5As shown, the electronic device may include: a processor 1501 , a communication interface 1502 , a memory 1503 and a communication bus 1504 , wherein the processor 1501 , the communication interface 1502 , and the memory 1503 communicate with each other via the communication bus 1504 .

[0185] Memory 1503, used for storing computer programs;

[0186] The processor 1501 is used to implement the steps of the above method embodiment when executing the program stored in the memory 1503.

[0187] The bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0188] The communication interface is used for communication between the above electronic device and other devices.

[0189] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0190] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0191] An embodiment of the present application further provides a computer-readable storage medium, the storage medium including a stored program, wherein the method steps of the above method embodiment are executed when the program is run.

[0192] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants 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, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0193] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A testing method, characterized in that: include: Receive test commands; Performing a write operation in the designated storage medium according to the test command to write original data in the designated storage medium; Performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, and recording a backup duration of the backup operation; By performing a restore operation to restore the target backup data to the designated storage medium, the restored data located in the designated storage medium is obtained; Performing a consistency check on the restored data and the original data to obtain a check result; Determining the cloud host performance of the cloud host to be tested according to the verification result and the backup duration; In which, the test command also carries a target backup number, and the method also includes: after performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, recording the current backup number; if the current backup number does not reach the target backup number, executing a first jump operation for jumping to the write operation in the designated storage medium according to the test command until the current backup number reaches the target backup number; if the current backup number reaches the target backup number, executing a second jump operation for jumping to the restore operation by restoring the target backup data to the designated storage medium to obtain the restored data located in the designated storage medium.

2. The method according to claim 1, characterized in that: The test command carries the virtual machine IP, virtual machine ID and virtual machine login password; Writing the original data to the designated storage medium according to the test command includes: According to the virtual machine IP, query the target virtual machine in the cloud host to be tested; Perform a login operation on the target virtual machine using the virtual machine ID and the virtual machine login password; The data disk mounted on the target virtual machine is used as a designated storage medium, and original data is written into the designated storage medium.

3. The method according to claim 1, characterized in that The test command carries a target data amount, and the writing operation is performed in the designated storage medium according to the test command to write the original data in the designated storage medium, including: Calling a preset data generation tool to generate the original data of the target data volume; The original data is written into a designated storage medium.

4. The method according to claim 1, characterized in that: After performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, the method further includes: Determine a target backup ID corresponding to the target backup data; Before obtaining the restored data in the designated storage medium by performing the restore operation of restoring the target backup data to the designated storage medium, the method further includes: Get the backup ID to be restored; When the backup ID to be restored is the target backup ID, the target backup data is obtained by selecting from all backup data according to the backup ID to be restored.

5. The method according to claim 1, characterized in that The restoring operation of restoring the target backup data to the designated storage medium includes: Determine the restoration start time and the restoration end time of the restoration operation; Determine the restoration duration according to the restoration start time and the restoration end time; The determining the cloud host performance of the cloud host to be tested according to the verification result and the backup duration includes: The cloud host performance of the cloud host to be tested is determined according to the verification result, the backup duration, and the restoration duration.

6. The method according to claim 1, characterized in that After writing the original data to the designated storage medium according to the test command, the method further includes: Performing a hash operation on the original data to obtain a first hash value of the original data; The performing consistency check on the restored data and the original data to obtain a check result includes: Calculate and obtain a second hash value of the restored data; Comparing the first Hash value with the second Hash value, and generating the verification result indicating that the restored data is consistent with the original data when the first Hash value is found to be consistent with the second Hash value; When the first Hash value is compared to the second Hash value and it is found that the first Hash value is inconsistent with the second Hash value, the verification result indicating that the restored data is inconsistent with the original data is generated.

7. The method according to claim 1, characterized in that After performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, the method further includes: Clean up the original data in the designated storage medium.

8. A testing device, characterized in that: include: A receiving module, used for receiving a test command; A writing module, used to perform a writing operation in a designated storage medium according to the test command, so as to write original data in the designated storage medium; A backup module, used to perform a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, and record the backup duration of the backup operation; A restoration module, configured to obtain restored data in the designated storage medium by performing a restoration operation on the target backup data to restore the target backup data to the designated storage medium; A verification module, used to perform consistency verification on the restored data and the original data to obtain a verification result; A performance determination module, used to determine the cloud host performance of the cloud host to be tested according to the verification result and the backup duration; In which, the test command also carries a target backup number, and the device also includes a module for performing the following operations: after performing a backup operation on the original data in the designated storage medium to create target backup data corresponding to the original data in the cloud host to be tested, recording the current backup number; if the current backup number does not reach the target backup number, executing a first jump operation for jumping to the write operation in the designated storage medium according to the test command until the current backup number reaches the target backup number; if the current backup number reaches the target backup number, executing a second jump operation for jumping to the restore operation by restoring the target backup data to the designated storage medium to obtain the restored data located in the designated storage medium.

9. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 7 when executed.