Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] debug ls2ls spec #17218

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions qa/integration/specs/logstash_to_logstash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
@fixture.teardown
}

def get_temp_path_dir
def get_temp_path_dir(config_name)
tmp_path = Stud::Temporary.pathname
tmp_data_path = File.join(tmp_path, "data")
tmp_data_path = File.join(tmp_path, "data", config_name)
FileUtils.mkdir_p(tmp_data_path)
tmp_data_path
end
Expand All @@ -55,7 +55,7 @@ def run_logstash_instance(config_name, options = {}, &block)
logstash_service.spawn_logstash("--node.name", config_name,
"--pipeline.id", config_name,
"--path.config", config_to_temp_file(@fixture.config(config_name, options)),
"--path.data", get_temp_path_dir,
"--path.data", get_temp_path_dir(config_name),
"--api.http.port", api_port.to_s)
wait_for_logstash(logstash_service)

Expand Down Expand Up @@ -95,19 +95,24 @@ def wait_for_logstash(service)
run_logstash_instance(input_config_name, all_config_options) do |downstream_logstash_service|
run_logstash_instance(output_config_name, all_config_options) do |upstream_logstash_service|

file_output_path = File.join(downstream_logstash_service.logstash_home, output_file_path_with_datetime)

try(num_retries) do
downstream_event_stats = downstream_logstash_service.monitoring_api.event_stats
upstream_event_stats = upstream_logstash_service.monitoring_api.event_stats
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dangerous part here, upstream has a generator input, which we don't have guarantee it and its monitoring API are live. That's why we didn't include the upstream expectation.


expect(upstream_event_stats).to include({"in" => num_events}), lambda { "expected upstream generates #{num_events} events"}
puts "upstream has done generating events"

# make sure received events are in the file
expect(File).to exist(file_output_path), "Logstash to Logstash output file: #{file_output_path} does not exist"
actual_lines = File.read(file_output_path).lines.to_a
expected_lines = (0...num_events).map { |sequence| "#{sequence}:Hello world!\n" }
expect(actual_lines).to match_array(expected_lines)

expect(downstream_event_stats).to include({"in" => num_events}), lambda { "expected #{num_events} events to have been received by downstream"}
end

# make sure received events are in the file
file_output_path = File.join(downstream_logstash_service.logstash_home, output_file_path_with_datetime)
expect(File).to exist(file_output_path), "Logstash to Logstash output file: #{file_output_path} does not exist"
actual_lines = File.read(file_output_path).lines.to_a
expected_lines = (0...num_events).map { |sequence| "#{sequence}:Hello world!\n" }
expect(actual_lines).to match_array(expected_lines)

File.delete(file_output_path)
end
end
Expand Down