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
123
123
log_prefix : options [ :log_prefix ] ,
124
124
bg_error_backtrace : options [ :bg_error_backtrace ] ,
125
125
)
126
+
127
+ # Avoid tight looping in push monitor - see RUBY-2806.
128
+ sleep ( 0.5 )
126
129
end
127
130
128
131
def check
Original file line number Diff line number Diff line change 76
76
push_monitor . do_work
77
77
end . should_not raise_error
78
78
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
79
98
end
80
99
end
81
100
You can’t perform that action at this time.
0 commit comments