All Products
Search
Document Center

PolarDB:Test verification

Last Updated:Nov 25, 2026

After you complete the data migration from Oracle to PolarDB for PostgreSQL (Compatible with Oracle), congratulations on completing the most critical data transfer work in the migration. However, the migration is not over yet. Switching services directly to a new database that has not been fully verified may cause online failures due to potential SQL compatibility issues, performance differences, or data consistency problems. This document describes how to test and verify the migrated PolarDB cluster. By combining business regression testing with automated traffic replay, you can systematically identify and resolve issues before the official cutover, ensuring a smooth and successful final service switchover.

Features

Test verification mainly includes two complementary methods: manual business regression testing and automated traffic replay.

  • Business regression testing (basic): This is the most direct verification method. You need to organize a test team to run your existing business test cases in the environment connected to the new PolarDB cluster, covering core business processes to verify functional correctness.

  • Automated traffic replay (advanced): This is a powerful cloud-native verification service provided by Alibaba Cloud. It realistically simulates production workloads to verify compatibility and performance. Its workflow consists of three steps:

    Stage

    Core function

    Description

    1. Traffic collection

    Capture the real workload of the source database

    On your source Oracle database, use dedicated tools to capture all real SQL requests, session information, and transaction behavior over a period of time (for example, a peak business hour), and save them as traffic files.

    2. SQL traffic replay

    Simulate production pressure and verify compatibility and performance

    Replay the collected traffic files on the target PolarDB cluster. This helps you:

    • Verify SQL syntax compatibility at scale.

    • Compare the execution time of SQL on the source and target databases to identify performance regressions.

    • Simulate future business growth pressure by adjusting concurrency parameters.

    3. SQL result verification

    Ensure consistent data processing results

    During replay, the tool executes the same SQL queries on both the source and target databases, compares the returned results one by one, and automatically flags any inconsistent data.

Benefits

Compared with manual business testing alone, automated traffic replay provides significant benefits:

  • Realism: Tests with real SQL from the production environment reflect actual problems better than simulated test cases.

  • High coverage: Automatically covers tens of thousands of SQL statements and finds edge compatibility issues that are hard to reach with manual testing.

  • Quantitative performance comparison: Provides accurate SQL execution time comparison reports, making performance optimization evidence-based.

  • Efficiency improvement: Automates a large amount of verification work, greatly shortening the test cycle and freeing up manpower.

Precautions

  • Region limits: SQL traffic replay is currently supported only in China (Hangzhou), China (Shanghai), China (Beijing), and China (Zhangjiakou).

  • Whitelist configuration: Add the private IP address of the ECS instance where the replay agent is deployed to the whitelist of the target PolarDB cluster.

  • Traffic collection timing: To make the collected traffic more representative, we recommend that you collect traffic during peak hours or over a complete business cycle (for example, one day).

  • Stored procedure verification: Traffic replay supports result verification for stored procedures, but this feature is in the grayscale phase. If you need this feature, please Submit a ticket to contact us to enable this feature.

Stage 1: Business regression testing

This is a necessary step to verify whether the core business logic is correct.

  1. Prepare the test environment: Configure your test applications to connect to the target PolarDB cluster.

  2. Run test cases: Run the full set of regression test cases for your business, covering all core functions such as user registration, order placement, payment, and query.

  3. Record and fix issues: Record all failed test cases, determine whether the cause is SQL compatibility, data, or something else, and fix them.

Stage 2: Traffic replay and verification

After basic business function verification is complete, use traffic replay for deeper stress and consistency testing.

Step 1: Traffic collection

In this step, use Oracle RAT (Real Application Testing) tools on your source Oracle database to capture all real SQL requests, session information, and transaction behavior over a period of time (for example, a peak business hour) and save them as traffic files, so that they can be replayed on the target PolarDB cluster.

  1. Prepare the environment: Prepare a server (Linux) that can access the source Oracle database to deploy the collection tool. Make sure that Java 1.8 is installed on the server.

    # Check whether the Java environment exists
    java -version
    # If not, install the Java environment
    yum -y list java*
    yum install -y java-1.8.0-openjdk.x86_64
  2. Install the collection tool: Download and decompress the sqla collection tool package (sqla-3.3.26.tar.gz).

    # Create the specified directory
    mkdir -p /home/frodo/collector
    # Go to the directory
    cd /home/frodo/collector/
    # Upload the collection tool package to the current directory
    
    # Decompress the tool package
    tar xvf sqla-3.3.26.tar.gz
  3. Capture traffic in the source Oracle database

    1. Log on to the Oracle database server and create a directory for storing capture files. You can use a custom directory. For RAC instances, create the directory on each node.

      # Create the capture directory
      su - oracle
      mkdir -p /home/oracle/db_replay_capture
      # Grant permissions on the capture directory
      chmod 777 /home/oracle/db_replay_capture
    2. Log on to Oracle and register the physical directory as a database directory.

      CREATE OR REPLACE DIRECTORY DB_REPLAY_DIR AS '/home/oracle/db_replay_capture';
    3. Run the WORKLOAD capture command. duration parameter specifies the capture duration in seconds.

      BEGIN
        DBMS_WORKLOAD_CAPTURE.START_CAPTURE(
          name     => 'capture_for_polardb_test', 
          dir      => 'DB_REPLAY_DIR',
          duration => 3600  -- Capture for 1 hour
        );
      END;
      /
    4. After the WORKLOAD capture is run, SQL traffic from the start time until the end of the period set by duration is continuously collected. During this period, the SQL traffic generated by the stress test is captured. You can check whether the capture has ended by running a command, or you can end the capture manually in advance.

      • Check whether the capture has ended.

        SELECT * FROM DBA_WORKLOAD_CAPTURES;
      • End the capture manually in advance.

        BEGIN
        DBMS_WORKLOAD_CAPTURE.finish_capture();
        END;
        /

      After the capture ends, in the /home/oracle/db_replay_capture/cap directory, view the generated wcr files: wcr_cr.html, wcr_cr.text, wcr_cr.xml, wcr_fcapture.wmd, and wcr_scapture.wmd.

  4. Parse traffic files: After the capture ends, use the sqla tool to parse the original .wcr files into the json format that DTS can recognize.

    cd /home/frodo/collector/sqla3/
    # Start sqla
    ./sqla --parsewcr -d /home/oracle/db_replay_capture

    After the parsing is successful, the tool generates the /home/oracle/db_replay_capture/ directory under sqla. In this directory, find the file named merge.json. This is the traffic file you need.

Step 2: SQL traffic replay and result verification

Note

Traffic replay is implemented by PolarDB through integration with the Cloud Migration Center's traffic replay (legacy) feature.

  1. Go to the PolarDB console and choose Oracle Online Migration in the left-side navigation pane. In the Test & Validate step, click the SQL Traffic Replay button under Start Replay.

  2. Apply for a license:

    The first time you use the feature, click Apply for License. The license is used to protect the agent from abuse. The license itself, including subsequent agent capabilities (except for ECS purchase), does not incur any charge for traffic replay.

  3. Install the agent:

    After applying for the license, deploy the traffic replay agent. To do so, you need to provide a server for agent installation. Choose the most suitable installation method from the following table based on the server environment:

    Deployment scenario

    Key condition

    Recommended installation method

    Remarks

    Alibaba Cloud ECS (standard case)

    Cloud Assistant is installed and running on the instance

    Automatic deployment

    Officially recommended. This is the most convenient and efficient installation method and the first choice.

    Alibaba Cloud ECS (special case)

    Cloud Assistant is not installed or is not running properly

    Manual deployment - private network connection

    Alternative on Alibaba Cloud ECS when automatic deployment is unavailable.

    Non-Alibaba Cloud server

    (such as self-built IDC or another cloud provider)

    The server network is connected to the Alibaba Cloud VPC through a leased line or VPN

    Manual deployment - private network connection

    Connects through the internal network for more secure data transmission and a more stable network.

    Non-Alibaba Cloud server

    (such as self-built IDC or another cloud provider)

    • Not connected to the Alibaba Cloud VPC network

    • The server has a public IP address

    Manual deployment - public network connection

    Applicable to server environments isolated from the Alibaba Cloud network but with Internet access

    Note

    If you use manual deployment, add the private or public IP address of the server to the PolarDB cluster's cluster whitelist.

    1. Fill in basic information: Click Agent Management, click Install Agent in the agent management list, and in the dialog box, select the appropriate Installation Method based on your server environment and fill in the basic information.

    2. Install the agent: Based on the Installation Method, wait for the automatic installation to complete or copy the command to install manually.

    3. Network connectivity: Wait for a connection to be established with the agent.

  4. Create a replay plan:

    1. Click Create Replay Plan, and select a replay type. There are two core options:

      • Traffic replay: Replays only on the target database for performance and compatibility testing.

      • Result comparison: Replays on both the source and target databases and compares the results for data consistency verification.

      Note

      First, create a Traffic replay plan and execute the collected SQL on the target PolarDB cluster for replay. This helps you verify whether the SQL can be executed successfully and identify SQL compatibility issues. You can also compare the SQL execution time with that on the source Oracle database. After you complete the performance and compatibility test on the target PolarDB cluster, create a Result comparison plan for the final result comparison.

    2. Fill in the connection information of the source and target databases based on your selection.

      Basic information

      Configuration

      Description

      Task name

      Represents the name of the replay task. Chinese and English letters of both cases and some special characters are allowed.

      Replay type

      Select a value based on the replay type.

      Source data source type

      Select Oracle.

      Destination data source information

      Destination data source type

      Select PolarDB for PostgreSQL (Compatible with Oracle)

      Acquisition method

      Select Instance acquisition or Address acquisition based on your business scenario.

      Database name

      Enter the name of the database to be replayed.

      Username

      Enter the account of the database.

      Password

      Enter the password for the database account.

      SQL file path and type

      Five common formats are supported: Standard format, CloudLens format, SLS JSON format, SLS CSV format, and Tshark format.

      Based on the files and format collected in Step 1: Traffic collection above, select Standard format and enter the absolute path of the file.

      Select agent

      Select the agent installed above.

      Parameter configuration

      Configuration

      Description

      Number of simulated clients

      Represents the number of threads for concurrent SQL execution in the replay instance. When resources are sufficient, more threads lead to faster execution.

      Replay speed factor

      Controls the waiting time between two SQL statements during execution. 1 indicates the original speed, 2 indicates twice the speed, and 10 indicates 10 times the speed. The default value is 1.

      Example: For two consecutive SQL statements with an interval of 5 seconds, if the replay speed factor is 1, the interval remains 5 seconds; if the factor is 5, the interval becomes 1 second; if the factor is 10, the interval becomes 0.5 seconds.

      Note

      This parameter does not take effect during loop replay.

      Loop replay

      If Yes is selected, replay continues from the beginning of the file after one run until the specified replay duration is reached. If No is selected, replay stops automatically after one run. The default value is No.

      Replay duration

      The running duration in seconds. The default value is 86400. It controls how long the task runs, and the task automatically ends when the duration expires.

      Schema mapping and filtering

      By default, this field is left empty and SQL of all schemas is replayed. If you specify schemas, only SQL of the specified schemas is replayed. If the schema names on the source and target sides are different, you can specify the mapping by using the schema1:schema2 format.

      SQL timeout

      The maximum waiting time for executing a single SQL statement. The default value is 60 seconds.

      Commit

      By default, traffic replay manually starts a transaction for replay and executes a rollback after each SQL statement. If you need to commit, set this parameter to Yes.

      Replay SQL type

      You can select All, DQL and DML. If you select DQL or DML, only SQL statements of the corresponding type are executed. By default, all SQL statements are executed.

      Skip failed SQL

      Specifies whether to skip SQL statements that have already failed. The default value is No, which means the SQL statements are executed again next time. If you select Yes, they are not executed again.

      (Optional) Advanced configuration

      Replay plan More advanced configurations are supported. Choose them based on your actual business situation.

      Configuration

      Description

      Exclude network time

      Network time is excluded from the elapsed time calculation. This parameter does not take effect for PolarDB for PostgreSQL (Compatible with Oracle) clusters.

      Enable streaming reads

      Specifies whether to execute SQL through JDBC. If a large number of data extraction SQL statements exist and the result sets are too large, enable streaming reads to avoid out-of-memory issues.

      Exclude template SQL that is not executed

      Filters out template SQL statements that do not need to be replayed, which is used to exclude some template SQL statements during stress testing. Separate multiple template SQL statements with the , character.

      Disable manual transactions

      Specifies whether to disable manual transactions. If disabled, SQL uses the autocommit mode.

      Enable detailed SQL replay logs

      Specifies whether to enable detailed SQL replay logs. After this switch is turned on, the system creates a file in the /run/$task/ directory, that is, detail.csv, and records the replay time of each SQL statement.

      Disable insert to replace conversion

      When this option is disabled, the INSERT INTO syntax is converted to the REPLACE INTO syntax.

  5. Create and execute tasks:

    1. After the replay plan is created, on the replay plan details page, click Create Task.

    2. You can keep the task configuration unchanged or adjust it as needed. After you click Save, a task in the Pending state is automatically created.

      • Execute the task: Click the Execute button in the Actions column to execute the plan.

      • Stop the task: Click the Stop button in the Actions column to stop the running plan.

      • View the task: Click View Progress in the Status column to view the real-time overall replay progress of the task.

      • View and export reports: After the replay is complete, click the Actions button in the Details button to view the overall replay status and export the overall report. The parameters in the exported report are described as follows:

        Parameter

        Description

        totalRequestCount

        Total number of requests.

        succussRequestCount

        Number of successful requests.

        failRequestCount

        Number of failed requests.

        sqlTemplateCount

        Number of SQL templates.

        successSqlTemplateCount

        Number of successful SQL templates.

        failSqlTemplateCount

        Number of failed SQL templates.

        Average execution time

        -

        Execution time details

        -

FAQ

What is the difference between traffic replay and result verification? Which one should I use?

  • Traffic replay: Focuses on performance and compatibility. It answers the question: "Can my SQL run on the target database, and how fast is it?"

  • Result verification: Focuses on data accuracy. It answers the question: "Are the results of my SQL the same on the source and target databases?"

Recommendation: Use both. First use traffic replay to verify compatibility and performance at scale, and after fixing the issues, use result verification to finally confirm data consistency for core queries.