Changeset 589

Show
Ignore:
Timestamp:
03/29/07 14:12:23 (2 years ago)
Author:
sacha
Message:

improved script. better logging.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bin/applications/nightly_build_test_infrastructure/chroot.rb

    r588 r589  
    4848    @release = release 
    4949    @arch = arch 
    50  
     50    @log_file = "#{@target_dir}/#{@name}.log" 
    5151    @complete_path = "#{@path}/#{@name}" 
    5252  end 
     
    6262 
    6363    run "#{@sudo}mkdir #{@complete_path}" 
    64     run "#{@sudo}debootstrap #{@release} #{@complete_path} http://ftp.debian.org/debian/  >> /tmp/hefeweizen_installation.log" 
    65     run "#{@sudo}mv /tmp/hefeweizen_installation.log #{@complete_path}/root" 
     64    run "#{@sudo}debootstrap #{@release} #{@complete_path} http://ftp.debian.org/debian/  >> #{@log_file}" 
    6665    run "#{@sudo}echo \"/proc #{@complete_path}/proc proc defaults 0 0\" >> /etc/fstab" 
    6766    run "#{@sudo}echo \"/dev #{@complete_path}/dev dev defaults 0 0\" >> /etc/fstab" 
     
    7877  # to ask for trusting the certificate). 
    7978  def install_subversion_and_add_ssl_certificate havanawave_certificate 
    80    
    81     run "#{@sudo}chroot #{@complete_path} apt-get update >> /root/hefeweizen_installation.log" 
    82     run "#{@sudo}chroot #{@complete_path} apt-get -y install subversion >> /root/hefeweizen_installation.log" 
     79    run "#{@sudo}chroot #{@complete_path} apt-get update >> #{@log_file}" 
     80    run "#{@sudo}chroot #{@complete_path} apt-get -y install subversion >> #{@log_file}" 
    8381    run "#{@sudo}cp #{havanawave_certificate} #{@complete_path}/root/" 
    8482    run "#{@sudo}echo \"ssl-authority-files = /root/#{File.basename havanawave_certificate}\" >> #{@complete_path}/etc/subversion/servers" 
    85  
    8683  end 
    8784 
    8885  # This method copies the HefeWeizen installation script 
    8986  def get_hefeweizen_installation_script command 
    90     run "#{@sudo}chroot #{@complete_path} #{command} >> /root/hefeweizen_installation.log
     87    run "#{@sudo}chroot #{@complete_path} #{command} >> #{@log_file}
    9188  end 
    9289 
    9390  # This method runs the HefeWeizen installation inside the chroot. 
    9491  def run_hefeweizen_installation 
    95     run "#{@sudo}chroot #{@complete_path} sh hefeweizen-installation.sh  >> /root/hefeweizen_installation.log
     92    run "#{@sudo}chroot #{@complete_path} sh hefeweizen-installation.sh  >> #{@log_file}
    9693  end 
    9794 
     
    104101  # This mehtod starts the HefeWeizen system 
    105102  def start_hefeweizen 
    106     run "#{@sudo}chroot #{@complete_path} sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/bin/run-hefeweizen.sh &
     103    run "#{@sudo}chroot #{@complete_path} sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/bin/run-hefeweizen.sh & >> #{@log_file}
    107104  end 
    108105 
    109106  # This method starts the HefeWeizen Test system 
    110107  def start_tester 
    111     run "#{@sudo}chroot #{@complete_path} sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/bin/run-tester.sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/bin
     108    run "#{@sudo}chroot #{@complete_path} sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/bin/run-tester.sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/bin >> #{@log_file}
    112109  end 
    113110   
    114111  # This method stops the HefeWeizen sytem. 
    115112  def stop_hefeweizen 
    116     run "#{@sudo}chroot #{@complete_path} sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/bin/stop-hefeweizen.sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/
     113    run "#{@sudo}chroot #{@complete_path} sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/bin/stop-hefeweizen.sh /usr/local/src/HefeWeizenProject/HefeWeizen/trunk/ >> #{@log_file}
    117114  end 
    118115   
     
    120117  def copy_test_result_to target, prefix 
    121118    Dir.glob("#{@complete_path}/home/hefeweizen-env/var/log/hefeweizen-test/*").each{ | dir | 
    122       run "#{@sudo}mv #{dir} #{target}/#{prefix}_#{File.basename dir}
     119      run "#{@sudo}mv \"#{dir}\" \"#{target}/#{prefix}_#{File.basename dir}\"
    123120    } 
    124121  end 
     
    128125  # This method executes a command and raises an Exception if the command failed. 
    129126  def run command 
    130     @logger.debug "command: #{command}" 
     127    @logger.debug "#{Time.now}: command: #{command}" 
    131128    system command 
    132 #    return true 
    133129    if $? != 0 then 
    134130      raise Exception.new "Error executing command '#{command}'" 
  • trunk/bin/applications/nightly_build_test_infrastructure/hefeweizen-test-system.rb

    r588 r589  
    5454DEFAULT_PATH = "/home/hefeweizen_builds/" 
    5555 
    56 @logger = Logger.new(STDOUT) 
    57 @logger.level = Logger::DEBUG 
    58  
    5956# This class is handling a complete Testing of HefeWeizen. This includes the creation of a chroot,  
    6057# installing the HefeWeizen system inside the chroot and running tests. 
     
    7774    architecture = "32bit" 
    7875    time = Time.now 
    79     puts chroot_name = "#{distribution}_#{release}_#{architecture}_#{time.to_f.to_s}_#{time.to_s.gsub(/ /, '_')}" 
     76    chroot_name = "#{distribution}_#{release}_#{architecture}_#{time.to_f.to_s}_#{time.to_s.gsub(/ /, '_')}" 
    8077    chroot = Chroot.new @logger, @use_sudo, chroot_name, @target_path, CHROOT_PATH, distribution, release, architecture 
    8178 
    8279    begin 
     80 
    8381      path = chroot.create 
    84       @logger.info "Created new chroot with the following path: #{path}" 
     82      @logger.info "Created new chroot with the name '#{chroot_name}' at the following path: #{path}" 
    8583 
    8684      @logger.info "Installing subversion and setting up ssl certificate" 
     
    111109      @logger.info "Stopping HefeWeizenTester" 
    112110      chroot.stop_hefeweizen 
    113        
     111 
    114112      @logger.info "Copying test result" 
    115113      chroot.copy_test_result_to "#{@target_path}/#{RESULTS_PATH}", prefix = chroot_name 
     
    127125end 
    128126 
    129 #options = {:path => DEFAULT_PATH, :sudo => false} 
    130127options = OpenStruct.new 
    131128options.path = [DEFAULT_PATH] 
     
    153150end.parse! 
    154151 
     152time_start = Time.now 
     153log_file = "#{options.path}/#{RESULTS_PATH}/hefeweizen-test-system-#{time_start.to_f}_#{time_start.to_s.gsub(/ /, "_").log}" 
     154@logger = Logger.new(log_file) 
     155@logger.level = Logger::DEBUG 
     156 
    155157@logger.info "HefeWeizen CHROOT Test System" 
    156158@logger.info "Path to install: #{options.path}"