本文整理汇总了Python中mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility.remove_standby方法的典型用法代码示例。如果您正苦于以下问题:Python GpUtility.remove_standby方法的具体用法?Python GpUtility.remove_standby怎么用?Python GpUtility.remove_standby使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility
的用法示例。
在下文中一共展示了GpUtility.remove_standby方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PromoteTestCase
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility import remove_standby [as 别名]
class PromoteTestCase(MPPTestCase):
'''testcase for gpstart'''
def __init__(self,methodName):
self.pgutil = GpUtility()
super(PromoteTestCase,self).__init__(methodName)
def setUp(self):
self.pgutil.check_and_start_gpdb()
# We should forcibly recreate standby, as it might has been promoted.
self.pgutil.remove_standby()
self.pgutil.install_standby()
def tearDown(self):
self.pgutil.remove_standby()
def test_promote_incomplete_stdby(self):
'''
remove the standby base dir, try promote and check if fail
'''
gpactivate_stdby = GpactivateStandby()
gpinit_stdby = GpinitStandby()
stdby_mdd = gpactivate_stdby.get_standby_dd()
stdby_host = gpinit_stdby.get_standbyhost()
stdby_port = gpactivate_stdby.get_standby_port()
destDir = os.path.join(stdby_mdd, 'base')
self.pgutil.clean_dir(stdby_host,destDir)
promote_cmd = "pg_ctl promote -D %s"%stdby_mdd
(rc, output) = gpactivate_stdby.run_remote(stdby_host,promote_cmd ,stdby_port,stdby_mdd)
self.assertEqual(rc, 0)
pid = self.pgutil.get_pid_by_keyword(host=stdby_host, pgport=stdby_port, keyword='master', option='bin')
self.assertTrue(int(pid) == -1, 'incomplete standby data directory promote succeeds.')
示例2: GpstopTestCase
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility import remove_standby [as 别名]
class GpstopTestCase(MPPTestCase):
'''testcase for gpstart'''
origin_mdd = os.environ.get('MASTER_DATA_DIRECTORY')
def __init__(self,methodName):
self.gputil = GpUtility()
super(GpstopTestCase,self).__init__(methodName)
def setUp(self):
self.gputil.check_and_start_gpdb()
stdby_presence = self.gputil.check_standby_presence()
if stdby_presence:
self.gputil.remove_standby()
self.gputil.install_standby()
def tearDown(self):
self.gputil.remove_standby()
self.gputil.run('gpstart -a')
self.gputil.run('gprecoverseg -a')
def test_gpstop_from_master(self):
self.assertTrue(self.gputil.gpstop_and_verify())
self.gputil.run('gpstart -a')
def test_gpstop_master_only(self):
self.assertTrue(self.gputil.gpstop_and_verify(option = '-m'))
self.gputil.run('gpstart -a')
def test_gpstop_fast(self):
#run transactions, and stop fast, check if transaction aborted, and the cluster was stopped
self.assertTrue(self.gputil.gpstop_and_verify(option = '-M fast'))
self.gputil.run('gpstart -a')
def test_gpstop_immediate(self):
self.assertTrue(self.gputil.gpstop_and_verify(option = '-M immediate'))
self.gputil.run('gpstart -a')
def test_gpstop_smart(self):
self.assertTrue(self.gputil.gpstop_and_verify(option = '-M smart'))
self.gputil.run('gpstart -a')
def test_gpdb_restart(self):
self.assertTrue(self.gputil.gpstop_and_verify('-r'))
def test_gpdb_reload(self):
self.assertTrue(self.gputil.gpstop_and_verify('-u'))
def test_gpstop_except_stdby(self):
self.assertTrue(self.gputil.gpstop_and_verify('-y'))
self.gputil.run('gpstart -y')
def test_gpstop_after_failover(self):
tinctest.logger.info("test gpstop from new master after failover")
activatestdby = GpactivateStandby()
standby_host = activatestdby.get_current_standby()
standby_port = activatestdby.get_standby_port()
standby_mdd = activatestdby.get_standby_dd()
activatestdby.activate()
(rc,stdout)=activatestdby.run_remote(standby_host, rmt_cmd='gpstop -a -M fast',
pgport=standby_port,standbydd=standby_mdd)
self.assertEqual(0,rc)
activatestdby.run_remote(standby_host, rmt_cmd='gpstart -a',
pgport=standby_port,
standbydd=standby_mdd)
self.gputil.failback_to_original_master(self.origin_mdd, standby_host, standby_mdd, standby_port)
示例3: test_tli_mismatch
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility import remove_standby [as 别名]
def test_tli_mismatch(self):
"""
Test to verify if TLI mismatch issue during Pass 3 of xlog record
(checkpoint) replay occurs or not. A set of checkpoints one after
the other when replayed on the standby and then if the
standby is promoted, it should go through the prmotion just fine.
The flow of this test is as follows.
1. Initiate the Standby using the Master (primary) postmaster
paramerters.
2. Perform explicit checkpoints and wait so that they get replicated.
3. Then promote the standby, wait and then try to access it.
4. If we can successfuly access it, its a Pass otherwise a Fail.
"""
PSQL.run_sql_command('DROP table if exists foo')
PSQL.run_sql_command('create table foo (a int)')
PSQL.run_sql_command('insert into foo '
'select * from generate_series(1, 1000)')
# Initial setup, forcibly remove standby and install new one
pgutil = GpUtility()
pgutil.remove_standby()
logger.info ('\nCreate a standby...')
res = self.standby.create()
self.assertEqual(res, 0)
res = self.standby.start()
self.assertTrue(res.wasSuccessful())
# Wait for the walreceiver to start
num_walsender = self.wait_for_walsender()
self.assertEqual(num_walsender, 1)
logger.info('Standby activated...')
logger.info('Give the standby some time to catchup...')
time.sleep(3)
logger.info('Create checkpoints and let them get replicated...')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
PSQL.run_sql_command('checkpoint')
time.sleep(2)
# Promote standby
# We don't kill/stop the primary, as it's convenient for
# next testing
logger.info('Promote the standby immediatly')
self.standby.promote()
logger.info('Wait for the standby to be ready to accept connections ...')
time.sleep(3)
# Verify the result replicated to the standby.
logger.info('Verify if table foo exists...')
proc = self.run_sql('select count(*) from foo',
str(self.standby.port))
# The table should exist
stdout = proc.communicate()[0]
logger.info(stdout)
search = "1000"
self.assertTrue(stdout.find(search) >= 0)
logger.info('Pass')
示例4: WalReplKillProcessTestCase
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility import remove_standby [as 别名]
#.........这里部分代码省略.........
tinctest.logger.info("local path for backend.sql is %s"%local_path(''))
for file in os.listdir(local_path('')):
if fnmatch.fnmatch(file,'backend.sql'):
PSQL.run_sql_file(local_path(file))
def get_down_segment(self):
query = 'select * from gp_segment_configuration where mode <> \'s\' and status <>\'u\''
result = PSQL.run_sql_command(query, flags = '-q -t', dbname='template1')
return result.strip()
def check_gpdb_status(self):
down_segments = self.get_down_segment()
self.assertEqual(down_segments,'')
def gpstart_helper(self):
'''helper method to run in scenario test'''
(rc, result) = self.pgutil.run('gpstart -a')
self.assertIn(rc,(0,1))
def gpstop_helper(self):
'''helper method to run in scenario test'''
cmd = Command('run gpstop', cmdStr = 'gpstop -a')
cmd.run(validateAfter=True)
def gpinitstandby_helper(self):
'''helper method to create a new standby'''
self.pgutil.install_standby()
def removestandby_helper(self):
''' helper method to remove standby'''
self.pgutil.remove_standby()
def verify_standby_sync(self):
if (self.stdby.check_gp_segment_config()) and (self.stdby.check_pg_stat_replication()) and (self.stdby.check_standby_processes()):
return True
else:
raise Exception('standby and master out of sync!')
def kill_standby_postmaster(self):
pid_list = []
delay = 0
postmaster_pid = self.pgutil.get_pid_by_keyword(host=WalReplKillProcessTestCase.stdby_host, pgport=WalReplKillProcessTestCase.stdby_port, keyword="master", option="bin")
while int(postmaster_pid) == -1 and delay < 20:
sleep(1)
delay = delay + 1
postmaster_pid = self.pgutil.get_pid_by_keyword(host=WalReplKillProcessTestCase.stdby_host, pgport=WalReplKillProcessTestCase.stdby_port, keyword="master", option="bin")
if int(postmaster_pid) == -1 or delay == 20:
tinctest.logger.error("error: standby postmaster process does not exist!")
return False
else:
pid_list.append(postmaster_pid)
return self.killProcess_byPid(pid_toKill=pid_list, host=WalReplKillProcessTestCase.stdby_host)
def initial_setup(self):
keyword = 'rh55-qavm65'
config = GPDBConfig()
(seg_host,seg_port) = config.get_hostandport_of_segment(psegmentNumber = 0, pRole = 'p')
cur_path = local_path('')
dir1 = os.path.join(cur_path, 'dml', 'sql','insert_from_external.sql.in')
dir2 = os.path.join(cur_path, 'dml', 'sql','insert_from_external.sql')
dir3 = os.path.join(cur_path, 'dml', 'expected','insert_from_external.ans.in')
dir4 = os.path.join(cur_path, 'dml', 'expected','insert_from_external.ans')
示例5: GpstartTestCase
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility import remove_standby [as 别名]
class GpstartTestCase(MPPTestCase):
'''
testcase for gpstart
gpstart may return status code 1 as well as 0 in the success case. The
difference is whether it produces WARNING or not, but here we don't care.
'''
origin_mdd = os.environ.get('MASTER_DATA_DIRECTORY')
def __init__(self,methodName):
self.gputil = GpUtility()
self.stdby = StandbyVerify()
super(GpstartTestCase,self).__init__(methodName)
def setUp(self):
self.gputil.check_and_start_gpdb()
stdby_presence = self.gputil.check_standby_presence()
# We should forcibly recreate standby, as it might has been promoted.
if stdby_presence:
self.gputil.remove_standby()
self.gputil.install_standby()
def tearDown(self):
self.gputil.remove_standby()
"""
Gpstart test cases in recovery mode
"""
def test_gpstart_from_master(self):
"""
tag
"""
self.gputil.check_and_stop_gpdb()
(rc, stdout) = self.gputil.run('gpstart -a ')
self.assertIn(rc, (0, 1))
self.assertTrue(self.gputil.gpstart_and_verify())
sleep(2)
self.assertTrue(self.stdby.check_gp_segment_config(),'standby master not cofigured')
self.assertTrue(self.stdby.check_pg_stat_replication(),'standby not in replication status')
self.assertTrue(self.stdby.check_standby_processes(), 'standby processes not running')
(rc, output) = self.gputil.run(command = 'ps -ef|grep "wal sender "|grep -v grep')
self.assertIsNotNone(output)
def test_gpstart_master_only(self):
"""
tag
"""
self.gputil.check_and_stop_gpdb()
(rc, stdout) = self.gputil.run('export GPSTART_INTERNAL_MASTER_ONLY=1; '
'gpstart -a -m ')
self.assertIn(rc, (0, 1))
self.assertTrue(self.gputil.gpstart_and_verify())
(rc,output) = self.gputil.run('PGDATABASE=template1 '
"PGOPTIONS='-c gp_session_role=utility' "
'psql')
self.assertEqual(rc, 0)
(rc, output) = self.gputil.run('psql template1')
# should fail due to master only mode
self.assertEqual(rc, 2)
self.gputil.run('gpstop -a -m')
self.gputil.run('gpstart -a')
def test_gpstart_restricted_mode_master(self):
"""Test -R option with standby."""
self.gputil.check_and_stop_gpdb()
(rc, stdout) = self.gputil.run('gpstart -a -R')
self.assertIn(rc, (0, 1))
self.assertTrue(self.gputil.gpstart_and_verify())
(rc,output) = self.gputil.run(command = 'psql template1')
self.assertIn(rc, (0, 1))
self.gputil.run('gpstop -ar')
def test_gpstart_master_w_timeout(self):
"""Test -t option with standby."""
self.gputil.check_and_stop_gpdb()
(rc, output) = self.gputil.run('gpstart -a -t 30')
self.assertIn(rc, (0, 1))
self.assertTrue(self.gputil.gpstart_and_verify())
self.gputil.run('gpstop -ar')
def test_gpstart_no_standby(self):
"""Test -y with standby configured."""
self.gputil.check_and_stop_gpdb()
(rc, stdout) = self.gputil.run('gpstart -a -y')
self.assertIn(rc, (0, 1))
self.assertTrue(self.gputil.gpstart_and_verify())
self.assertFalse(self.stdby.check_standby_processes(),
'gpstart without standby failed, standby was running')
self.gputil.run('gpstop -ar')
def test_gpstart_wo_standby(self):
"""Test -y without standby configured."""
self.gputil.remove_standby()
#.........这里部分代码省略.........