@@ -207,23 +207,22 @@ def test_can_run_with_autoscaling_poller_behavior
207207 )
208208 )
209209 worker . run do
210- # Give pollers a beat to get started
211- sleep ( 0.3 )
212-
213- dump = Net ::HTTP . get ( URI ( "http://#{ prom_addr } /metrics" ) )
214- lines = dump . split ( "\n " )
215-
216- matches = lines . select { |l | l . include? ( 'temporal_num_pollers' ) }
217- activity_pollers = matches . select { |l | l . include? ( 'activity_task' ) }
218- assert_equal 1 , activity_pollers . size
219- assert activity_pollers [ 0 ] . end_with? ( '2' )
220-
221- workflow_pollers = matches . select { |l | l . include? ( 'workflow_task' ) }
222- assert_equal 2 , workflow_pollers . size
223- # There's sticky & non-sticky pollers, and they may have a count of 1 or 2 depending on
224- # initialization timing.
225- assert ( workflow_pollers [ 0 ] . end_with? ( '2' ) || workflow_pollers [ 0 ] . end_with? ( '1' ) )
226- assert ( workflow_pollers [ 1 ] . end_with? ( '2' ) || workflow_pollers [ 1 ] . end_with? ( '1' ) )
210+ assert_eventually do
211+ dump = Net ::HTTP . get ( URI ( "http://#{ prom_addr } /metrics" ) )
212+ lines = dump . split ( "\n " )
213+
214+ matches = lines . select { |l | l . include? ( 'temporal_num_pollers' ) }
215+ activity_pollers = matches . select { |l | l . include? ( 'activity_task' ) }
216+ assert_equal 1 , activity_pollers . size
217+ assert activity_pollers [ 0 ] . end_with? ( '2' )
218+
219+ workflow_pollers = matches . select { |l | l . include? ( 'workflow_task' ) }
220+ assert_equal 2 , workflow_pollers . size
221+ # There's sticky & non-sticky pollers, and they may have a count of 1 or 2 depending on
222+ # initialization timing.
223+ assert ( workflow_pollers [ 0 ] . end_with? ( '2' ) || workflow_pollers [ 0 ] . end_with? ( '1' ) )
224+ assert ( workflow_pollers [ 1 ] . end_with? ( '2' ) || workflow_pollers [ 1 ] . end_with? ( '1' ) )
225+ end
227226
228227 handles = Array . new ( 20 ) do
229228 env . client . start_workflow (
0 commit comments