Data Management (DMS) provides the Test Data Generation feature that is supported by a powerful algorithm engine. You can use this feature to generate various test data at a time, including random values, region names, and virtual IP addresses. This way, you can prepare test data with ease. This topic describes the Test Data Generation feature and shows you how to generate test data.
The following types of databases are supported:
MySQL: ApsaraDB RDS for MySQL, PolarDB for MySQL, MyBase for MySQL, PolarDB for Xscale, AnalyticDB for MySQL, and third-party MySQL databases
SQL Server: ApsaraDB RDS for SQL Server, MyBase for SQL Server, and third-party SQL Server databases
PostgreSQL: ApsaraDB RDS for PostgreSQL, PolarDB for PostgreSQL, MyBase for PostgreSQL, AnalyticDB for PostgreSQL, and third-party PostgreSQL databases
MariaDB: ApsaraDB for MariaDB and third-party MariaDB databases
ApsaraDB for OceanBase in MySQL mode
PolarDB for PostgreSQL(Compatible with Oracle)
In general, test data is required for functional tests or performance tests. You may use the following methods to generate test data:
Write test data. This method has low efficiency and is inapplicable to scenarios in which a large amount of test data is required.
Maintain existing scripts. This method is costly. 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 leaks.
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 for more constructive work. To this end, DMS provides the Test Data Generation feature to help you generate test data with ease.
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 repeatedly.
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. Traffic throttling is enabled, which prevents database overload caused by the generation of a large amount of data in a short time.
One million rows of data can be generated for four fields in about 60 seconds.
One million rows of data can be generated for 40 fields in about 120 to 180 seconds.
- Log on to the DMS console V5.0.
In the top navigation bar, choose .Note
If you use the DMS console in simple mode, move the pointer over the icon in the upper-left corner of the DMS console and choose.
On the Test Data Generation Tickets page, click Test Data Generation in the upper-right corner.Note
Alternatively, you can go to the SQL console of the database for which you want to generate test data, right-click the desired table in the table list and choose.
In the Test data build dialog box, set the parameters in the Application step as required and click Submit. The following table describes the parameters.
Required. The name of the task. Specify a name that facilitates future searches and helps approvers understand the purpose of the operation.
Required. The name of a specific database in the specified database instance. You must have permissions to manage the database in DMS. Enter the prefix of a database name in the field and select the database from the matching results.
Required. The table for which you want to generate test data. Enter the prefix of a table name in the field and select the table from the matching results. You can specify multiple tables.
Configure the algorithm
Required. The algorithm that you want to use to generate test data. This parameter appears only after you select a table name. For more information, see Algorithms.
Number of rows generated
Required. The number of rows of test data that you want to generate.
Required. Specifies how DMS handles data conflicts. Valid values:
Skip when encountering data conflict: If a data conflict occurs while writing data of the primary key or a unique key, DMS skips the conflicting data records and continues to write other data records.
Replace when encountering data conflict: If a data conflict occurs while writing data of the primary key or a unique key, DMS updates the original data records and continues to write other data records.
Optional. The stakeholders involved in the task. This parameter appears only after you select a database name. Only users relevant to the task, including those who participate in the ticket approval process, have access to the ticket details.
After you submit the ticket, wait for the ticket to be approved. After it is approved, the system automatically generates test data and writes it into the specified database.Note
By default, the tickets for generating test data are approved by database administrators (DBAs). For more information, see Security rules for test data generation.
You can use one of the following algorithms to generate test data: Random, Customize, and Enumeration.
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 date and time values can be generated based on a specified time range.
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.
You 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.