From 68c22f32b2090e83e5ae64ae3b1f25f1a9575ff8 Mon Sep 17 00:00:00 2001 From: Jiaqiang Huang Date: Thu, 14 Nov 2024 15:45:17 +0800 Subject: [PATCH] dm: support dump task mode in openapi (#11729) close pingcap/tiflow#9230 --- dm/openapi/gen.server.go | 100 ++++++++++----------- dm/openapi/gen.types.go | 2 + dm/openapi/spec/dm.yaml | 1 + dm/tests/_utils/run_dm_ctl_with_retry | 13 ++- dm/tests/openapi/client/openapi_task_check | 40 +++++++++ dm/tests/openapi/run.sh | 53 +++++++++++ 6 files changed, 156 insertions(+), 53 deletions(-) diff --git a/dm/openapi/gen.server.go b/dm/openapi/gen.server.go index 12964ec809d..6f465412eb0 100644 --- a/dm/openapi/gen.server.go +++ b/dm/openapi/gen.server.go @@ -1306,56 +1306,56 @@ var swaggerSpec = []string{ "0Ru5eStIIp1bjRMcChQpTFRkmqf6wDRLdCq6uMigiW/Jl6VmpZJR7r37uOMGrtVBCqVSF0GBpFmzFssQ", "56beZDQeVcUn7sW0WR+WFlHekHrByo3cJS3RV1sr4QtFUMEeNIkyMNIqxErN1yrEaUVCPonSxaGpLmgu", "FUuTs+RKZgxQY8bDi6WVUjUV0w1l08j9brBXuvT6BAr4WoaSRcLHzVoF5AVNDDfFeZJIREjIUIqIrmWG", - "iaqPrQQIJslQR7ICoUd7NoSvib9zV5oM7bZfDt3uOi0RSCkgOTEHUBQnyAm6RknL9hilq6y9I5SSPxd+", - "vkcf18bUSAuiNBmiew0Mpia8XdGXQSEQU7U02kb6gfENr+D63xOmYtn+EwbnDvyWJ4nhd6lMfBeXrdyF", - "5MRSviQXtRNokMBk/W+XcFJ18sVoomuveJ7KKbPVmuMQJgCnRdK51NiGcbUGld6D/DOO63xvPWvRoVjo", - "iUBD04whzidX15MMYsa7wTKjwdU1UKPd8DlWIRxzgUi47py/sGOYGMdcnejq+jfKpAWN1e29cjYAOc+Z", - "VBZ14cgFdcEhp/MUYgnK4FIVDbT9gL1psX5gLHh7Zsyvgq85L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Ft80OfNTQn5KyPz7BEt1", + "5tv9YKlTDP1ZsjI981MUN178RxHEh09RWknBphz+uWqxtcRtaDa7vVYBe+tcLuSYHzDzXeK96/dx1Sbf", + "Mfk87GaR9WXZHVT2ZUvzXa+t39FLTOZaheaezbiTZr3Ki2Y/pO7SaO++6qKZX3Opj4+w62JH683n1zTf", + "i2gKMVGt50eS1GYCty4Y9XW7j2g4uMW96Wk//Zrj8GqiNPBEl6VOqq5gNR0zcnlmCu3tQnWDxWoSpRY8", + "atk2NEUX2HJc8cPt59v/CwAA//+dbnwDZLwAAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/dm/openapi/gen.types.go b/dm/openapi/gen.types.go index a1ac719d35d..6ffb8d0e38d 100644 --- a/dm/openapi/gen.types.go +++ b/dm/openapi/gen.types.go @@ -28,6 +28,8 @@ const ( const ( TaskTaskModeAll TaskTaskMode = "all" + TaskTaskModeDump TaskTaskMode = "dump" + TaskTaskModeFull TaskTaskMode = "full" TaskTaskModeIncremental TaskTaskMode = "incremental" diff --git a/dm/openapi/spec/dm.yaml b/dm/openapi/spec/dm.yaml index 9881b1538a2..c07b6139d25 100644 --- a/dm/openapi/spec/dm.yaml +++ b/dm/openapi/spec/dm.yaml @@ -1825,6 +1825,7 @@ components: - "full" - "incremental" - "all" + - "dump" shard_mode: type: string description: the way to coordinate DDL diff --git a/dm/tests/_utils/run_dm_ctl_with_retry b/dm/tests/_utils/run_dm_ctl_with_retry index b27149c057d..ea53e806e03 100755 --- a/dm/tests/_utils/run_dm_ctl_with_retry +++ b/dm/tests/_utils/run_dm_ctl_with_retry @@ -8,8 +8,15 @@ workdir=$1 master_addr=$2 cmd=$3 +retry_times=10 # Default retry times -shift 3 +# Validate retry_times is a number +if [[ $4 =~ ^[0-9]+$ ]] && [[ $# -gt 4 ]]; then + retry_times=$4 + shift 4 +else + shift 3 +fi PWD=$(pwd) binary=$PWD/bin/dmctl.test @@ -18,8 +25,8 @@ dmctl_log=$workdir/dmctl.$ts.log pid=$$ all_matched=true -echo "dmctl test cmd: \"$cmd\"" -for ((k = 0; k < 10; k++)); do +echo "dmctl test cmd: \"$cmd\" with max $retry_times retries" +for ((k = 0; k < retry_times; k++)); do echo "$cmd" | $binary -test.coverprofile="$TEST_DIR/cov.$TEST_NAME.dmctl.$ts.$pid.out" DEVEL --master-addr=$master_addr >$dmctl_log 2>&1 all_matched=true for ((i = 1; i < $#; i += 2)); do diff --git a/dm/tests/openapi/client/openapi_task_check b/dm/tests/openapi/client/openapi_task_check index 4389131d572..3fbf9a67249 100755 --- a/dm/tests/openapi/client/openapi_task_check +++ b/dm/tests/openapi/client/openapi_task_check @@ -268,6 +268,45 @@ def create_shard_task_success(): print("create_shard_task_success resp=", resp.json()) assert resp.status_code == 201 +def create_dump_task_success(): + task = { + "name": "test-dump", + "task_mode": "dump", + "meta_schema": "dm-meta", + "enhance_online_schema_change": True, + "on_duplicate": "error", + "target_config": { + "host": "127.0.0.1", + "port": 4000, + "user": "root", + "password": "", + }, + "table_migrate_rule": [ + { + "source": { + "source_name": SOURCE1_NAME, + "schema": "openapi", + "table": "*", + }, + "target": {"schema": "openapi", "table": "t"}, + } + ], + "source_config": { + "full_migrate_conf": { + "export_threads": 4, + "import_threads": 16, + "data_dir": "./exported_data", + "consistency": "auto", + }, + "incr_migrate_conf": {"repl_threads": 16, "repl_batch": 100}, + "source_conf": [ + {"source_name": SOURCE1_NAME}, + ], + } + } + resp = requests.post(url=API_ENDPOINT, json={"task": task}) + print("create_dump_task_success resp=", resp.json()) + assert resp.status_code == 201 def start_task_success(task_name, source_name): url = API_ENDPOINT + "/" + task_name + "/start" @@ -703,6 +742,7 @@ if __name__ == "__main__": "create_task_failed": create_task_failed, "create_noshard_task_success": create_noshard_task_success, "create_shard_task_success": create_shard_task_success, + "create_dump_task_success": create_dump_task_success, "create_incremental_task_with_gtid_success": create_incremental_task_with_gtid_success, "delete_task_failed": delete_task_failed, "delete_task_success": delete_task_success, diff --git a/dm/tests/openapi/run.sh b/dm/tests/openapi/run.sh index 5577da3d0d1..aceae7c16b2 100644 --- a/dm/tests/openapi/run.sh +++ b/dm/tests/openapi/run.sh @@ -24,6 +24,12 @@ function init_noshard_data() { run_sql_source2 "INSERT INTO openapi.t2(i,j) VALUES (3, 4);" } +function init_dump_data() { + + run_sql_source1 "CREATE TABLE openapi.t1(i TINYINT, j INT UNIQUE KEY);" + run_sql_source1 "INSERT INTO openapi.t1(i,j) VALUES (1, 2),(3,4);" +} + function init_shard_data() { run_sql_source1 "CREATE TABLE openapi.t(i TINYINT, j INT UNIQUE KEY);" run_sql_source2 "CREATE TABLE openapi.t(i TINYINT, j INT UNIQUE KEY);" @@ -176,6 +182,52 @@ function test_relay() { } +function test_dump_task() { + echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>START TEST OPENAPI: dump TASK" + prepare_database + + task_name="test-dump" + + # create source successfully + openapi_source_check "create_source1_success" + # get source list success + openapi_source_check "list_source_success" 1 + + # create source successfully + openapi_source_check "create_source2_success" + # get source list success + openapi_source_check "list_source_success" 2 + + # get source status success + openapi_source_check "get_source_status_success" "mysql-01" + + # create task success: not valid task create request + openapi_task_check "create_task_failed" + + # create dump task success + openapi_task_check "create_dump_task_success" + run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ + "query-status $task_name" \ + "\"stage\": \"Stopped\"" 1 + + init_dump_data + + # start dump task success + openapi_task_check "start_task_success" $task_name "" + run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ + "query-status $task_name" \ + "\"stage\": \"Running\"" 1 + + # wait dump task finish + run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ + "query-status $task_name" 100 \ + "\"stage\": \"Finished\"" 1 + + clean_cluster_sources_and_tasks + echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TEST OPENAPI: dump TASK" + +} + function test_shard_task() { echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>START TEST OPENAPI: SHARD TASK" prepare_database @@ -1040,6 +1092,7 @@ function run() { test_shard_task test_multi_tasks test_noshard_task + test_dump_task test_task_templates test_noshard_task_dump_status test_complex_operations_of_source_and_task