示例#1
0
def before_scenario(context, scenario):
    if "skip" in scenario.effective_tags:
        scenario.skip("skipping scenario tagged with @skip")
        return

    if 'gpmovemirrors' in context.feature.tags:
        context.mirror_context = MirrorMgmtContext()

    if 'gpaddmirrors' in context.feature.tags:
        context.mirror_context = MirrorMgmtContext()

    if 'gprecoverseg' in context.feature.tags:
        context.mirror_context = MirrorMgmtContext()

    if 'gpconfig' in context.feature.tags:
        context.gpconfig_context = GpConfigContext()

    if 'gpssh-exkeys' in context.feature.tags:
        context.gpssh_exkeys_context = GpsshExkeysMgmtContext(context)

    tags_to_skip = ['gpexpand', 'gpaddmirrors', 'gpstate', 'gpmovemirrors',
                    'gpconfig', 'gpssh-exkeys', 'gpstop', 'gpinitsystem', 'cross_subnet']
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'testdb')
    if 'gp_bash_functions.sh' in context.feature.tags or 'backup_restore_bashrc' in scenario.effective_tags:
        backup_bashrc()
示例#2
0
def before_scenario(context, scenario):
    if 'gpexpand' in context.feature.tags or 'gpaddmirrors' in context.feature.tags:
        return

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'testdb')
示例#3
0
def before_scenario(context, scenario):
    if "skip_fixme_ubuntu18.04" in scenario.effective_tags:
        if platform.linux_distribution()[0].lower(
        ) == "ubuntu" and platform.linux_distribution()[1] == "18.04":
            scenario.skip(
                "skipping scenario tagged with @skip_fixme_ubuntu18.04")
            return

    if "skip" in scenario.effective_tags:
        scenario.skip("skipping scenario tagged with @skip")
        return

    if 'gpmovemirrors' in context.feature.tags:
        context.mirror_context = MirrorMgmtContext()

    if 'gpconfig' in context.feature.tags:
        context.gpconfig_context = GpConfigContext()

    if 'gpssh-exkeys' in context.feature.tags:
        context.gpssh_exkeys_context = GpsshExkeysMgmtContext(context)

    tags_to_skip = [
        'gpexpand', 'gpaddmirrors', 'gpstate', 'gpmovemirrors', 'gpconfig',
        'gpssh-exkeys', 'gpstop', 'gpinitsystem', 'cross_subnet'
    ]
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'testdb')
示例#4
0
def after_scenario(context, scenario):
    if 'gpexpand' in context.feature.tags or 'gpaddmirrors' in context.feature.tags:
        return

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)

        home_dir = os.path.expanduser('~')
        if not check_user_permissions(home_dir, 'write') and hasattr(context, 'orig_write_permission')\
                                                         and context.orig_write_permission:
            run_command(context, 'sudo chmod u+w %s' % home_dir)

        if os.path.isdir('%s/gpAdminLogs.bk' % home_dir):
            shutil.move('%s/gpAdminLogs.bk' % home_dir, '%s/gpAdminLogs' % home_dir)

    if 'gpssh' in context.feature.tags:
        run_command(context, 'sudo tc qdisc del dev lo root netem')

    # for cleaning up after @given('"{path}" has its permissions set to "{perm}"')
    if (hasattr(context, 'path_for_which_to_restore_the_permissions') and
            hasattr(context, 'permissions_to_restore_path_to')):
        os.chmod(context.path_for_which_to_restore_the_permissions, context.permissions_to_restore_path_to)
    elif hasattr(context, 'path_for_which_to_restore_the_permissions'):
        raise Exception('Missing permissions_to_restore_path_to for %s' %
                        context.path_for_which_to_restore_the_permissions)
    elif hasattr(context, 'permissions_to_restore_path_to'):
        raise Exception('Missing path_for_which_to_restore_the_permissions despite the specified permission %o' %
                        context.permissions_to_restore_path_to)
示例#5
0
def after_scenario(context, scenario):
    tags_to_skip = ['gpexpand', 'gpaddmirrors', 'gpstate', 'gpinitstandby']
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    if 'gpmovemirrors' in context.feature.tags:
        if 'temp_base_dir' in context:
            shutil.rmtree(context.temp_base_dir)

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)

        home_dir = os.path.expanduser('~')
        if not check_user_permissions(home_dir, 'write') and hasattr(context, 'orig_write_permission')\
                                                         and context.orig_write_permission:
            run_command(context, 'sudo chmod u+w %s' % home_dir)

        if os.path.isdir('%s/gpAdminLogs.bk' % home_dir):
            shutil.move('%s/gpAdminLogs.bk' % home_dir, '%s/gpAdminLogs' % home_dir)

    if 'gpssh' in context.feature.tags:
        run_command(context, 'sudo tc qdisc del dev lo root netem')

    # for cleaning up after @given('"{path}" has its permissions set to "{perm}"')
    if (hasattr(context, 'path_for_which_to_restore_the_permissions') and
            hasattr(context, 'permissions_to_restore_path_to')):
        os.chmod(context.path_for_which_to_restore_the_permissions, context.permissions_to_restore_path_to)
    elif hasattr(context, 'path_for_which_to_restore_the_permissions'):
        raise Exception('Missing permissions_to_restore_path_to for %s' %
                        context.path_for_which_to_restore_the_permissions)
    elif hasattr(context, 'permissions_to_restore_path_to'):
        raise Exception('Missing path_for_which_to_restore_the_permissions despite the specified permission %o' %
                        context.permissions_to_restore_path_to)
示例#6
0
def before_scenario(context, scenario):
    if 'gpexpand' in context.feature.tags or 'gpaddmirrors' in context.feature.tags or 'gpstate' in context.feature.tags:
        return

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'testdb')
示例#7
0
def after_scenario(context, scenario):
    if 'analyzedb' not in context.feature.tags:
        master_data_dir = os.environ.get('MASTER_DATA_DIRECTORY')
        fn = os.path.join(master_data_dir, 'dirty_hack.txt')
        if os.path.exists(fn):
            #os.remove(fn)
            pass
        start_database_if_not_started(context)

        home_dir = os.path.expanduser('~')
        if not check_user_permissions(home_dir, 'write') and hasattr(context, 'orig_write_permission')\
                                                         and context.orig_write_permission:
            run_command(context, 'sudo chmod u+w %s' % home_dir)

        if os.path.isdir('%s/gpAdminLogs.bk' % home_dir):
            shutil.move('%s/gpAdminLogs.bk' % home_dir, '%s/gpAdminLogs' % home_dir)

    if 'gpssh' in context.feature.tags:
        run_command(context, 'sudo tc qdisc del dev lo root netem')

    # for cleaning up after @given('"{path}" has its permissions set to "{perm}"')
    if (hasattr(context, 'path_for_which_to_restore_the_permissions') and
            hasattr(context, 'permissions_to_restore_path_to')):
        os.chmod(context.path_for_which_to_restore_the_permissions, context.permissions_to_restore_path_to)
    elif hasattr(context, 'path_for_which_to_restore_the_permissions'):
        raise Exception('Missing permissions_to_restore_path_to for %s' %
                        context.path_for_which_to_restore_the_permissions)
    elif hasattr(context, 'permissions_to_restore_path_to'):
        raise Exception('Missing path_for_which_to_restore_the_permissions despite the specified permission %o' %
                        context.permissions_to_restore_path_to)
示例#8
0
def before_scenario(context, scenario):
    if 'analyzedb' not in context.feature.tags:
        master_data_dir = os.environ.get('MASTER_DATA_DIRECTORY')
        fn = os.path.join(master_data_dir, 'dirty_hack.txt')
        if os.path.exists(fn):
            os.remove(fn)
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'testdb')
示例#9
0
文件: environment.py 项目: 50wu/gpdb
def before_scenario(context, scenario):
    if 'analyzedb' not in context.feature.tags:
        master_data_dir = os.environ.get('MASTER_DATA_DIRECTORY')
        fn = os.path.join(master_data_dir, 'dirty_hack.txt')
        if os.path.exists(fn):
            os.remove(fn)
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'testdb')
示例#10
0
def after_scenario(context, scenario):
    #TODO: you'd think that the scenario.skip() in before_scenario() would
    #  cause this to not be needed
    if "skip" in scenario.effective_tags:
        return

    if 'tablespaces' in context:
        for tablespace in list(context.tablespaces.values()):
            tablespace.cleanup()

    if 'gpstop' in scenario.effective_tags:
        context.execute_steps('''
            # restart the cluster so that subsequent tests re-use the existing demo cluster
            Then the user runs "gpstart -a"
            And gpstart should return a return code of 0
            ''')

    # NOTE: gpconfig after_scenario cleanup is in the step `the gpconfig context is setup`
    tags_to_skip = [
        'gpexpand', 'gpaddmirrors', 'gpstate', 'gpinitstandby', 'gpconfig',
        'gpstop', 'gpinitsystem', 'cross_subnet'
    ]
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    tags_to_cleanup = ['gpmovemirrors', 'gpssh-exkeys']
    if set(context.feature.tags).intersection(tags_to_cleanup):
        if 'temp_base_dir' in context:
            shutil.rmtree(context.temp_base_dir)

    tags_to_not_restart_db = ['analyzedb', 'gpssh-exkeys']
    if not set(context.feature.tags).intersection(tags_to_not_restart_db):
        start_database_if_not_started(context)

        home_dir = os.path.expanduser('~')
        if not check_user_permissions(home_dir, 'write') and hasattr(context, 'orig_write_permission')\
                                                         and context.orig_write_permission:
            run_command(context, 'sudo chmod u+w %s' % home_dir)

        if os.path.isdir('%s/gpAdminLogs.bk' % home_dir):
            shutil.move('%s/gpAdminLogs.bk' % home_dir,
                        '%s/gpAdminLogs' % home_dir)

    if 'gpssh' in context.feature.tags:
        run_command(context, 'sudo tc qdisc del dev lo root netem')

    # for cleaning up after @given('"{path}" has its permissions set to "{perm}"')
    if (hasattr(context, 'path_for_which_to_restore_the_permissions')
            and hasattr(context, 'permissions_to_restore_path_to')):
        os.chmod(context.path_for_which_to_restore_the_permissions,
                 context.permissions_to_restore_path_to)
    elif hasattr(context, 'path_for_which_to_restore_the_permissions'):
        raise Exception('Missing permissions_to_restore_path_to for %s' %
                        context.path_for_which_to_restore_the_permissions)
    elif hasattr(context, 'permissions_to_restore_path_to'):
        raise Exception(
            'Missing path_for_which_to_restore_the_permissions despite the specified permission %o'
            % context.permissions_to_restore_path_to)
示例#11
0
def before_feature(context, feature):
    # we should be able to run gpexpand without having a cluster initialized
    tags_to_skip = [
        'gpexpand', 'gpaddmirrors', 'gpstate', 'gpmovemirrors', 'gpconfig',
        'gpssh-exkeys'
    ]
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    drop_database_if_exists(context, 'testdb')
    drop_database_if_exists(context, 'bkdb')
    drop_database_if_exists(context, 'fullbkdb')
    drop_database_if_exists(context, 'schematestdb')

    if 'analyzedb' in feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'incr_analyze')
        create_database(context, 'incr_analyze')
        drop_database_if_exists(context, 'incr_analyze_2')
        create_database(context, 'incr_analyze_2')
        context.conn = dbconn.connect(dbconn.DbURL(dbname='incr_analyze'))
        context.dbname = 'incr_analyze'

        # setting up the tables that will be used
        context.execute_steps(u"""
        Given there is a regular "ao" table "t1_ao" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "heap" table "t2_heap" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "ao" table "t3_ao" with column name list "a,b,c" and column type list "int,text,real" in schema "public"
        And there is a hard coded ao partition table "sales" with 4 child partitions in schema "public"
        """)

    if 'minirepro' in feature.tags:
        start_database_if_not_started(context)
        minirepro_db = 'minireprodb'
        drop_database_if_exists(context, minirepro_db)
        create_database(context, minirepro_db)
        context.conn = dbconn.connect(dbconn.DbURL(dbname=minirepro_db))
        context.dbname = minirepro_db
        dbconn.execSQL(context.conn, 'create table t1(a integer, b integer)')
        dbconn.execSQL(context.conn, 'create table t2(c integer, d integer)')
        dbconn.execSQL(context.conn, 'create table t3(e integer, f integer)')
        dbconn.execSQL(
            context.conn,
            'create view v1 as select a, b from t1, t3 where t1.a=t3.e')
        dbconn.execSQL(
            context.conn,
            'create view v2 as select c, d from t2, t3 where t2.c=t3.f')
        dbconn.execSQL(
            context.conn,
            'create view v3 as select a, d from v1, v2 where v1.a=v2.c')
        dbconn.execSQL(context.conn, 'insert into t1 values(1, 2)')
        dbconn.execSQL(context.conn, 'insert into t2 values(1, 3)')
        dbconn.execSQL(context.conn, 'insert into t3 values(1, 4)')
        context.conn.commit()
示例#12
0
def before_scenario(context, scenario):
    if 'gpmovemirrors' in context.feature.tags:
        context.mirror_context = MirrorMgmtContext()

    tags_to_skip = ['gpexpand', 'gpaddmirrors', 'gpstate', 'gpmovemirrors']
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'testdb')
示例#13
0
def before_scenario(context, scenario):
    if 'gpmovemirrors' in context.feature.tags:
        context.mirror_context = MirrorMgmtContext()

    tags_to_skip = ['gpexpand', 'gpaddmirrors', 'gpstate', 'gpmovemirrors']
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'testdb')
示例#14
0
def before_feature(context, feature):
    drop_database_if_exists(context, 'testdb')
    drop_database_if_exists(context, 'bkdb')
    drop_database_if_exists(context, 'fullbkdb')
    drop_database_if_exists(context, 'schematestdb')

    if 'gpperfmon' in feature.tags:
        drop_database_if_exists(context, 'gpperfmon')
        pgport = os.getenv('PGPORT', 5432)
        command = "gpperfmon_install --enable --password changeme --port %s" % pgport
        run_gpcommand(context, command)
        run_gpcommand(context, "gpstop -ar")

    if 'analyzedb' in feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'incr_analyze')
        create_database(context, 'incr_analyze')
        drop_database_if_exists(context, 'incr_analyze_2')
        create_database(context, 'incr_analyze_2')
        context.conn = dbconn.connect(dbconn.DbURL(dbname='incr_analyze'))
        context.dbname = 'incr_analyze'

        # setting up the tables that will be used
        context.execute_steps(u"""
        Given there is a regular "ao" table "t1_ao" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "heap" table "t2_heap" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "ao" table "t3_ao" with column name list "a,b,c" and column type list "int,text,real" in schema "public"
        And there is a hard coded ao partition table "sales" with 4 child partitions in schema "public"
        """)

    if 'minirepro' in feature.tags:
        start_database_if_not_started(context)
        minirepro_db = 'minireprodb'
        drop_database_if_exists(context, minirepro_db)
        create_database(context, minirepro_db)
        context.conn = dbconn.connect(dbconn.DbURL(dbname=minirepro_db))
        context.dbname = minirepro_db
        dbconn.execSQL(context.conn, 'create table t1(a integer, b integer)')
        dbconn.execSQL(context.conn, 'create table t2(c integer, d integer)')
        dbconn.execSQL(context.conn, 'create table t3(e integer, f integer)')
        dbconn.execSQL(
            context.conn,
            'create view v1 as select a, b from t1, t3 where t1.a=t3.e')
        dbconn.execSQL(
            context.conn,
            'create view v2 as select c, d from t2, t3 where t2.c=t3.f')
        dbconn.execSQL(
            context.conn,
            'create view v3 as select a, d from v1, v2 where v1.a=v2.c')
        dbconn.execSQL(context.conn, 'insert into t1 values(1, 2)')
        dbconn.execSQL(context.conn, 'insert into t2 values(1, 3)')
        dbconn.execSQL(context.conn, 'insert into t3 values(1, 4)')
        context.conn.commit()
示例#15
0
文件: environment.py 项目: 50wu/gpdb
def after_scenario(context, scenario):
    if 'analyzedb' not in context.feature.tags:
        master_data_dir = os.environ.get('MASTER_DATA_DIRECTORY')
        fn = os.path.join(master_data_dir, 'dirty_hack.txt')
        if os.path.exists(fn):
            #os.remove(fn)
            pass
        start_database_if_not_started(context)

        home_dir = os.path.expanduser('~')
        if not check_user_permissions(home_dir, 'write') and hasattr(context, 'orig_write_permission')\
                                                         and context.orig_write_permission:
            run_command(context, 'sudo chmod u+w %s' % home_dir)

        if os.path.isdir('%s/gpAdminLogs.bk' % home_dir):
            shutil.move('%s/gpAdminLogs.bk' % home_dir, '%s/gpAdminLogs' % home_dir)
示例#16
0
def after_scenario(context, scenario):
    if 'analyzedb' not in context.feature.tags:
        master_data_dir = os.environ.get('MASTER_DATA_DIRECTORY')
        fn = os.path.join(master_data_dir, 'dirty_hack.txt')
        if os.path.exists(fn):
            #os.remove(fn)
            pass
        start_database_if_not_started(context)

        home_dir = os.path.expanduser('~')
        if not check_user_permissions(home_dir, 'write') and hasattr(context, 'orig_write_permission')\
                                                         and context.orig_write_permission:
            run_command(context, 'sudo chmod u+w %s' % home_dir)

        if os.path.isdir('%s/gpAdminLogs.bk' % home_dir):
            shutil.move('%s/gpAdminLogs.bk' % home_dir, '%s/gpAdminLogs' % home_dir)
示例#17
0
文件: environment.py 项目: 50wu/gpdb
def before_feature(context, feature):
    drop_database_if_exists(context, 'testdb')
    drop_database_if_exists(context, 'bkdb')
    drop_database_if_exists(context, 'fullbkdb')
    drop_database_if_exists(context, 'schematestdb')

    if 'gpperfmon' in feature.tags:
        drop_database_if_exists(context, 'gpperfmon')
        pgport = os.getenv('PGPORT', 5432)
        command = "gpperfmon_install --enable --password changeme --port %s" % pgport
        run_gpcommand(context, command)
        run_gpcommand(context, "gpstop -ar")

    if 'analyzedb' in feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'incr_analyze')
        create_database(context, 'incr_analyze')
        drop_database_if_exists(context, 'incr_analyze_2')
        create_database(context, 'incr_analyze_2')
        context.conn = dbconn.connect(dbconn.DbURL(dbname='incr_analyze'))
        context.dbname = 'incr_analyze'

        # setting up the tables that will be used
        context.execute_steps(u"""
        Given there is a regular "ao" table "t1_ao" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "heap" table "t2_heap" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "ao" table "t3_ao" with column name list "a,b,c" and column type list "int,text,real" in schema "public"
        And there is a hard coded ao partition table "sales" with 4 child partitions in schema "public"
        """)

    if 'minirepro' in feature.tags:
        start_database_if_not_started(context)
        minirepro_db = 'minireprodb'
        drop_database_if_exists(context, minirepro_db)
        create_database(context, minirepro_db)
        context.conn = dbconn.connect(dbconn.DbURL(dbname=minirepro_db))
        context.dbname = minirepro_db
        dbconn.execSQL(context.conn, 'create table t1(a integer, b integer)')
        dbconn.execSQL(context.conn, 'create table t2(c integer, d integer)')
        dbconn.execSQL(context.conn, 'create table t3(e integer, f integer)')
        dbconn.execSQL(context.conn, 'create view v1 as select a, b from t1, t3 where t1.a=t3.e')
        dbconn.execSQL(context.conn, 'create view v2 as select c, d from t2, t3 where t2.c=t3.f')
        dbconn.execSQL(context.conn, 'create view v3 as select a, d from v1, v2 where v1.a=v2.c')
        dbconn.execSQL(context.conn, 'insert into t1 values(1, 2)')
        dbconn.execSQL(context.conn, 'insert into t2 values(1, 3)')
        dbconn.execSQL(context.conn, 'insert into t3 values(1, 4)')
        context.conn.commit()
示例#18
0
def before_feature(context, feature):
    # we should be able to run gpexpand without having a cluster initialized
    tags_to_skip = ['gpexpand', 'gpaddmirrors', 'gpstate', 'gpmovemirrors']
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    drop_database_if_exists(context, 'testdb')
    drop_database_if_exists(context, 'bkdb')
    drop_database_if_exists(context, 'fullbkdb')
    drop_database_if_exists(context, 'schematestdb')

    if 'analyzedb' in feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'incr_analyze')
        create_database(context, 'incr_analyze')
        drop_database_if_exists(context, 'incr_analyze_2')
        create_database(context, 'incr_analyze_2')
        context.conn = dbconn.connect(dbconn.DbURL(dbname='incr_analyze'))
        context.dbname = 'incr_analyze'

        # setting up the tables that will be used
        context.execute_steps(u"""
        Given there is a regular "ao" table "t1_ao" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "heap" table "t2_heap" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "ao" table "t3_ao" with column name list "a,b,c" and column type list "int,text,real" in schema "public"
        And there is a hard coded ao partition table "sales" with 4 child partitions in schema "public"
        """)

    if 'minirepro' in feature.tags:
        start_database_if_not_started(context)
        minirepro_db = 'minireprodb'
        drop_database_if_exists(context, minirepro_db)
        create_database(context, minirepro_db)
        context.conn = dbconn.connect(dbconn.DbURL(dbname=minirepro_db))
        context.dbname = minirepro_db
        dbconn.execSQL(context.conn, 'create table t1(a integer, b integer)')
        dbconn.execSQL(context.conn, 'create table t2(c integer, d integer)')
        dbconn.execSQL(context.conn, 'create table t3(e integer, f integer)')
        dbconn.execSQL(context.conn, 'create view v1 as select a, b from t1, t3 where t1.a=t3.e')
        dbconn.execSQL(context.conn, 'create view v2 as select c, d from t2, t3 where t2.c=t3.f')
        dbconn.execSQL(context.conn, 'create view v3 as select a, d from v1, v2 where v1.a=v2.c')
        dbconn.execSQL(context.conn, 'insert into t1 values(1, 2)')
        dbconn.execSQL(context.conn, 'insert into t2 values(1, 3)')
        dbconn.execSQL(context.conn, 'insert into t3 values(1, 4)')
        context.conn.commit()
示例#19
0
def after_scenario(context, scenario):
    if 'tablespaces' in context:
        for tablespace in context.tablespaces.values():
            tablespace.cleanup()

    # NOTE: gpconfig after_scenario cleanup is in the step `the gpconfig context is setup`
    tags_to_skip = [
        'gpexpand', 'gpaddmirrors', 'gpstate', 'gpinitstandby', 'gpconfig'
    ]
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    if 'gpmovemirrors' in context.feature.tags:
        if 'temp_base_dir' in context:
            shutil.rmtree(context.temp_base_dir)

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)

        home_dir = os.path.expanduser('~')
        if not check_user_permissions(home_dir, 'write') and hasattr(context, 'orig_write_permission')\
                                                         and context.orig_write_permission:
            run_command(context, 'sudo chmod u+w %s' % home_dir)

        if os.path.isdir('%s/gpAdminLogs.bk' % home_dir):
            shutil.move('%s/gpAdminLogs.bk' % home_dir,
                        '%s/gpAdminLogs' % home_dir)

    if 'gpssh' in context.feature.tags:
        run_command(context, 'sudo tc qdisc del dev lo root netem')

    # for cleaning up after @given('"{path}" has its permissions set to "{perm}"')
    if (hasattr(context, 'path_for_which_to_restore_the_permissions')
            and hasattr(context, 'permissions_to_restore_path_to')):
        os.chmod(context.path_for_which_to_restore_the_permissions,
                 context.permissions_to_restore_path_to)
    elif hasattr(context, 'path_for_which_to_restore_the_permissions'):
        raise Exception('Missing permissions_to_restore_path_to for %s' %
                        context.path_for_which_to_restore_the_permissions)
    elif hasattr(context, 'permissions_to_restore_path_to'):
        raise Exception(
            'Missing path_for_which_to_restore_the_permissions despite the specified permission %o'
            % context.permissions_to_restore_path_to)
示例#20
0
def before_scenario(context, scenario):
    if "skip" in scenario.effective_tags:
        scenario.skip("skipping scenario tagged with @skip")
        return

    if 'gpmovemirrors' in context.feature.tags:
        context.mirror_context = MirrorMgmtContext()

    if 'gpconfig' in context.feature.tags:
        context.gpconfig_context = GpConfigContext()

    tags_to_skip = [
        'gpexpand', 'gpaddmirrors', 'gpstate', 'gpmovemirrors', 'gpconfig'
    ]
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    if 'analyzedb' not in context.feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'testdb')
示例#21
0
def before_feature(context, feature):
    # we should be able to run gpexpand without having a cluster initialized
    tags_to_skip = ['gpexpand', 'gpaddmirrors', 'gpstate', 'gpmovemirrors',
                    'gpconfig', 'gpssh-exkeys', 'gpstop', 'gpinitsystem', 'cross_subnet']
    if set(context.feature.tags).intersection(tags_to_skip):
        return

    drop_database_if_exists(context, 'testdb')
    drop_database_if_exists(context, 'bkdb')
    drop_database_if_exists(context, 'fullbkdb')
    drop_database_if_exists(context, 'schematestdb')

    if 'analyzedb' in feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'incr_analyze')
        create_database(context, 'incr_analyze')
        drop_database_if_exists(context, 'incr_analyze_2')
        create_database(context, 'incr_analyze_2')
        context.conn = dbconn.connect(dbconn.DbURL(dbname='incr_analyze'), unsetSearchPath=False)
        context.dbname = 'incr_analyze'

        # setting up the tables that will be used
        context.execute_steps("""
        Given there is a regular "ao" table "t1_ao" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "heap" table "t2_heap" with column name list "x,y,z" and column type list "int,text,real" in schema "public"
        And there is a regular "ao" table "t3_ao" with column name list "a,b,c" and column type list "int,text,real" in schema "public"
        And there is a hard coded partition table "sales" with 4 child partitions in schema "public"
        """)

    if 'gpreload' in feature.tags:
        start_database_if_not_started(context)
        drop_database_if_exists(context, 'gpreload_db')
        create_database(context, 'gpreload_db')
        context.conn = dbconn.connect(dbconn.DbURL(dbname='gpreload_db'), unsetSearchPath=False)
        context.dbname = 'gpreload_db'

    if 'minirepro' in feature.tags:
        start_database_if_not_started(context)
        minirepro_db = 'minireprodb'
        drop_database_if_exists(context, minirepro_db)
        create_database(context, minirepro_db)
        context.conn = dbconn.connect(dbconn.DbURL(dbname=minirepro_db), unsetSearchPath=False)
        context.dbname = minirepro_db
        dbconn.execSQL(context.conn, 'create table t1(a integer, b integer)')
        dbconn.execSQL(context.conn, 'create table t2(c integer, d integer)')
        dbconn.execSQL(context.conn, 'create table t3(e integer, f integer)')
        dbconn.execSQL(context.conn, 'create view v1 as select a, b from t1, t3 where t1.a=t3.e')
        dbconn.execSQL(context.conn, 'create view v2 as select c, d from t2, t3 where t2.c=t3.f')
        dbconn.execSQL(context.conn, 'create view v3 as select a, d from v1, v2 where v1.a=v2.c')
        dbconn.execSQL(context.conn, 'insert into t1 values(1, 2)')
        dbconn.execSQL(context.conn, 'insert into t2 values(1, 3)')
        dbconn.execSQL(context.conn, 'insert into t3 values(1, 4)')
        context.conn.commit()

    if 'gppkg' in feature.tags:
        run_command(context, 'bash demo/gppkg/generate_sample_gppkg.sh buildGppkg')
        run_command(context, 'cp -f /tmp/sample-gppkg/sample.gppkg test/behave/mgmt_utils/steps/data/')