Module: RRRSpec::Client::Support
- Defined in:
- lib/rrrspec/client/support.rb
Class Method Summary collapse
-
.estimate_sec_sorted(taskset_class, spec_files) ⇒ Object
Public: Sort the spec filepaths by their estiamted spec execution times.
- .is_using_rsync?(rsync_name) ⇒ Boolean
- .run_rsync_package(rsync_name) ⇒ Object
- .show_result(taskset, verbose = false, show_errors = false) ⇒ Object
- .start_taskset(conf, rsync_name) ⇒ Object
Class Method Details
.estimate_sec_sorted(taskset_class, spec_files) ⇒ Object
Public: Sort the spec filepaths by their estiamted spec execution times.
Returns an array of [spec_file, estiamte_sec]
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/rrrspec/client/support.rb', line 153 def estimate_sec_sorted(taskset_class, spec_files) estimate_secs = TasksetEstimation.estimate_secs(taskset_class) spec_files.map do |spec_file| [spec_file, estimate_secs[spec_file]] end.sort do |a, b| case when a[1] == nil && b[1] == nil then 0 when a[1] == nil && b[1] != nil then 1 when a[1] != nil && b[1] == nil then -1 else a[1] - b[1] end end end |
.is_using_rsync?(rsync_name) ⇒ Boolean
144 145 146 147 148 |
# File 'lib/rrrspec/client/support.rb', line 144 def is_using_rsync?(rsync_name) ActiveTaskset.list.any? do |taskset| taskset.rsync_name == rsync_name end end |
.run_rsync_package(rsync_name) ⇒ Object
135 136 137 138 139 140 141 142 |
# File 'lib/rrrspec/client/support.rb', line 135 def run_rsync_package(rsync_name) conf = RRRSpec.configuration remote_path = File.join(conf.rsync_remote_path, rsync_name) command = "rsync #{conf.} #{conf.packaging_dir}/ #{remote_path}" $stderr.puts command system(command) $?.success? end |
.show_result(taskset, verbose = false, show_errors = false) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/rrrspec/client/support.rb', line 43 def show_result(taskset, verbose=false, show_errors=false) if show_errors puts "Failed Tasks:\n\n" taskset.tasks.each do |task| if task.status == "failed" trial = task.trials.detect { |t| t.status == "failed" } stdout = trial.stdout puts "Task: #{task.spec_file}\n\n" unless stdout.blank? puts "\tSTDOUT:" stdout.each_line { |line| puts "\t#{line}" } end stderr = trial.stderr unless stderr.blank? puts "STDERR:" stderr.each_line { |line| puts "\t#{line}" } end puts "\n" end end puts end puts "Status: #{taskset.status}" puts "Created: #{taskset.created_at}" puts "Finished: #{taskset.finished_at}" puts "Tasks: #{taskset.task_size}" puts "Succeeded: #{taskset.succeeded_count}" puts "Failed: #{taskset.failed_count}" if verbose puts puts "Log:" taskset.log.each_line { |line| puts "\t#{line}" } puts puts "Workers:" taskset.worker_logs.each do |worker_log| puts "\tKey: #{worker_log.key}" puts "\tStarted: #{worker_log.started_at}" puts "\tRSync Finished: #{worker_log.rsync_finished_at}" puts "\tSetup Finished: #{worker_log.setup_finished_at}" puts "\tFinished: #{worker_log.finished_at}" puts "\tLog:" worker_log.log.each_line { |line| puts "\t\t#{line}" } end puts puts "Slaves:" taskset.slaves.each do |slave| puts "\tKey: #{slave.key}" puts "\tStatus: #{slave.status}" puts "\tTrials:" slave.trials.each do |trial| puts "\t\t#{trial.key}" end puts "\tLog:" slave.log.each_line { |line| puts "\t\t#{line}" } end puts puts "Tasks:" taskset.tasks.each do |task| puts "\tKey: #{task.key}" puts "\tSpec: #{task.spec_file}" puts "\tStatus: #{task.status}" puts "\tTrials:" task.trials.each do |trial| puts "\t\tKey: #{trial.key}" puts "\t\tSlave: #{trial.slave.key}" puts "\t\tStatus: #{trial.status}" puts "\t\tStarted: #{trial.started_at}" puts "\t\tFinished: #{trial.finished_at}" puts "\t\tPassed: #{trial.passed}" puts "\t\tPending: #{trial.pending}" puts "\t\tFailed: #{trial.failed}" stdout = trial.stdout if stdout puts "\t\tSTDOUT:" stdout.each_line { |line| puts "\t\t\t#{line}" } end stderr = trial.stderr if stderr puts "\t\tSTDERR:" stderr.each_line { |line| puts "\t\t\t#{line}" } end end end end end |
.start_taskset(conf, rsync_name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rrrspec/client/support.rb', line 6 def start_taskset(conf, rsync_name) $stderr.puts '1/3) Start rsync...' if is_using_rsync?(rsync_name) $stderr.puts 'It seems you are running rrrspec already' $stderr.puts 'Please wait until the previous run finishes' exit 1 end unless run_rsync_package(rsync_name) $stderr.puts 'rsync failed.' exit 1 end $stderr.puts '2/3) Creating a new taskset...' taskset = Taskset.create( rsync_name, conf.setup_command, conf.slave_command, conf.worker_type, conf.taskset_class, conf.max_workers, conf.max_trials, conf.unknown_spec_timeout_sec, conf.least_timeout_sec ) estimate_sec_sorted(conf.taskset_class, conf.spec_files.uniq).reverse_each do |spec_file, estimate_sec| task = Task.create(taskset, estimate_sec, spec_file) taskset.add_task(task) taskset.enqueue_task(task) end $stderr.puts '3/3) Enqueue the taskset...' ActiveTaskset.add(taskset) DispatcherQueue.notify $stderr.puts 'Your request is successfully enqueued!' return taskset end |