def set_syslog_ng_paths(self, instance_name): if self.__instance_name is not None: raise Exception("Instance already configured") self.__instance_name = instance_name working_dir = self.__testcase_parameters.get_working_dir() relative_working_dir = self.__testcase_parameters.get_relative_working_dir() install_dir = self.__testcase_parameters.get_install_dir() if not install_dir: raise ValueError("Missing --installdir start parameter") self.__syslog_ng_paths = { "dirs": {"working_dir": working_dir, "install_dir": Path(install_dir)}, "file_paths": { "config_path": Path(working_dir, "syslog_ng_{}.conf".format(instance_name)), "persist_path": Path(working_dir, "syslog_ng_{}.persist".format(instance_name)), "pid_path": Path(working_dir, "syslog_ng_{}.pid".format(instance_name)), "control_socket_path": Path(relative_working_dir, "syslog_ng_{}.ctl".format(instance_name)), "stderr": Path(working_dir, "syslog_ng_{}_stderr".format(instance_name)), "stdout": Path(working_dir, "syslog_ng_{}_stdout".format(instance_name)), "valgrind": Path( working_dir, "valgrind_{}.log".format(get_unique_id()) ), }, "binary_file_paths": { "syslog_ng_binary": Path(install_dir, "sbin", "syslog-ng"), "syslog_ng_ctl": Path(install_dir, "sbin", "syslog-ng-ctl"), }, } return self
def register_external_tool_output_path(self, external_tool): self.__syslog_ng_paths['file_paths'].update( { external_tool: Path(tc_parameters.WORKING_DIR, "{}_{}.log".format( external_tool, get_unique_id())), }, )
def write(self, content, rate=None): loggen_input_file_path = Path( tc_parameters.WORKING_DIR, "loggen_input_{}.txt".format(get_unique_id())) loggen_input_file = File(loggen_input_file_path) with loggen_input_file.open_file(mode="a+") as f: f.write(content) Loggen().start(self.__ip, self.__port, read_file=str(loggen_input_file_path), dont_parse=True, permanent=True, rate=rate, **self.__transport.value)
def test_pp_tls_passthrough(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-passthrough"', 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_file_path = Path( tc_parameters.WORKING_DIR, "loggen_input_{}.txt".format(get_unique_id())) loggen_input_file = File(loggen_input_file_path) loggen_input_file.open(mode="w") loggen_input_file.write(INPUT_MESSAGES) loggen_input_file.close() loggen.start( network_source.options["ip"], network_source.options["port"], number=NUMBER_OF_MESSAGES, use_ssl=True, proxied_tls_passthrough=True, read_file=str(loggen_input_file_path), dont_parse=True, proxy_src_ip="1.1.1.1", proxy_dst_ip="2.2.2.2", proxy_src_port="3333", proxy_dst_port="4444", ) wait_until_true( lambda: loggen.get_sent_message_count() == NUMBER_OF_MESSAGES) assert file_destination.read_log() == EXPECTED_MESSAGES
def get_backtrace_from_core(self, core_file): gdb_command_args = [ "gdb", "-ex", "bt full", "--batch", self.__instance_paths.get_syslog_ng_bin(), "--core", core_file, ] core_postfix = "gdb_core_{}".format(get_unique_id()) return self.__command_executor.run( command=gdb_command_args, stdout_path=self.__instance_paths.get_stdout_path_with_postfix(postfix=core_postfix), stderr_path=self.__instance_paths.get_stderr_path_with_postfix(postfix=core_postfix), )
def get_backtrace_from_core(self, core_file): gdb_command_args = [ "gdb", "-ex", "bt full", "--batch", self.__instance_paths.get_syslog_ng_bin(), "--core", core_file, ] core_postfix = "gdb_core_{}".format(get_unique_id()) return self.__command_executor.run( command=gdb_command_args, stdout_path=self.__instance_paths.get_stdout_path_with_postfix(postfix=core_postfix), stderr_path=self.__instance_paths.get_stderr_path_with_postfix(postfix=core_postfix), )
def __init__(self, statements): super(StatementGroup, self).__init__(cast_to_list(statements)) self.__group_type = self.__calculate_group_type(cast_to_list(statements)) self.__group_id = "%s_%s" % (self.__group_type, get_unique_id())
def __init__(self, statements): super(StatementGroup, self).__init__(cast_to_list(statements)) self.__group_type = self.__calculate_group_type(cast_to_list(statements)) self.__group_id = "%s_%s" % (self.__group_type, get_unique_id())
def get_temp_file(self): temp_dir = self.get_temp_dir() temp_file_path = Path(temp_dir, get_unique_id()) self.__registered_files.append(temp_file_path) return temp_file_path