installer/utils/nix_install_test.rb in rhoconnect-3.1.0 vs installer/utils/nix_install_test.rb in rhoconnect-3.1.1
- old
+ new
@@ -1,10 +1,11 @@
#!/usr/bin/env ruby
$:.unshift File.expand_path(File.dirname(__FILE__))
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'installer', 'utils'))
+require 'rhoconnect'
require 'rubygems'
require 'fog'
require 'net/http'
require 'constants'
require 'readline'
@@ -14,41 +15,47 @@
# cmd
# easily issue system commands in a clear way
def cmd(cmd)
puts cmd
system(cmd)
- # Return the exit status
- $?
+ exit 1 if !$?.to_i == 0
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
+ exit_code = @ssh.run('echo $?')[0].stdout
+ exit 1 if exit_code.to_i != 0
end #ssh_cmd
+# nightly_build?
+# Return whether or not
+def nightly_build?
+ ARGV.include? 'nightly'
+end #nightly_build?
+
# compile_stack_info
# Fills in all necessary information which is stack specific
def compile_stack_info
# 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/"
+
+ # Determine whether or not the build is a nightly build.
+ bucket = nightly_build? ? 'rhoconnect' : 'rhoconnect-test'
+ # Determine which folder in the bucket to grab files from
+ packages = Rhoconnect::VERSION.include?('beta') ? 'beta-packages' : 'packages'
+
# 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',
@@ -56,11 +63,11 @@
: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://#{bucket}.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',
@@ -68,11 +75,11 @@
: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" +
+ "baseurl=http://#{bucket}.s3.amazonaws.com/#{packages}/rpm" +
'\nenabled=1\n' +
'gpgcheck=0\n' }
else
puts "Incorrect user name"
@@ -181,16 +188,10 @@
# 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
['Redis', 'Nginx'].each do |program|
attempts = 0
while @ssh.run("pgrep #{program.downcase}")[0].stdout.strip == "" and
@@ -199,12 +200,13 @@
attempts += 1
sleep 1
end #while
if attempts >= max_attempts
puts "#{program} failed to start."
+ exit 1
else
- puts "#{program} start took #{attempts} attempts."
+ puts "#{program} start took #{attempts} attempts." if attempts > 1
end #if
puts
end #do
end # start_servers
@@ -223,11 +225,11 @@
end #check_rc_service
# compute_time
# General time computation method
def compute_time(start_time, end_time)
- time_delta = (end_time - start_time)
+ time_delta = (end_time - start_time).round 3
if time_delta >= 60
time_delta /= 60
time_units = 'minute'
if time_delta > 1
@@ -243,9 +245,12 @@
# SCRIPT
# Test Package installations
Constants::STACKS.each do |stack|
start_time = Time.now
+
+
+
begin
@stack = stack
compile_stack_info
puts "\n" +