def stop_start_validate(self, expect_down_segments=False): """ Do gpstop -i, gpstart and see if all segments come back up fine """ self.gpstart = GpStart() self.gpstop = GpStop() tinctest.logger.info("[STLRTest] Running stop_start_validate") tinctest.logger.info("[STLRTest]Shutting down the cluster") ok = self.gpstop.run_gpstop_cmd(immediate='i') if not expect_down_segments: if not ok: raise Exception( '[STLRTest]Problem while shutting down the cluster') tinctest.logger.info( "[STLRTest]Successfully shutdown the cluster.") tinctest.logger.info("[STLRTest]Restarting the cluster.") ok = self.gpstart.run_gpstart_cmd() if not ok: raise Exception('[STLRTest]Failed to bring the cluster back up') tinctest.logger.info("[STLRTest]Successfully restarted the cluster.") if not self.anydownsegments(): raise Exception("[STLRTest]segments were marked down") else: return (True, "All segments are up")
def __init__(self, host, usr, db, entry_type="host", authmethod="password", password=None): """ Constructor for GpUserRole @param host: which host to be tested; @param usr: user name to login host and login database; @param db: database name @change: Ritesh Jaltare @param entry_type: if a user is created, then we need the type of entry for pg_hba.conf for authen eg host, local, hostssl @param authmethod: denotes the authentication method used, eg: trust , password, md5 @param address: denotes the IP address of the host. it can be both IPV4 or IPV6 """ self.gpstop = GpStop() self.host = host if password is None: self.password = r"'password'" else: self.password = password self.usr = usr self.db = db if self.db is "all": self.pgpassdb = "*" else: self.pgpassdb=self.db gpconfig = GpConfig() masterSSLValue = gpconfig.getParameterMasterOnly("ssl") if masterSSLValue is "on" and entry_type is "host": self.entry_type = "hostssl" else: self.entry_type = entry_type self.authmethod = authmethod if os.path.exists(PGPASSFILE) is False: file = open(PGPASSFILE, 'w') os.chmod(PGPASSFILE,0600)
def __init__(self, methodName): self.pgport = os.environ.get('PGPORT') self.fileutil = Filerepe2e_Util() self.gpstate = Gpstate() self.gpprimarymirror = Gpprimarymirror() self.gpstart = GpStart() self.gpstop = GpStop() super(FtsTransitions,self).__init__(methodName)
def __init__(self): self.gpstart = GpStart() self.gpstop = GpStop() self.config = GpConfig() self.port = os.getenv('PGPORT') self.gphome = (os.getenv('GPHOME')) self.base_dir = os.path.dirname( sys.modules[self.__class__.__module__].__file__)
def setUp(self): self.basedir = os.path.dirname(__file__) self.gphome = os.environ.get('GPHOME') self.gp=GpStart() self.gps=GpStop() self.MAX_TRY=3 self.TIMEOUT=90 self.MAXPARALLELSEG=60
def remove_user(self): pghba = PgHba() for role in ('dsp_role1', 'dsp_role2', 'dsp_role3', 'dsp_role4', 'dsp_role5'): entries = pghba.search( user = role ) for ent in entries: ent.delete() pghba.write() gpstop = GpStop() gpstop.run_gpstop_cmd(reload=True) # reload to activate the users
def stop_db(self): """ @summary: Stops the greenplum DB based on the options provided @param option: represents different gpstop command options @return: output of the executed command as a string """ gpstop = GpStop() gpstop.run_gpstop_cmd()
def reset_gpconfig(self, param): ''' Reset the configuration parameter ''' command = "gpconfig -r %s " % (param) rc = run_shell_command(command) if not rc: raise Exception('Unable to reset the configuration parameter %s ' % param) gpstop = GpStop() gpstop.run_gpstop_cmd(restart=True)
def tearDown(self): # just stop the cluster if there is a failure, to preserve the data directories for debugging if self._resultForDoCleanups.failures or self._resultForDoCleanups.errors: result = True try: result = GpStop().run_gpstop_cmd(mdd=os.path.join(self.testcase_master_dir, 'gpseg-1')) except Exception, e: tinctest.logger.exception(e) tinctest.logger.warning("gpstop failed with errors / warnings")
def __init__(self, methodName): self.pgport = os.environ.get('PGPORT') self.util = Filerepe2e_Util() self.gpconfig = GpConfig() self.config = GPDBConfig() self.gpr = GpRecover(self.config) self.dbstate = DbStateClass('run_validation', self.config) self.gpstart = GpStart() self.gpstop = GpStop() super(FilerepTestCase, self).__init__(methodName)
def __init__(self, methodName): self.filereputil = Filerepe2e_Util() self.config = GPDBConfig() self.gprecover = GpRecover(self.config) self.gpstop = GpStop() self.gpstart = GpStart() self.gpverify = GpdbVerify(config=self.config) self.dbstate = DbStateClass('run_validation', self.config) self.port = os.getenv('PGPORT') super(PgtwoPhaseClass, self).__init__(methodName)
def set_gpconfig(self, param, value): ''' Set the configuration parameter using gpconfig ''' command = "gpconfig -c %s -v \"\'%s\'\" --skipvalidation" % (param, value) rc = run_shell_command(command) if not rc: raise Exception('Unable to set the configuration parameter %s ' % param) gpstop = GpStop() gpstop.run_gpstop_cmd(restart=True)
def __init__(self,methodName): self.fileutil = Filerepe2e_Util() self.config = GPDBConfig() self.gprecover = GpRecover(self.config) self.gpstart = GpStart() self.gpstop = GpStop() self.gpfile = Gpfilespace(self.config) self.dbstate = DbStateClass('run_validation', self.config) self.port = os.getenv('PGPORT') self.base = GPDBStorageBaseTestCase() super(SuspendCheckpointCrashRecovery,self).__init__(methodName)
def setUpClass(cls): super(AppendOnlyEOFTests, cls).setUpClass() gpconfig = GpConfig() (cls.master_value, cls.segment_value) = gpconfig.getParameter('max_appendonly_tables') tinctest.logger.debug("Original max_appendonly_tables values - Master Value: %s Segment Value: %s" %(cls.master_value, cls.segment_value)) gpconfig.setParameter('max_appendonly_tables', '3', '3') GpStop().run_gpstop_cmd(restart=True) (master_value, segment_value) = gpconfig.getParameter('max_appendonly_tables') tinctest.logger.debug("Set max_appendonly_tables to Master Value: %s Segment Value: %s " %(master_value, segment_value)) if master_value != '3' or segment_value != '3': raise Exception("Failed to set max_appendonly_tables to the required values")
def run_restart_database(self): ''' @summary : Restart the database ''' self.gpstart = GpStart() self.gpstop = GpStop() tinctest.logger.info("[STLRTest] Running run_restart_database") ok = self.gpstop.run_gpstop_cmd(immediate='i') tinctest.logger.info(ok) ok = self.gpstart.run_gpstart_cmd() tinctest.logger.info(ok)
def remove_user(self, role): """ @description: Remove an entry for user in pg_hba.conf """ pghba = PgHba() entries = pghba.search( user = role ) for ent in entries: ent.delete() pghba.write() gpstop = GpStop() gpstop.run_gpstop_cmd(reload=True) # reload to activate the users
def __init__(self, config=None): if config is not None: self.config = config else: self.config = GPDBConfig() self.filereputil = Filerepe2e_Util() self.gprecover = GpRecover(self.config) self.gpstop = GpStop() self.gpstart = GpStart() self.gpverify = GpdbVerify(config=self.config) self.dbstate = DbStateClass('run_validation', self.config) self.port = os.getenv('PGPORT')
def tearDownClass(cls): gpconfig = GpConfig() if (not cls.master_value) or (not cls.segment_value): raise Exception("Original max_appendonly_tables value is None") gpconfig.setParameter('max_appendonly_tables', cls.master_value, cls.segment_value) GpStop().run_gpstop_cmd(restart=True) # Make sure the values are reset properly (master_value, segment_value) = gpconfig.getParameter('max_appendonly_tables') try: if master_value != cls.master_value or segment_value != cls.segment_value: raise Exception("Failed to reset max_appendonly_tables to the required values") finally: super(AppendOnlyEOFTests, cls).tearDownClass()
def run_restart_database(self): ''' @summary : Restart the database ''' self.gpstart = GpStart() self.gpstop = GpStop() tinctest.logger.info("[STLRTest] Running run_restart_database") ok = self.gpstop.run_gpstop_cmd(immediate = 'i') tinctest.logger.info(ok) ok = self.gpstart.run_gpstart_cmd() tinctest.logger.info(ok) tinctest.logger.info("[STLRTest] printing gp segment configuration") (gp_seg_conf) = PSQL.run_sql_command("select * from gp_segment_configuration order by dbid") tinctest.logger.info(gp_seg_conf)
def add_user(self, role, mode): """ @description: Add an entry for each user in pg_hba.conf """ pghba = PgHba() new_entry = Entry(entry_type='local', database = 'all', user = role, authmethod = mode) pghba.add_entry(new_entry) pghba.write() # Check if the roles are added correctly res = pghba.search(type='local', database='all', user = role, authmethod= mode) if not res: raise Exception('The entry is not added to pg_hba.conf correctly') gpstop = GpStop() gpstop.run_gpstop_cmd(reload=True) # reload to activate the users
def setUpModule(): """ gpstop a cluster if up and running. Since the tests take care of initsystem themselves and CI sets up a cluster for now, we do this at the beginning of this module """ tinctest.logger.info("Setting up test module. gpstop and gpseginstall") result = True try: result = GpStop().run_gpstop_cmd() except: tinctest.logger.warning("gpstop failed with errors / warnings") if not result: tinctest.logger.warning("gpstop failed with errors / warnings") #return hosts = get_gpexpand_hosts() cmd = GpSegInstall(os.environ.get('GPHOME'), hosts) result = cmd.run(validate=True) if result.rc > 0: tinctest.logger.error("gpseginstall failed with an error code: %s" %result) raise GPExpandTestCaseException("gpseginstall failed with an error code. Failing the test module") tinctest.logger.info("Finished setting up test module successfully")
def __init__(self, methodName): self.gpstop = GpStop() self.dbname = os.environ.get('PGDATABASE') super(languageTestCase, self).__init__(methodName)
def restart(self): # GpStop does not accept immedaite and restart both... GpStop().run_gpstop_cmd(immediate=True) GpStart().run_gpstart_cmd()
def __init__(self, methodName): self.gpstop = GpStop() super(PgcryptoMPPTestCase, self).__init__(methodName)