本文整理汇总了Python中mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby.get_standbyhost方法的典型用法代码示例。如果您正苦于以下问题:Python GpinitStandby.get_standbyhost方法的具体用法?Python GpinitStandby.get_standbyhost怎么用?Python GpinitStandby.get_standbyhost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby
的用法示例。
在下文中一共展示了GpinitStandby.get_standbyhost方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_stdby_stop
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [as 别名]
def check_stdby_stop(self):
gpstdby = GpinitStandby()
stdby_host = gpstdby.get_standbyhost()
activate_stdby = GpactivateStandby()
stdby_port = activate_stdby.get_standby_port()
master_pid = self.pgutil.get_pid_by_keyword(host=stdby_host, pgport=stdby_port, keyword="master", option = "bin")
if int(master_pid) != -1:
raise Exception("standby should stop but failed!")
示例2: start_stdby
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [as 别名]
def start_stdby(self):
gpstdby = GpinitStandby()
stdby_host = gpstdby.get_standbyhost()
stdby_dbid = self.get_standby_dbid()
activate_stdby = GpactivateStandby()
stdby_mdd = activate_stdby.get_standby_dd()
stdby_port = activate_stdby.get_standby_port()
cmd="pg_ctl -D %s -o '-p %s --gp_dbid=%s --gp_num_contents_in_cluster=2 --silent-mode=true -i -M master --gp_contentid=-1 -x 0 -E' start &"%(stdby_mdd, stdby_port, stdby_dbid)
self.run_remote(stdby_host,cmd,stdby_port,stdby_mdd)
示例3: setUp
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [as 别名]
def setUp(self):
super(WalReplKillProcessScenarioTestCase, self).setUp()
pgutil.check_and_start_gpdb()
# We should forcibly recreate standby, as it might has been promoted.
pgutil.remove_standby()
pgutil.install_standby()
gpact_stdby = GpactivateStandby()
gpinit_stdb = GpinitStandby()
WalReplKillProcessTestCase.stdby_port = gpact_stdby.get_standby_port()
WalReplKillProcessTestCase.stdby_host = gpinit_stdb.get_standbyhost()
示例4: setUp
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [as 别名]
def setUp(self):
pgutil.check_and_start_gpdb()
# We should forcibly recreate standby, as it might has been promoted.
# here we need to install locally, otherwise can not run remote sql
pgutil.remove_standby()
pgutil.install_standby(new_stdby_host=socket.gethostname())
gpact_stdby = GpactivateStandby()
gpinit_stdb = GpinitStandby()
WalReplKillProcessTestCase.stdby_port = gpact_stdby.get_standby_port()
WalReplKillProcessTestCase.stdby_host = gpinit_stdb.get_standbyhost()
self.standby_dir = gpact_stdby.get_standby_dd()
示例5: test_gpactivatestandby_on_new_host
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [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)
示例6: kill_walreceiver
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [as 别名]
def kill_walreceiver(self):
gpstdby = GpinitStandby()
stdby_host = gpstdby.get_standbyhost()
activate_stdby = GpactivateStandby()
stdby_port = activate_stdby.get_standby_port()
pid_list = []
walreceiver_pid = self.pgutil.get_pid_by_keyword(host=stdby_host, pgport=stdby_port, keyword="wal receiver process")
if int(walreceiver_pid) == -1:
tinctest.logger.error("error: wal receiver process does not exist!")
return False
else:
pid_list.append(walreceiver_pid)
self.killProcess_byPid(pid_toKill=pid_list, host=stdby_host)
示例7: start_stdby
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [as 别名]
def start_stdby(self):
gpstdby = GpinitStandby()
stdby_host = gpstdby.get_standbyhost()
stdby_dbid = self.get_standby_dbid()
activate_stdby = GpactivateStandby()
stdby_mdd = activate_stdby.get_standby_dd()
stdby_port = activate_stdby.get_standby_port()
cmd = "pg_ctl -D %s -o '-p %s -b %s -z 2 --silent-mode=true -i -M master -C -1 -x 0 -E' start &" % (
stdby_mdd,
stdby_port,
stdby_dbid,
)
self.run_remote(stdby_host, cmd, stdby_port, stdby_mdd)
示例8: test_gpactivatestandby_new_host_with_filespace
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [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)
示例9: test_promote_incomplete_stdby
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [as 别名]
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.')
示例10: gpactivatestandby
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhost [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