All Products
Search
Document Center

Test data generation

Last Updated: Jul 14, 2020

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, including random values, region names, and virtual IP addresses. This makes it much easier for you to prepare test data. This topic describes the Test Data Generate feature and how to generate test data in DMS.

Background

Functional tests or performance tests often require test data. Generally, you may use the following approaches to generate test data:

  • Manually write test data. This approach has low efficiency and is inapplicable to scenarios where a large amount of test data is required.
  • Write and maintain scripts. This approach incurs high costs. Scripts must be modified for different tests. In addition, the data generated by using this approach is not discrete enough.
  • Export data from an online environment and write the data to an offline environment. This approach is not secure and may cause data leakage.

However, the preceding approaches are insufficient to meet the requirements of the actual development process, which may require frequent test data generation. High data security and controllable data discreteness are required. You also need to ensure high efficiency to save time and do more constructive work. To this end, DMS provides the Test Data Generate feature to help you easily generate test data.

Prerequisites

  • A database that contains the target table for which you want to generate test data based on corresponding fields is created. The test data you generate will be written directly to the target database.

    Before you use the Test Data Generate feature to generate test data for the target database, we recommend that you use the Database Clone feature to clone the target database from an online environment to an offline environment.

  • The target database uses one of the following database engines:

    • MySQL
    • PolarDB-MySQL
    • ADB3.0-MySQL
    • ADB2.0
    • DRDS
    • OceanBase2.0-MySQL
    • OceanBase1.0

Important notes

  • You can use the Test Data Generate feature to generate test data for one table at a time. To generate test data for multiple tables, you must use this feature multiple times.
  • A maximum of 1 million rows of data can be generated at a time.
  • You can refer to the following performance metrics of the Test Data Generate feature. Traffic throttling is enabled. This prevents instantaneous generation of excessive data from causing database overload.
    • 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

  1. Log on to the .

  2. In the top navigation bar, choose Data Plans > Test Data Generate.

  3. On the Test Data Generate Tickets page, click Test Data Generate in the upper-right corner.

    Alternatively, you can choose SQLConsole > Single Database query in the top navigation bar. In the dialog box that appears, select the database that contains the table for which you want to generate test data and click Confirm. On the page that appears, right-click the target table in the left-side pane and choose Data Plans > Test Data Generate. In the dialog box that appears, set relevant parameters.
    1

  4. On the Test data build work order application page, set the parameters as described in the following table. After that, click Submit.
    2

    Parameter Description
    Task Name (Required) The name of the task. The name needs to clearly identify the ticket so that approvers can easily find the ticket and know what to do with the ticket.
    Database Name (Required) The name of the target database. You must have the permission to manage the database. Enter a keyword and select a database whose name starts with the keyword from the matched result.
    Table Name (Required) The table for which you want to generate test data. Enter a keyword and select a table whose name contains the keyword from the matched result.
    Configure the algorithm (Required) The algorithms that you want to use to generate test data. You can select an algorithm for each field. For more information, see Algorithms.
    Number of rows generated (Required) The number of rows of test data that you want to generate.
    Conflict Handling (Required) Specifies how the system handles conflicts that occur when test data is being generated. Valid values:
    Skip when encountering data conflicts: If a primary key conflict or a unique index conflict occurs when test data is being generated, the system ignores the conflict and continues to generate test data.
    Replace when encountering data conflict: If a primary key conflict or a unique index conflict occurs when test data is being generated, the system deletes relevant data and continues to generate test data.
    Change Stakeholder (Optional) The stakeholder of the ticket. You can specify multiple stakeholders. Only users who are relevant to the ticket, including those who participate in the approval process of the ticket, can view ticket details.
  5. After you submit the ticket, the ticket approval process starts.

    By default, test data generation tickets are approved by database administrators (DBAs). For more information about approval rules for test data generation tickets, see Test Data Generate.

  6. After the ticket is approved, the system automatically starts to generate test data and write the test data directly to the target database.

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 specify the Starting value and Step parameters. If you set the build type to Interval number, you must specify the Minimum value and Maximum value parameters.
      3

    • String type: Two build types are provided. If you set the build type to Variable length string, you must specify the Minimum length, Maximum length, and Character range parameters. If you set the build type to Do not repeat string, you must specify the Options parameter.
      4

    • Time type: Random dates and time values can be generated based on a specified time range. You can specify the Start time, End time, and Format parameters to set a time range. You can also select Generate based on current time.

  • Customize
    The Customize algorithm can be used to generate only test data of the string type, for example, personal information, geographic location, and industry-related common information.
    5

  • Enumeration
    If you use the Enumeration algorithm to generate test data, you must create a limited number of values for the system to select.

    The Enumeration algorithm can be used to generate test data of the integer, string, and time types.

    6