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


Python GpactivateStandby.failback_to_original_master方法代码示例

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


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

示例1: run_test

# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.gpactivatestandby.GpactivateStandby import failback_to_original_master [as 别名]
    def run_test(self):
        """
        Override of SQLTestCase.  Create a base backup and start standby,
        run some SQL in primary side then promote, check if the data is
        streamed correctly.
        """
        sql_file = self.sql_file
        ans_file = self.ans_file
        
        Command('gpinitstandby -r', 'gpinitstandby -ra').run()
        self.assertEqual(self.standby.create(), 0)
        gpact_stdby = GpactivateStandby()
        res = self.standby.start()
        self.assertTrue(res.wasSuccessful())

        # wait for the walreceiver to start
        num_walsender = self.wait_for_walsender()
        self.assertEqual(num_walsender, 1)

        # 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))

        if self.promote_using_pg_ctl:
            self.assertTrue(self.standby.promote())
        else:
            self.assertTrue(self.standby.promote_manual())

        # fetch timelineids for both primary and standby (post-promote)
        primary_tli = self.fetch_tli(os.environ.get('MASTER_DATA_DIRECTORY'))
        standby_tli = self.fetch_tli(self.standby_datadir)

        logger.info("primary tli = " + primary_tli)
        logger.info("standby tli after promote = " + standby_tli)

        # primary_tli should be less than standby_tli by 1
        self.assertTrue(int(primary_tli) + 1 == int(standby_tli))

        # SQLTestCase doesn't allow to set port.  Use environ to tell it.
        with NewEnv(PGPORT=self.standby_port,MASTER_DATA_DIRECTORY=self.standby_datadir) as env:
            result = super(PromoteTestCase, self).run_test()
            return result
        # always fail back to old master after test complete
        gpact_stdby.failback_to_original_master()
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:49,代码来源:__init__.py


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