Class: Ace::TestRunner::Suite::DurationEstimator
- Inherits:
-
Object
- Object
- Ace::TestRunner::Suite::DurationEstimator
- Defined in:
- lib/ace/test_runner/suite/duration_estimator.rb
Overview
Estimates expected test duration for packages based on historical data. Used by Orchestrator to schedule slowest packages first, preventing them from becoming bottlenecks at the end of parallel test runs.
Instance Method Summary collapse
-
#enrich_packages(packages) ⇒ Array<Hash>
Enrich packages with expected_duration from historical data.
-
#estimate(package) ⇒ Float?
Read historical duration from package’s latest summary.json.
-
#initialize(report_root: nil) ⇒ DurationEstimator
constructor
A new instance of DurationEstimator.
Constructor Details
#initialize(report_root: nil) ⇒ DurationEstimator
Returns a new instance of DurationEstimator.
12 13 14 |
# File 'lib/ace/test_runner/suite/duration_estimator.rb', line 12 def initialize(report_root: nil) @report_root = report_root end |
Instance Method Details
#enrich_packages(packages) ⇒ Array<Hash>
Enrich packages with expected_duration from historical data
41 42 43 44 45 46 |
# File 'lib/ace/test_runner/suite/duration_estimator.rb', line 41 def enrich_packages(packages) packages.each do |pkg| pkg["expected_duration"] = estimate(pkg) || 0 end packages end |
#estimate(package) ⇒ Float?
Read historical duration from package’s latest summary.json
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ace/test_runner/suite/duration_estimator.rb', line 20 def estimate(package) reports_dir = Atoms::ReportPathResolver.report_directory( package["path"], report_root: @report_root, package_name: package["name"] ) return nil unless reports_dir summary_file = File.join(reports_dir, "summary.json") return nil unless File.exist?(summary_file) data = JSON.parse(File.read(summary_file)) data["duration"] rescue JSON::ParserError, Errno::ENOENT, Errno::EACCES nil end |