From c720aa9bec54a9406e45441f6b0c2a9c86a17857 Mon Sep 17 00:00:00 2001 From: shirley_zhengx Date: Fri, 26 Apr 2024 21:40:08 +0800 Subject: [PATCH] add testcase for forward_oldest_xmin --- ...ShareStorage_ForwardOldestXmin_Case0001.py | 145 ++++++++++++++ ...ShareStorage_ForwardOldestXmin_Case0002.py | 178 ++++++++++++++++++ ...ShareStorage_ForwardOldestXmin_Case0003.py | 162 ++++++++++++++++ ...ShareStorage_ForwardOldestXmin_Case0004.py | 139 ++++++++++++++ 4 files changed, 624 insertions(+) create mode 100644 sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0001.py create mode 100644 sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0002.py create mode 100644 sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0003.py create mode 100644 sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0004.py diff --git a/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0001.py b/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0001.py new file mode 100644 index 0000000000..78c8410bcc --- /dev/null +++ b/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0001.py @@ -0,0 +1,145 @@ +""" +Copyright (c) 2022 Huawei Technologies Co.,Ltd. + +openGauss is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + + http://license.coscl.org.cn/MulanPSL2 + +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +""" +""" +Case Type : 推进oldest_xmin +Case Name : 修改ss_txnstatus_cache_size参数,主节点写业务,备节点读业务; +Create At : 2024/4/24 +Owner : zhengxue +Description : + 1、查询ss_txnstatus_cache_size默认值,show ss_txnstatus_cache_size; + 2、修改ss_txnstatus_cache_size为最大值,gs_guc set -D {cluster/dn1} -c "ss_txnstatus_cache_size=524288",重启集群; + 3、运行tpcc业务,主节点写业务,备节点读业务; + 4、过程中查看tpcc是否存在; + 5、tpcc业务结束,查询集群状态; + 6、修改ss_txnstatus_cache_size为默认值,gs_guc set -D {cluster/dn1} -c "ss_txnstatus_cache_size=131072",重启集群; +Expect : + 1、显示默认值 + 2、参数修改成功; + 3、tpcc运行正常; + 4、tpcc进程存在; + 5、集群状态正常; + 6、恢复默认值成功; +History : +""" + +import os +import time +import unittest +from yat.test import Node +from yat.test import macro +from testcase.utils.Logger import Logger +from testcase.utils.Common import Common +from testcase.utils.CommonSH import CommonSH +from testcase.utils.Constant import Constant +from testcase.utils.ComThread import ComThread + +Primary_SH = CommonSH('PrimaryDbUser') +Primary_ROOTSH = CommonSH('PrimaryRoot') + +class SharedStorage(unittest.TestCase): + def setUp(self): + self.logger = Logger() + self.com = Common() + self.constant = Constant() + self.primaryRoot = Node('PrimaryRoot') + + self.logger.info("===Opengauss_Function_Guc_ForwardOldestXmin_Case0002开始执行===") + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + + self.assertTrue("Degraded" in status or "Normal" in status) + + self.txnstatus_cache_size_default = 131072 + self.txnstatus_cache_size_max = 524288 + self.txnstatus_cache_size = 'ss_txnstatus_cache_size' + + def test_guc(self): + self.logger.info("======step1:查询ss_txnstatus_cache_size,默认值为131072;expect:查询成功======") + show_ss_txnstatus_cache_size = Primary_SH.execut_db_sql('''show ss_txnstatus_cache_size;''') + self.logger.info(show_ss_txnstatus_cache_size) + self.assertEqual("131072", show_ss_txnstatus_cache_size.split("\n")[-2].strip()) + + step2 = '======step2:设置ss_txnstatus_cache_size为最大值;expect:设置成功======' + self.logger.info(step2) + result1 = Primary_SH.execute_gsguc( + 'set', self.constant.GSGUC_SUCCESS_MSG, + f'{self.txnstatus_cache_size}={self.txnstatus_cache_size_max}') + restart_res = Primary_SH.restart_db_cluster() + show_ss_txnstatus_cache_size = Primary_SH.execut_db_sql('''show ss_txnstatus_cache_size;''') + self.logger.info(show_ss_txnstatus_cache_size) + self.assertEqual("524288", show_ss_txnstatus_cache_size.split("\n")[-2].strip()) + + step3 = '======step3:运行tpcc业务;expect:tpcc进程运行======' + self.logger.info(step3) + primary_tpcc = ComThread(self.com.start_tpcc, + args=(self.primaryRoot,'/data/benchmarksql-5.0/run', + './runBenchmark.sh primary_write.pg')) + standby1_tpcc = ComThread(self.com.start_tpcc, + args=(self.primaryRoot, '/data/benchmarksql-5.0/run', + './runBenchmark.sh standby_read1.pg')) + standby2_tpcc = ComThread(self.com.start_tpcc, + args=(self.primaryRoot, '/data/benchmarksql-5.0/run', + './runBenchmark.sh standby_read2.pg')) + primary_tpcc.setDaemon(True) + standby1_tpcc.setDaemon(True) + standby2_tpcc.setDaemon(True) + primary_tpcc.start() + standby1_tpcc.start() + standby2_tpcc.start() + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('primary_write.pg', status, '执行失败' + step3) + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('standby_read1.pg', status, '执行失败' + step3) + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('standby_read2.pg', status, '执行失败' + step3) + time.sleep(10) + + step4 = "======step4:过程中查看tpcc是否存在;expect:tpcc进程运行======" + self.logger.info(step4) + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('primary_write.pg', status, '执行失败' + step4) + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('standby_read2.pg', status, '执行失败' + step4) + + primary_tpcc.join() + standby1_tpcc.join() + standby2_tpcc.join() + + step5 = "======step5:tpcc业务结束,查询集群状态;expect:集群状态正常======" + self.logger.info(step5) + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + self.assertIn('cluster_state : Normal', status, '执行失败' + step4) + res1 = status.splitlines()[-1].split('|')[0].split('6001')[-1] + res2 = status.splitlines()[-1].split('|')[1].split('6002')[-1] + res3 = status.splitlines()[-1].split('|')[2].split('6003')[-1] + self.assertIn('P Primary Normal', res1, '执行失败' + step5) + self.assertIn('S Standby Normal', res2, '执行失败' + step5) + self.assertIn('S Standby Normal', res3, '执行失败' + step5) + + def tearDown(self): + step6 = "======step6:环境清理,恢复参数;expect:环境清理成功,恢复参数成功======" + self.logger.info(step6) + + result1 = Primary_SH.execute_gsguc( + 'set', self.constant.GSGUC_SUCCESS_MSG, + f'{self.txnstatus_cache_size}={self.txnstatus_cache_size_default}') + restart_res = Primary_SH.restart_db_cluster() + show_txnstatus_cache_size = self.com.show_param(self.txnstatus_cache_size) + + self.logger.info("-----断言teardown-----") + self.assertEquals(show_txnstatus_cache_size, '131072', '执行失败' + step6) + self.logger.info(f"-----{os.path.basename(__file__)} end-----") + diff --git a/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0002.py b/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0002.py new file mode 100644 index 0000000000..cab80f1adc --- /dev/null +++ b/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0002.py @@ -0,0 +1,178 @@ +""" +Copyright (c) 2022 Huawei Technologies Co.,Ltd. + +openGauss is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + + http://license.coscl.org.cn/MulanPSL2 + +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +""" +""" +Case Type : 推进oldest_xmin +Case Name : 修改ss_txnstatus_cache_size,备节点重启加入; +Create At : 2024/4/24 +Owner : zhengxue +Description : + 1、查询ss_txnstatus_cache_size默认值,show ss_txnstatus_cache_size; + 2、修改ss_txnstatus_cache_size为262144,gs_guc set -D {cluster/dn1} -c "ss_txnstatus_cache_size=262144",重启集群; + 3、运行tpcc业务,主节点写业务,备节点读业务; + 4、备节点1踢出; + 5、查询集群状态; + 6、备节点重启加入; + 7、查询集群状态; + 8、修改ss_txnstatus_cache_size为默认值,gs_guc set -D {cluster/dn1} -c "ss_txnstatus_cache_size=131072",重启集群; +Expect : + 1、显示默认值ss_txnstatus_cache_stat + 2、参数修改成功; + 3、tpcc运行正常; + 4、备节点1踢出成功; + 5、集群状态degraded; + 6、备节点重启加入成功; + 7、集群状态正常; + 6、恢复默认值成功; +History : +""" + +import os +import time +import unittest +from yat.test import Node +from yat.test import macro +from testcase.utils.Logger import Logger +from testcase.utils.Common import Common +from testcase.utils.CommonSH import CommonSH +from testcase.utils.Constant import Constant +from testcase.utils.ComThread import ComThread + +Primary_SH = CommonSH('PrimaryDbUser') +Primary_ROOTSH = CommonSH('PrimaryRoot') + +class SharedStorage(unittest.TestCase): + def setUp(self): + self.logger = Logger() + self.com = Common() + self.constant = Constant() + self.primaryRoot = Node('PrimaryRoot') + + self.logger.info("===Opengauss_Function_Guc_ForwardOldestXmin_Case0002开始执行===") + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + + self.assertTrue("Degraded" in status or "Normal" in status) + + self.txnstatus_cache_size_default = 131072 + self.txnstatus_cache_size_set = 262144 + self.txnstatus_cache_size = 'ss_txnstatus_cache_size' + + def test_guc(self): + self.logger.info("======step1:查询ss_txnstatus_cache_size,默认值为131072;expect:查询成功======") + show_ss_txnstatus_cache_size = Primary_SH.execut_db_sql('''show ss_txnstatus_cache_size;''') + self.logger.info(show_ss_txnstatus_cache_size) + self.assertEqual("131072", show_ss_txnstatus_cache_size.split("\n")[-2].strip()) + + step2 = '======step2:设置ss_txnstatus_cache_size为最大值;expect:设置成功======' + self.logger.info(step2) + result1 = Primary_SH.execute_gsguc( + 'set', self.constant.GSGUC_SUCCESS_MSG, + f'{self.txnstatus_cache_size}={self.txnstatus_cache_size_set}') + restart_res = Primary_SH.restart_db_cluster() + show_ss_txnstatus_cache_size = Primary_SH.execut_db_sql('''show ss_txnstatus_cache_size;''') + self.logger.info(show_ss_txnstatus_cache_size) + self.assertEqual("262144", show_ss_txnstatus_cache_size.split("\n")[-2].strip()) + + step3 = '======step3:运行tpcc业务;expect:tpcc进程运行======' + self.logger.info(step3) + primary_tpcc = ComThread(self.com.start_tpcc, + args=(self.primaryRoot,'/data/benchmarksql-5.0/run', + './runBenchmark.sh primary_write.pg')) + standby1_tpcc = ComThread(self.com.start_tpcc, + args=(self.primaryRoot, '/data/benchmarksql-5.0/run', + './runBenchmark.sh standby_read1.pg')) + standby2_tpcc = ComThread(self.com.start_tpcc, + args=(self.primaryRoot, '/data/benchmarksql-5.0/run', + './runBenchmark.sh standby_read2.pg')) + primary_tpcc.setDaemon(True) + standby1_tpcc.setDaemon(True) + standby2_tpcc.setDaemon(True) + primary_tpcc.start() + standby1_tpcc.start() + standby2_tpcc.start() + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('primary_write.pg', status, '执行失败' + step3) + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('standby_read1.pg', status, '执行失败' + step3) + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('standby_read2.pg', status, '执行失败' + step3) + + step4 = "======step4:备节点1踢出;expect:踢出成功======" + self.logger.info(step4) + result = Primary_SH.exec_cm_ctl(mode='stop', param='-n 2') + self.logger.info(result) + self.assertIn('successfully', result, '执行失败' + step4) + + step5 = "======step5:查询集群状态;expect:集群状态正常======" + self.logger.info(step5) + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + self.assertIn('cluster_state : Degraded', status, '执行失败' + step5) + self.assertIn('S Down Unknown', + status.splitlines()[-1].split('|')[1].split('6002')[-1], + '执行失败' + step5) + + step6 = "======step6:备节点重启加入;expect:reform成功======" + self.logger.info(step6) + result = Primary_SH.exec_cm_ctl(mode='start', param='-n 2') + self.logger.info(result) + self.assertIn('successfully', result, '执行失败' + step6) + time.sleep(10) + + primary_tpcc.join() + standby1_tpcc.join() + standby2_tpcc.join() + + step7 = "======step7:tpcc业务结束,查询集群状态;expect:集群状态正常======" + self.logger.info(step7) + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + self.assertIn('cluster_state : Normal', status, '执行失败' + step7) + self.assertIn('P Primary Normal', + status.splitlines()[-1].split('|')[0].split('6001')[-1], + '执行失败' + step7) + self.assertIn('S Standby Normal', + status.splitlines()[-1].split('|')[1].split('6002')[-1], + '执行失败' + step7) + + + def tearDown(self): + step8 = "======step8:环境清理,恢复参数;expect:环境清理成功,恢复参数成功======" + self.logger.info(step8) + + result1 = Primary_SH.execute_gsguc( + 'set', self.constant.GSGUC_SUCCESS_MSG, + f'{self.txnstatus_cache_size}={self.txnstatus_cache_size_default}') + restart_res = Primary_SH.restart_db_cluster() + show_txnstatus_cache_size = self.com.show_param(self.txnstatus_cache_size) + + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + + self.logger.info("-----断言teardown-----") + self.assertEquals(show_txnstatus_cache_size, '131072', '执行失败' + step8) + self.assertIn('cluster_state : Normal', status, '执行失败' + step8) + self.assertIn('P Primary Normal', + status.splitlines()[-1].split('|')[0].split('6001')[-1], + '执行失败' + step8) + self.assertIn('S Standby Normal', + status.splitlines()[-1].split('|')[1].split('6002')[-1], + '执行失败' + step8) + self.assertIn('S Standby Normal', + status.splitlines()[-1].split('|')[2].split('6003')[-1], + '执行失败' + step8) + + self.logger.info(f"-----{os.path.basename(__file__)} end-----") + diff --git a/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0003.py b/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0003.py new file mode 100644 index 0000000000..e8e7255657 --- /dev/null +++ b/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0003.py @@ -0,0 +1,162 @@ +""" +Copyright (c) 2022 Huawei Technologies Co.,Ltd. + +openGauss is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + + http://license.coscl.org.cn/MulanPSL2 + +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +""" +""" +Case Type : 推进oldest_xmin +Case Name : 修改ss_txnstatus_cache_size,测试数据一致性; +Create At : 2024/4/24 +Owner : zhengxue +Description : + 1、查询ss_txnstatus_cache_size默认值,show ss_txnstatus_cache_size; + 2、设置参数; + 3、运行tpcc业务; + 4、备1执行一致性语句; + 5、查询集群状态; + 6、修改参数为默认值; +Expect : + 1、显示默认值ss_txnstatus_cache_stat + 2、参数修改成功; + 3、tpcc运行正常; + 4、一致性检查正常; + 5、集群状态正常; + 6、恢复默认值成功; +History : +""" + +import os +import time +import unittest +from yat.test import Node +from yat.test import macro +from testcase.utils.Logger import Logger +from testcase.utils.Common import Common +from testcase.utils.CommonSH import CommonSH +from testcase.utils.Constant import Constant +from testcase.utils.ComThread import ComThread + +Primary_SH = CommonSH('PrimaryDbUser') +Standby1_SH = CommonSH('Standby1DbUser') +Primary_ROOTSH = CommonSH('PrimaryRoot') + +class SharedStorage(unittest.TestCase): + def setUp(self): + self.logger = Logger() + self.com = Common() + self.constant = Constant() + self.primaryRoot = Node('PrimaryRoot') + + self.logger.info("===Opengauss_Function_Guc_ForwardOldestXmin_Case0002开始执行===") + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + + self.assertTrue("Degraded" in status or "Normal" in status) + + self.txnstatus_cache_size_default = 131072 + self.txnstatus_cache_size_set = 262144 + self.txnstatus_cache_size = 'ss_txnstatus_cache_size' + + def test_guc(self): + self.logger.info("======step1:查询ss_txnstatus_cache_size,默认值为131072;expect:查询成功======") + show_ss_txnstatus_cache_size = Primary_SH.execut_db_sql('''show ss_txnstatus_cache_size;''') + self.logger.info(show_ss_txnstatus_cache_size) + self.assertEqual("131072", show_ss_txnstatus_cache_size.split("\n")[-2].strip()) + + step2 = '======step2:设置参数;expect:设置成功======' + self.logger.info(step2) + set_enable_mergejoin = Standby1_SH.execut_db_sql('''set enable_mergejoin=off;''') + self.logger.info(set_enable_mergejoin) + self.assertIn("SET", set_enable_mergejoin, '执行失败' + step2) + set_enable_nestloop = Standby1_SH.execut_db_sql('''set enable_nestloop=off;''') + self.logger.info(set_enable_nestloop) + self.assertIn("SET", set_enable_nestloop, '执行失败' + step2) + + step3 = '======step3:运行tpcc业务;expect:tpcc进程运行======' + self.logger.info(step3) + primary_tpcc = ComThread(self.com.start_tpcc, + args=(self.primaryRoot,'/data/benchmarksql-5.0/run', + './runBenchmark.sh primary_write.pg')) + primary_tpcc.setDaemon(True) + primary_tpcc.start() + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('primary_write.pg', status, '执行失败' + step3) + + step4 = "======step4:备节点1执行一致性语句;expect:主备一致性正常======" + self.logger.info(step4) + consistence_res1 = Standby1_SH.execut_db_sql('''(Select w_id, w_ytd from bmsql_warehouse) + except(select d_w_id, sum(d_ytd) from bmsql_district group by d_w_id);''') + self.logger.info(consistence_res1) + self.assertIn('0 rows', consistence_res1.splitlines()[-1], '执行失败' + step4) + + consistence_res2 = Standby1_SH.execut_db_sql('''(Select d_w_id, d_id, D_NEXT_O_ID - 1 from bmsql_district) except + (select o_w_id, o_d_id, max(o_id) from bmsql_oorder group by o_w_id, o_d_id);''') + self.logger.info(consistence_res2) + self.assertIn('0 rows', consistence_res2.splitlines()[-1], '执行失败' + step4) + + consistence_res3 = Standby1_SH.execut_db_sql('''(Select d_w_id, d_id, D_NEXT_O_ID - 1 from bmsql_district) except + (select no_w_id, no_d_id, max(no_o_id) from bmsql_new_order group by no_w_id, no_d_id);''') + self.logger.info(consistence_res3) + self.assertIn('0 rows', consistence_res3.splitlines()[-1], '执行失败' + step4) + + consistence_res4 = Standby1_SH.execut_db_sql(''' + select * from (select (count(no_o_id)-(max(no_o_id)-min(no_o_id)+1)) as + diff from bmsql_new_order group by no_w_id, no_d_id) where diff != 0;''') + self.logger.info(consistence_res4) + self.assertIn('0 rows', consistence_res4.splitlines()[-1], '执行失败' + step4) + + consistence_res5 = Standby1_SH.execut_db_sql('''(select o_w_id, o_d_id, sum(o_ol_cnt) from bmsql_oorder + group by o_w_id, o_d_id) except (select ol_w_id, ol_d_id, count(ol_o_id) from bmsql_order_line + group by ol_w_id, ol_d_id);''') + self.logger.info(consistence_res5) + self.assertIn('0 rows', consistence_res5.splitlines()[-1], '执行失败' + step4) + + primary_tpcc.join() + + step5 = "======step5:tpcc业务结束,查询集群状态;expect:集群状态正常======" + self.logger.info(step5) + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + self.assertIn('cluster_state : Normal', status, '执行失败' + step5) + self.assertIn('P Primary Normal', + status.splitlines()[-1].split('|')[0].split('6001')[-1], + '执行失败' + step5) + self.assertIn('S Standby Normal', + status.splitlines()[-1].split('|')[1].split('6002')[-1], + '执行失败' + step5) + + def tearDown(self): + step6 = "======step6:环境清理,恢复参数;expect:环境清理成功,恢复参数成功======" + self.logger.info(step6) + + set_enable_mergejoin = Primary_SH.execut_db_sql('''set enable_mergejoin=on;''') + self.logger.info(set_enable_mergejoin) + self.assertIn("SET", set_enable_mergejoin, '执行失败' + step6) + set_enable_nestloop = Primary_SH.execut_db_sql('''set enable_nestloop=on;''') + self.logger.info(set_enable_nestloop) + self.assertIn("SET", set_enable_nestloop, '执行失败' + step6) + + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + self.assertIn('cluster_state : Normal', status, '执行失败' + step6) + self.assertIn('P Primary Normal', + status.splitlines()[-1].split('|')[0].split('6001')[-1], + '执行失败' + step6) + self.assertIn('S Standby Normal', + status.splitlines()[-1].split('|')[1].split('6002')[-1], + '执行失败' + step6) + self.assertIn('S Standby Normal', + status.splitlines()[-1].split('|')[2].split('6003')[-1], + '执行失败' + step6) + + self.logger.info(f"-----{os.path.basename(__file__)} end-----") + diff --git a/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0004.py b/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0004.py new file mode 100644 index 0000000000..6f13bf5132 --- /dev/null +++ b/sharestorage/testcase/FORWARD_OLDEST_XMIN/Opengauss_ShareStorage_ForwardOldestXmin_Case0004.py @@ -0,0 +1,139 @@ +""" +Copyright (c) 2022 Huawei Technologies Co.,Ltd. + +openGauss is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + + http://license.coscl.org.cn/MulanPSL2 + +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. +""" +""" +Case Type : 推进oldest_xmin +Case Name : 修改ss_txnstatus_cache_size,主节点故障,备节点failover; +Create At : 2024/4/24 +Owner : zhengxue +Description : + 1、查询ss_txnstatus_cache_size默认值,show ss_txnstatus_cache_size; + 2、修改ss_txnstatus_cache_size为262144,gs_guc set -D {cluster/dn1} -c "ss_txnstatus_cache_size=262144",重启集群; + 3、运行tpcc业务; + 4、主节点故障,备节点failover; + 5、查询集群状态; + 6、修改ss_txnstatus_cache_size为默认值,gs_guc set -D {cluster/dn1} -c "ss_txnstatus_cache_size=131072",重启集群; +Expect : + 1、显示默认值 + 2、参数修改成功; + 3、tpcc运行正常; + 4、failover成功; + 5、集群状态degraded; + 6、恢复默认值成功; +History : +""" + +import os +import time +import unittest +from yat.test import Node +from yat.test import macro +from testcase.utils.Logger import Logger +from testcase.utils.Common import Common +from testcase.utils.CommonSH import CommonSH +from testcase.utils.Constant import Constant +from testcase.utils.ComThread import ComThread + +Primary_SH = CommonSH('PrimaryDbUser') +Primary_ROOTSH = CommonSH('PrimaryRoot') + +class SharedStorage(unittest.TestCase): + def setUp(self): + self.logger = Logger() + self.com = Common() + self.constant = Constant() + self.primaryRoot = Node('PrimaryRoot') + + self.logger.info("===Opengauss_Function_Guc_ForwardOldestXmin_Case0002开始执行===") + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + + self.assertTrue("Degraded" in status or "Normal" in status) + + self.txnstatus_cache_size_default = 131072 + self.txnstatus_cache_size_set = 262144 + self.txnstatus_cache_size = 'ss_txnstatus_cache_size' + + def test_guc(self): + self.logger.info("======step1:查询ss_txnstatus_cache_size,默认值为131072;expect:查询成功======") + show_ss_txnstatus_cache_size = Primary_SH.execut_db_sql('''show ss_txnstatus_cache_size;''') + self.logger.info(show_ss_txnstatus_cache_size) + self.assertEqual("131072", show_ss_txnstatus_cache_size.split("\n")[-2].strip()) + + step2 = '======step2:设置ss_txnstatus_cache_size为最大值;expect:设置成功======' + self.logger.info(step2) + result1 = Primary_SH.execute_gsguc( + 'set', self.constant.GSGUC_SUCCESS_MSG, + f'{self.txnstatus_cache_size}={self.txnstatus_cache_size_set}') + restart_res = Primary_SH.restart_db_cluster() + show_ss_txnstatus_cache_size = Primary_SH.execut_db_sql('''show ss_txnstatus_cache_size;''') + self.logger.info(show_ss_txnstatus_cache_size) + self.assertEqual("262144", show_ss_txnstatus_cache_size.split("\n")[-2].strip()) + + step3 = '======step3:运行tpcc业务;expect:tpcc进程运行======' + self.logger.info(step3) + primary_tpcc = ComThread(self.com.start_tpcc, + args=(self.primaryRoot,'/data/benchmarksql-5.0/run', + './runBenchmark.sh primary_write.pg')) + primary_tpcc.setDaemon(True) + primary_tpcc.start() + status = Primary_ROOTSH.exec_cmd_under_root("ps -ux | grep './runBenchmark.sh' | grep -v -- '--color'") + self.assertIn('primary_write.pg', status, '执行失败' + step3) + + step4 = "======step4:主节点故障,备节点failover;expect:failover成功======" + self.logger.info(step4) + result_failover = Primary_SH.exec_failover() + self.logger.info(result_failover) + self.assertIn('kill done', result_failover, '执行失败' + step4) + time.sleep(60) + + primary_tpcc.join() + + step5 = "======step5:tpcc业务结束,查询集群状态;expect:集群状态degraded======" + self.logger.info(step5) + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + self.assertIn('cluster_state : Degraded', status, '执行失败' + step5) + + def tearDown(self): + step6 = "======step6:环境清理,恢复参数;expect:环境清理成功,恢复参数成功======" + self.logger.info(step6) + + result1 = Primary_SH.execute_gsguc( + 'set', self.constant.GSGUC_SUCCESS_MSG, + f'{self.txnstatus_cache_size}={self.txnstatus_cache_size_default}') + restart_res = Primary_SH.restart_db_cluster() + show_txnstatus_cache_size = self.com.show_param(self.txnstatus_cache_size) + self.assertEquals(show_txnstatus_cache_size, '131072', '执行失败' + step6) + + recovery = Primary_SH.exec_cm_ctl(mode='switchover', param='-a') + self.logger.info(recovery) + self.assertIn(self.constant.cm_switchover_success_msg, recovery, + '执行失败' + step6) + + status = Primary_SH.exec_cm_ctl(mode='query', param='-Cv') + self.logger.info(status) + self.assertIn('cluster_state : Normal', status, '执行失败' + step6) + self.assertIn('P Primary Normal', + status.splitlines()[-1].split('|')[0].split('6001')[-1], + '执行失败' + step6) + self.assertIn('S Standby Normal', + status.splitlines()[-1].split('|')[1].split('6002')[-1], + '执行失败' + step6) + self.assertIn('S Standby Normal', + status.splitlines()[-1].split('|')[2].split('6003')[-1], + '执行失败' + step6) + + self.logger.info(f"-----{os.path.basename(__file__)} end-----") + -- Gitee