Data Management Service (DMS) provides the Test Data Generate feature that is supported by a powerful algorithm engine. You can use this feature to generate large amounts of information at a time, such as random values, region names, and virtual IP addresses. This way, you can prepare test data with ease. This topic describes the Test Data Generate feature and shows you how to generate test data.
Prerequisites
- A database that contains the table for which you want to generate test data based
on specific fields is created. The generated test data is directly written to the
database.
Note Before you use the Test Data Generate feature to generate test data for the database, we recommend that you use the Database Clone feature to clone the database from an online environment to an offline environment.
- The following types of databases are supported:
- MySQL
- PolarDB-MySQL
- ADB3.0-MySQL
- ADB2.0
- DRDS
- Oceanbase2.0-MySQL
- Oceanbase1.0
Background information
In general, test data is required for functional tests or performance tests. You may use the following methods to generate test data:
- Write and import test data. This method has low efficiency and is inapplicable to scenarios where a large amount of test data is required.
- Maintain existing scripts. This method incurs high costs. Scripts must be modified for different tests. In addition, the data generated by using this method is not discrete enough.
- Export data from an online environment and write the data to an offline environment. This method is not secure and may cause data leak.
The preceding methods are insufficient to meet the requirements of the actual development process in which test data is frequently required. This process requires high data security and controllable data discreteness. It also requires high efficiency to save time and complete more constructive work. To this end, DMS provides the Test Data Generate feature to help you generate test data with ease.
Usage notes
- You can use this feature to generate test data for one table at a time. To generate test data for multiple tables, use this feature multiple times.
- A maximum of one million rows of data can be generated at a time.
- You can generate test data based on the following performance metrics. In this case,
traffic throttling is enabled. This prevents database overload that is caused by instantaneous
generation of excessive data.
- One million rows of data with four fields can be generated in about 60 seconds.
- One million rows of data with 40 fields can be generated in about 120 to 180 seconds.
Procedure
Algorithms
You can use one of the following algorithms to generate test data: Random, Customize, and Enumeration.
- Random
- INTEGER type: Two build types are provided. If you set the build type to Self-increasing sequence, you must set the Starting value and Step parameters. If you set the build type to Interval number, you must set the Minimum value and Maximum value parameters.
- STRING type: Two build types are provided. If you set the build type to Variable length string, you must set the Minimum length, Maximum length, and Character range parameters.
If you set the build type to Do not repeat string, you must set the Options parameter.
- TIME type: Random dates and time values can be generated based on a specified time range.
- INTEGER type: Two build types are provided. If you set the build type to Self-increasing sequence, you must set the Starting value and Step parameters. If you set the build type to Interval number, you must set the Minimum value and Maximum value parameters.
- Customize
The Customize algorithm can be used to generate only test data of the STRING type, such as personal information, geographic location information, and industry-related common information.
- EnumerationYou must create a limited number of values for DMS to select.Note The Enumeration algorithm can be used to generate test data of the INTEGER, STRING, and TIME types.