当前位置: 首页>>代码示例>>Python>>正文


Python GpinitStandby.get_primary_pid方法代码示例

本文整理汇总了Python中mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby.get_primary_pid方法的典型用法代码示例。如果您正苦于以下问题:Python GpinitStandby.get_primary_pid方法的具体用法?Python GpinitStandby.get_primary_pid怎么用?Python GpinitStandby.get_primary_pid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby的用法示例。


在下文中一共展示了GpinitStandby.get_primary_pid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GpinitStandsbyTestCase

# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby import get_primary_pid [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))
    

#.........这里部分代码省略.........
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:103,代码来源:test_gpinitstandby.py


注:本文中的mpp.gpdb.tests.storage.walrepl.gpinitstandby.GpinitStandby.get_primary_pid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。