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


Python GpUtility.failback_to_original_master方法代码示例

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


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

示例1: GpstopTestCase

# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility import failback_to_original_master [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) 
开发者ID:50wu,项目名称:gpdb,代码行数:69,代码来源:test_gpstop.py

示例2: GpstartTestCase

# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility import failback_to_original_master [as 别名]

#.........这里部分代码省略.........

        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()
        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(), 'standby processes presented')
        self.gputil.run('gpstop -ar')

    """
    Gpstart, test case in failover mode
    """

    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)

    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)

    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)
开发者ID:50wu,项目名称:gpdb,代码行数:104,代码来源:test_gpstart.py


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