def __init__(self,methodName): self.gputil = GpUtility() self.mirrorConfig = [] self.master_port = os.environ.get('PGPORT') self.masterdd = os.environ.get('MASTER_DATA_DIRECTORY') self.activatestdby = "" super(GpstateTestCase,self).__init__(methodName)
def __init__(self): self.stdby = StandbyVerify() self.runmixin = StandbyRunMixin() self.runmixin.createdb(dbname='walrepl') self.mdd = os.environ.get('MASTER_DATA_DIRECTORY') self.config = GPDBConfig() self.pgutil = GpUtility() self.host = socket.gethostname()
def __init__(self, methodName): self.gphome = os.environ.get('GPHOME') self.pgport = os.environ.get('PGPORT') self.pgdatabase = os.environ.get('PGDATABASE') self.stdby_host = 'localhost' self.master_dd = os.environ.get('MASTER_DATA_DIRECTORY') self.pgutil = GpUtility() self.stdby = StandbyVerify() super(WalReplKillProcessTestCase, self).__init__(methodName)
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 __init__(self): self.gpinit = GpinitStandby() self.pgutil = GpUtility() self.runmixin = StandbyRunMixin() self.runmixin.createdb(dbname='walrepl') self.gphome = os.environ.get('GPHOME') self.pgport = os.environ.get('PGPORT') self.mdd = os.environ.get('MASTER_DATA_DIRECTORY') self.config = GPDBConfig() self.host = socket.gethostname() dburl = dbconn.DbURL() gparray = GpArray.initFromCatalog(dburl, utility=True) self.numcontent = gparray.getNumSegmentContents() self.orig_master = gparray.master
def test_run_five(self): for i in xrange(5): with NewEnv(PGPORT=self.port, MASTER_DATA_DIRECTORY=self.mdd): pguti = GpUtility() if i == 0: pguti.install_standby(socket.gethostname(), self.mdd) # starting from second time, init standby from new master, standby_dir will be like master_newstandby_newstandby... else: pguti.install_standby(socket.gethostname(), os.path.join(self.mdd, 'newstandby')) gpact = GpactivateStandby() self.mdd = gpact.get_standby_dd() self.port = gpact.get_standby_port() gpact.activate() tinctest.logger.info("self.mdd is %s, self.port is %s" % (self.mdd, self.port))
limitations under the License. """ import os import socket import tinctest import unittest2 as unittest from tinctest.models.scenario import ScenarioTestCase from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby from mpp.gpdb.tests.storage.walrepl.crash import WalReplKillProcessTestCase from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility from mpp.gpdb.tests.storage.walrepl import lib as walrepl pgutil = GpUtility() class WalReplKillProcessScenarioTestCase(ScenarioTestCase): origin_mdd = os.environ.get('MASTER_DATA_DIRECTORY') def __init__(self, methodName): self.standby_dir = os.environ.get('MASTER_DATA_DIRECTORY') self.pgdatabase = self.pgdatabase = os.environ.get('PGDATABASE') super(WalReplKillProcessScenarioTestCase, self).__init__(methodName) def setUp(self): pgutil.check_and_start_gpdb() # We should forcibly recreate standby, as it might has been promoted. # here we need to install locally, otherwise can not run remote sql
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from mpp.models import MPPTestCase from mpp.lib.config import GPDBConfig from mpp.gpdb.tests.storage.walrepl import lib as walrepl from mpp.gpdb.tests.storage.walrepl.lib.pqwrap import * from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility import subprocess import os gputil = GpUtility() gputil.check_and_start_gpdb() config = GPDBConfig() class GPLibPQTestCase(MPPTestCase): """This test case is to use gplibpq library, which is SQL function interface for walreceiver's libpq part. List of functions Schema | Name | Result data type | Argument data types --------+-----------------+------------------+---------------------- public | test_connect | boolean | text public | test_disconnect | boolean | public | test_receive | boolean | public | test_scenario1 | boolean | text public | test_send | boolean |
def test_tli_mismatch(self): """ Test to verify if TLI mismatch issue during Pass 3 of xlog record (checkpoint) replay occurs or not. A set of checkpoints one after the other when replayed on the standby and then if the standby is promoted, it should go through the prmotion just fine. The flow of this test is as follows. 1. Initiate the Standby using the Master (primary) postmaster paramerters. 2. Perform explicit checkpoints and wait so that they get replicated. 3. Then promote the standby, wait and then try to access it. 4. If we can successfully access it, its a Pass otherwise a Fail. """ PSQL.run_sql_command('DROP table if exists foo') PSQL.run_sql_command('create table foo (a int)') PSQL.run_sql_command('insert into foo ' 'select * from generate_series(1, 1000)') # Initial setup, forcibly remove standby and install new one pgutil = GpUtility() pgutil.remove_standby() logger.info('\nCreate a standby...') res = self.standby.create() self.assertEqual(res, 0) 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) logger.info('Standby activated...') logger.info('Give the standby some time to catchup...') time.sleep(3) logger.info('Create checkpoints and let them get replicated...') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') PSQL.run_sql_command('checkpoint') time.sleep(2) # Promote standby # We don't kill/stop the primary, as it's convenient for # next testing logger.info('Promote the standby immediatly') self.standby.promote() logger.info( 'Wait for the standby to be ready to accept connections ...') time.sleep(3) # Verify the result replicated to the standby. logger.info('Verify if table foo exists...') proc = self.run_sql('select count(*) from foo', str(self.standby.port)) # The table should exist stdout = proc.communicate()[0] logger.info(stdout) search = "1000" self.assertTrue(stdout.find(search) >= 0) logger.info('Pass')
def __init__(self, methodName): self.gp = GpinitStandby() self.mdd = os.environ.get('MASTER_DATA_DIRECTORY') self.pgutil = GpUtility() super(WalRecTestCase, self).__init__(methodName)
def __init__(self, methodName): self.gpinitstandby = GpinitStandby() self.gputil = GpUtility() super(OOMGpstartTestCase, self).__init__(methodName)
def __init__(self, methodName): self.pgutil = GpUtility() super(PromoteTestCase, self).__init__(methodName)
def init_standby(self): pg = GpUtility() pg.install_standby()
def __init__(self,methodName): self.gputil = GpUtility() super(GpstopTestCase,self).__init__(methodName)