本文整理汇总了Python中mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby.get_standbyhostnode方法的典型用法代码示例。如果您正苦于以下问题:Python GpinitStandby.get_standbyhostnode方法的具体用法?Python GpinitStandby.get_standbyhostnode怎么用?Python GpinitStandby.get_standbyhostnode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby
的用法示例。
在下文中一共展示了GpinitStandby.get_standbyhostnode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CancelBkndTestCase
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhostnode [as 别名]
class CancelBkndTestCase(MPPTestCase):
''' Testcases for pg_cancel_backed and pg_terminate_backed on wal sender'''
def __init__(self, methodName):
self.gp = GpinitStandby()
self.mdd = os.environ.get('MASTER_DATA_DIRECTORY')
self.standby = self.gp.get_standbyhostnode()
super(CancelBkndTestCase,self).__init__(methodName)
def setUp(self):
#Remove standby if present
self.gp.run(option='-r')
def get_walsender_pid(self):
''' get wal sender pid '''
pid_cmd = "ps -ef|grep \'%s\' |grep -v grep" % ('wal sender')
cmd = Command('Get the pid of the wal sender process', cmdStr = pid_cmd)
tinctest.logger.info ('%s' % cmd)
cmd.run(validateAfter=False)
result = cmd.get_results()
while(result.rc !=0):
cmd.run(validateAfter=False)
result = cmd.get_results()
tinctest.logger.info(result)
pid = result.stdout.splitlines()[0].split()[1].strip()
return pid
def cancel_query(self,query):
res = 't'
count = 0
while(res.strip() != 'f'):
res = PSQL.run_sql_command(query, dbname='postgres', flags = '-q -t')
if res.strip() == 'f':
return True
else:
sleep(2)
count+=1
if count > 120 :
return False
def terminate_backend(self):
wal_pid_1 = self.get_walsender_pid()
psql_command = "select pg_terminate_backend('%s')" % wal_pid_1
return(self.cancel_query(psql_command))
@unittest.skipIf(not config.is_multinode(), "Test applies only to a multinode cluster")
def test_terminate_bknd_wal_sender(self):
self.gp.create_dir_on_standby(self.standby, os.path.split(self.mdd)[0])
self.assertTrue(self.gp.run(option = '-s %s' % self.standby))
self.assertTrue(self.terminate_backend())
示例2: GpinitStandsbyTestCase
# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_standbyhostnode [as 别名]
class GpinitStandsbyTestCase(MPPTestCase):
''' Testcases for gpinitstandby'''
db_name = 'walrepl'
standby_port = '5433'
standby_dirname = 'newstandby'
def __init__(self, methodName):
self.gp = GpinitStandby()
self.host = socket.gethostname()
self.mdd = os.environ.get('MASTER_DATA_DIRECTORY')
self.standby = self.gp.get_standbyhostnode()
self.standby_loc = os.path.join(os.path.split(self.mdd)[0],
self.standby_dirname)
self.primary_pid = 0
super(GpinitStandsbyTestCase,self).__init__(methodName)
def setUp(self):
#Remove standby if present
self.primary_pid = self.gp.get_primary_pid()
self.gp.run(option='-r')
def tearDown(self):
# Cleanup Filespaces
walrepl.cleanupFilespaces(dbname=self.db_name)
def create_directory(self,location):
pgutil.clean_dir(self.standby,os.path.split(location)[0])
pgutil.create_dir(self.standby,os.path.split(location)[0])
def create_unmodifiable_file(self, filename):
filepath = os.path.join(self.mdd, filename)
with open(filepath, 'w') as fp:
pass
os.chmod(filepath, 000)
def remove_unmodifiable_file(self, filename):
filepath = os.path.join(self.mdd, filename)
os.chmod(filepath, 777)
os.remove(filepath)
def touch_file(self, filename):
file_dir = os.path.split(filename)[0]
if not os.path.exists(file_dir):
os.makedirs(file_dir)
with open(filename, 'w') as fp:
pass
def test_gpinitstandby_exclude_dirs(self):
"""
Test pg_basebackup exclusions when copying filespaces from
the master to the standby during gpinitstandby
"""
os.makedirs(self.mdd + '/db_dumps')
self.touch_file(self.mdd + '/db_dumps/testfile')
self.touch_file(self.mdd + '/gpperfmon/logs/test.log')
self.touch_file(self.mdd + '/gpperfmon/data/testfile')
self.touch_file(self.mdd + '/pg_log/testfile')
self.gp.run(option = '-P %s -s %s -F pg_system:%s' % (self.standby_port, self.host, self.standby_loc))
shutil.rmtree(self.mdd + '/db_dumps')
os.remove(self.mdd + '/gpperfmon/logs/test.log')
os.remove(self.mdd + '/gpperfmon/data/testfile')
os.remove(self.mdd + '/pg_log/testfile')
self.assertFalse(os.path.exists(self.standby_loc + '/db_dumps/testfile'))
self.assertFalse(os.path.exists(self.standby_loc + '/gpperfmon/logs/test.log'))
self.assertFalse(os.path.exists(self.standby_loc + '/gpperfmon/data/testfile'))
self.assertFalse(os.path.exists(self.standby_loc + '/pg_log/testfile'))
self.assertTrue(self.gp.run(option = '-r'))
@unittest.skipIf(not config.is_multinode(), "Test applies only to a multinode cluster")
def test_gpinitstanby_to_new_host(self):
self.create_directory(self.mdd)
self.assertTrue(self.gp.run(option = '-s %s' % self.standby))
self.assertTrue(self.gp.verify_gpinitstandby(self.primary_pid))
def test_gpinitstandby_to_same_host_new_port_and_new_mdd(self):
pgutil.clean_dir(self.host,self.standby_loc)
self.assertTrue(self.gp.run(option = '-P %s -s %s -F pg_system:%s' % (self.standby_port, self.host, self.standby_loc)))
self.assertTrue(self.gp.verify_gpinitstandby(self.primary_pid))
@unittest.skipIf(not config.is_multinode(), "Test applies only to a multinode cluster")
def test_gpinitstandby_new_host_new_port(self):
self.create_directory(self.mdd)
self.assertTrue(self.gp.run(option = '-P %s -s %s' % (self.standby_port, self.standby)))
self.assertTrue(self.gp.verify_gpinitstandby(self.primary_pid))
@unittest.skipIf(not config.is_multinode(), "Test applies only to a multinode cluster")
def test_gpinitstandby_new_host_new_mdd(self):
self.create_directory(self.standby_loc)
self.assertTrue(self.gp.run(option = '-F pg_system:%s -s %s' % (self.standby_loc, self.standby)))
self.assertTrue(self.gp.verify_gpinitstandby(self.primary_pid))
#.........这里部分代码省略.........