File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,9 @@ def do_work
123123 log_prefix : options [ :log_prefix ] ,
124124 bg_error_backtrace : options [ :bg_error_backtrace ] ,
125125 )
126+
127+ # Avoid tight looping in push monitor - see RUBY-2806.
128+ sleep ( 0.5 )
126129 end
127130
128131 def check
Original file line number Diff line number Diff line change 7676 push_monitor . do_work
7777 end . should_not raise_error
7878 end
79+
80+ it 'throttles checks' do
81+ push_monitor
82+
83+ start = Mongo ::Utils . monotonic_time
84+
85+ expect ( Socket ) . to receive ( :getaddrinfo ) . and_raise ( SocketError . new ( 'Test exception' ) )
86+ lambda do
87+ push_monitor . do_work
88+ end . should_not raise_error
89+
90+ expect ( Socket ) . to receive ( :getaddrinfo ) . and_raise ( SocketError . new ( 'Test exception' ) )
91+ lambda do
92+ push_monitor . do_work
93+ end . should_not raise_error
94+
95+ elapsed = Mongo ::Utils . monotonic_time - start
96+ elapsed . should > 0.5
97+ end
7998 end
8099 end
81100
You can’t perform that action at this time.
0 commit comments