本文整理汇总了Python中mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby.activate方法的典型用法代码示例。如果您正苦于以下问题:Python GpactivateStandby.activate方法的具体用法?Python GpactivateStandby.activate怎么用?Python GpactivateStandby.activate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby
的用法示例。
在下文中一共展示了GpactivateStandby.activate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_inject_primary_after_promote
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_inject_primary_after_promote(self):
"""
Promote to standby, bring down primary segments, run gprecoverseg.
"""
tinctest.logger.info("-failover to standby, inject primary segments, and recoverseg")
# get standby host, port, and master data directory
activatestdby = GpactivateStandby()
self.standby_host = activatestdby.get_current_standby()
self.standby_mdd = activatestdby.get_standby_dd()
self.standby_port = activatestdby.get_standby_port()
activatestdby.activate()
# bring down primary segments
inject_cmd = 'gpfaultinjector -f postmaster -m async -y panic -r primary -H ALL'
activatestdby.run_remote(self.standby_host, inject_cmd, self.standby_port, self.standby_mdd)
# wait till segments come up in change tracking
self.wait_till_changetracking_transition(self.standby_host, self.standby_port)
# recoverseg from new master
(rc, stdout) = activatestdby.run_remote(self.standby_host,'gprecoverseg -a',self.standby_port,self.standby_mdd)
tinctest.logger.info("in test_inject_primary_after_promote: gprecoverseg -a: %s"%stdout)
keyword = 'Segment Pairs in Resynchronization'
self.wait_till_insync_transition(activatestdby,self.standby_host,self.standby_port,self.standby_mdd,keyword,False)
# rebalance from new master
(rc, stdout) = activatestdby.run_remote(self.standby_host,'gprecoverseg -ra',self.standby_port,self.standby_mdd)
tinctest.logger.info("in test_inject_primary_after_promote: gprecoverseg -ar: %s"%stdout)
# check if all segments are up and sync
keyword = 'All segments are running normally'
self.wait_till_insync_transition(activatestdby,self.standby_host,self.standby_port,self.standby_mdd, keyword, True)
示例2: test_failover_run__workload
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_failover_run__workload(self):
''' activate the standby, run workload, check master and standby
integrity, currently support local standby, can not run workload
remotely
'''
activatestdby = GpactivateStandby()
activatestdby.activate()
with walrepl.NewEnv(MASTER_DATA_DIRECTORY=self.standby_dir,
PGPORT=WalReplKillProcessTestCase.stdby_port,
PGDATABASE=self.pgdatabase) as env:
test_case_list1 = []
test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.dml.test_dml.DMLTestCase")
test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.ddl.test_ddl.DDLTestCase")
self.test_case_scenario.append(test_case_list1)
test_case_list2 = []
test_case_list2.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.check_mirror_seg")
self.test_case_scenario.append(test_case_list2)
test_case_list3 = []
test_case_list3.append("mpp.gpdb.tests.storage.walrepl.crash.verify.verify.DataVerifyTestCase")
self.test_case_scenario.append(test_case_list3)
pgutil.failback_to_original_master(self.origin_mdd, WalReplKillProcessTestCase.stdby_host, self.standby_dir,WalReplKillProcessTestCase.stdby_port)
示例3: test_inject_mirror_after_promote
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_inject_mirror_after_promote(self):
"""
Promote to standby, bring down mirror segments,run gprecoverseg.
"""
tinctest.logger.info("-failover to standby, inject mirror segments, and recoverseg")
# get standby host, port, and master data directory
activatestdby = GpactivateStandby()
self.standby_host = activatestdby.get_current_standby()
self.standby_mdd = activatestdby.get_standby_dd()
self.standby_port = activatestdby.get_standby_port()
activatestdby.activate()
# inject the mirror segments from new master
inject_cmd = 'gpfaultinjector -f filerep_consumer -m async -y fault -r mirror -H ALL'
activatestdby.run_remote(self.standby_host, inject_cmd, self.standby_port, self.standby_mdd)
# wait till segments come up in change tracking
self.wait_till_changetracking_transition(self.standby_host, self.standby_port)
# recoverseg from new master
(rc, stdout) = activatestdby.run_remote(self.standby_host,'gprecoverseg -a',self.standby_port,self.standby_mdd)
tinctest.logger.info("in test_inject_mirror_after_promote: gprecoverseg -a: %s"%stdout)
# check if all segments are up and sync
keyword = 'All segments are running normally'
self.wait_till_insync_transition(activatestdby,self.standby_host,self.standby_port,self.standby_mdd,keyword, True)
示例4: test_failover_insync
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_failover_insync(self):
"""
bring down mirror segments,suspend in resync mode,failover to standby, run gprecoverseg.
"""
tinctest.logger.info("-failover to standby in resync and recoverseg")
# get standby host, port, and master data directory
activatestdby = GpactivateStandby()
self.standby_host = activatestdby.get_current_standby()
self.standby_mdd = activatestdby.get_standby_dd()
self.standby_port = activatestdby.get_standby_port()
# bring down mirror segments and suspend
Command('fault inject mirror segment', 'gpfaultinjector -f filerep_consumer -m async -y fault -r mirror -H ALL').run()
# wait till segments come up in change tracking
self.wait_till_changetracking_transition('localhost', os.environ['PGPORT'])
Command('Injecting fault to suspend resync','gpfaultinjector -f filerep_resync -m async -y suspend -r primary -H ALL').run()
Command('recover and suspend in insync','gprecoverseg -a').run()
activatestdby.activate()
# Injecting Fault to resume resync
resume_resync_cmd = 'gpfaultinjector -f filerep_resync -m async -y resume -r primary -H ALL'
activatestdby.run_remote(self.standby_host, resume_resync_cmd, self.standby_port, self.standby_mdd)
# Injecting Fault to reset resync
reset_resync_cmd = 'gpfaultinjector -f filerep_resync -m async -y reset -r primary -H ALL'
activatestdby.run_remote(self.standby_host, reset_resync_cmd, self.standby_port, self.standby_mdd)
# check if all segments are up and sync
keyword = 'All segments are running normally'
self.wait_till_insync_transition(activatestdby,self.standby_host,self.standby_port,self.standby_mdd,keyword,True)
示例5: test_backup_restore
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_backup_restore(self):
# Create standby if not present
Command('createdb bkdb','dropdb bkdb; createdb bkdb').run()
self.create_standby()
# Run workload
self.run_workload('sql')
# Create backup
self.assertTrue(self.run_backup())
# Activate standby
gpac = GpactivateStandby()
gpac.activate()
# Restore from new master
self.assertTrue(self.run_restore())
示例6: test_gpstop_after_failover
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
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)
示例7: test_run_five
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_run_five(self):
for i in xrange(5):
with NewEnv(PGPORT=self.port,
MASTER_DATA_DIRECTORY=self.mdd):
pguti = GpUtility()
if i == 0:
pguti.install_standby(socket.gethostname(), self.mdd)
# starting from second time, init standby from new master, standby_dir will be like master_newstandby_newstandby...
else:
pguti.install_standby(socket.gethostname(), os.path.join(self.mdd,'newstandby'))
gpact = GpactivateStandby()
self.mdd = gpact.get_standby_dd()
self.port = gpact.get_standby_port()
gpact.activate()
tinctest.logger.info("self.mdd is %s, self.port is %s"%(self.mdd, self.port))
示例8: test_gpstart_master_after_failover
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_gpstart_master_after_failover(self):
"""
failover, start from new master, then recover the cluster back to
have the old master active.
"""
tinctest.logger.info("failover, and run gpstart master test")
self.gputil.check_and_start_gpdb()
activatestdby = GpactivateStandby()
standby_host = activatestdby.get_current_standby()
standby_mdd = activatestdby.get_standby_dd()
standby_port = activatestdby.get_standby_port()
activatestdby.activate()
self.stdby._run_remote_command(standby_host, command = 'gpstop -a')
stdout = self.stdby._run_remote_command(standby_host,command = 'gpstart -a')
self.assertNotRegexpMatches(stdout,"FATAL","ERROR")
self.assertTrue(self.gputil.gpstart_and_verify(master_dd = standby_mdd, host = standby_host))
self.gputil.failback_to_original_master(self.origin_mdd, standby_host, standby_mdd, standby_port)
示例9: test_gpstart_original_master_after_promote
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_gpstart_original_master_after_promote(self):
"""
failover, start from new master, then recover the cluster back to
have the old master active.
"""
tinctest.logger.info("activate and run gpstart for original master")
activatestdby = GpactivateStandby()
standby_host = activatestdby.get_current_standby()
standby_mdd = activatestdby.get_standby_dd()
standby_port = activatestdby.get_standby_port()
activatestdby.activate()
(rc, stdout) = self.gputil.run('gpstart -a -v')
self.gputil.run('pg_controldata %s' % self.origin_mdd)
self.stdby._run_remote_command(standby_host, command = 'pg_controldata %s' % standby_mdd)
self.assertNotEqual(rc, 0)
# This below error message comes from gpstart product code (if its modified change it here as well.)
self.assertRegexpMatches(stdout,"Standby activated, this node no more can act as master.")
self.gputil.failback_to_original_master(self.origin_mdd, standby_host, standby_mdd, standby_port)
示例10: test_gpstart_master_only_after_failover
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_gpstart_master_only_after_failover(self):
"""
for test purpose, failing back to old master should
remove standby from primary after activate standby
"""
tinctest.logger.info("start master only with -m option after failover")
activatestdby = GpactivateStandby()
standby_host = activatestdby.get_current_standby()
standby_mdd = activatestdby.get_standby_dd()
standby_port = activatestdby.get_standby_port()
activatestdby.activate()
self.stdby._run_remote_command(standby_host,command = 'gpstop -a')
stdout = self.stdby._run_remote_command(standby_host,command = 'export GPSTART_INTERNAL_MASTER_ONLY=1; gpstart -a -m')
self.assertNotRegexpMatches(stdout,"ERROR","Start master only after failover failed")
self.assertTrue(self.gputil.gpstart_and_verify(master_dd = standby_mdd, host = standby_host))
self.stdby._run_remote_command(standby_host,command = 'gpstop -a -m')
self.gputil.run(command = 'gpstop -ar')
self.gputil.failback_to_original_master(self.origin_mdd, standby_host, standby_mdd, standby_port)
示例11: test_run_workload_before_activate_standby
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_run_workload_before_activate_standby(self):
#run workload while removing initstandby, check master mirror integrity
activatestdby = GpactivateStandby()
test_case_list0 = []
test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.dml.test_dml.DMLTestCase")
test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.ddl.test_ddl.DDLTestCase")
self.test_case_scenario.append(test_case_list0)
activatestdby.activate()
test_case_list1 = []
test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.check_mirror_seg")
self.test_case_scenario.append(test_case_list1)
test_case_list2 = []
test_case_list2.append("mpp.gpdb.tests.storage.walrepl.crash.verify.verify.DataVerifyTestCase")
self.test_case_scenario.append(test_case_list2)
pgutil.failback_to_original_master(self.origin_mdd,WalReplKillProcessTestCase.stdby_host, self.standby_dir,WalReplKillProcessTestCase.stdby_port)
示例12: test_gpactivatestandby_on_same_host
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_gpactivatestandby_on_same_host(self):
''' Doesn't work due to STO-374'''
gputil.install_standby(new_stdby_host='localhost')
initstdby = GpinitStandby()
gpact_stdby = GpactivateStandby()
self.mdd = gpact_stdby.get_standby_dd()
self.port = gpact_stdby.get_standby_port()
self.standby_pid = gpact_stdby.get_standby_pid('localhost', self.port, self.mdd)
PSQL.run_sql_file(local_path('create_tables.sql'), dbname = self.db_name)
self.assertTrue(gpact_stdby.activate())
self.assertTrue(gpact_stdby.verify_gpactivatestandby(self.standby_pid, 'localhost', self.port, self.mdd))
gputil.failback_to_original_master(self.origin_mdd,socket.gethostname(),self.mdd,self.port)
示例13: test_gpactivatestandby_on_new_host
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_gpactivatestandby_on_new_host(self):
gputil.install_standby()
initstdby = GpinitStandby()
gpact_stdby = GpactivateStandby()
self.mdd = gpact_stdby.get_standby_dd()
self.host = initstdby.get_standbyhost()
self.port = gpact_stdby.get_standby_port()
self.standby_pid = gpact_stdby.get_standby_pid(self.host, self.port, self.mdd)
PSQL.run_sql_file(local_path('create_tables.sql'), dbname = self.db_name)
self.assertTrue(gpact_stdby.activate())
self.assertTrue(gpact_stdby.verify_gpactivatestandby(self.standby_pid, self.host, self.port, self.mdd))
gputil.failback_to_original_master(self.origin_mdd,self.host,self.mdd,self.port)
示例14: test_gpactivatestandby_new_host_with_filespace
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
def test_gpactivatestandby_new_host_with_filespace(self):
from mpp.lib.gpfilespace import Gpfilespace
gpfile = Gpfilespace()
gpfile.create_filespace('fs_walrepl_a')
PSQL.run_sql_file(local_path('filespace.sql'), dbname= self.db_name)
gputil.install_standby()
initstdby = GpinitStandby()
gpact_stdby = GpactivateStandby()
self.mdd = gpact_stdby.get_standby_dd()
self.host = initstdby.get_standbyhost()
self.port = gpact_stdby.get_standby_port()
self.standby_pid = gpact_stdby.get_standby_pid(self.host, self.port, self.mdd)
PSQL.run_sql_file(local_path('create_tables.sql'), dbname = self.db_name)
self.assertTrue(gpact_stdby.activate())
self.assertTrue(gpact_stdby.verify_gpactivatestandby(self.standby_pid, self.host, self.port, self.mdd))
gputil.failback_to_original_master(self.origin_mdd,self.host,self.mdd,self.port)
示例15: gpactivatestandby
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import activate [as 别名]
class gpactivatestandby(mpp.gpdb.tests.storage.walrepl.run.StandbyRunMixin, mpp.gpdb.tests.storage.walrepl.lib.PreprocessFileMixin,
SQLTestCase):
"""
@gucs gp_create_table_random_default_distribution=off
"""
sql_dir = 'sql'
ans_dir = 'ans'
out_dir = 'output'
standby_dir = ''
standby_host = ''
standby_port = ''
@unittest.skipIf(config.is_multinode(), "Test applies only to a singlenode cluster")
def setUp(self):
# For each test case we create a fresh standby and start it.
self.db_name = self.__class__.db_name
self.createdb(self.db_name)
gputil.remove_standby()
gputil.install_standby(new_stdby_host=socket.gethostname())
self.gpinit_stdby = GpinitStandby()
self.activatestdby = GpactivateStandby()
def tearDown(self):
# Clean up filespaces to be tidy. Although we want to preserve
# it for the investigation in case of test failure, without cleaning
# it up it will prevent next tests from running correctly.
gputil.failback_to_original_master(origin_mdd,self.standby_host,self.standby_dir,self.standby_port)
# remove standby
cmd = Command('gpinitstandby', 'gpinitstandby -ar')
cmd.run()
def get_gp_dbid(self,standby_dd=''):
# We use gppylib from the installation
from gppylib.gp_dbid import GpDbidFile
return GpDbidFile(standby_dd, True).dbid
def run_test(self):
"""
Override of SQLTestCase. Initialize standby, run some sql,
then activate it, and check if the data is streamed correctly.
"""
sql_file = self.sql_file
ans_file = self.ans_file
nsender = self.wait_for_walsender()
self.assertEqual(nsender, 1, 'replication has not begun')
# setup script is run on primary while standby is running.
# .in file will be substitute with runtime information, if any.
setup_file = sql_file.replace('.sql', '_setup.sql')
if os.path.exists(setup_file + '.in'):
self.preprocess_file(setup_file + '.in')
self.assertTrue(PSQL.run_sql_file(setup_file, dbname=self.db_name))
self.standby_dir = self.activatestdby.get_standby_dd()
self.standby_port = self.activatestdby.get_standby_port()
self.standby_host = self.gpinit_stdby.get_standbyhost()
self.activatestdby.activate()
datadir = os.path.abspath(self.standby_datadir)
with walrepl.NewEnv(MASTER_DATA_DIRECTORY=self.standby_dir,
PGPORT=self.standby_port) as env:
result = super(gpactivatestandby, self).run_test()
sql = 'SHOW gp_dbid'
result = PSQL.run_sql_command(sql, flags='-A -t')
self.assertEqual(result.strip(), '1')
self.assertEqual(self.get_gp_dbid(self.standby_dir), 1, 'gp_dbid should show 1')
if 'cleanup_filespace' in self._metadata:
mpp.gpdb.tests.storage.walrepl.lib.cleanupFilespaces(dbname=self.db_name)
return result