From 2ee5bd52d47152c98cc0664d58bf98e5e17a095a Mon Sep 17 00:00:00 2001 From: chinaxing Date: Wed, 24 Apr 2024 15:54:14 +0000 Subject: [PATCH] fix tx_free_route test --- .../test_suite/trx/t/tx_free_route.inc | 98 +++++++++++++++++++ .../test_suite/trx/t/tx_free_route.test | 2 +- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 tools/deploy/mysql_test/test_suite/trx/t/tx_free_route.inc diff --git a/tools/deploy/mysql_test/test_suite/trx/t/tx_free_route.inc b/tools/deploy/mysql_test/test_suite/trx/t/tx_free_route.inc new file mode 100644 index 000000000..f6cdfce0f --- /dev/null +++ b/tools/deploy/mysql_test/test_suite/trx/t/tx_free_route.inc @@ -0,0 +1,98 @@ +## ------- +## common routines to prepare table and ls topology for tx_free_route test +## ------- + +# check tenant has multiple ls + +connection sys; + +let $breakLoop=0; +let $i=0; +let $fail = 0; +while ($breakLoop == 0) { + --inc $i + let $lsCnt=`select count(ls_id) from oceanbase.__all_virtual_ls where tenant_id = $tenant_id and ls_id != 1 and status = "NORMAL" and flag not like "%DUPLICATE%"`; + if ($lsCnt > 1) { + --inc $breakLoop + } + if ($i >= 300) { + --inc $fail + --inc $breakLoop + } + --sleep 0.2 +} + +if ($fail > 0) { + --echo "tenant normal ls not distributed to multiple server" + eval select * from oceanbase.__all_virtual_ls where tenant_id = $tenant_id; +} + +connection conn0; + +let $tname=$tenant_name; + +if ($tname == '') { + die "error , tenant_name unspeficied: $tenant_name"; +} + +if ($tname == 'mysql') { + --disable_warnings + drop table if exists t; + --enable_warnings +} + +if ($tname == 'oracle') { + --disable_abort_on_error + --disable_result_log + drop table t purge; + --enable_abort_on_error + --enable_result_log +} + +create table t(id int primary key) partition by range(id) + (partition p0 values less than (10000), partition p1 values less than (3000000000)); + +# insert rows to ensure tablet created +--disable_result_log +--disable_query_log +insert into t values(9999),(99999); +commit; +--enable_result_log +--enable_query_log + +# check tablet of target table distributed to multiple ls +connection sys; +let $table_id=`select table_id from oceanbase.__all_virtual_table where table_name = 't' and tenant_id = $tenant_id`; +let $breakLoop=0; +let $i=0; +let $fail=0; +while ($breakLoop == 0) +{ + --inc $i + let $lsCnt=`select count(distinct ls_id) from oceanbase.__all_virtual_tablet_to_ls where tenant_id = $tenant_id and table_id = $table_id`; + if ($lsCnt > 1) { + --inc $breakLoop + } + if ($i >= 300) { + --inc $fail + --inc $breakLoop + } + --sleep 0.2 +} + +if ($fail > 0) { + --echo "error, table should distributed to all ls" + eval select * from oceanbase.__all_virtual_tablet_to_ls where tenant_id = $tenant_id and table_id = $table_id; + eval select * from oceanbase.__all_virtual_ls where tenant_id = $tenant_id; +} + +# check ls leader distributed to multiple server +let $check_ts=`select now()`; +let $svrCnt=`select count(distinct svr_ip,svr_port) from oceanbase.__all_virtual_ls_info where tenant_id = $tenant_id and ls_state = 'LEADER' and ls_id in (select distinct ls_id from oceanbase.__all_virtual_tablet_to_ls where tenant_id = $tenant_id and table_id = $table_id)`; +if ($svrCnt <= 1) { + --echo "ls leader not distributed to all server, check_ts=$check_ts, table_id=$table_id"; + eval select * from oceanbase.__all_virtual_tablet_to_ls where tenant_id = $tenant_id and table_id = $table_id; + eval select * from oceanbase.__all_virtual_ls_meta_table where tenant_id = $tenant_id and role = 1 order by ls_id; + eval select * from oceanbase.__all_virtual_ls where tenant_id = $tenant_id; + eval select * from oceanbase.__all_virtual_ls_info where tenant_id = $tenant_id; +} diff --git a/tools/deploy/mysql_test/test_suite/trx/t/tx_free_route.test b/tools/deploy/mysql_test/test_suite/trx/t/tx_free_route.test index 9477b1d6f..84e042726 100644 --- a/tools/deploy/mysql_test/test_suite/trx/t/tx_free_route.test +++ b/tools/deploy/mysql_test/test_suite/trx/t/tx_free_route.test @@ -16,7 +16,7 @@ let $tenant_id=`select tenant_id from oceanbase.__all_tenant where tenant_name = let $tenant_name=mysql; ---source tx_free_route.inc +--source mysql_test/test_suite/trx/t/tx_free_route.inc connection conn0;