lib/oats/driver.rb in oats-0.1.0 vs lib/oats/driver.rb in oats-0.1.1

- old
+ new

@@ -7,51 +7,18 @@ module Oats module Driver - def Driver.agent - ENV['KILL_AGENT' ] = 'KILL_AGENT' if $oats_execution['options']["_:kill_agent"] - ENV['OATS_USER' ] = $oats_execution['options']["_:oats_user"] if $oats_execution['options']["_:oats_user"] - ENV['OATS_TESTS_REPOSITORY_VERSION' ] = $oats_execution['options']["_:repository_version"] if $oats_execution['options']["_:repository_version"] - nick = $oats_execution['options']["execution:occ:agent_nickname"] - ENV['OATS_AGENT_NICKNAME' ] = nick if nick - port = $oats_execution['options']["execution:occ:agent_port"].to_s - ENV['OATS_AGENT_PORT'] = port if port - dir = ENV['HOME'] + "/results_archive/#{nick}/agent_logs" - FileUtils.mkdir_p(dir) unless File.exists?(dir) - ENV['OATS_AGENT_CONFIG_FILE'] = "#{dir}/config-agent.txt" - dat = `date +'%m%d%H%M%S'`.chomp - log_file = "#{dir}/agent_#{dat}.log" - ENV['OATS_AGENT_LOGFILE'] = log_file - agent_log_file = "#{dir}/agent.log" - cmd = ENV['OATS_HOME'] + '/bin/agent' - pid = `#{cmd}`.chomp - puts "Running PID: " + pid + ', Log: ' + log_file - # echo "$NICKNAME $PORT $PID $DISPLAY_NUM" >| $config_agent_file - 10.times do - if File.exist? log_file - FileUtils.rm_f agent_log_file - FileUtils.ln log_file, agent_log_file - break - end - sleep 1 - end - end - - # Main method that starts oats execution in either agent or standalone mode. - # Parameters are command-line arguments - # Returns oats_info object containing execution results - def Driver.run(args) + def Driver.init(args=nil) unless ENV['HOSTNAME'] if RUBY_PLATFORM =~ /(mswin|mingw)/ ENV['HOSTNAME'] = ENV['COMPUTERNAME'] else ENV['HOSTNAME'] = `hostname`.chomp end end - Log4r::Logger.root.level = Log4r::DEBUG Log4r::StdoutOutputter.new('console', :level=>1, :formatter=>Log4r::PatternFormatter.new(:depth=>50, :pattern => "%-5l %d %M", :date_pattern=>"%y-%m-%d %H:%M:%S")) $log = Log4r::Logger.new('R') @@ -60,36 +27,18 @@ $oats_info = {} $oats_global = {} @@quiet = options['_:quiet'] # save quiet option from initial commandline options $log.remove('console') if @@quiet ENV['HOME'] = Util.expand_path(ENV['HOME']) if ENV['HOME'] # Normalize for cygwin - if $oats_execution['agent'] - require 'oats/ragent' - # $oats_execution['agent'] (used by framework) == Oats.global['agent'] (by YAMLs) === options - $oats = OatsData.load(options['_:ini_file']) - $oats['_']['options'] = options - Roptions.override(options) - # $oats would be reset and and regenerated by agents across jobs. - - options['execution:occ:agent_host'] = $oats['execution']['occ']['agent_host'] - options['execution:occ:agent_port'] = $oats['execution']['occ']['agent_port'] - options['execution:occ:agent_nickname'] = ($oats['execution']['occ']['agent_nickname'] || options['execution:occ:agent_host'].sub(/\..*/,'')) - $oats['execution']['occ']['agent_nickname'] = options['execution:occ:agent_nickname'] - - if options['_:command'] - require 'oats/rclient' - options['_:id'] = Time.now.to_i.to_s - request = { :command => options['_:command'], :args => options['_:args'] } - request[:id] = options['_:id'] if options['_:id'] - EventMachine::run { EventMachine::connect options['execution:occ:agent_host'], - options['execution:occ:agent_port'].to_i, Rclient, options['execution:occ:agent_host'], request - } - else - Ragent.start $oats['execution']['occ'] - end - else - Driver.start(nil,options) - end + options + end + + # Main method that starts oats execution in either agent or standalone mode. + # Parameters are command-line arguments + # Returns oats_info object containing execution results + def Driver.run(args) + options = Driver.init(args) + Driver.start(nil,options) $oats_info end # Executes OATS # Returns oats_info object containing execution results \ No newline at end of file