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

Fix flaky tests #132

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions test/process_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class ProcessManagerTest
end
pm.stdin.add_data("10\n")
pm.run!
assert_equal '', pm.stderr.to_s
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't necessarily fix anything, but asserting there were no errors could help when this thing actually fails.

assert_equal pm.stdout.to_s.lines.map(&:chomp), %w[10 9 8 7 6 5 4 3 2 1 0]
end
end
Expand Down
17 changes: 6 additions & 11 deletions test/task_launcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ class TaskLauncherTest < Minitest::Spec

class DummyDynflowAction < Dynflow::Action
def plan(input)
callback input
plan_self received_input: input
end

def callback(_input); end
end

describe TaskLauncher do
Expand All @@ -27,10 +25,8 @@ def callback(_input); end
let(:launcher_class) { Single }

it 'triggers an action' do
DummyDynflowAction.any_instance.expects(:callback).with do |arg|
Dynflow::Utils::IndifferentHash.new(arg) == expected_result
end
launcher.launch!(launcher_input)
plan = launcher.launch!(launcher_input).finished.value!
_(plan.entry_action.input[:received_input]).must_equal expected_result
end

it 'provides results' do
Expand All @@ -44,17 +40,16 @@ def callback(_input); end
let(:launcher_class) { Batch }

it 'triggers the actions' do
DummyDynflowAction.any_instance.expects(:callback).with do |arg|
arg == expected_result
end.twice

parent = launcher.launch!('foo' => launcher_input, 'bar' => launcher_input)
wait_until(iterations: 15, interval: 1) do
load_execution_plan(parent[:task_id]).state == :stopped
end
plan = load_execution_plan(parent[:task_id])
_(plan.result).must_equal :success
_(plan.sub_plans.count).must_equal 2
plan.sub_plans.each do |plan|
_(plan.entry_action.input[:received_input]).must_equal expected_result
end
end

it 'provides results' do
Expand Down