All Products
Search
Document Center

Data Management:Generate test data

Last Updated:Jun 18, 2024

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, 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 Generation feature and shows you how to generate test data.

Prerequisites

The database is of one of the following types:

  • MySQL: ApsaraDB RDS for MySQL, PolarDB for MySQL, ApsaraDB MyBase for MySQL, PolarDB-X, AnalyticDB for MySQL, and third-party MySQL databases

  • SQL Server: ApsaraDB RDS for SQL Server, ApsaraDB MyBase for SQL Server, and third-party SQL Server databases

  • PostgreSQL: ApsaraDB RDS for PostgreSQL, PolarDB for PostgreSQL, ApsaraDB MyBase for PostgreSQL, AnalyticDB for PostgreSQL, and third-party PostgreSQL databases

  • MariaDB: ApsaraDB RDS for MariaDB and third-party MariaDB databases

  • ApsaraDB for OceanBase in MySQL mode

  • PolarDB for PostgreSQL (Compatible with Oracle)

Background information

In most cases, test data is required for functional tests or performance tests. You can use the following methods to generate test data:

  • Write test data. This method is inefficient and does not apply 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 cannot meet the discreteness requirements.

  • 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.

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. Traffic throttling is enabled to prevent database overload that is caused by the generation of massive data in a short period of 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.

Procedure

  1. Log on to the DMS console V5.0.
  2. In the top navigation bar, choose Database Development > Environment Construction > Test Data Generation.

    Note

    If you use the DMS console in simple mode, move the pointer over the 2023-01-28_15-57-17.pngicon in the upper-left corner of the console and choose All Features > Database Development > Environment Construction > Test Data Generation.

  3. On the Test Data GenerationTickets 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 a table in the table list, and choose Data Plans > Test Data Generation.

  4. On the Ticket Application page, configure the parameters in the Application step as required and click Submit. The following table describes the parameters.

    Parameter

    Description

    Task Name

    The name of the task. Enter a name that facilitates future searches and helps approvers understand the purpose of the ticket.

    Database Name

    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.

    Table Name

    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

    The algorithm that you want to use to generate test data. This parameter appears only after you specify the Table Name parameter. You can configure a test data generation method for each field. For more information, see the Algorithms section of this topic.

    Number of rows generated

    The number of rows of the test data that you want to generate.

    Conflict Handling

    Specifies how DMS handles data conflicts. Valid values:

    • Skip when encountering data conflicts: If a data conflict occurs during data writing 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 during data writing of the primary key or a unique key, DMS overwrites the original data records and continues to write other data records.

    Change Stakeholder

    The stakeholders involved in the ticket. You can select stakeholders based on your business requirements. Only users who are relevant to the ticket, including those who participate in the approval process of the ticket, can view the ticket details.

  5. After you submit the ticket, wait for the ticket to be approved. After the ticket is approved, the system automatically generates test data and writes the generated data into the destination database.

    Note

    By default, the tickets that are submitted to generate test data are approved by database administrators (DBAs). For more information, see Test data generation.

Algorithms

You can use one of the following algorithms to generate test data: Random, Customize, and Enumeration.

  • Random

    • If a field is of the INTEGER type, two build types are provided. If you set the Build type parameter to Self-increasing sequence, you must set the Starting value and Step parameters. If you set the Build type parameter to Interval number, you must set the Minimum value and Maximum value parameters.

    • If a field is of the TEXT type, two build types are provided. If you set the Build type parameter to Variable length string, you must set the Minimum length, Maximum length, and Character range parameters. If you set the Build type parameter to Do not repeat string, you must set the Options parameter.

    • If a field is of the DATETIME type, random dates and time values can be generated based on the specified time range.

  • Customize

    The Customize algorithm can be used to generate only test data of the TEXT type, such as personal information, geographic location information, and industry-related standard data information.

  • Enumeration

    You must add a number of values for DMS to select.

    Note

    The Enumeration algorithm can be used to generate test data for fields of the INTEGER, TEXT, and DATETIME types.

What to do next

After test data is generated for a database, you can perform the following operations: