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


Python GpUtility.clean_dir方法代码示例

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


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

示例1: PromoteTestCase

# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility import clean_dir [as 别名]
class PromoteTestCase(MPPTestCase):
   '''testcase for gpstart''' 
 
   def __init__(self,methodName):
       self.pgutil = GpUtility()
       super(PromoteTestCase,self).__init__(methodName)
  
   def setUp(self):
       self.pgutil.check_and_start_gpdb()
       # We should forcibly recreate standby, as it might has been promoted.
       self.pgutil.remove_standby()
       self.pgutil.install_standby()


   def tearDown(self):
       self.pgutil.remove_standby()

   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.')
开发者ID:HaozhouWang,项目名称:gpdb,代码行数:35,代码来源:test_promote_negative.py

示例2: OOMClass

# 需要导入模块: from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility [as 别名]
# 或者: from mpp.gpdb.tests.storage.walrepl.lib.pg_util.GpUtility import clean_dir [as 别名]
class OOMClass(object):
    '''Class for methods required for OOM testcase'''

    standby_port = '5433'
    standby_dirname = 'newstandby'

    def __init__(self):
        self.gpinit = GpinitStandby()
        self.mdd = os.environ.get('MASTER_DATA_DIRECTORY')
        self.config = GPDBConfig()
        self.pgutil = GpUtility()
        self.verify = StandbyVerify()
        self.host = socket.gethostname()
        self.standby_loc = os.path.join(os.path.split(self.mdd)[0],
                                        self.standby_dirname)
        self.standby = Standby(self.standby_loc, self.standby_port)

    def create_standby(self):
        self.pgutil.clean_dir(self.host,self.standby_loc)
        self.gpinit.run(option = '-P %s -s %s -F pg_system:%s' % (self.standby_port, self.host, self.standby_loc))

    def setup_oom(self):
        # Build it before testing.
        thisdir = os.path.dirname(__file__)
        builddir = os.path.join(thisdir, 'lib')
        subprocess.check_call(['make', '-C', builddir, 'install'])

        #Copy oom_malloc.so and wrapper.sh to all the segment nodes
        for host in config.get_hosts() :
            if host.strip() == self.host :
                continue
            cmd = "gpssh -h %s -e 'mkdir -p %s'; scp %s/oom_malloc.so %s:%s/; scp %s/wrapper.sh %s:%s/" % (host.strip(), builddir, builddir, host.strip(), builddir, builddir, host.strip(), builddir)
            self.pgutil.run(cmd)

    def touch_malloc(self):
        # Touch file oom_malloc in standby directory
        cmd = 'touch %s/oom_malloc' % self.standby_loc
        self.pgutil.run(cmd)

    def startdb(self):
        (rc, result) = self.pgutil.run('gpstart -a --wrapper %s' % (local_path('lib/wrapper.sh')))
        if rc != 0 and 'Could not start standby master' in result :
            return False
        return True

    def restartdb(self):
        # Remove file oom_malloc from standby
        cmd = 'rm %s/oom_malloc' % self.standby_loc
        self.pgutil.run(cmd)
        (rc, result) = self.pgutil.run('gpstop -ar')
        if rc == 0 and (self.verify.check_pg_stat_replication()):
            return True
        return False

    def psql_and_oom(self):
        #Touch oom_malloc in standby_dir and issue PSQL : Check if processes are gone
        self.touch_malloc()
        PSQL.run_sql_command('Drop table if exists wal_oomt1;Create table wal_oomt1(a1 int, a2 text) with(appendonly=true);')
        sleep(2)
        if not (self.verify.check_standby_processes()):
            return True
        return False 

    def start_standby(self):
        # Remove oom_malloc and start standby : Check if all processes are back
        cmd = 'rm %s/oom_malloc' % self.standby_loc
        self.pgutil.run(cmd)
        res = self.standby.start()
        sleep(2)
        if (self.verify.check_standby_processes()) :
            return True
        return False
开发者ID:50wu,项目名称:gpdb,代码行数:74,代码来源:__init__.py


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