class basebackup_filespace(StandbyRunMixin, MPPTestCase, PreprocessFileMixin): def setUp(self): """ Override """ # Removing standby as these tests will fail if there is a standby enabled # Ignore any failures run_shell_command(cmdstr='gpinitstandby -ra', cmdname='remove standby') self.createdb(self.db_name) self.standby = Standby(self.standby_datadir, self.standby_port) def tearDown(self): """ Override """ try: dburl = dbconn.DbURL() self.standby.remove_catalog_standby(dburl) except Exception: pass cleanupFilespaces(dbname=self.db_name) def test_filespace(self): """ pg_basebackup should work with user filespace. @tags sanity """ # Add standby entry in catalog before regisering filespace. fsbase = os.path.join(self.fsprefix, 'fs') shutil.rmtree(fsbase, True) os.makedirs(fsbase) shutil.rmtree(self.standby_datadir, True) dburl = dbconn.DbURL() gparray = GpArray.initFromCatalog(dburl, utility=True) if gparray.standbyMaster: self.standby.remove_catalog_standby(dburl) self.standby.add_catalog_standby(dburl, gparray) #self.preprocess_file(local_path('filespace.sql.in')) sql_file = local_path('filespace.sql') from mpp.lib.gpfilespace import Gpfilespace gpfile = Gpfilespace() gpfile.create_filespace('fs_walrepl_a') result = PSQL.run_sql_file(sql_file, dbname=self.db_name) self.assertTrue(result) subprocess.check_call(['pg_basebackup', '-D', self.standby_datadir]) #fsdir = os.path.join(self.fsprefix, 'fs', 'gpdb1') fsdir = os.path.join(os.path.split(self.standby_datadir)[0], 'fs_walrepl_a','mirror','pg_system') self.assertTrue(os.path.isdir(fsdir), '{0} does not dir'.format(fsdir))
class basebackup_filespace(StandbyRunMixin, MPPTestCase, PreprocessFileMixin): def setUp(self): """ Override """ # Removing standby as these tests will fail if there is a standby enabled # Ignore any failures run_shell_command(cmdstr='gpinitstandby -ra', cmdname='remove standby') self.createdb(self.db_name) self.standby = Standby(self.standby_datadir, self.standby_port) def tearDown(self): """ Override """ try: dburl = dbconn.DbURL() self.standby.remove_catalog_standby(dburl) except Exception: pass cleanupFilespaces(dbname=self.db_name) def test_filespace(self): """ pg_basebackup should work with user filespace. @tags sanity """ # Add standby entry in catalog before regisering filespace. fsbase = os.path.join(self.fsprefix, 'fs') shutil.rmtree(fsbase, True) os.makedirs(fsbase) shutil.rmtree(self.standby_datadir, True) dburl = dbconn.DbURL() gparray = GpArray.initFromCatalog(dburl, utility=True) if gparray.standbyMaster: self.standby.remove_catalog_standby(dburl) self.standby.add_catalog_standby(dburl, gparray) #self.preprocess_file(local_path('filespace.sql.in')) sql_file = local_path('filespace.sql') from mpp.lib.gpfilespace import Gpfilespace gpfile = Gpfilespace() gpfile.create_filespace('fs_walrepl_a') result = PSQL.run_sql_file(sql_file, dbname=self.db_name) self.assertTrue(result) subprocess.check_call(['pg_basebackup', '-D', self.standby_datadir]) #fsdir = os.path.join(self.fsprefix, 'fs', 'gpdb1') fsdir = os.path.join( os.path.split(self.standby_datadir)[0], 'fs_walrepl_a', 'mirror', 'pg_system') self.assertTrue(os.path.isdir(fsdir), '{0} does not dir'.format(fsdir))