def many_filters_to_none_conf_v2(): ret = True darwin_configure(CONF_THREE_V2) darwin_configure(CONF_FTEST, path=PATH_CONF_FTEST) process = darwin_start() resp = requests(REQ_MONITOR) if not all(x in resp for x in [RESP_TEST_1, RESP_TEST_2, RESP_TEST_3]): logging.error( "many_filters_to_none: Mismatching monitor response; got \"{}\"". format(resp)) ret = False darwin_configure(CONF_EMPTY) resp = requests(REQ_UPDATE_THREE) if RESP_STATUS_OK not in resp: logging.error( "many_filters_to_none: Update response error; got \"{}\"".format( resp)) ret = False resp = requests(REQ_MONITOR) if RESP_EMPTY not in resp: logging.error( "many_filters_to_none: Mismatching second monitor response; got \"{}\"" .format(resp)) ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FTEST) return ret
def many_update_many_conf_v2(): ret = True darwin_configure(CONF_THREE_V2) darwin_configure(CONF_FTEST, path=PATH_CONF_FTEST) process = darwin_start() resp = requests(REQ_MONITOR) if not all(x in resp for x in [RESP_TEST_1, RESP_TEST_2, RESP_TEST_3]): logging.error( "many_update_many: Mismatching monitor response; got \"{}\"". format(resp)) ret = False sleep(1) # Need this because of the starting delay resp = requests(REQ_UPDATE_TWO) if RESP_STATUS_OK not in resp: logging.error( "many_update_many: Update response error; got \"{}\"".format(resp)) ret = False resp = requests(REQ_MONITOR) if not all(x in resp for x in [RESP_TEST_1, RESP_TEST_2, RESP_TEST_3]): logging.error( "many_update_many: Mismatching monitor response; got \"{}\"". format(resp)) ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FTEST) return ret
def one_update_one_conf_v2(): ret = True darwin_configure(CONF_ONE_V2) darwin_configure(CONF_FTEST, path=PATH_CONF_FTEST) process = darwin_start() resp = requests(REQ_MONITOR) if RESP_TEST_1 not in resp: logging.error( "one_update_one: Mismatching monitor response; got \"{}\"".format( resp)) ret = False sleep(2) # Need this because of the starting delay resp = requests(REQ_UPDATE_ONE) if RESP_STATUS_OK not in resp: logging.error( "one_update_one: Update response error; got \"{}\"".format(resp)) ret = False sleep(1) # Need this because of the starting delay resp = requests(REQ_MONITOR) if RESP_TEST_1 not in resp: logging.error( "one_update_one: Mismatching monitor response; got \"{}\"".format( resp)) ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FTEST) return ret
def no_filter_to_many(): ret = True darwin_configure(CONF_EMPTY) process = darwin_start() resp = requests(REQ_MONITOR) if RESP_EMPTY not in resp: logging.error( "no_filter_to_many: Mismatching monitor response; got \"{}\"". format(resp)) ret = False darwin_configure(CONF_THREE) darwin_configure(CONF_FLOGS, path=PATH_CONF_FLOGS) resp = requests(REQ_UPDATE_THREE) if RESP_STATUS_OK not in resp: logging.error( "no_filter_to_many: Update response error; got \"{}\"".format( resp)) ret = False resp = requests(REQ_MONITOR) if not all(x in resp for x in [RESP_LOGS_1, RESP_LOGS_2, RESP_LOGS_3]): logging.error( "no_filter_to_many: Mismatching monitor response; got \"{}\"". format(resp)) ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FLOGS) return ret
def non_existing_filter_conf_v2(): ret = True darwin_configure(CONF_THREE_V2) darwin_configure(CONF_FTEST, path=PATH_CONF_FTEST) process = darwin_start() resp = requests(REQ_MONITOR) if not all(x in resp for x in [RESP_TEST_1, RESP_TEST_2, RESP_TEST_3]): logging.error( "non_existing_filter: Mismatching monitor response; got \"{}\"". format(resp)) ret = False sleep(1) # Need this because of the starting delay resp = requests(REQ_UPDATE_NON_EXISTING) if RESP_ERROR_FILTER_NOT_EXISTING not in resp: logging.error( "non_existing_filter: Update response error; got \"{}\"".format( resp)) ret = False resp = requests(REQ_MONITOR) if not all(x in resp for x in [RESP_TEST_1, RESP_TEST_2, RESP_TEST_3]): logging.error( "non_existing_filter: Mismatching monitor response; got \"{}\"". format(resp)) ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FTEST) return ret
def update_no_filter(): ret = True darwin_configure(CONF_ONE) darwin_configure(CONF_FLOGS, path=PATH_CONF_FLOGS) process = darwin_start() resp = requests(REQ_MONITOR) if RESP_LOGS_1 not in resp: logging.error( "update_no_filter: Mismatching monitor response; got \"{}\"". format(resp)) ret = False sleep(1) # Need this because of the starting delay resp = requests(REQ_UPDATE_NO_FILTER) if RESP_STATUS_OK not in resp: logging.error( "update_no_filter: Update response error; got \"{}\"".format(resp)) ret = False resp = requests(REQ_MONITOR) if RESP_LOGS_1 not in resp: logging.error( "update_no_filter: Mismatching monitor response; got \"{}\"". format(resp)) ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FLOGS) return ret
def no_filter_to_one(): ret = True darwin_configure(CONF_EMPTY) process = darwin_start() resp = requests(REQ_MONITOR) if RESP_EMPTY not in resp: logging.error( "no_filter_to_one: Mismatching monitor response; got \"{}\"". format(resp)) ret = False darwin_configure(CONF_ONE) darwin_configure(CONF_FTEST, path=PATH_CONF_FTEST) resp = requests(REQ_UPDATE_ONE) if RESP_STATUS_OK not in resp: logging.error( "no_filter_to_one: Update response error; got \"{}\"".format(resp)) ret = False resp = requests(REQ_MONITOR) if RESP_TEST_1 not in resp: logging.error( "no_filter_to_one: Mismatching monitor response; got \"{}\"". format(resp)) ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FTEST) return ret
def proc_stats_wrong(): ret = False darwin_configure( CONF_TEMPLATE.substitute(log_path=DEFAULT_FILTER_PATH, conf_path=PATH_CONF_FLOGS, conf_redis="", conf_file="", proc_stats="")) darwin_configure(CONF_FLOGS, path=PATH_CONF_FLOGS) process = darwin_start() try: resp = json.loads(requests(REQ_MONITOR_ERROR)) try: result = resp['logs_1']['proc_stats'] if len(result) == 0: ret = True else: logging.error( "proc_stats_wrong(): not expected result -> {} (supposed to have empty dict {{}})" .format(result)) except KeyError as e: logging.error("proc_stats_wrong(): {}".format(e)) except Exception as e: logging.error("proc_stats_wrong(): {}".format(e)) darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FLOGS) return ret
def proc_stats_custom(): ret = False darwin_configure( CONF_TEMPLATE.substitute(log_path=DEFAULT_FILTER_PATH, conf_path=PATH_CONF_FLOGS, conf_redis="", conf_file="", proc_stats="")) darwin_configure(CONF_FLOGS, path=PATH_CONF_FLOGS) process = darwin_start() try: resp = json.loads(requests(REQ_MONITOR_CUSTOM_STATS)) try: result = resp['logs_1']['proc_stats'] if [x in result for x in ['name', 'pid', 'memory_percent'] ] and len(result) == 3: ret = True else: logging.error( "proc_stats_custom(): not expected result -> {}".format( result)) except KeyError as e: logging.error("proc_stats_custom(): {}".format(e)) except Exception as e: logging.error("proc_stats_custom(): {}".format(e)) darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FLOGS) return ret
def many_update_all_wrong_conf(): ret = True darwin_configure(CONF_THREE) darwin_configure(CONF_FTEST, path=PATH_CONF_FTEST) process = darwin_start() resp = requests(REQ_MONITOR) if not all(x in resp for x in [RESP_TEST_1, RESP_TEST_2, RESP_TEST_3]): logging.error( "one_update_one_wrong_conf: Mismatching monitor response; got \"{}\"" .format(resp)) ret = False sleep(2) # Need this because of the starting delay darwin_configure(CONF_FTEST_WRONG_CONF, path=PATH_CONF_FTEST) resp = requests(REQ_UPDATE_THREE) if RESP_STATUS_KO not in resp: logging.error( "one_update_one_wrong_conf: Update response error; got \"{}\"". format(resp)) ret = False resp = requests(REQ_MONITOR) if not all(x in resp for x in [RESP_TEST_1, RESP_TEST_2, RESP_TEST_3]): logging.error( "one_update_one_wrong_conf: Mismatching monitor response; got \"{}\"" .format(resp)) ret = False if not check_filter_files("test_1", ".1"): logging.error("Error: filter files check failed") ret = False if not check_filter_files("test_2", ".1"): logging.error("Error: filter files check failed") ret = False if not check_filter_files("test_3", ".1"): logging.error("Error: filter files check failed") ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FTEST) return ret
def no_filter(): ret = False darwin_configure(CONF_EMPTY) process = darwin_start() resp = requests(REQ_MONITOR) if RESP_EMPTY in resp: ret = True darwin_stop(process) darwin_remove_configuration() return ret
def one_update_one_wrong_conf_conf_v2(): ret = True darwin_configure(CONF_ONE_V2) darwin_configure(CONF_FLOGS, path=PATH_CONF_FLOGS) process = darwin_start() resp = requests(REQ_MONITOR) if RESP_LOGS_1 not in resp: logging.error( "one_update_one_wrong_conf: Mismatching monitor response; got \"{}\"" .format(resp)) ret = False sleep(2) # Need this because of the starting delay darwin_configure(CONF_FLOGS_WRONG_CONF, path=PATH_CONF_FLOGS) resp = requests(REQ_UPDATE_ONE) if RESP_STATUS_KO not in resp: logging.error( "one_update_one_wrong_conf: Update response error; got \"{}\"". format(resp)) ret = False resp = requests(REQ_MONITOR) if RESP_LOGS_1 not in resp: logging.error( "one_update_one_wrong_conf: Mismatching monitor response; got \"{}\"" .format(resp)) ret = False if not check_filter_files("logs_1", ".1"): logging.error("Error: filter files check failed") ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FLOGS) return ret
def many_filters_to_one(): ret = True darwin_configure(CONF_THREE) darwin_configure(CONF_FLOGS, path=PATH_CONF_FLOGS) process = darwin_start() resp = requests(REQ_MONITOR) if not all(x in resp for x in [RESP_LOGS_1, RESP_LOGS_2, RESP_LOGS_3]): logging.error( "many_filters_to_one: Mismatching monitor response; got \"{}\"". format(resp)) ret = False sleep(1) # Need this beacause of the starting delay darwin_configure(CONF_ONE) resp = requests(REQ_UPDATE_TWO) if RESP_STATUS_OK not in resp: logging.error( "many_filters_to_one: Update response error; got \"{}\"".format( resp)) ret = False sleep(1) resp = requests(REQ_MONITOR) if RESP_LOGS_1 not in resp: logging.error( "many_filters_to_one: Mismatching monitor response; got \"{}\"". format(resp)) ret = False darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FLOGS) return ret
def one_filters_running(): ret = False darwin_configure(CONF_ONE) darwin_configure(CONF_FLOGS, path=PATH_CONF_FLOGS) process = darwin_start() resp = requests(REQ_MONITOR) if RESP_LOGS_1 in resp: ret = True darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FLOGS) return ret
def multiple_filters_running_one_fail_conf_v2(): ret = False darwin_configure(CONF_THREE_ONE_WRONG_V2) darwin_configure(CONF_FLOGS, path=PATH_CONF_FLOGS) process = darwin_start() resp = requests(REQ_MONITOR) if all(x in resp for x in [RESP_LOGS_1, RESP_LOGS_3]): ret = True darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FLOGS) return ret
def multiple_filters_running_conf_v2(): ret = False darwin_configure(CONF_THREE_V2) darwin_configure(CONF_FTEST, path=PATH_CONF_FTEST) process = darwin_start() resp = requests(REQ_MONITOR) if all(x in resp for x in [RESP_TEST_1, RESP_TEST_2, RESP_TEST_3]): ret = True darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FTEST) return ret
def one_filters_running_conf_v2(): ret = False darwin_configure(CONF_ONE_V2) darwin_configure(CONF_FTEST, path=PATH_CONF_FTEST) process = darwin_start() resp = requests(REQ_MONITOR) if RESP_TEST_1 in resp: ret = True darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FTEST) return ret
def proc_stats_other_defaults(): ret = False darwin_configure( CONF_TEMPLATE.substitute( log_path=DEFAULT_FILTER_PATH, conf_path=PATH_CONF_FLOGS, conf_redis="", conf_file="", proc_stats='"proc_stats": ["name", "username", "memory_full_info"],' )) darwin_configure(CONF_FLOGS, path=PATH_CONF_FLOGS) process = darwin_start() try: resp = json.loads(requests(REQ_MONITOR)) try: result = resp['logs_1']['proc_stats'] if [x in result for x in ['name', 'username', 'memory_full_info'] ] and len(result) == 3: ret = True else: logging.error( "proc_stats_other_defaults(): not expected result -> {}". format(result)) except KeyError as e: logging.error("proc_stats_other_defaults(): {}".format(e)) except Exception as e: logging.error("proc_stats_other_defaults(): {}".format(e)) darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FLOGS) return ret
def proc_stats_default(): ret = False darwin_configure( CONF_TEMPLATE.substitute(log_path=DEFAULT_FILTER_PATH, conf_path=PATH_CONF_FTEST, conf_redis="", conf_file="", proc_stats="")) darwin_configure(CONF_FTEST, path=PATH_CONF_FTEST) process = darwin_start() try: resp = json.loads(requests(REQ_MONITOR)) try: result = resp['test_1']['proc_stats'] if [x in result for x in ['memory_percent', 'cpu_percent'] ] and len(result) == 2: ret = True else: logging.error( "proc_stats_default(): not expected result -> {}".format( result)) except KeyError as e: logging.error("proc_stats_default(): {}".format(e)) except Exception as e: logging.error( "proc_stats_default(): error loading json -> {}".format(e)) darwin_stop(process) darwin_remove_configuration() darwin_remove_configuration(path=PATH_CONF_FTEST) return ret