Sha256: dcc5755aaf34fa49e8996ff4712574ef8e720f47fbfce7dc40a4d6d6784c68d6

Contents?: true

Size: 793 Bytes

Versions: 9

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

require_relative "base"

require_relative "../../ext/test"

module Datadog
  module CI
    module TestRetries
      module Driver
        class RetryFailed < Base
          attr_reader :max_attempts

          def initialize(max_attempts:)
            @max_attempts = max_attempts

            @attempts = 0
            @passed_once = false
          end

          def should_retry?
            @attempts < @max_attempts && !@passed_once
          end

          def record_retry(test_span)
            super

            @attempts += 1
            @passed_once = true if test_span&.passed?

            Datadog.logger.debug { "Retry Attempts [#{@attempts} / #{@max_attempts}], Passed: [#{@passed_once}]" }
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
datadog-ci-1.12.0 lib/datadog/ci/test_retries/driver/retry_failed.rb
datadog-ci-1.11.0 lib/datadog/ci/test_retries/driver/retry_failed.rb
datadog-ci-1.10.0 lib/datadog/ci/test_retries/driver/retry_failed.rb
datadog-ci-1.9.0 lib/datadog/ci/test_retries/driver/retry_failed.rb
datadog-ci-1.8.1 lib/datadog/ci/test_retries/driver/retry_failed.rb
datadog-ci-1.8.0 lib/datadog/ci/test_retries/driver/retry_failed.rb
datadog-ci-1.7.0 lib/datadog/ci/test_retries/driver/retry_failed.rb
datadog-ci-1.6.0 lib/datadog/ci/test_retries/driver/retry_failed.rb
datadog-ci-1.5.0 lib/datadog/ci/test_retries/driver/retry_failed.rb