Skip to content

Commit 5b046c2

Browse files
committed
Clear agent actions works properly on restart
1 parent 1a02f0c commit 5b046c2

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

spec/concurrent/agent_spec.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -691,36 +691,34 @@ def update(time, old_value, new_value)
691691
it 'removes all actions from the queue when :clear_actions is true' do
692692
latch = Concurrent::CountDownLatch.new
693693
subject = Agent.new(0, error_mode: :fail)
694+
end_latch = Concurrent::CountDownLatch.new
694695

695696
subject.send_via(executor){ latch.wait; raise StandardError }
696-
5.times{ subject.send_via(executor){ nil } }
697-
698-
queue = subject.instance_variable_get(:@queue)
699-
expect(queue.size).to be > 0
697+
subject.send_via(executor){ end_latch.count_down }
700698

701699
latch.count_down
702700
10.times{ break if subject.failed?; sleep(0.1) }
703701

704702
subject.restart(42, clear_actions: true)
705-
expect(queue).to be_empty
703+
result = end_latch.wait(0.1)
704+
expect(result).to be false
706705
end
707706

708-
it 'does not clear the action queue when :clear_actions is false', buggy: true do
707+
it 'does not clear the action queue when :clear_actions is false' do
709708
latch = Concurrent::CountDownLatch.new
709+
end_latch = Concurrent::CountDownLatch.new
710+
710711
subject = Agent.new(0, error_mode: :fail)
711712

712713
subject.send_via(executor){ latch.wait; raise StandardError }
713-
5.times{ subject.send_via(executor){ nil } }
714-
715-
queue = subject.instance_variable_get(:@queue)
716-
size = queue.size
717-
expect(size).to be > 0
714+
subject.send_via(executor){ end_latch.count_down }
718715

719716
latch.count_down
720717
10.times{ break if subject.failed?; sleep(0.1) }
721718

722719
subject.restart(42, clear_actions: false)
723-
expect(queue.size).to eq size-1
720+
result = end_latch.wait(3)
721+
expect(result).to be true
724722
end
725723

726724
it 'does not clear the action queue when :clear_actions is not given' do

0 commit comments

Comments
 (0)