module RSpec::Queue::ParserExtension

Private Instance Methods

parser(options) click to toggle source
Calls superclass method
# File lib/rspec/queue.rb, line 65
      def parser(options)
        parser = super

        parser.separator("\n  **** Queue options ****\n\n")

        help = <<~EOS
          URL of the queue, e.g. redis://example.com.
          Defaults to $CI_QUEUE_URL if set.
        EOS
        parser.separator ""
        parser.on('--queue URL', *help) do |url|
          options[:queue_url] = url
        end

        help = <<~EOS
          Wait for all workers to complete and summarize the test failures.
        EOS
        parser.on('--report', *help) do |url|
          options[:report] = true
          options[:runner] = RSpec::Queue::ReportRunner.new
        end

        help = <<~EOS
          Replays a previous run in the same order.
        EOS
        parser.on('--retry', *help) do |url|
          STDERR.puts "Warning: The --retry flag is deprecated"
        end

        help = <<~EOS
          Unique identifier for the workload. All workers working on the same suite of tests must have the same build identifier.
          If the build is tried again, or another revision is built, this value must be different.
          It's automatically inferred on Buildkite, CircleCI and Travis.
        EOS
        parser.separator ""
        parser.on('--build BUILD_ID', *help) do |build_id|
          queue_config.build_id = build_id
        end

        help = <<~EOS
          Optional. Sets a prefix for the build id in case a single CI build runs multiple independent test suites.
            Example: --namespace integration
        EOS
        parser.separator ""
        parser.on('--namespace NAMESPACE', *help) do |namespace|
          queue_config.namespace = namespace
        end

        help = <<~EOS
          Specify a timeout after which if a test haven't completed, it will be picked up by another worker.
          It is very important to set this vlaue higher than the slowest test in the suite, otherwise performance will be impacted.
          Defaults to 30 seconds.
        EOS
        parser.separator ""
        parser.on('--timeout TIMEOUT', *help) do |timeout|
          queue_config.timeout = Float(timeout)
        end

        help = <<~EOS
          A unique identifier for this worker, It must be consistent to allow retries.
          If not specified, retries won't be available.
          It's automatically inferred on Buildkite and CircleCI.
        EOS
        parser.separator ""
        parser.on('--worker WORKER_ID', *help) do |worker_id|
          queue_config.worker_id = worker_id
        end

        help = <<~EOS
          Defines how many time a single test can be requeued.
          Defaults to 0.
        EOS
        parser.separator ""
        parser.on('--max-requeues MAX', *help) do |max|
          queue_config.max_requeues = Integer(max)
        end

        help = <<~EOS
          Defines how many requeues can happen overall, based on the test suite size. e.g 0.05 for 5%.
          Defaults to 0.
        EOS
        parser.separator ""
        parser.on('--requeue-tolerance RATIO', *help) do |ratio|
          queue_config.requeue_tolerance = Float(ratio)
        end

        help = <<~EOS
          Defines after how many consecutive failures the worker will be considered unhealthy and terminate itself.
          Defaults to disabled.
        EOS
        parser.separator ""
        parser.on('--max-consecutive-failures MAX', *help) do |max|
          queue_config.max_consecutive_failures = Integer(max)
        end

        parser
      end
queue_config() click to toggle source
# File lib/rspec/queue.rb, line 163
def queue_config
  ::RSpec::Queue.config
end