예제 #1
0
    def do_PLPERL_initialize(self):
        """ Language PL/PERL upgrade to 9.1: initialize test data  """

        gpuserRole = GpUserRole(HOST, USER, DBNAME)
        gpuserRole.createUser('pltestuser', 'NOSUPERUSER')
        gpuserRole.createUser('plsuperuser', 'SUPERUSER')
        pg_hba_path = os.path.join(os.environ.get('MASTER_DATA_DIRECTORY'),
                                   'pg_hba.conf')
        print 'pg_hba_path', pg_hba_path
        pghba_file = PgHba.PgHba(pg_hba_path)
        new_ent = PgHba.Entry(entry_type='local',
                              database=DBNAME,
                              user='******',
                              authmethod='trust')
        pghba_file.add_entry(new_ent)
        new_ent = PgHba.Entry(entry_type='local',
                              database=DBNAME,
                              user='******',
                              authmethod='trust')
        pghba_file.add_entry(new_ent)
        pghba_file.write()
        grantcmd = 'CREATE SCHEMA pltest; GRANT ALL ON SCHEMA pltest TO pltestuser;'
        cmd = PSQL(sql_cmd=grantcmd, dbname=DBNAME)
        tinctest.logger.info("Running command - %s" % cmd)
        cmd.run(validateAfter=False)
        result = cmd.get_results()
        ok = result.rc
        out = result.stdout
        if ok:
            raise Exception(
                'Grant all on schema pltest to pltestuser failed: %s' % out)
예제 #2
0
 def do_PLPERL_initialize(self):
     """ Language PL/PERL upgrade to 9.1: initialize test data  """
     self.doTest(None, "plperl91/test000_initialize", default='-e')
     """ Initialize: generate data tbctest.lineitem.tbl, and add users to pg_hba.conf """
     fname = os.environ.get(
         'TINCREPOHOME') + '/mpp/lib/datagen/datasets/lineitem.csv'
     copycmd = 'copy pltest.lineitem from \'' + fname + '\' DELIMITER \'|\';'
     cmd = PSQL(sql_cmd=copycmd, dbname=DBNAME)
     tinctest.logger.info("Running command - %s" % cmd)
     cmd.run(validateAfter=False)
     result = cmd.get_results()
     ok = result.rc
     out = result.stdout
     if ok:
         raise Exception('Copy statement failed: %s' % out)
     gpuserRole = GpUserRole(HOST, USER, DBNAME)
     gpuserRole.createUser('pltestuser', 'NOSUPERUSER')
     gpuserRole.createUser('plsuperuser', 'SUPERUSER')
     pg_hba_path = os.path.join(os.environ.get('MASTER_DATA_DIRECTORY'),
                                'pg_hba.conf')
     print 'pg_hba_path', pg_hba_path
     pghba_file = PgHba.PgHba(pg_hba_path)
     new_ent = PgHba.Entry(entry_type='local',
                           database=DBNAME,
                           user='******',
                           authmethod='trust')
     pghba_file.add_entry(new_ent)
     new_ent = PgHba.Entry(entry_type='local',
                           database=DBNAME,
                           user='******',
                           authmethod='trust')
     pghba_file.add_entry(new_ent)
     pghba_file.write()
     grantcmd = 'GRANT ALL ON SCHEMA pltest TO pltestuser;'
     cmd = PSQL(sql_cmd=grantcmd, dbname=DBNAME)
     tinctest.logger.info("Running command - %s" % cmd)
     cmd.run(validateAfter=False)
     result = cmd.get_results()
     ok = result.rc
     out = result.stdout
     if ok:
         raise Exception(
             'Grant all on schema pltest to pltestuser failed: %s' % out)
예제 #3
0
    def test_add_new_value(self):
        new_ent = PgHba.Entry(entry_type='local', 
                              database = 'test_database',
                              user = '******', 
                              authmethod = 'sspi')
        self.pghba_file.add_entry(new_ent)
        self.assertEqual(3, len(self.pghba_file.get_contents_without_comments()))

        res = self.pghba_file.search(type='local', 
                                     database='test_database',
                                     user='******',
                                     authmethod='sspi')
        self.assertTrue(res)
예제 #4
0
 def setUp(self):
     self.pghba_file = PgHba.PgHba(os.path.join(_BASEDIR, 'input', 'pg_hba.conf'))