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)
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)
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)
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)
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)
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)
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)