Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
River2000i committed Nov 22, 2024
1 parent cc11fc0 commit d6ce61d
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 40 deletions.
76 changes: 38 additions & 38 deletions dm/openapi/gen.server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dm/openapi/gen.types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dm/openapi/spec/dm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,7 @@ components:
- Stopped
- Running
- Finished
- Paused
Task:
description: "task"
type: object
Expand Down
21 changes: 20 additions & 1 deletion dm/tests/openapi/client/openapi_task_check
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,24 @@ def check_load_task_finished_status_success(task_name, finished_bytes, total_byt
assert load_status.get("finished_bytes") == int(finished_bytes)
assert load_status.get("total_bytes") == int(total_bytes)

def check_dump_task_finished_status_success(task_name, completed_tables, total_tables, estimate_total_rows,finished_rows,finished_bytes):
url = API_ENDPOINT + "/" + task_name + "/status"
resp = requests.get(url=url)
data = resp.json()
assert resp.status_code == 200
print("check_dump_task_finished_status_success resp=", data)

for item in data.get("data", []):
# Only validate dump task status
assert item.get("unit") == "Dump"
assert item.get("stage") == "Finished"
dump_status = item.get("dump_status", {})
assert dump_status.get("progress") == "100.00 %"
assert dump_status.get("completed_tables") == int(completed_tables)
assert dump_status.get("total_tables") == int(total_tables)
assert dump_status.get("estimate_total_rows") == int(estimate_total_rows)
assert dump_status.get("finished_rows") == int(finished_rows)
assert dump_status.get("finished_bytes") == int(finished_bytes)

def check_task_stage_success(task_name, total, stage):
url = API_ENDPOINT + "/" + task_name + "/status"
Expand Down Expand Up @@ -818,9 +836,10 @@ if __name__ == "__main__":
"check_noshard_task_dump_status_success": check_noshard_task_dump_status_success,
"do_complex_operations": do_complex_operations,
"create_task_with_precheck": create_task_with_precheck,
"check_task_stage_success": check_task_stage_success,
"check_sync_task_status_success": check_sync_task_status_success,
"check_load_task_finished_status_success": check_load_task_finished_status_success,
"check_task_stage_success": check_task_stage_success,
"check_dump_task_finished_status_success": check_dump_task_finished_status_success,
}

func = FUNC_MAP[sys.argv[1]]
Expand Down
7 changes: 6 additions & 1 deletion dm/tests/openapi/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ 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);"

run_sql_source1 "CREATE TABLE openapi.t2(i TINYINT, j INT UNIQUE KEY);"
run_sql_source1 "INSERT INTO openapi.t2(i,j) VALUES (1, 2),(3,4);"
}

function init_shard_data() {
Expand Down Expand Up @@ -209,6 +212,7 @@ function test_dump_task() {
run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status $task_name" \
"\"stage\": \"Stopped\"" 1
openapi_task_check "check_task_stage_success" $task_name 1 "Stopped"

init_dump_data

Expand All @@ -222,6 +226,7 @@ function test_dump_task() {
run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status $task_name" 100 \
"\"stage\": \"Finished\"" 1
openapi_task_check "check_dump_task_finished_status_success" $task_name 2 2 4 4 228

clean_cluster_sources_and_tasks
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>TEST OPENAPI: dump TASK"
Expand Down Expand Up @@ -258,7 +263,7 @@ function test_full_mode_task() {
openapi_task_check "check_task_stage_success" $task_name 2 "Stopped"

init_noshard_data

# start task success
openapi_task_check "start_task_success" $task_name ""
run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
Expand Down

0 comments on commit d6ce61d

Please sign in to comment.