提交 168e0258 编写于 作者: W wangzelin.wzl

fix a bug about sync mysqltest

上级 f2294866
# 如何执行MySQLtest
## 名词解释
- OBD:[OceanBase Deploy](https://github.com/oceanbase/obdeploy)的简称。
- case:执行MySQLtest的最小单位,一个case至少包含一个test文件和一个result文件
- suite:一组case的集合,称为suite
## 启动测试
#### __启动测试前,你需要先使用OBD启动一个集群。[使用OBD快速启动OceanBase数据库](https://github.com/oceanbase/obdeploy#%E5%BF%AB%E9%80%9F%E5%90%AF%E5%8A%A8-oceanbase-%E6%95%B0%E6%8D%AE%E5%BA%93)__
### 全量测试
执行mysql_test/test_suite下全部的测试,可以使用以下命令:
```shell
obd test mysqltest <deploy name> --all --auto-retry
# 如果执行obd命令时不处于当前目录请使用 --suite-dir 选项
# 一些case中包含是相当路径,不在当前目录执行可能会导致失败
```
#### 参数与选项解释
参数 `deploy name` 为部署配置名称,可以理解为配置文件名称。
选项 `--suite-dir` 为 suite 所在目录,默认为 ./mysql_test/test_suite
选项 `--all` 为执行 `--suite-dir` 下全部suite。
选项 `--auto-retry` 开启后,当case第一次执行失败时会自动重部署集群进行重试。
### 单suite测试
对mysql_test/test_suite下指定suite执行测试,可以使用以下命令:
```shell
obd test mysqltest <deploy name> --suite <suite_name> --auto-retry
# 如果执行obd命令时不处于当前目录请使用 --suite-dir 选项
# 一些case中包含是相当路径,不在当前目录执行可能会导致失败
```
#### 参数与选项解释
参数 `deploy name` 为部署配置名称,可以理解为配置文件名称。
选项 `--suite-dir` 为 suite 所在目录,默认为 ./mysql_test/test_suite
选项 `--suite` 为要执行suite的集合,多个suite之间使用英文逗号`,`间隔
选项 `--auto-retry` 开启后,当case第一次执行失败时会自动重部署集群进行重试。
### 单case测试
对特定case进行测试,比如对mysql_test/test_suite/alter/t/alter_log_archive_option.test进行测试,可以使用以下命令:
```shell
obd test mysqltest <deploy name> --test-dir ./mysql_test/test_suite/alter/t --result-dir ./mysql_test/test_suite/alter/r --test-set alter_log_archive_option --auto-retry
# 如果执行obd命令时不处于当前目录请调整 --test-dir 和 --result-dir
# 一些case中包含是相当路径,不在当前目录执行可能会导致失败
```
#### 参数与选项解释
参数 `deploy name` 为部署配置名称,可以理解为配置文件名称。
选项 `--test-dir` 为 test文件 所在目录,默认为 ./t
选项 `--result-dir` 为 result文件 所在目录,默认为 ./r
选项 `--test-set` 为要执行case的集合,多个case之间使用英文逗号`,`间隔
选项 `--auto-retry` 开启后,当case第一次执行失败时会自动重部署集群进行重试。
#--disable_query_log
#--disable_result_log
#
#let $index_status_expect = 2;
#let $result = 2;
#
#connect (obsys_caio,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
#connection obsys_caio;
#let $i=210;
#while($i>0)
#{
# sleep 1;
# #--echo $index_name
# ## let $result = query_get_value(select count(*) from oceanbase.__all_virtual_table where table_name like '__idx_%' and index_status!=2,count(*),1);
# let $result = query_get_value(select count(*) from oceanbase.__all_virtual_table as t join oceanbase.__all_virtual_database as d where t.tenant_id = d.tenant_id and t.database_id = d.database_id and d.in_recyclebin = false and d.database_name != "__recyclebin" and t.table_name like '__idx_%' and t.index_status!=2,count(*),1);
# if($result == 0)
# {
# let $i = -4;
# }
# dec $i;
#}
#sleep 2;
#if($i != -5)
#{
# let $table_id = query_get_value(select table_id from oceanbase.__all_virtual_table as t join oceanbase.__all_virtual_database as d where t.tenant_id = d.tenant_id and t.database_id = d.database_id and d.in_recyclebin = false and d.database_name != "__recyclebin" and t.table_name like '__idx_%' and t.index_status!=2 limit 1,table_id,1);
# --echo $result idx is build failed, first table id is $table_id
#}
#disconnect obsys_caio;
#connection default;
#--enable_query_log
#--enable_result_log
let $cluster_is_ob = 1;
let $cluster_is_mysql = 0;
let $collation_count = query_get_value(select count(1) as cnt from information_schema.COLLATIONS, cnt, 1);
if ($collation_count > 100) {
let $cluster_is_ob = 0;
let $cluster_is_mysql = 1;
}
connect (ob_sys_check_schema,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection ob_sys_check_schema;
let $i = 10;
while($i > 0)
{
sleep 1;
let $cnt = query_get_value(select count(*) as cnt from oceanbase.__all_virtual_server_schema_info as a join oceanbase.__all_virtual_server_schema_info as b on a.tenant_id = b.tenant_id where a.refreshed_schema_version != b.refreshed_schema_version, cnt, 1);
dec $i;
if ($cnt == 0)
{
let $i = -4;
}
}
if ($i != -4)
{
--echo check schema sync timeout
eval select * from oceanbase.__all_virtual_server_schema_info;
}
disconnect ob_sys_check_schema;
--disable_query_log
--disable_result_log
connection default;
let $tenant_id = query_get_value(select effective_tenant_id() as ID from dual, ID, 1);
connect (obsys_ydm,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys_ydm;
let $__i__= 100;
while($__i__ > 0)
{
sleep 1;
dec $__i__;
## 检查有没有分区的列级统计信息还没有汇报上来
let $__num__ = query_get_value(select count(*) as num from oceanbase.__all_virtual_meta_table a where a.tenant_id = $tenant_id and not exists (select 1 from oceanbase.__all_virtual_column_statistic b where a.table_id = b.table_id and a.partition_id = b.partition_id and b.tenant_id = $tenant_id), num, 1);
if($__num__ == 0)
{
let $__i__ = -5;
}
}
connection default;
disconnect obsys_ydm;
--enable_query_log
--enable_result_log
let $server_cnt = query_get_value(select count(*) as cnt from oceanbase.__all_server, cnt, 1);
let $schema_version = query_get_value(select max(schema_version) as max_schema_version from oceanbase.__all_tenant_history, max_schema_version, 1);
let $sync_cnt = 0;
let $i = 10;
while($i > 0)
{
sleep 1;
dec $i;
let $sync_cnt = query_get_value(select count(*) as cnt from oceanbase.__all_virtual_server_schema_info where refreshed_schema_version >= $schema_version and tenant_id = 1, cnt, 1);
if ($sync_cnt == $server_cnt)
{
let $i = -4;
}
}
if ($i != -4)
{
--echo check tenant sync timeout, sync_cnt:$sync_cnt, server_cnt:$server_cnt
eval select * from oceanbase.__all_virtual_server_schema_info where refreshed_schema_version >= $schema_version and tenant_id = 1;
}
## 功能: 获取指定租户的ip&port
# 1.最好使用前sleep下,否则tenant_schema有可能还未刷到server上导致连接不上
# 2.如果分布于多个server,取unit_id最小的
## 用法:
# 1.设置待连接的tenant_name
# 2.source本文件
# 3.connect
## 模板:
# sleep 3;
# let $__tenant_name__ = 'tt1';
# --source mysql_test/include/get_tenant_server.inc
# connect (conn1,$TE_SERVER_IP,root@tt1,,*NO-ONE*,$TE_SERVER_PORT);
--disable_query_log
--disable_result_log
connect (obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys;
let $__tenant_id__ = `select tenant_id from oceanbase.__all_tenant where tenant_name = $__tenant_name__ limit 1`;
let $__resource_pool_id__ = `select resource_pool_id from oceanbase.__all_resource_pool where tenant_id = $__tenant_id__ limit 1`;
let $__svr_ip__ = `select svr_ip from oceanbase.__all_unit where resource_pool_id = $__resource_pool_id__ limit 1`;
let $__svr_port__ = `select svr_port from oceanbase.__all_unit where resource_pool_id = $__resource_pool_id__ limit 1`;
let $__inner_port__ = `select inner_port from oceanbase.__all_server where svr_ip = '$__svr_ip__' and svr_port = $__svr_port__ limit 1`;
let $TE_SERVER_IP = $__svr_ip__;
let $TE_SERVER_PORT = $__inner_port__;
disconnect obsys;
connection default;
--enable_query_log
--enable_result_log
connect (obsys_idm,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys_idm;
set ob_enable_index_direct_select=1;
alter system set merger_check_interval = '10s';
disconnect obsys_idm;
connection default;
connect (obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys;
alter system major freeze;
disconnect obsys;
connection default;
-- require mysql_test/r/not_embedded.require
disable_query_log;
select version() like '%embedded%' as 'have_embedded';
enable_query_log;
connection default;
--disable_query_log
--disable_result_log
select * from proxy_mock_table_for_pc;
--enable_query_log
--enable_result_log
--replace_regex /REPLICA_NUM = [0-9]*/REPLICA_NUM = 1/g /ROW_FORMAT = (DYNAMIC|COMPRESSED|COMPACT|REDUNDANT)[ ]*//g /(NOCOMPRESS|COMPRESS) (FOR)*[ ]*(BASIC|OLTP|QUERY|ARCHIVE)*[ ]*//g /zstd_1\.3\.8/lz4_1.0/g /OBFK_[0-9]*/OBFK_1234/g /OBPK_[0-9]*/OBPK_1234/g /OBUNIQUE_[0-9]*/OBUNIQUE_1234/g /RECYCLE_\$_[0-9]*_[0-9]*_OBCHECK_[0-9]*/RECYCLE_$_1_2_OBCHECK_3/g /PCTFREE = [0-9]*/PCTFREE = 10/g
--replace_regex /REPLICA_NUM = [0-9]*/REPLICA_NUM = NUM/g /ROW_FORMAT = (DYNAMIC|COMPRESSED|COMPACT|REDUNDANT|CONDENSED)[ ]*//g /(NOCOMPRESS|COMPRESS) (FOR)*[ ]*(BASIC|OLTP|QUERY|ARCHIVE)*[ ]*//g /zstd_1\.3\.8/lz4_1.0/g /OBFK_[0-9]*/OBFK_1234/g /OBIDX_[0-9]*/OBIDX_1234/g /OBCHECK_[0-9]*/OBCHECK_1234/g /OBPK_[0-9]*/OBPK_1234/g /OBUNIQUE_[0-9]*/OBUNIQUE_1234/g /zone1;zone2/zone1/g /BLOCK_SIZE = [0-9]*/BLOCK_SIZE = SIZE/g /TABLET_SIZE = [0-9]*/TABLET_SIZE = SIZE/g /ZONE_LIST = \(.*\)/ZONE_LIST = (test)/g /PRIMARY_ZONE = .*/PRIMARY_ZONE = /g /PCTFREE = [0-9]*/PCTFREE = 10/g
#--disable_query_log
#--disable_result_log
connect (obsys_ydm,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys_ydm;
let $__i__= 600;
while($__i__ > 0)
{
sleep 1;
dec $__i__;
let $__forzen_version__ = query_get_value(select value from oceanbase.__all_zone where name = 'frozen_version', value, 1);
let $__merged_version__ = query_get_value(select value from oceanbase.__all_zone where name = 'last_merged_version' and zone = '', value, 1);
if($__forzen_version__ == $__merged_version__)
{
let $__i__ = -5;
}
}
###判断集群状态,先注释掉
#let $__j__= 180;
#while($__j__ > 0)
#{
# sleep 1;
# dec $__j__;
# let $__global_stat__ = query_get_value(select comment from oceanbase.__all_cluster_stat where name='global_stat',comment, 1);
# if($__global_stat__ == NORMAL)
# {
# let $__j__ = -5;
# }
#}
#if($__j__ != -5)
#{
# --echo major freeze failed
#}
if($__i__ != -5)
{
--echo major freeze failed
}
sleep 2;
disconnect obsys_ydm;
connection default;
--enable_query_log
--enable_result_log
--disable_warnings
drop table if exists t_h3_01_20;
drop table if exists t_h3_05_24;
drop table if exists t_h3_09_28;
drop table if exists t_h5_01_20;
drop table if exists t_h5_05_24;
drop table if exists t_h5_09_28;
drop table if exists t_r4_01_20;
drop table if exists t_r4_05_24;
drop table if exists t_r4_09_28;
drop table if exists t_r5_01_20;
drop table if exists t_r5_05_24;
drop table if exists t_r5_09_28;
drop table if exists t_h3_r4_01_20;
drop table if exists t_h3_r5_09_28;
drop table if exists t_h5_r4_01_20;
drop table if exists t_h5_r5_09_28;
drop table if exists t_refered;
drop table if exists t_h5_int;
drop table if exists t_r4_int;
drop table if exists t_r4_date;
drop table if exists t_r4_datetime;
drop table if exists t_r4_timestamp;
drop table if exists t_h5_r4_int_int;
drop table if exists t_h5_r4_int_int_datetime;
drop table if exists t_r4_h2_date_int;
drop table if exists t_r4_h3_date_int;
drop table if exists t_r4_h3_date_bigint;
drop table if exists tt;
drop table if exists t_many_range_part;
--enable_warnings
#--echo
#--echo ########### import time zone info ###########
--disable_query_log
--disable_result_log
--disable_warnings
connect (conn_admin_tz, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection conn_admin_tz;
select count(*) c1 from oceanbase.__all_tenant_time_zone;
select count(*) c1 from oceanbase.__all_tenant_time_zone_name;
select count(*) c1 from oceanbase.__all_tenant_time_zone_transition;
select count(*) c1 from oceanbase.__all_tenant_time_zone_transition_type;
delete from oceanbase.__all_tenant_time_zone;
delete from oceanbase.__all_tenant_time_zone_name;
delete from oceanbase.__all_tenant_time_zone_transition;
delete from oceanbase.__all_tenant_time_zone_transition_type;
alter system change tenant mysql ;
sleep 2;
--source mysql_test/test_suite/time_zone/t/time_zone_info.sql
sleep 10;
disconnect conn_admin_tz;
connection default;
--enable_query_log
--enable_result_log
--enable_warnings
set ob_query_timeout=1000000000;
--disable_warnings
drop database if exists px_test;
--enable_warnings
create database px_test;
use px_test;
# 场景:一个年级 6 个班,修了2门课,英语和数学
create table stu (
sid int,
name varchar(32),
cls int,
primary key (cls, sid)
) partition by hash(sid) partitions 6;
create table teacher (
tid int,
name varchar(32),
subject varchar(4),
primary key (tid)
) partition by hash(tid) partitions 8;
create table score (
sid int,
subject varchar(4),
score int,
primary key (sid, subject)
) partition by hash(sid) partitions 6;
insert into stu values
(11, 'a1', 1),
(12, 'b1', 1),
(13, 'c1', 1),
(21, 'a2', 2),
(22, 'b2', 2),
(31, 'a3', 3),
(41, 'a4', 4),
(42, 'b4', 4),
(51, 'a5', 5),
(52, 'b5', 5),
(61, 'a6', 6),
(62, 'b6', 6),
(63, 'c6', 6),
(64, 'd6', 6);
insert into teacher values
(1, 'Miss Zhang', 'EN'),
(2, 'Mr Wang', 'MA');
insert into score values
(11, 'EN', 60),
(12, 'EN', 70),
(13, 'EN', 80),
(21, 'EN', 58),
(22, 'EN', 90),
(31, 'EN', 80),
(41, 'EN', 80),
(42, 'EN', 90),
(51, 'EN', 89),
(52, 'EN', 99),
(61, 'EN', 100),
(62, 'EN', 90),
(63, 'EN', 99),
(64, 'EN', 87);
insert into score values
(11, 'MA', 60),
(12, 'MA', 70),
(13, 'MA', 80),
(21, 'MA', 58),
(22, 'MA', 90),
(31, 'MA', 80),
(41, 'MA', 80),
(42, 'MA', 90),
(51, 'MA', 89),
(52, 'MA', 99),
(61, 'MA', 100),
(62, 'MA', 90),
(63, 'MA', 99),
(64, 'MA', 87);
--disable_query_log
--disable_result_log
select * from stu;
select * from teacher;
select * from score;
--enable_query_log
--enable_result_log
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册