Spare machine test execution method and device, storage medium and electronic equipment
By using the target redundant copy of the production environment in the distributed database to create a consistent test sub-environment, execute the test cases and roll back the data, the problem of the lack of standby test solutions for the distributed database is solved, and the accuracy and efficiency of the test are improved. .
Patent Information
- Application Number
- CN202411072233.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-10-18
AI Technical Summary
The distributed database lacks a backup test plan, resulting in inconsistency between the test environment and the production environment, affecting the accuracy and efficiency of the test.
Create a test sub-environment consistent with the production environment architecture by using the target redundant copy of the production environment, execute test cases in the test sub-environment, record the results, roll back the data changes to the initial state and synchronize them to the production environment.
It ensures the accuracy and effectiveness of the test environment, improves the speed and security of the test process, and achieves lossless rollback of test data and efficient utilization of resources.
Smart Images

Figure CN118796708A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a method, device, storage medium and electronic device for executing a standby machine test. Background Art
[0002] The core function of standby testing is to conduct an in-depth and comprehensive review and evaluation of the trading system. This process uses real environments, data and applications for actual combat simulation, aiming to timely verify the system and reveal potential problems to prevent unnecessary troubles and economic losses on trading days. The key to standby testing lies in its prevention mechanism. It verifies the stability, reliability and performance of the system by replicating real trading scenarios, thereby ensuring the smooth and safe actual trading process. In standby testing, the role of the database is crucial. As the core repository of trading data and test data, the database stores all transaction records, customer information and market dynamics, providing detailed data support for testing. In the simulation exercise, the database needs to use production data to simulate high-load read and write requests to get close to the real trading pressure scenario. Through a thorough testing process, the financial industry can continuously improve the robustness and performance of its systems, thereby providing better services to the market and investors. Given the particularity of standby testing, the test environment must be highly consistent with the production environment, covering all aspects such as applications, data and database configuration. However, distributed databases previously lacked a backup testing solution and were generally verified through data backup and recovery or by exporting production data to a test environment. Summary of the invention
[0003] The present application provides a standby machine test execution method, device, storage medium and electronic device to solve the technical problem of lack of standby machine test solution for distributed database.
[0004] In a first aspect, the present application provides a method for executing standby machine tests, comprising: using a target redundant copy of a production environment to create a test sub-environment that is consistent with the architecture of the above-mentioned production environment; executing all test cases in the above-mentioned test sub-environment, and recording the test results of each of the above-mentioned test cases; rolling back the data changes of the above-mentioned test sub-environment to restore the above-mentioned test sub-environment to its initial state; and synchronizing the data of the above-mentioned test sub-environment to the above-mentioned production environment.
[0005] In the second aspect, the present application provides a standby machine test execution device, including: a creation module, used to use the target redundant copy of the production environment to create a test sub-environment consistent with the architecture of the above-mentioned production environment; an execution module, used to execute all test cases in the above-mentioned test sub-environment, and record the test results of each of the above-mentioned test cases; a rollback module, used to roll back the data changes of the above-mentioned test sub-environment to restore the above-mentioned test sub-environment to its initial state; a synchronization module, used to synchronize the data of the above-mentioned test sub-environment to the above-mentioned production environment.
[0006] As an optional example, the creation module includes: a determination unit, for determining the target redundant copy from all redundant copies of the production environment according to the test requirements of the production environment; a creation unit, for creating the test sub-environment using the target redundant copy; a configuration unit, for configuring management nodes, global transaction nodes, computing nodes and data nodes in the test sub-environment according to the architecture of the production environment, so that the test sub-environment is consistent with the production environment architecture; a synchronization unit, for synchronizing the data of the target redundant copy to the management nodes, global transaction nodes, computing nodes and data nodes in the test sub-environment when it is determined that there are no active transactions in the production environment.
[0007] As an optional example, the above-mentioned determination unit includes: a first determination sub-unit, used to determine a target redundant copy group from all redundant copies of the above-mentioned production environment, wherein the global transaction state of each redundant copy in the above-mentioned target redundant copy group is consistent with the global transaction state of the primary copy of the above-mentioned production environment; a first determination sub-unit, used to determine the synchronization delay of each redundant copy in the above-mentioned target redundant copy group; and a third determination sub-unit, used to determine the redundant copy with the smallest synchronization delay in the above-mentioned target redundant copy group as the above-mentioned target redundant copy.
[0008] As an optional example, the above-mentioned configuration unit includes: a setting sub-unit, which is used for the above-mentioned test sub-environment not to include the data master node and the global transaction master node of the above-mentioned production environment, and to set the management node, global transaction node, computing node and data node in the above-mentioned test sub-environment in the same computer room.
[0009] As an optional example, the above-mentioned execution module includes: a first execution unit, used to define all functional modules that need to be tested and the corresponding functional test cases, and execute all the above-mentioned functional test cases in the above-mentioned test sub-environment, and record the functional test results of each of the above-mentioned functional test cases; a second execution unit, used to define performance test cases under different scenarios, and execute all the above-mentioned performance test cases in the above-mentioned test sub-environment, and record the performance test results of each of the above-mentioned performance test cases; a third execution unit, used to define stress test cases under high concurrency scenarios, and execute all the above-mentioned stress test cases in the above-mentioned test sub-environment, and record the stress test results of each of the above-mentioned stress test cases.
[0010] As an optional example, the rollback module includes: a rollback unit, used to roll back the data changes of the test sub-environment to an initial state based on the backup data of the test sub-environment, wherein before executing all test cases in the test sub-environment, the data of the test sub-environment is backed up to obtain the backup data.
[0011] As an optional example, the apparatus further includes: a processing module, configured to use the test sub-environment as a backup machine or a read-only copy of the production environment after synchronizing the data of the test sub-environment to the production environment.
[0012] In a third aspect, the present application provides a storage medium storing a computer program, wherein the computer program executes the above-mentioned standby machine test execution method when executed by a processor.
[0013] In a fourth aspect, the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the standby machine test execution method through the computer program.
[0014] In an embodiment of the present application, a method is adopted in which a target redundant copy of a production environment is used to create a test sub-environment consistent with the architecture of the above-mentioned production environment; all test cases are executed in the above-mentioned test sub-environment, and the test results of each of the above-mentioned test cases are recorded; the data changes of the above-mentioned test sub-environment are rolled back to restore the above-mentioned test sub-environment to its initial state; and the data of the above-mentioned test sub-environment is synchronized to the above-mentioned production environment. Since in the above-mentioned method, a test sub-environment is constructed using a redundant copy of the production environment, the architecture of the test sub-environment is consistent with the production environment, and a test data rollback mechanism is adopted to ensure that after the test is completed, the data in the test sub-environment can be losslessly rolled back to the state before the test started. Finally, after the test is completed, the verified test sub-environment can be seamlessly resynchronized to the production environment, thereby achieving the purpose of ensuring the accuracy and effectiveness of the standby machine test and improving the speed and security of the test process, thereby solving the technical problem of the lack of standby machine testing solutions for distributed databases. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0016] In order to more clearly illustrate the embodiments of the present application 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.
[0017] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0018] Figure 1 is a flowchart of an optional standby machine test execution method according to an embodiment of the present application;
[0019] Figure 2 is a structural schematic diagram of an optional standby machine test execution device according to an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0021] 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.
[0022] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0023] According to a first aspect of an embodiment of the present application, a standby machine test execution method is provided, optionally, as follows: Figure 1 As shown, the above method includes:
[0024] S102, using the target redundant copy of the production environment to create a test sub-environment that is consistent with the architecture of the production environment;
[0025] S104, executing all test cases in the test sub-environment and recording the test result of each test case;
[0026] S106, rolling back the data changes of the test sub-environment to restore the test sub-environment to an initial state;
[0027] S108, synchronizing the data of the test sub-environment to the production environment.
[0028] Optionally, in this embodiment, the distributed database is generally composed of four categories: management node, global transaction management node, computing node, and data node. In the actual production environment, it generally contains multiple redundant components, such as three copies in a single computer room, and five copies in two locations, three centers, and the like. This embodiment provides real data support for the standby machine test by building a test environment through various redundant copies, which not only ensures the accuracy and effectiveness of the standby machine test, but also improves the speed and security of the test process. According to the data synchronization mechanism, the distributed database needs to select the most suitable copy from the redundant copies of the production environment to build a test sub-environment, which not only ensures the independence of the test environment, but also maximizes the use of existing resources. In the process of building the test sub-environment, it is necessary to make consistency judgments on the data of each shard to ensure that the consistency of the distributed data is met. After the test is completed, a reverse statement is generated through the database transaction log to roll back the test data to ensure the integrity and efficiency of the data rollback.
[0029] Optionally, in this embodiment, first, using the redundant copies in the production environment, including management nodes, global transaction nodes, computing nodes, and data nodes, a test sub-environment is created that is consistent with the production environment architecture but less, and the test sub-environment can truly reflect the actual operation of the production environment. The test sub-environment completely replicates all components and configurations of the production environment, including database structure, application version, network settings, etc., and ensuring that the architecture is consistent is to ensure the reliability and relevance of the test results. Then, in the constructed test sub-environment, all planned test cases are executed, and these test cases may include functional tests, performance tests, security tests, etc. The purpose of the test is to verify the performance of the system under various circumstances. After each test case is executed, its test results are recorded. The test results may include pass, fail, performance indicators, etc. These records are used to analyze the performance of the system and provide data support for subsequent repairs and optimizations. After all tests are completed, the data changes in the test sub-environment are rolled back. The purpose of the rollback is to restore the test sub-environment to the initial state, that is, the state before the test is started, which ensures the cleanliness and reusability of the test environment. Finally, the data in the test sub-environment is synchronized to the production environment. This step is to apply the tested and verified updates and fixes to the production environment to improve the actual operating status of the system.
[0030] Optionally, in this embodiment, redundant copies existing in the distributed database, including management nodes, global transaction management nodes, computing nodes, and data nodes, are used to directly build a test sub-environment without the need for additional construction or data migration, thereby achieving efficient use of resources. By ensuring that the data and architecture of the test sub-environment are synchronized with the production environment, a high degree of consistency between the test environment and the production environment is achieved, greatly improving the authenticity and effectiveness of the test. A test data rollback mechanism is designed to ensure that after the test is completed, the data in the test sub-environment can be losslessly rolled back to the state before the test began, which not only ensures the integrity of the test, but also avoids the potential impact of the test data on the production environment. The entire process is isolated from the production environment and has no impact on the business continuity and data consistency of the production environment.
[0031] As an optional example, creating a test sub-environment that is consistent with the production environment's architecture using a target redundant copy of the production environment includes:
[0032] According to the test requirements of the production environment, determine the target redundant copy from all redundant copies of the production environment;
[0033] Create a test sub-environment using redundant copies of the target;
[0034] According to the architecture of the production environment, configure management nodes, global transaction nodes, computing nodes, and data nodes in the test sub-environment to make the test sub-environment consistent with the production environment architecture;
[0035] When it is determined that there are no active transactions in the production environment, the data of the target redundant copy is synchronized to the management node, global transaction node, computing node, and data node in the test sub-environment.
[0036] Optionally, in this embodiment, first, the specific requirements of the test need to be clarified. These requirements may include different types of tests such as functional testing, performance testing, and security testing. Based on these requirements, it can be determined which redundant copy is most suitable for use as the basis for the test. The production environment usually has multiple redundant copies to ensure high availability and fault tolerance of the data. According to the test requirements, a redundant copy that is closest to the current production environment state and most suitable for testing is selected. This copy is called the target redundant copy. After selecting the target redundant copy, this copy is used to create a test sub-environment, including copying all data, configurations, and applications of the copy to ensure that the test sub-environment is consistent with the production environment in terms of data and architecture. According to the architecture of the production environment, management nodes, global transaction nodes, computing nodes, and data nodes are configured in the test sub-environment to make the test sub-environment consistent with the production environment architecture. Before synchronizing data to the test sub-environment, ensure that there are no active transactions in the production environment, which can be done by temporarily suspending new transaction processing or during low-load periods to avoid data inconsistencies and conflicts. Synchronize the data in the target redundant replica to the management nodes, global transaction nodes, compute nodes, and data nodes in the test sub-environment, including copying and applying all necessary data, changes, and configurations to ensure that the test sub-environment fully reflects the status of the production environment.
[0037] As an optional example, according to the test requirements of the production environment, determining the target redundant copy from all redundant copies of the production environment includes:
[0038] Determine a target redundant copy group from all redundant copies of the production environment, wherein the global transaction state of each redundant copy in the target redundant copy group is consistent with the global transaction state of the primary copy of the production environment;
[0039] Determining a synchronization delay of each redundant replica in the target redundant replica group;
[0040] A redundant replica with the smallest synchronization delay in the target redundant replica group is determined as the target redundant replica.
[0041] Optionally, in this embodiment, starting from all redundant replicas in the production environment, the global transaction status of each replica is checked. The global transaction status includes the execution status of the transaction and the data consistency. There is a master replica in the production environment, and the global transaction status of the replica is the benchmark of the system. Redundant replicas whose global transaction status is consistent with the master replica are selected to form a target redundant replica group. Synchronization delay refers to the data update delay time between a redundant replica and the master replica. That is, the time difference between the redundant replica and the latest data change of the master replica. For each replica in the target redundant replica group, their synchronization delay is measured by comparing the timestamps of the latest transaction logs of the replica and the master replica. A smaller synchronization delay means that the replica can reflect the latest status of the master replica more promptly. In the target redundant replica group, the replica with the smallest synchronization delay is selected as the target redundant replica. This replica will be used to create a test sub-environment because it is closest to the status of the master replica in the production environment, ensuring the accuracy and consistency of the test environment.
[0042] As an optional example, the test sub-environment does not include the data master node and the global transaction master node of the production environment. The management node, the global transaction node, the computing node, and the data node are configured in the test sub-environment according to the architecture of the production environment so that the test sub-environment is consistent with the architecture of the production environment, including:
[0043] Set up the management node, global transaction node, computing node, and data node in the test sub-environment in the same computer room.
[0044] Optionally, in this embodiment, the test sub-environment does not include the data master node and the global transaction master node of the production environment, and an error is reported if they are included. The management node, global transaction node, computing node, and data node in the test sub-environment are in the same computer room, and an error is reported if they are not.
[0045] As an optional example, executing all test cases in the test sub-environment and recording the test results of each test case include:
[0046] Define all functional modules that need to be tested and the corresponding functional test cases, execute all functional test cases in the test sub-environment, and record the functional test results of each functional test case;
[0047] Define performance test cases in different scenarios, execute all performance test cases in the test sub-environment, and record the performance test results of each performance test case;
[0048] Define stress test cases under high concurrency scenarios, execute all stress test cases in the test sub-environment, and record the stress test results of each stress test case.
[0049] Optionally, in this embodiment, the required test cases are executed in the test sub-environment and various indicators during the test process are monitored and recorded, including but not limited to functional testing, performance testing, stress testing, etc., to ensure system stability and performance.
[0050] As an optional example, rolling back the data changes of the test sub-environment to restore the test sub-environment to its initial state includes:
[0051] According to the backup data of the test sub-environment, the data change of the test sub-environment is rolled back to the initial state, wherein before executing all the test cases in the test sub-environment, the data of the test sub-environment is backed up to obtain the backup data.
[0052] Optionally, in this embodiment, in order to ensure that the data changes can be rolled back to the initial state after all test cases are executed in the test sub-environment, it is necessary to back up the data of the test sub-environment before the test starts. Specifically, before the test starts, select a suitable backup method according to the database type. Common backup methods include logical backup and physical backup. Run the backup command to back up the data in the test sub-environment to a safe storage location. After the test is completed, select a suitable rollback method according to the backup method. Usually, the restore command corresponding to the backup method is used, and then the backup file is used to restore the data of the test sub-environment to the state at the time of backup. Finally, check the integrity and consistency of the data after recovery to ensure that the data state is consistent with that at the time of backup.
[0053] As an optional example, after synchronizing the data of the test sub-environment to the production environment, the method further includes:
[0054] Use the test subenvironment as a standby or read-only copy of the production environment.
[0055] Optionally, in this embodiment, the tested test sub-environment that has been rolled back to the initial state is resynchronized to the production environment and continues to be used as a standby machine or a read-only copy.
[0056] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0057] According to another aspect of the embodiment of the present application, a standby machine test execution device is also provided, such as Figure 2 As shown, including:
[0058] A creation module 202, configured to create a test sub-environment consistent with the architecture of the production environment using a target redundant copy of the production environment;
[0059] An execution module 204 is used to execute all test cases in the test sub-environment and record the test results of each test case;
[0060] The rollback module 206 is used to roll back the data changes of the test sub-environment to restore the test sub-environment to the initial state;
[0061] The synchronization module 208 is used to synchronize the data of the test sub-environment to the production environment.
[0062] Optionally, in this embodiment, the distributed database is generally composed of four categories: management node, global transaction management node, computing node, and data node. In the actual production environment, it generally contains multiple redundant components, such as three copies in a single computer room, and five copies in two locations, three centers, and the like. This embodiment provides real data support for the standby machine test by building a test environment through various redundant copies, which not only ensures the accuracy and effectiveness of the standby machine test, but also improves the speed and security of the test process. According to the data synchronization mechanism, the distributed database needs to select the most suitable copy from the redundant copies of the production environment to build a test sub-environment, which not only ensures the independence of the test environment, but also maximizes the use of existing resources. In the process of building the test sub-environment, it is necessary to make consistency judgments on the data of each shard to ensure that the consistency of the distributed data is met. After the test is completed, a reverse statement is generated through the database transaction log to roll back the test data to ensure the integrity and efficiency of the data rollback.
[0063] Optionally, in this embodiment, first, using the redundant copies in the production environment, including management nodes, global transaction nodes, computing nodes, and data nodes, a test sub-environment is created that is consistent with the production environment architecture but less, and the test sub-environment can truly reflect the actual operation of the production environment. The test sub-environment completely replicates all components and configurations of the production environment, including database structure, application version, network settings, etc., and ensuring that the architecture is consistent is to ensure the reliability and relevance of the test results. Then, in the constructed test sub-environment, all planned test cases are executed, and these test cases may include functional tests, performance tests, security tests, etc. The purpose of the test is to verify the performance of the system under various circumstances. After each test case is executed, its test results are recorded. The test results may include pass, fail, performance indicators, etc. These records are used to analyze the performance of the system and provide data support for subsequent repairs and optimizations. After all tests are completed, the data changes in the test sub-environment are rolled back. The purpose of the rollback is to restore the test sub-environment to the initial state, that is, the state before the test is started, which ensures the cleanliness and reusability of the test environment. Finally, the data in the test sub-environment is synchronized to the production environment. This step is to apply the tested and verified updates and fixes to the production environment to improve the actual operating status of the system.
[0064] Optionally, in this embodiment, redundant copies existing in the distributed database, including management nodes, global transaction management nodes, computing nodes, and data nodes, are used to directly build a test sub-environment without the need for additional construction or data migration, thereby achieving efficient use of resources. By ensuring that the data and architecture of the test sub-environment are synchronized with the production environment, a high degree of consistency between the test environment and the production environment is achieved, greatly improving the authenticity and effectiveness of the test. A test data rollback mechanism is designed to ensure that after the test is completed, the data in the test sub-environment can be losslessly rolled back to the state before the test began, which not only ensures the integrity of the test, but also avoids the potential impact of the test data on the production environment. The entire process is isolated from the production environment and has no impact on the business continuity and data consistency of the production environment.
[0065] As an optional example, create a module including:
[0066] A determination unit, used to determine a target redundant copy from all redundant copies of the production environment according to a test requirement of the production environment;
[0067] A creation unit for creating a test sub-environment using a target redundant copy;
[0068] A configuration unit, used to configure management nodes, global transaction nodes, computing nodes, and data nodes in the test sub-environment according to the architecture of the production environment, so that the test sub-environment is consistent with the architecture of the production environment;
[0069] The synchronization unit is used to synchronize the data of the target redundant copy to the management node, global transaction node, computing node and data node in the test sub-environment when it is determined that there is no active transaction in the production environment.
[0070] Optionally, in this embodiment, first, the specific requirements of the test need to be clarified. These requirements may include different types of tests such as functional testing, performance testing, and security testing. Based on these requirements, it can be determined which redundant copy is most suitable for use as the basis for the test. The production environment usually has multiple redundant copies to ensure high availability and fault tolerance of the data. According to the test requirements, a redundant copy that is closest to the current production environment state and most suitable for testing is selected. This copy is called the target redundant copy. After selecting the target redundant copy, this copy is used to create a test sub-environment, including copying all data, configurations, and applications of the copy to ensure that the test sub-environment is consistent with the production environment in terms of data and architecture. According to the architecture of the production environment, management nodes, global transaction nodes, computing nodes, and data nodes are configured in the test sub-environment to make the test sub-environment consistent with the production environment architecture. Before synchronizing data to the test sub-environment, ensure that there are no active transactions in the production environment, which can be done by temporarily suspending new transaction processing or during low-load periods to avoid data inconsistencies and conflicts. Synchronize the data in the target redundant replica to the management nodes, global transaction nodes, compute nodes, and data nodes in the test sub-environment, including copying and applying all necessary data, changes, and configurations to ensure that the test sub-environment fully reflects the status of the production environment.
[0071] As an optional example, the determining unit includes:
[0072] A first determination subunit is used to determine a target redundant copy group from all redundant copies of the production environment, wherein the global transaction state of each redundant copy in the target redundant copy group is consistent with the global transaction state of the primary copy of the production environment;
[0073] A first determination subunit, configured to determine a synchronization delay of each redundant copy in a target redundant copy group;
[0074] The third determining subunit is used to determine the redundant copy with the smallest synchronization delay in the target redundant copy group as the target redundant copy.
[0075] Optionally, in this embodiment, starting from all redundant replicas in the production environment, the global transaction status of each replica is checked. The global transaction status includes the execution status of the transaction and the data consistency. There is a master replica in the production environment, and the global transaction status of the replica is the benchmark of the system. Redundant replicas whose global transaction status is consistent with the master replica are selected to form a target redundant replica group. Synchronization delay refers to the data update delay time between a redundant replica and the master replica. That is, the time difference between the redundant replica and the latest data change of the master replica. For each replica in the target redundant replica group, their synchronization delay is measured by comparing the timestamps of the latest transaction logs of the replica and the master replica. A smaller synchronization delay means that the replica can reflect the latest status of the master replica more promptly. In the target redundant replica group, the replica with the smallest synchronization delay is selected as the target redundant replica. This replica will be used to create a test sub-environment because it is closest to the status of the master replica in the production environment, ensuring the accuracy and consistency of the test environment.
[0076] As an optional example, the configuration unit includes:
[0077] Set up a sub-unit to test that the sub-environment does not include the data master node and global transaction master node of the production environment, and set the management node, global transaction node, computing node and data node in the test sub-environment in the same computer room.
[0078] Optionally, in this embodiment, the test sub-environment does not include the data master node and the global transaction master node of the production environment, and an error is reported if they are included. The management node, global transaction node, computing node, and data node in the test sub-environment are in the same computer room, and an error is reported if they are not.
[0079] As an optional example, the execution module includes:
[0080] The first execution unit is used to define all functional modules that need to be tested and the corresponding functional test cases, and execute all functional test cases in the test sub-environment, and record the functional test results of each functional test case;
[0081] The second execution unit is used to define performance test cases in different scenarios, execute all performance test cases in the test sub-environment, and record the performance test results of each performance test case;
[0082] The third execution unit is used to define stress test cases in high concurrency scenarios, execute all stress test cases in the test sub-environment, and record the stress test results of each stress test case.
[0083] Optionally, in this embodiment, the required test cases are executed in the test sub-environment and various indicators during the test process are monitored and recorded, including but not limited to functional testing, performance testing, stress testing, etc., to ensure system stability and performance.
[0084] As an optional example, the rollback module includes:
[0085] The rollback unit is used to roll back the data change of the test sub-environment to the initial state according to the backup data of the test sub-environment, wherein before executing all the test cases in the test sub-environment, the data of the test sub-environment is backed up to obtain the backup data.
[0086] Optionally, in this embodiment, in order to ensure that the data changes can be rolled back to the initial state after all test cases are executed in the test sub-environment, it is necessary to back up the data of the test sub-environment before the test starts. Specifically, before the test starts, select a suitable backup method according to the database type. Common backup methods include logical backup and physical backup. Run the backup command to back up the data in the test sub-environment to a safe storage location. After the test is completed, select a suitable rollback method according to the backup method. Usually, use the restore command corresponding to the backup method, and then use the backup file to restore the data of the test sub-environment to the state at the time of backup. Finally, check the integrity and consistency of the data after recovery to ensure that the data state is consistent with that at the time of backup.
[0087] As an optional example, the above device further includes:
[0088] The processing module is used to use the test sub-environment as a standby machine or a read-only copy of the production environment after synchronizing the data of the test sub-environment to the production environment.
[0089] Optionally, in this embodiment, the tested test sub-environment that has been rolled back to the initial state is resynchronized to the production environment and continues to be used as a standby machine or a read-only copy.
[0090] For other examples of this embodiment, please refer to the above examples and will not be repeated here.
[0091] Figure 3 is a schematic diagram of an optional electronic device according to an embodiment of the present application, such as Figure 3 As shown, it includes a processor 302, a communication interface 304, a memory 306 and a communication bus 308, wherein the processor 302, the communication interface 304 and the memory 306 communicate with each other through the communication bus 308, wherein,
[0092] Memory 306, used for storing computer programs;
[0093] The processor 302 is used to implement the following steps when executing the computer program stored in the memory 306:
[0094] Use a target redundant copy of the production environment to create a test sub-environment that is consistent with the production environment's architecture;
[0095] Execute all test cases in the test sub-environment and record the test results of each test case;
[0096] Roll back the data changes of the test sub-environment to restore the test sub-environment to its initial state;
[0097] Synchronize the data of the test sub-environment to the production environment.
[0098] Optionally, in this embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The communication interface is used for communication between the above electronic device and other devices.
[0099] The memory may include RAM, or may include non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0100] As an example, the memory 306 may include but is not limited to the creation module 202, execution module 204, rollback module 206 and synchronization module 208 in the standby test execution device. In addition, it may also include but is not limited to other module units in the standby test execution device, which will not be repeated in this example.
[0101] The above-mentioned processor can be a general-purpose processor, which can include but not be limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0102] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0103] It can be understood by those skilled in the art that Figure 3 The structure shown is for illustration only. The device for implementing the above-mentioned standby machine test execution method may be a terminal device, which may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 3 The structure of the electronic device is not limited. For example, the electronic device may also include Figure 3 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 3 Different configurations shown.
[0104] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which can include: a flash drive, ROM, RAM, a magnetic disk or an optical disk, etc.
[0105] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program executes the steps in the above-mentioned standby machine test execution method when executed by a processor.
[0106] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0107] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0108] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0109] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0110] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0111] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0112] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0113] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for executing a standby machine test, characterized in that: include: Creating a test sub-environment consistent with the architecture of the production environment using a target redundant copy of the production environment; Execute all test cases in the test sub-environment and record the test result of each test case; Rolling back the data changes of the test sub-environment to restore the test sub-environment to an initial state; Synchronize the data of the test sub-environment to the production environment.
2. The method according to claim 1, characterized in that: The step of using the target redundant copy of the production environment to create a test sub-environment consistent with the architecture of the production environment includes: According to the test requirements of the production environment, determining the target redundant copy from all redundant copies of the production environment; Creating the test sub-environment using the target redundant copy; According to the architecture of the production environment, configure a management node, a global transaction node, a computing node, and a data node in the test sub-environment so that the test sub-environment is consistent with the architecture of the production environment; When it is determined that there is no active transaction in the production environment, the data of the target redundant copy is synchronized to the management node, the global transaction node, the computing node, and the data node in the test sub-environment.
3. The method according to claim 2, characterized in that The step of determining the target redundant copy from all redundant copies of the production environment according to the test requirements of the production environment includes: Determine a target redundant copy group from all redundant copies of the production environment, wherein the global transaction state of each redundant copy in the target redundant copy group is consistent with the global transaction state of the primary copy of the production environment; Determining a synchronization delay of each redundant replica in the target redundant replica group; The redundant copy with the smallest synchronization delay in the target redundant copy group is determined as the target redundant copy.
4. The method according to claim 2, characterized in that: The test sub-environment does not include the data master node and the global transaction master node of the production environment, and the configuration of the management node, the global transaction node, the computing node, and the data node in the test sub-environment according to the architecture of the production environment so that the test sub-environment is consistent with the architecture of the production environment includes: The management node, global transaction node, computing node and data node in the test sub-environment are arranged in the same computer room.
5. The method according to claim 1, characterized in that The executing all the test cases in the test sub-environment and recording the test result of each of the test cases includes: Define all functional modules that need to be tested and the corresponding functional test cases, execute all the functional test cases in the test sub-environment, and record the functional test results of each functional test case; Define performance test cases in different scenarios, execute all the performance test cases in the test sub-environment, and record the performance test results of each performance test case; Define stress test cases in high-concurrency scenarios, execute all of the stress test cases in the test sub-environment, and record the stress test results of each stress test case.
6. The method according to claim 1, characterized in that The rolling back of the data changes of the test sub-environment to restore the test sub-environment to an initial state includes: According to the backup data of the test sub-environment, the data change of the test sub-environment is rolled back to the initial state, wherein before executing all the test cases in the test sub-environment, the data of the test sub-environment is backed up to obtain the backup data.
7. The method according to claim 1, characterized in that After synchronizing the data of the test sub-environment to the production environment, the method further includes: The test sub-environment is used as a standby or read-only copy of the production environment.
8. A standby machine test execution device, characterized in that: include: A creation module, configured to create a test sub-environment consistent with the architecture of the production environment using a target redundant copy of the production environment; An execution module, used for executing all test cases in the test sub-environment and recording the test result of each test case; A rollback module, used to roll back the data changes of the test sub-environment to restore the test sub-environment to an initial state; The synchronization module is used to synchronize the data of the test sub-environment to the production environment.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.
