Skip to content
Browse files

scout checks in on install

  • Loading branch information...
1 parent 0e7b998 commit 0b6e54aa33df6bfea48c25d02f04151e7de5755a Andre Lewis committed
Showing with 26 additions and 8 deletions.
  1. +4 −1 lib/scout/command/install.rb
  2. +22 −7 test/scout_test.rb
View
5 lib/scout/command/install.rb
@@ -22,7 +22,10 @@ def run
puts "\nAttempting to contact the server..."
begin
- Scout::Server.new(server, key, history, log) { |scout| scout.fetch_plan }
+ Scout::Server.new(server, key, history, log) do |scout|
+ scout.fetch_plan
+ scout.run_plugins_by_plan
+ end
puts <<-END_SUCCESS.gsub(/^ {10}/, "")
Success!
View
29 test/scout_test.rb
@@ -6,7 +6,8 @@
$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' )
require 'test/unit'
require 'lib/scout'
-
+require "pty"
+require "expect"
require 'rubygems'
require "active_record"
@@ -34,10 +35,26 @@ def setup
# avoid client limit issues
assert @client.account.subscription.update_attribute(:clients,100)
end
-
- # Holding off...not sure how to pass thru inputs to STDIN
- def test_should_run_install
+ def test_should_checkin_during_interactive_install
+ Client.update_all "last_checkin=null"
+ res=""
+ PTY.spawn("bin/scout -s http://localhost:4567 -d #{PATH_TO_DATA_FILE} install ") do | stdin, stdout, pid |
+ begin
+ stdin.expect("Enter the Server Key:", 3) do |response|
+ assert_not_nil response, "Agent didn't print prompt for server key"
+ stdout.puts @client.key # feed the agent the key
+ res=stdin.read.lstrip
+ end
+ rescue Errno::EIO
+ # don't care
+ end
+ end
+
+ assert res.match(/Attempting to contact the server.+Success!/m), "Output from interactive install session isn't right"
+
+ assert_in_delta Time.now.utc.to_i, @client.reload.last_ping.to_i, 100
+ assert_in_delta Time.now.utc.to_i, @client.reload.last_checkin.to_i, 100
end
def test_should_run_first_time
@@ -67,7 +84,7 @@ def test_should_run_when_forced
scout(@client.key,'-F')
assert @client.reload.last_checkin > prev_checkin
end
-
+
# Needed to ensure that malformed embedded options don't bork the agent in test mode
def test_embedded_options_are_invalid
@@ -98,9 +115,7 @@ def test_should_get_plan_with_blank_history_file
assert_in_delta Time.now.utc.to_i, @client.reload.last_checkin.to_i, 100
end
- # TODO: Can't think of a way to set a lower timeout on a plugin basis that works for a test.
def test_should_generate_error_on_plugin_timeout
-
end

0 comments on commit 0b6e54a

Please sign in to comment.
Something went wrong with that request. Please try again.