コード例 #1
0
ファイル: __init__.py プロジェクト: stefanieqiang/gpdb-1
 def __init__(self):
     self.host = str(socket.gethostbyname(socket.gethostname()))
     self.port = str(getOpenPort())
     self.gpfdist_dir = local_path('')
     self.gpfdist = GPFDIST(self.port,
                            self.host,
                            directory=self.gpfdist_dir)
コード例 #2
0
    def setUpClass(cls):
        super(GpfdistSQLTestCase, cls).setUpClass()
        if not cls.start_on in cls._start_on_valid_values:
            raise TINCException("Invalid value specified for attribute 'start_on' : %s" %cls.start_on)

        config = GPDBConfig()
        host_list = cls._form_host_list(cls.start_on, config)

        for host in host_list:
            cls.port = mppUtil.getOpenPort(cls.port, host=host)
            tinctest.logger.info("gpfdist host = {0}, port = {1}".format(host,cls.port))
            gpfdist = GPFDIST(cls.port, host, directory=cls.get_data_dir())
            gpfdist.startGpfdist()
            cls.gpfdist.append(gpfdist)
コード例 #3
0
    def setUpClass(cls):
        # we need an empty db to run the tests
        tinctest.logger.info("recreate database wet using dropdb/createdb")
        cmd = Command('recreatedb', 'dropdb wet; createdb wet')
        cmd.run(validateAfter=False)

        cls.drop_roles()

        super(LegacyWETTestCase, cls).setUpClass()

        source_dir = cls.get_source_dir()
        config = GPDBConfig()
        host, _ = config.get_hostandport_of_segment(0)
        port = mppUtil.getOpenPort(8080)
        tinctest.logger.info("gpfdist host = {0}, port = {1}".format(host, port))

        cls.config = config

        data_dir = os.path.join(source_dir, 'data')
        cls.gpfdist = GPFDIST(port, host, directory=data_dir)
        cls.gpfdist.startGpfdist()

        # WET writes into this directory.
        data_out_dir = os.path.join(cls.gpfdist.getdir(), 'output')
        shutil.rmtree(data_out_dir, ignore_errors=True)
        os.mkdir(data_out_dir)
コード例 #4
0
ファイル: __init__.py プロジェクト: 50wu/gpdb
class MDT:

    def __init__(self):
        self.host = str(socket.gethostbyname(socket.gethostname()))
        self.port = str(getOpenPort())
        self.gpfdist_dir = local_path('')
        self.gpfdist = GPFDIST(self.port, self.host, directory=self.gpfdist_dir)

    def setup_gpfdist(self):
        self.gpfdist.killGpfdist()
        self.gpfdist.startGpfdist()

    def cleanup_gpfdist(self):
        self.gpfdist.killGpfdist()
        return True

    def pre_process_sql(self, sql_path = local_path("sql")):
        for dir in os.listdir(sql_path):
            file = os.path.join(local_path('sql'), dir)
            if os.path.isfile(file):
                self.do_insert_select(file)
                self.modify_sql_file(file)

    def pre_process_ans(self, sql_path = local_path("expected")):
        for dir in os.listdir(sql_path):
            file = os.path.join(local_path('expected'), dir)
            if os.path.isfile(file):
                self.modify_ans_file(file)

    def do_insert_select(self, filename=None):
        tmp_file = filename + '.tmp'
        a=0
        #if (filename.find('alter_part_table')>=0) or (filename.find('create_table_partitions')>=0):
        if (filename.find('part')>=0):
            selectString='select classname,schemaname, objname, usestatus, usename, actionname, subtype, partitionlevel, parenttablename, parentschemaname  from pg_stat_partition_operations  where statime > ( select statime from pg_stat_partition_operations where objname =\'my_first_table\' and actionname =\'CREATE\') and objname  not in (\'pg_stat_operations\',\'pg_stat_partition_operations\') order by statime;'
        else:
            selectString='select classname  , schemaname , objname  , usestatus , usename , actionname , subtype from pg_stat_operations  where statime > ( select statime from pg_stat_operations where objname =\'my_first_table\' and actionname =\'CREATE\') and objname  not in (\'pg_stat_operations\',\'pg_stat_partition_operations\') order by statime;'
        f = open(filename,'r')
        f1 = open(tmp_file, 'w')
        for line in f:
            if (line.find('drop ')!=-1) and (a==0):
                f1.write(selectString)
                f1.write('\n')
                a = 1
            f1.write(line)
        f.close()
        f1.write(selectString)
        f1.write('\n')
        f1.close()
        shutil.move(tmp_file, filename)

    def modify_sql_file(self, file = None):    
        for line in fileinput.FileInput(file,inplace=1):
            line = re.sub('(\d+)\.(\d+)\.(\d+)\.(\d+)\:(\d+)', self.host+':'+self.port, line)
            print str(re.sub('\n','',line))

    def modify_ans_file(self, file = None):
        for line in fileinput.FileInput(file,inplace=1):
            line = re.sub('gpadmin', getpass.getuser(), line)
            print str(re.sub('\n','',line))
コード例 #5
0
    def setUpClass(cls):
        super(other_tests, cls).setUpClass()
        source_dir = cls.get_source_dir()
        config = GPDBConfig()
        host, _ = config.get_hostandport_of_segment(0)
        port = mppUtil.getOpenPort(8080)
        tinctest.logger.info("gpfdist host = {0}, port = {1}".format(
            host, port))

        data_dir = os.path.join(source_dir, 'data')
        cls.gpfdist = GPFDIST(port, host, directory=data_dir)
        cls.gpfdist.startGpfdist()

        data_out_dir = os.path.join(data_dir, 'output')
        shutil.rmtree(data_out_dir, ignore_errors=True)
        os.mkdir(data_out_dir)
コード例 #6
0
ファイル: test_read.py プロジェクト: stefanieqiang/gpdb-1
    def setUpClass(cls):
        super(LegacyRETTestCase, cls).setUpClass()

        cls.split_tbl()

        source_dir = cls.get_source_dir()
        config = GPDBConfig()
        host, _ = config.get_hostandport_of_segment(0)
        port = mppUtil.getOpenPort(8080)
        tinctest.logger.info("gpfdist host = {0}, port = {1}".format(
            host, port))

        data_dir = os.path.join(source_dir, 'data')
        cls.gpfdist = GPFDIST(port, host, directory=data_dir)
        cls.gpfdist.startGpfdist()

        # Some test writes data into disk temporarily.
        data_out_dir = os.path.join(data_dir, 'output')
        shutil.rmtree(data_out_dir, ignore_errors=True)
        os.mkdir(data_out_dir)
コード例 #7
0
ファイル: __init__.py プロジェクト: 50wu/gpdb
 def __init__(self):
     self.host = str(socket.gethostbyname(socket.gethostname()))
     self.port = str(getOpenPort())
     self.gpfdist_dir = local_path('')
     self.gpfdist = GPFDIST(self.port, self.host, directory=self.gpfdist_dir)
コード例 #8
0
ファイル: __init__.py プロジェクト: stefanieqiang/gpdb-1
class MDT:
    def __init__(self):
        self.host = str(socket.gethostbyname(socket.gethostname()))
        self.port = str(getOpenPort())
        self.gpfdist_dir = local_path('')
        self.gpfdist = GPFDIST(self.port,
                               self.host,
                               directory=self.gpfdist_dir)

    def setup_gpfdist(self):
        self.gpfdist.killGpfdist()
        self.gpfdist.startGpfdist()

    def cleanup_gpfdist(self):
        self.gpfdist.killGpfdist()
        return True

    def pre_process_sql(self, sql_path=local_path("sql")):
        for dir in os.listdir(sql_path):
            file = os.path.join(local_path('sql'), dir)
            if os.path.isfile(file):
                self.do_insert_select(file)
                self.modify_sql_file(file)

    def pre_process_ans(self, sql_path=local_path("expected")):
        for dir in os.listdir(sql_path):
            file = os.path.join(local_path('expected'), dir)
            if os.path.isfile(file):
                self.modify_ans_file(file)

    def do_insert_select(self, filename=None):
        tmp_file = filename + '.tmp'
        a = 0
        #if (filename.find('alter_part_table')>=0) or (filename.find('create_table_partitions')>=0):
        if (filename.find('part') >= 0):
            selectString = 'select classname,schemaname, objname, usestatus, usename, actionname, subtype, partitionlevel, parenttablename, parentschemaname  from pg_stat_partition_operations  where statime > ( select statime from pg_stat_partition_operations where objname =\'my_first_table\' and actionname =\'CREATE\') and objname  not in (\'pg_stat_operations\',\'pg_stat_partition_operations\') order by statime;'
        else:
            selectString = 'select classname  , schemaname , objname  , usestatus , usename , actionname , subtype from pg_stat_operations  where statime > ( select statime from pg_stat_operations where objname =\'my_first_table\' and actionname =\'CREATE\') and objname  not in (\'pg_stat_operations\',\'pg_stat_partition_operations\') order by statime;'
        f = open(filename, 'r')
        f1 = open(tmp_file, 'w')
        for line in f:
            if (line.find('drop ') != -1) and (a == 0):
                f1.write(selectString)
                f1.write('\n')
                a = 1
            f1.write(line)
        f.close()
        f1.write(selectString)
        f1.write('\n')
        f1.close()
        shutil.move(tmp_file, filename)

    def modify_sql_file(self, file=None):
        for line in fileinput.FileInput(file, inplace=1):
            line = re.sub('(\d+)\.(\d+)\.(\d+)\.(\d+)\:(\d+)',
                          self.host + ':' + self.port, line)
            print str(re.sub('\n', '', line))

    def modify_ans_file(self, file=None):
        for line in fileinput.FileInput(file, inplace=1):
            line = re.sub('gpadmin', getpass.getuser(), line)
            print str(re.sub('\n', '', line))