def test_pp_reload(config, syslog_ng, loggen, port_allocator): loggen_input_path = str(tc_parameters.WORKING_DIR) + "/loggen_input.txt" network_source = config.create_network_source(ip="localhost", port=port_allocator(), transport='"proxied-tcp"', flags="no-parse") file_destination = config.create_file_destination(file_name="output.log", template=TEMPLATE) config.create_logpath(statements=[network_source, file_destination]) syslog_ng.start(config) create_file(loggen_input_path, INPUT_MESSAGES) loggen.start(network_source.options["ip"], network_source.options["port"], stream=True, permanent=True, rate=1, read_file=loggen_input_path, dont_parse=True) # With the current loggen implementation there is no way to properly timing messages. # Here I made an assumption that with rate=1, there will be messages which will arrive # into syslog-ng AFTER the reload. Timing the reload after the first message arrives. # Note: The worst case scenario in case of extreme slowness in the test environment, is # that syslog-ng will receive all the messages before reload. In this case the test will # not fill it's purpose, and do not test if the headers are reserved between reloads. # But at least the test wont be flaky, it will pass in this corner case too. assert file_destination.read_log() == EXPECTED_MESSAGE0 syslog_ng.reload(config) assert file_destination.read_log() == EXPECTED_MESSAGE1 assert file_destination.read_log() == EXPECTED_MESSAGE2
def test_pp_tls(config, syslog_ng, port_allocator, loggen, testcase_parameters): server_key_path = copy_shared_file(testcase_parameters, "server.key") server_cert_path = copy_shared_file(testcase_parameters, "server.crt") network_source = config.create_network_source( ip="localhost", port=port_allocator(), transport='"proxied-tls"', flags="no-parse", tls={ "key-file": server_key_path, "cert-file": server_cert_path, "peer-verify": '"optional-untrusted"', }, ) file_destination = config.create_file_destination(file_name="output.log", template=TEMPLATE) config.create_logpath(statements=[network_source, file_destination]) syslog_ng.start(config) loggen_input_path = str(tc_parameters.WORKING_DIR) + "loggen_input.txt" create_file(loggen_input_path, INPUT_MESSAGES) loggen.start(target=network_source.options["ip"], port=network_source.options["port"], use_ssl=True, permanent=True, read_file=loggen_input_path, dont_parse=True) assert file_destination.read_log() == EXPECTED_MESSAGES
def test_pp_acceptance(config, syslog_ng, loggen, port_allocator): loggen_input_path = str(tc_parameters.WORKING_DIR) + "/loggen_input.txt" network_source = config.create_network_source(ip="localhost", port=port_allocator(), transport='"proxied-tcp"', flags="no-parse") file_destination = config.create_file_destination(file_name="output.log", template=TEMPLATE) config.create_logpath(statements=[network_source, file_destination]) syslog_ng.start(config) create_file(loggen_input_path, INPUT_MESSAGES) loggen.start(network_source.options["ip"], network_source.options["port"], stream=True, permanent=True, read_file=loggen_input_path, dont_parse=True) assert file_destination.read_log() == EXPECTED_MESSAGE0
def test_pp_with_syslog_proto(config, port_allocator, syslog_ng, loggen): loggen_input_path = str(tc_parameters.WORKING_DIR) + "/loggen_input.txt" network_source = config.create_network_source(ip="localhost", port=port_allocator(), transport="proxied-tcp") file_destination = config.create_file_destination(file_name="output.log") config.create_logpath(statements=[network_source, file_destination]) config.update_global_options(keep_hostname="yes") syslog_ng.start(config) create_file(loggen_input_path, PROXY_PROTO_HEADER + RFC3164_EXAMPLE) loggen.start( network_source.options["ip"], network_source.options["port"], inet=True, stream=True, permanent=True, read_file=loggen_input_path, dont_parse=True, ) assert file_destination.read_log() == RFC3164_EXAMPLE_WITHOUT_PRI
def test_pp_with_multiple_clients(config, port_allocator, syslog_ng): network_source = config.create_network_source(ip="localhost", port=port_allocator(), transport="proxied-tcp", flags="no-parse") file_destination = config.create_file_destination(file_name="output.log", template=TEMPLATE) config.create_logpath(statements=[network_source, file_destination]) syslog_ng.start(config) client_A_loggen_input_path = str( tc_parameters.WORKING_DIR) + "/client_A_loggen_input.txt" client_B_loggen_input_path = str( tc_parameters.WORKING_DIR) + "/client_B_loggen_input.txt" create_file(client_A_loggen_input_path, CLIENT_A_INPUT) create_file(client_B_loggen_input_path, CLIENT_B_INPUT) # These 2 run simultaneously Loggen().start( network_source.options["ip"], network_source.options["port"], inet=True, stream=True, permanent=True, read_file=client_A_loggen_input_path, dont_parse=True, rate=1, ) Loggen().start( network_source.options["ip"], network_source.options["port"], inet=True, stream=True, permanent=True, read_file=client_B_loggen_input_path, dont_parse=True, rate=1, ) output_messages = file_destination.read_logs(counter=4) assert sorted(output_messages) == sorted(CLIENT_A_EXPECTED + CLIENT_B_EXPECTED)