elasticsearch-api/api-spec-testing/test_file.rb
def run_actions_and_retry(actions)
        count = 0
        loop do
          actions.delete_if do |action|
            begin
              action.execute(client)
              true
            rescue Elastic::Transport::Transport::Errors::RequestTimeout,
                   Elastic::Transport::Transport::Errors::ServiceUnavailable => e
              # The action sometimes gets the cluster in a recovering state, so we
              # retry a few times and then raise an exception if it's still
              # happening
              count += 1
              sleep 10
              logger.debug(
                "The server responded with an #{e.class} error. Retrying action - (#{count})"
              )
              raise e if count > 11

              false
            end
          end
          break if actions.empty?
        end
      end
# Helper function to run actions. If the server returns an error, give it some time and retry
# for a few times.
Helper function to run actions. If the server returns an error, give it some time and retry
for a few times.
Helper function to run actions . If the server returns an error give it some time and retry for a few times .
def run_actions_and_retry(actions)
        count = 0
        loop do
          actions.delete_if do |action|
            begin
              action.execute(client)
              true
            rescue Elastic::Transport::Transport::Errors::RequestTimeout,
                   Elastic::Transport::Transport::Errors::ServiceUnavailable => e
              count += 1
              sleep 10
              logger.debug(
                "The server responded with an #{e.class} error. Retrying action - (#{count})"
              )
              raise e if count > 11
              false
            end
          end
          break if actions.empty?
        end
      end
def run_actions_and_retry ( actions ) count = 0 loop do actions . delete_if do | action | begin action . execute ( client ) true rescue Elastic :: Transport :: Transport :: Errors :: RequestTimeout , Elastic :: Transport :: Transport :: Errors :: ServiceUnavailable => e count += 1 sleep 10 logger . debug ( "The server responded with an #{e.class} error. Retrying action - (#{count})" ) raise e if count > 11 false end end break if actions . empty? end end
Helper function to run actions.
Helper function to run actions .
# The action sometimes gets the cluster in a recovering state, so we # retry a few times and then raise an exception if it's still # happening
actions