installer/utils/nix_install_test.rb in rhoconnect-3.0.2 vs installer/utils/nix_install_test.rb in rhoconnect-3.0.3
- old
+ new
@@ -30,25 +30,27 @@
# 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/"
+ local_file = "#{`pwd`.strip}/pkg/"
# Append the rest of the file name according to distribution
if @user == 'ubuntu'
- @dist = { :package => "rhoconnect_#{Constants::RC_VERSION}_all.deb",
- :local_file => "#{local_file}rhoconnect_#{Constants::RC_VERSION}_all.deb",
- :pkg_mgr => 'dpkg',
- :pkg_repo => 'apt-get -y',
- :deps => Constants::DEB_DEPS }
+ @dist = { :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 -y',
+ :deps => Constants::DEB_DEPS }
elsif @user == 'root'
- @dist = { :package => "rhoconnect_#{Constants::RC_VERSION}_noarch.rpm",
- :local_file => "#{local_file}rhoconnect_#{Constants::RC_VERSION}_noarch.rpm",
- :pkg_mgr => 'rpm',
- :pkg_repo => 'yes | yum',
- :deps => Constants::RPM_DEPS }
+ @dist = { :package => "rhoconnect-#{Constants::RC_VERSION}.noarch.rpm",
+ :local_file => "#{local_file}rhoconnect-#{Constants::RC_VERSION}.noarch.rpm",
+ :pkg_mgr => 'rpm',
+ :pkg_type => 'RPM',
+ :pkg_repo => 'yes | yum',
+ :deps => Constants::RPM_DEPS }
else
puts "Incorrect user name"
exit
end #i
end #compile_stack_info
@@ -120,21 +122,22 @@
end #create_scp_connection
# transfer
# transfers given data to remote machine via scp
def transfer(local_data, remote_data)
- puts "Attempting to establish SCP connection..."
+ puts "Attempting file transfer via SCP"
+ puts "Transferring #{local_data} to #{remote_data}..."
@scp.upload( local_data, remote_data ) do |cd, name, sent, total|
print "\r#{name}: #{(sent.to_f * 100 / total.to_f).to_i}%"
end #do
puts
end #establish_scp_connection
# transfer_rhoconnect
# Transfers the rhoconnect package over SCP
def transfer_rhoconnect
- transfer @dist[:local_file], Constants::REMOTE_HOME
+ transfer @dist[:local_file], @dist[:remote_home]
end #transfer_rhoconnect
# destroy_ec2_instance
# Terminates the current ec2 instance
def destroy_ec2_instance
@@ -161,12 +164,24 @@
ssh_cmd "sudo #{@dist[:pkg_mgr]} -i #{@dist[:package]}"
puts
end #install_package
def start_servers
- ssh_cmd "sudo /etc/init.d/redis start"
- ssh_cmd "sudo /etc/init.d/nginx start"
+ attempts = 0
+ while @ssh.run("pgrep redis")[0].stdout.strip == ""
+ ssh_cmd "sudo /etc/init.d/redis start"
+ attempts += 0
+ 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 += 0
+ end #while
+ puts "Nginx start took #{attempts} attempts."
+ puts
puts "Waiting #{Constants::SLEEP} seconds for servers to initialize"
Constants::SLEEP.times do
sleep 1
print '.'
STDOUT.flush
@@ -196,69 +211,54 @@
end #if
else
time_units = 'seconds'
end #if
-"Test completed in #{time_delta} #{time_units}"
+"\nTest completed in #{time_delta} #{time_units}\n"
end #compute_time
# SCRIPT
-### This part has been set as a dependency in the :test rake task
-# Create Packages
-
-# Creating debian package
-#cmd "sudo rake build:deb"
-# Make sure package was created successfully
-#if $? != 0
-# puts "Debian package was not created successfully" +
-# "Exiting..."
-# exit 1
-#end #if
-
-# Keep commented until running on a machine with rpm
-# Creating RPM package
-#cmd "sudo rake build:rpm"
-# Make sure package was created successfully
-#if $? != 0
-# puts "RPM package was not created successfully" +
-# "Exiting..."
-# exit 1
-#end #if
-
# Test Package installations
-start_time = Time.now
Constants::STACKS.each do |stack|
+ start_time = Time.now
begin
@stack = stack
compile_stack_info
+ puts
+ puts "================================================"
+ puts "Now starting test of #{@dist[:pkg_type]} package"
+ puts "================================================"
+ puts
create_ec2_instance
# Establish connections
establish_ssh_connection
+ @dist[:remote_home] = @ssh.run("echo ~")[0].stdout.strip
establish_scp_connection
# Transfer the Rhoconnect package to the remote machine
transfer_rhoconnect
puts "Installing rhoconnect package.\n" +
- "This may take a while..."
+ "This may take a while...\n\n"
install_package
# Start the redis and nginx servers on the remote machine
start_servers
# Check the status of the rhoconnect service
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
ensure
if @server != nil
destroy_ec2_instance
end #if
end #begin
end #do
-end_time = Time.now
-puts compute_time(start_time, end_time)