class Minitest::Distributed::Configuration
Constants
- DEFAULT_BATCH_SIZE
- DEFAULT_MAX_ATTEMPTS
- DEFAULT_TEST_TIMEOUT_SECONDS
Public Class Methods
from_command_line_options(opts, options)
click to toggle source
# File lib/minitest/distributed/configuration.rb, line 31 def from_command_line_options(opts, options) configuration = from_env configuration.progress = options[:io].tty? opts.on("--coordinator=URI", "The URI pointing to the coordinator") do |uri| configuration.coordinator_uri = URI.parse(uri) end opts.on("--test-timeout=TIMEOUT", "The maximum run time for a single test in seconds") do |timeout| configuration.test_timeout_seconds = Float(timeout) end opts.on("--max-attempts=ATTEMPTS", "The maximum number of attempts to run a test") do |attempts| configuration.max_attempts = Integer(attempts) end opts.on("--test-batch-size=NUMBER", "The number of tests to process per batch") do |batch_size| configuration.test_batch_size = Integer(batch_size) end opts.on("--max-failures=FAILURES", "The maximum allowed failure before aborting a run") do |failures| configuration.max_failures = Integer(failures) end opts.on("--run-id=ID", "The ID for this run shared between coordinated workers") do |id| configuration.run_id = id end opts.on("--worker-id=ID", "The unique ID for this worker") do |id| configuration.worker_id = id end opts.on( "--[no-]retry-failures", "Retry failed and errored tests from a previous run attempt " \ "with the same run ID (default: enabled)" ) do |enabled| configuration.retry_failures = enabled end opts.on("--[no-]progress", "Show progress during the test run") do |enabled| configuration.progress = enabled end opts.on("--exclude-file=FILE_PATH", "Specify a file of tests to be excluded from running") do |file_path| configuration.exclude_file = file_path end opts.on("--include-file=FILE_PATH", "Specify a file of tests to be included in the test run") do |file_path| configuration.include_file = file_path end configuration end
from_env(env = ENV.to_h)
click to toggle source
# File lib/minitest/distributed/configuration.rb, line 18 def from_env(env = ENV.to_h) new( coordinator_uri: URI(env["MINITEST_COORDINATOR"] || "memory:"), run_id: env["MINITEST_RUN_ID"] || SecureRandom.uuid, worker_id: env["MINITEST_WORKER_ID"] || SecureRandom.uuid, test_timeout_seconds: Float(env["MINITEST_TEST_TIMEOUT_SECONDS"] || DEFAULT_TEST_TIMEOUT_SECONDS), test_batch_size: Integer(env["MINITEST_TEST_BATCH_SIZE"] || DEFAULT_BATCH_SIZE), max_attempts: Integer(env["MINITEST_MAX_ATTEMPTS"] || DEFAULT_MAX_ATTEMPTS), max_failures: (max_failures_env = env["MINITEST_MAX_FAILURES"]) ? Integer(max_failures_env) : nil, ) end
Public Instance Methods
coordinator()
click to toggle source
# File lib/minitest/distributed/configuration.rb, line 102 def coordinator @coordinator = T.let(@coordinator, T.nilable(Coordinators::CoordinatorInterface)) @coordinator ||= case coordinator_uri.scheme when "redis" Coordinators::RedisCoordinator.new(configuration: self) when "memory" Coordinators::MemoryCoordinator.new(configuration: self) else raise NotImplementedError, "Unknown coordinator implementation: #{coordinator_uri.scheme}" end end