def wrapper(*args, **kwargs): args[0].env.__wrapped__ = 'check_fuel_statistics' result = func(*args, **kwargs) args[0].env.__wrapped__ = None if not settings.FUEL_STATS_CHECK: return result logger.info('Test "{0}" passed. Checking stats.'.format(func.__name__)) fuel_settings = args[0].env.get_fuel_settings() nailgun_actions = args[0].env.nailgun_actions postgres_actions = args[0].env.postgres_actions remote_collector = args[0].env.get_ssh_to_remote_by_key( settings.FUEL_STATS_HOST, '{0}/.ssh/id_rsa'.format(expanduser("~"))) master_uuid = args[0].env.get_masternode_uuid() logger.info("Master Node UUID: '{0}'".format(master_uuid)) nailgun_actions.force_fuel_stats_sending() if not settings.FUEL_STATS_ENABLED: assert_equal(0, int(count_stats_on_collector(remote_collector, master_uuid)), "Sending of Fuel stats is disabled in test, but " "usage info was sent to collector!") assert_equal(args[0].env.postgres_actions.count_sent_action_logs(), 0, ("Sending of Fuel stats is disabled in test, but " "usage info was sent to collector!")) return result test_scenario = inspect.getdoc(func) if 'Scenario' not in test_scenario: logger.warning(("Can't check that fuel statistics was gathered " "and sent to collector properly because '{0}' " "test doesn't contain correct testing scenario. " "Skipping...").format(func.__name__)) return func(*args, **kwargs) try: check_action_logs(test_scenario, postgres_actions) check_stats_private_info(remote_collector, postgres_actions, master_uuid, fuel_settings) check_stats_on_collector(remote_collector, postgres_actions, master_uuid) return result except Exception: logger.error(traceback.format_exc()) raise
def wrapper(*args, **kwargs): result = func(*args, **kwargs) if not settings.FUEL_STATS_CHECK: return result logger.info('Test "{0}" passed. Checking stats.'.format(func.__name__)) fuel_settings = args[0].env.admin_actions.get_fuel_settings() nailgun_actions = args[0].env.nailgun_actions postgres_actions = args[0].env.postgres_actions remote_collector = args[0].env.collector master_uuid = args[0].env.get_masternode_uuid() logger.info("Master Node UUID: '{0}'".format(master_uuid)) nailgun_actions.force_fuel_stats_sending() if not settings.FUEL_STATS_ENABLED: assert_equal( 0, int(count_stats_on_collector(remote_collector, master_uuid)), "Sending of Fuel stats is disabled in test, but " "usage info was sent to collector!", ) assert_equal( args[0].env.postgres_actions.count_sent_action_logs(), 0, ("Sending of Fuel stats is disabled in test, but " "usage info was sent to collector!"), ) return result test_scenario = inspect.getdoc(func) if "Scenario" not in test_scenario: logger.warning( ( "Can't check that fuel statistics was gathered " "and sent to collector properly because '{0}' " "test doesn't contain correct testing scenario. " "Skipping..." ).format(func.__name__) ) return func(*args, **kwargs) try: check_action_logs(test_scenario, postgres_actions) check_stats_private_info(remote_collector, postgres_actions, master_uuid, fuel_settings) check_stats_on_collector(remote_collector, postgres_actions, master_uuid) return result except Exception: logger.error(traceback.format_exc()) raise