installer/utils/nix_install_test.rb in rhoconnect-3.1.0.beta2 vs installer/utils/nix_install_test.rb in rhoconnect-3.1.0

- old
+ new

@@ -14,43 +14,53 @@ # cmd # easily issue system commands in a clear way def cmd(cmd) puts cmd system(cmd) + # Return the exit status + $? end #cmd +# nightly_build? +# Return whether or not +def nightly_build? + ARGV.include? 'nightly' +end #nightly_build? + # ssh_cmd # More easily issue commands over the ssh connection. def ssh_cmd(cmd) puts cmd puts @ssh.run(cmd)[0].stdout end #ssh_cmd # compile_stack_info # Fills in all necessary information which is stack specific def compile_stack_info - # User is stack specific but not to + # User is stack specific but not to # be included in the fog creation hash @user = @stack[:user] @stack.delete :user # This part of the package name will always be the same local_file = "#{`pwd`.strip}/pkg/" # Append the rest of the file name according to distribution if @user == 'ubuntu' + nightly_build? ? packages = 'beta-packages' : packages = 'packages' + @dist = { :flavor => "ubuntu", :package => "rhoconnect_#{Constants::RC_VERSION}_all.deb", :local_file => "#{local_file}rhoconnect_#{Constants::RC_VERSION}_all.deb", :pkg_mgr => 'dpkg', :pkg_type => 'DEB', :pkg_repo => 'apt-get', :deps => Constants::DEB_DEPS, :repo_src_file => '/etc/apt/sources.list', :repo_str => '\n' + '# This is the repository for rhoconnect packages\n' + - 'deb http://rhoconnect.s3.amazonaws.com/packages/deb rhoconnect main' } + "deb http://rhoconnect.s3.amazonaws.com/#{packages}/deb rhoconnect main" } elsif @user == 'root' @dist = { :flavor => "centos", :package => "rhoconnect-#{Constants::RC_VERSION}.noarch.rpm", :local_file => "#{local_file}rhoconnect-#{Constants::RC_VERSION}.noarch.rpm", :pkg_mgr => 'rpm', @@ -58,12 +68,12 @@ :pkg_repo => 'yum', :deps => Constants::RPM_DEPS, :repo_src_file => '/etc/yum.repos.d/rhoconnect.repo', :repo_str => '[rhoconnect]\n' + 'name=Rhoconnect\n' + - 'baseurl=http://rhoconnect.s3.amazonaws.com/packages/rpm\n' + - 'enabled=1\n' + + "baseurl=http://rhoconnect.s3.amazonaws.com/#{packages}/rpm" + + '\nenabled=1\n' + 'gpgcheck=0\n' } else puts "Incorrect user name" exit 3 @@ -155,12 +165,10 @@ ssh_cmd "echo -e \"#{src_str}\" >> #{filename}" ssh_cmd "sudo chmod 0#{perms} #{filename}" - cat_src = @ssh.run("cat #{@dist[:repo_src_file]}")[0].stdout.strip - ssh_cmd "sudo #{@dist[:pkg_repo]} update" unless @dist[:flavor] == "centos" end #prepare_sources # install_package # Issues commands to the remote machine to start the installation @@ -172,34 +180,34 @@ end #install_package # start_servers # Attempts to start redis and nginx servers def start_servers + max_attempts = 100 puts "Waiting #{Constants::SLEEP} seconds for services to initialize." Constants::SLEEP.times do |sec| print '.' STDOUT.flush sleep 1 end #do puts - - attempts = 0 - while @ssh.run("pgrep redis")[0].stdout.strip == "" - ssh_cmd "sudo /etc/init.d/redis start" - attempts += 1 - sleep 1 - end #while - puts "Redis start took #{attempts} attempts" - puts - attempts = 0 - while @ssh.run("pgrep nginx")[0].stdout.strip == "" - ssh_cmd "sudo /etc/init.d/nginx start" - attempts += 1 - sleep 1 - end #while - puts "Nginx start took #{attempts} attempts." - puts + + ['Redis', 'Nginx'].each do |program| + attempts = 0 + while @ssh.run("pgrep #{program.downcase}")[0].stdout.strip == "" and + attempts < max_attempts + ssh_cmd "sudo /etc/init.d/#{program.downcase} start" + attempts += 1 + sleep 1 + end #while + if attempts >= max_attempts + puts "#{program} failed to start." + else + puts "#{program} start took #{attempts} attempts." + end #if + puts + end #do end # start_servers # chack_rc_service # Makes an HTTP request to check that the rhoconnect service is working def check_rc_service @@ -262,10 +270,9 @@ check_rc_service end_time = Time.now puts compute_time(start_time, end_time) rescue => e - puts "OH NOEZ, Exception!!" puts e.inspect puts e.backtrace exit 15 ensure if @server != nil