diff --git a/openGaussBase/expect/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0002 b/openGaussBase/expect/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0002 index 969389bd03280aeaec216efe81129f7000521cbb..f22a21a453d6dbe737e25f1ba21c8ec8d196cb97 100644 --- a/openGaussBase/expect/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0002 +++ b/openGaussBase/expect/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0002 @@ -4,19 +4,18 @@ @connect; CONNECT SUCCESS --step1:show collation验证列名大写 expect:区分大小写 -show collation like 'aa_DJ'; -+-----------+---------+-------+---------+----------+---------+ -| collation | charset | id | default | compiled | sortlen | -+-----------+---------+-------+---------+----------+---------+ -?.*aa_DJ.* -?.*aa_DJ.* -+-----------+---------+-------+---------+----------+---------+ -show collation like 'aa_dj'; +show collation like 'zh_CN.utf8'; ++------------+---------+-------+---------+----------+---------+ +| collation | charset | id | default | compiled | sortlen | ++------------+---------+-------+---------+----------+---------+ +?.*zh_CN.utf8.*utf8.* ++------------+---------+-------+---------+----------+---------+ +show collation like 'zh_cn.utf8'; +-----------+---------+----+---------+----------+---------+ | collation | charset | id | default | compiled | sortlen | +-----------+---------+----+---------+----------+---------+ +-----------+---------+----+---------+----------+---------+ -show collation like 'AA_DJ'; +show collation like 'ZH_CN.utf8'; +-----------+---------+----+---------+----------+---------+ | collation | charset | id | default | compiled | sortlen | +-----------+---------+----+---------+----------+---------+ diff --git a/openGaussBase/expect/PROCEDURE/PROC_BINARY/Opengauss_Function_Procedure_Binary_Case0004 b/openGaussBase/expect/PROCEDURE/PROC_BINARY/Opengauss_Function_Procedure_Binary_Case0004 index e759eb73da898be010604edc35b3c5832915accc..b8fded88b81a1b68667501a885b9fcff4cfbc703 100644 --- a/openGaussBase/expect/PROCEDURE/PROC_BINARY/Opengauss_Function_Procedure_Binary_Case0004 +++ b/openGaussBase/expect/PROCEDURE/PROC_BINARY/Opengauss_Function_Procedure_Binary_Case0004 @@ -1,3 +1,5 @@ +-- @owner: buter +-- @date: 2021-10-12 -- @testpoint: 存储过程二进制类型的测试 测试raw类型和blob的转换 drop table if exists proc_binary_table_004; SQL SUCCESS @@ -56,21 +58,35 @@ SQL SUCCESS --更新表中数据 update proc_binary_table_004 set t2=t3 where t3 is not null; SQL SUCCESS -select * from proc_binary_table_004; -?.* -?.* t1 .* t2 .* t3 .* -?.* -?.* 1 .* 01FABD011365489000 .* -?.* +select rawtohex(t2),t3 from proc_binary_table_004; ++--------------------+--------------------+ +| rawtohex | t3 | ++--------------------+--------------------+ +| 01FABD011365489000 | 01FABD011365489000 | ++--------------------+--------------------+ --删除表中t3lie alter table proc_binary_table_004 drop column t3; SQL SUCCESS -select * from proc_binary_table_004; -?.* -?.* t1 .* t2 .* -?.* -?.* 1 .* -?.* +--查看表结构 +SELECT attname AS column_name, + format_type(atttypid, atttypmod) AS data_type, + attnotnull AS is_not_null +FROM pg_catalog.pg_attribute +WHERE attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname = 'proc_binary_table_004') + AND attnum > 0; ++------------------------------+-----------+-------------+ +| column_name | data_type | is_not_null | ++------------------------------+-----------+-------------+ +| t1 | integer | false | +| t2 | blob | false | +| ........pg.dropped.3........ | - | false | ++------------------------------+-----------+-------------+ +select rawtohex(t2) from proc_binary_table_004; ++--------------------+ +| rawtohex | ++--------------------+ +| 01FABD011365489000 | ++--------------------+ --清理环境 drop table if exists proc_binary_table_004; SQL SUCCESS diff --git a/openGaussBase/testcase/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0001.py b/openGaussBase/testcase/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0001.py index b09eb33a16e03762d84fa2753e79a0c00c6e4703..006197f0a09c1c536cb90aa0ecc22c8c3b2a96ca 100644 --- a/openGaussBase/testcase/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0001.py +++ b/openGaussBase/testcase/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0001.py @@ -41,17 +41,17 @@ class ShowCollation(unittest.TestCase): res = self.pri_b_sh.execut_db_sql(cmd) self.log.info(res) self.assertTrue('ERROR' not in res - and 'uz_UZ.iso88591' in res - and 'tl_PH.iso88591' in res, '执行失败' + text) + and 'zh_HK.utf8' in res + and 'zh_CN.utf8' in res, '执行失败' + text) text = '-----step2:使用查询到的字符序建库 expect:成功-----' self.log.info(text) cmd = """ set dolphin.b_compatibility_mode = off; drop database if exists test_database_001a; - create database test_database_001a with lc_collate 'uz_UZ.iso88591'; + create database test_database_001a with lc_collate 'zh_HK.utf8'; drop database if exists test_database_001b; - create database test_database_001b with lc_collate 'tl_PH.iso88591'; + create database test_database_001b with lc_collate 'zh_CN.utf8'; """ self.log.info(cmd) res = self.pri_b_sh.execut_db_sql(cmd) diff --git a/openGaussBase/testcase/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0002.sql b/openGaussBase/testcase/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0002.sql index 94bbc6acfacb5e4e825e9c540448df457bb3d7de..3e4f294fadccf498a7bc225041532046dd019caf 100644 --- a/openGaussBase/testcase/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0002.sql +++ b/openGaussBase/testcase/COMPATIBILITY/SHOW_COLLATION/Opengauss_Compatibility_Show_Collation_Case0002.sql @@ -3,8 +3,8 @@ -- @testpoint: like区分大小写 @conn PrimaryDbBmode; --step1:show collation验证列名大写 expect:区分大小写 -show collation like 'aa_DJ'; -show collation like 'aa_dj'; -show collation like 'AA_DJ'; +show collation like 'zh_CN.utf8'; +show collation like 'zh_cn.utf8'; +show collation like 'ZH_CN.utf8'; --step2:无需清理环境 \ No newline at end of file diff --git a/openGaussBase/testcase/PROCEDURE/PROC_BINARY/Opengauss_Function_Procedure_Binary_Case0004.sql b/openGaussBase/testcase/PROCEDURE/PROC_BINARY/Opengauss_Function_Procedure_Binary_Case0004.sql index 5f647d15aba5f8c28fd605aebf1d2222677e28d3..c65138fb8fcfbfc277cce31a8b6fa3944f3803ca 100644 --- a/openGaussBase/testcase/PROCEDURE/PROC_BINARY/Opengauss_Function_Procedure_Binary_Case0004.sql +++ b/openGaussBase/testcase/PROCEDURE/PROC_BINARY/Opengauss_Function_Procedure_Binary_Case0004.sql @@ -1,3 +1,5 @@ +-- @owner: buter +-- @date: 2021-10-12 -- @testpoint: 存储过程二进制类型的测试 测试raw类型和blob的转换 drop table if exists proc_binary_table_004; @@ -35,11 +37,19 @@ alter table proc_binary_table_004 modify t2 blob; --更新表中数据 update proc_binary_table_004 set t2=t3 where t3 is not null; -select * from proc_binary_table_004; +select rawtohex(t2),t3 from proc_binary_table_004; --删除表中t3lie alter table proc_binary_table_004 drop column t3; -select * from proc_binary_table_004; +--查看表结构 +SELECT attname AS column_name, + format_type(atttypid, atttypmod) AS data_type, + attnotnull AS is_not_null +FROM pg_catalog.pg_attribute +WHERE attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname = 'proc_binary_table_004') + AND attnum > 0; + +select rawtohex(t2) from proc_binary_table_004; --清理环境 drop table if exists proc_binary_table_004; diff --git a/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0008.py b/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0008.py index 03165245d1413e20c629d903ceebeafde24dcaac..eb121aa8d0c66c0b0e418d997b2c6b0023f9cc5b 100644 --- a/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0008.py +++ b/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0008.py @@ -310,7 +310,7 @@ class Tools(unittest.TestCase): expan_result = self.primary_root_node.sh(expansion_cmd).result() self.log.info(expan_result) error_msg = f'The IP address is invalid.' \ - f'The IP address is: {err_host} Please check it.' + f'The IP address is: {err_host}. Please check it.' self.assertIn(error_msg, expan_result, text + '执行事变') text = '----step9:执行gs_expansion进行备机扩容,xml文件不存在 expect:失败' diff --git a/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0060.py b/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0060.py index 75416bec55ec05aa63ceff41d17c4ba16e1cd36d..3110ee8509413a492b1b9b1f7e979deb519bed3a 100644 --- a/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0060.py +++ b/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0060.py @@ -22,6 +22,7 @@ import re import unittest from yat.test import macro +from yat.test import Node from testcase.utils.Common import Common from testcase.utils.CommonSH import CommonSH @@ -36,10 +37,14 @@ Node_Num = Pri_U_SH.get_node_num() class GsExpansion60(unittest.TestCase): def setUp(self): self.sh = {'pri_root': CommonSH('PrimaryRoot'), + 'pri_user': CommonSH('PrimaryDbUser'), 'sta1_user': CommonSH('Standby1DbUser'), 'sta2_user': CommonSH('Standby2DbUser'), 'sta1_root': CommonSH('Standby1Root'), 'sta2_root': CommonSH('Standby2Root')} + self.pri_node_root = Node('PrimaryRoot') + self.standby1_node_root = Node('Standby1Root') + self.standby2_node_root = Node('Standby2Root') self.log = Logger() self.cons = Constant() self.com = Common() @@ -60,11 +65,9 @@ class GsExpansion60(unittest.TestCase): f'tar -xf openGauss-Package-bak*.tar.gz && ' \ f'ls {macro.DB_SCRIPT_PATH}|grep gs_sshexkey' self.log.info(cmd) - res = self.com.get_sh_result(self.sh.get("pri_root").node, cmd) + res = self.com.get_sh_result(self.sh.get("pri_user").node, cmd) self.assertEqual(res, 'gs_sshexkey', f'执行失败: {text}') - - text = '----前置操作: 建立root互信 expect: 成功----' - self.log.info(text) + text = '----前置操作: 建立互信 expect: 成功----' del_cmd = f"rm -rf {os.path.join('~', '.ssh', '*')}" self.result = (self.com.get_sh_result(self.sh.get('pri_root').node, del_cmd), @@ -73,16 +76,21 @@ class GsExpansion60(unittest.TestCase): self.com.get_sh_result(self.sh.get('sta2_root').node, del_cmd)) self.log.info(self.result) - self.assertEqual({''}, set(self.result), 'root互信删除失败') + self.assertEqual({''}, set(self.result), '互信删除失败') self.hosts = (self.sh.get("pri_root").node.ssh_host, self.sh.get("sta1_user").node.ssh_host, self.sh.get("sta2_user").node.ssh_host) self.params = {'-f': 'expansion_28_hosts'} - res = self.sh['pri_root'].exec_gs_sshexkey(macro.DB_SCRIPT_PATH, + res = self.sh['pri_user'].exec_gs_sshexkey(macro.DB_SCRIPT_PATH, *self.hosts, **self.params) self.assertIn('Successfully created SSH trust', res, f'执行失败: {text}') + self.expansion_cmd = f'cd {macro.DB_SCRIPT_PATH};' \ + f'source {macro.DB_ENV_PATH}\n' \ + f'./gs_expansion -U {Pri_U_SH.node.ssh_user} ' \ + f'-G {Pri_U_SH.node.ssh_user} -X {macro.DB_XML_PATH} ' \ + f'-h {self.sh.get("sta2_user").node.ssh_host} -L' def test_1(self): text = '----step1: 一主两备减容一备 expect: 成功----' @@ -113,13 +121,8 @@ class GsExpansion60(unittest.TestCase): text = '----step3: 执行扩容流程 expect: 成功----' self.log.info(text) - self.expansion_cmd = f'cd {macro.DB_SCRIPT_PATH};' \ - f'source {macro.DB_ENV_PATH}\n' \ - f'./gs_expansion -U {Pri_U_SH.node.ssh_user} ' \ - f'-G {Pri_U_SH.node.ssh_user} -X {macro.DB_XML_PATH} ' \ - f'-h {self.sh.get("sta2_user").node.ssh_host} -L' self.log.info(self.expansion_cmd) - res = self.com.get_sh_result(self.sh.get("pri_root").node, + res = self.com.get_sh_result(self.sh.get("pri_user").node, self.expansion_cmd) expect = 'Expansion results:.*:.*Success.*Expansion Finish.' regex_res = re.search(expect, res, re.S) @@ -142,13 +145,13 @@ class GsExpansion60(unittest.TestCase): regex_res = re.findall('(instance_state.*:.*Normal)', res) self.log.info(regex_res) if len(regex_res) != Node_Num: - text = '----建立root互信,执行扩容----' + text = '----建立互信,执行扩容----' self.log.info(text) - ssh_res = self.sh['pri_root'].exec_gs_sshexkey( + ssh_res = self.sh['pri_user'].exec_gs_sshexkey( macro.DB_SCRIPT_PATH, *self.hosts, **self.params) self.log.info(self.expansion_cmd) - res = self.com.get_sh_result(self.sh.get("pri_root").node, + res = self.com.get_sh_result(self.sh.get("pri_user").node, self.expansion_cmd) expect = 'Expansion results:.*:.*Success.*Expansion Finish.' diff --git a/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0061.py b/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0061.py index cb16e043065cc2e0888ae9b152b653077849f22f..638df8276f66a8f5c9b66952acd25d3eab547efe 100644 --- a/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0061.py +++ b/openGaussBase/testcase/TOOLS/INTERNAL_TOOLS/gs_expansion/Opengauss_Function_Tools_Gs_Expansion_Case0061.py @@ -10,15 +10,17 @@ Description : Expect : 1、缩容成功 2、准备XML成功 - 3、运行报错,提示不是root用户执行 + 3、执行成功 History : 2022-04-27 opentestcase022 因多任务并行可能存在执行扩容前root互信被删除的情况,故在teardown中增加建互信扩容以恢复环境 + 2024-12-29 lonely-dance 支持以个人用户执行扩容 """ import os import re import unittest from yat.test import macro +from yat.test import Node from testcase.utils.Common import Common from testcase.utils.CommonSH import CommonSH @@ -33,13 +35,17 @@ Node_Num = Pri_U_SH.get_node_num() class GsExpansion61(unittest.TestCase): def setUp(self): self.sh = {'pri_root': CommonSH('PrimaryRoot'), + 'pri_user': CommonSH('PrimaryDbUser'), 'sta1_user': CommonSH('Standby1DbUser'), 'sta2_user': CommonSH('Standby2DbUser')} + self.pri_sh_user = CommonSH('PrimaryDbUser') + self.pri_node_root = Node('PrimaryRoot') + self.standby1_node_root = Node('Standby1Root') + self.standby2_node_root = Node('Standby2Root') self.log = Logger() self.cons = Constant() self.com = Common() - self.script_path = os.path.join(os.path.dirname( - macro.DB_INSTANCE_PATH), 'tool', 'script') + self.script_path = macro.DB_SCRIPT_PATH text = f'-----{os.path.basename(__file__)} start-----' self.log.info(text) @@ -54,10 +60,10 @@ class GsExpansion61(unittest.TestCase): text = '----前置操作: 数据库主机解压安装包,以免找不到扩容脚本 expect: 成功----' self.log.info(text) cmd = f'cd {os.path.dirname(macro.DB_SCRIPT_PATH)} && ' \ - f'tar -xf openGauss-Package-bak*.tar.gz && ' \ - f'ls {macro.DB_SCRIPT_PATH}|grep gs_sshexkey' + f'tar -xf openGauss-Package-bak*.tar.gz && ' \ + f'ls {macro.DB_SCRIPT_PATH}|grep gs_sshexkey' self.log.info(cmd) - res = self.com.get_sh_result(self.sh.get("pri_root").node, cmd) + res = self.com.get_sh_result(self.sh.get("pri_user").node, cmd) self.assertEqual(res, 'gs_sshexkey', f'执行失败: {text}') text = '----前置操作: 建立root互信 expect: 成功----' @@ -66,7 +72,7 @@ class GsExpansion61(unittest.TestCase): self.sh.get("sta1_user").node.ssh_host, self.sh.get("sta2_user").node.ssh_host) self.params = {'-f': 'expansion_28_hosts'} - res = self.sh['pri_root'].exec_gs_sshexkey(macro.DB_SCRIPT_PATH, + res = self.sh['pri_user'].exec_gs_sshexkey(macro.DB_SCRIPT_PATH, *self.hosts, **self.params) self.assertIn('Successfully created SSH trust', res, @@ -98,8 +104,8 @@ class GsExpansion61(unittest.TestCase): text = '----step3.1: 数据库主机解压安装包,以免找不到扩容脚本 expect: 成功----' self.log.info(text) cmd = f'cd {os.path.dirname(self.script_path)} && ' \ - f'tar -xf openGauss-Package-bak*.tar.gz && ' \ - f'ls {self.script_path}|grep gs_sshexkey' + f'tar -xf openGauss-Package-bak*.tar.gz && ' \ + f'ls {self.script_path}|grep gs_sshexkey' self.log.info(cmd) res = self.com.get_sh_result(Pri_U_SH.node, cmd) self.assertEqual(res, 'gs_sshexkey', f'执行失败: {text}') @@ -107,41 +113,50 @@ class GsExpansion61(unittest.TestCase): cmd = cmd.replace(os.path.dirname(self.script_path), os.path.dirname(macro.DB_SCRIPT_PATH)) self.log.info(cmd) - res = self.com.get_sh_result(self.sh.get("pri_root").node, cmd) + res = self.com.get_sh_result(self.sh.get("pri_user").node, cmd) self.assertEqual(res, 'gs_sshexkey', f'执行失败: {text}') - text = '----step3.2: 以个人用户执行扩容 expect: 运行报错,提示不是root用户执行----' + text = '----step3.2: 以个人用户执行扩容 expect: 扩容成功----' self.log.info(text) self.expansion_cmd = f'cd {self.script_path};' \ - f'source {macro.DB_ENV_PATH}\n' \ - f'./gs_expansion -U {Pri_U_SH.node.ssh_user} ' \ - f'-G {Pri_U_SH.node.ssh_user} -X {macro.DB_XML_PATH} ' \ - f'-h {self.sh.get("sta2_user").node.ssh_host} -L' + f'source {macro.DB_ENV_PATH}\n' \ + f'./gs_expansion -U {Pri_U_SH.node.ssh_user} ' \ + f'-G {Pri_U_SH.node.ssh_user} -X {macro.DB_XML_PATH} ' \ + f'-h {self.sh.get("sta2_user").node.ssh_host} -L' self.log.info(self.expansion_cmd) res = self.com.get_sh_result(Pri_U_SH.node, self.expansion_cmd) - expect = 'Only a user with the root permission can run this script' + expect = 'Success' self.assertIn(expect, res, f'执行失败: {text}') def tearDown(self): text = '----run teardown----' self.log.info(text) - text1 = '----后置操作: 建立root互信 expect: 成功----' - self.log.info(text1) - res1 = self.sh['pri_root'].exec_gs_sshexkey(macro.DB_SCRIPT_PATH, - *self.hosts, - **self.params) - - text2 = '----后置操作: 扩容备机恢复集群 expect: 成功----' - self.log.info(text2) - self.expansion_cmd = self.expansion_cmd.replace(self.script_path, - macro.DB_SCRIPT_PATH) - self.log.info(self.expansion_cmd) - res2 = self.com.get_sh_result(self.sh.get("pri_root").node, - self.expansion_cmd) - expect = 'Expansion results:.*:.*Success.*Expansion Finish.' - regex_res2 = re.search(expect, res2, re.S) + text = '----查看节点数量----' + self.log.info(text) + status_res = self.pri_sh_user.get_db_cluster_status(param="detail") + num = status_res.count('Normal') + self.log.info(num) + if num < 4: + text1 = '----后置操作: 建立root互信 expect: 成功----' + self.log.info(text1) + res1 = self.sh['pri_user'].exec_gs_sshexkey(macro.DB_SCRIPT_PATH, + *self.hosts, + **self.params) + + text2 = '----后置操作: 扩容备机恢复集群 expect: 成功----' + self.log.info(text2) + self.expansion_cmd = self.expansion_cmd.replace(self.script_path, + macro.DB_SCRIPT_PATH) + self.log.info(self.expansion_cmd) + res2 = self.com.get_sh_result(self.sh.get("pri_user").node, + self.expansion_cmd) + expect = 'Expansion results:.*:.*Success.*Expansion Finish.' + regex_res2 = re.search(expect, res2, re.S) + self.assertIn('Successfully created SSH trust', res1, + f'执行失败: {text1}') + self.assertIsNotNone(regex_res2, f'执行失败: {text2}') text3 = f'----检查集群状态是否正常----' self.log.info(text3) @@ -149,10 +164,6 @@ class GsExpansion61(unittest.TestCase): self.log.info(res3) regex_res3 = re.findall('(instance_state.*:.*Normal)', res3) self.log.info(regex_res3) - - self.assertIn('Successfully created SSH trust', res1, - f'执行失败: {text1}') - self.assertIsNotNone(regex_res2, f'执行失败: {text2}') self.assertEqual(len(regex_res3), Node_Num, f'执行失败: {text3}') text = f'-----{os.path.basename(__file__)} end-----'