scout 5.6.11 → 5.7.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ # 5.7.0
2
+
3
+ * Added support for environments
4
+
1
5
  # 5.6.11
2
6
 
3
7
  * Remove the scout_streamer.pid file after the realtime processes has expired.
data/Gemfile CHANGED
@@ -8,4 +8,6 @@ group :test do
8
8
  gem "activerecord", "2.2.2"
9
9
  gem "mysql"
10
10
  gem "mocha", :require => false
11
+ gem "json"
12
+ gem 'pry'
11
13
  end
@@ -57,7 +57,6 @@ module Scout
57
57
  options[:roles] = roles
58
58
  end
59
59
 
60
-
61
60
  opts.on( "-s", "--server SERVER", String,
62
61
  "The URL for the server to report to." ) do |url|
63
62
  options[:server] = url
@@ -92,6 +91,10 @@ module Scout
92
91
  options[:hostname] = hostname
93
92
  end
94
93
 
94
+ opts.on( "-e", "--environment ENVIRONMENT", String, "Environment for this server. Environments are defined through scoutapp.com's web UI" ) do |environment|
95
+ options[:environment] = environment
96
+ end
97
+
95
98
  opts.separator " "
96
99
  opts.separator "Common Options:"
97
100
  opts.separator "--------------------------------------------------------------------------"
@@ -178,6 +181,7 @@ module Scout
178
181
  @http_proxy = options[:http_proxy] || ""
179
182
  @https_proxy = options[:https_proxy] || ""
180
183
  @hostname = options[:hostname] || Socket.gethostname
184
+ @environment = options[:environment] || ""
181
185
  @options = options
182
186
  @args = args
183
187
 
@@ -104,7 +104,7 @@ module Scout
104
104
  end
105
105
 
106
106
  def test_server_connection(key)
107
- Scout::Server.new(server, key, history, log, server_name, @http_proxy, @https_proxy, @roles, @hostname) do |scout|
107
+ Scout::Server.new(server, key, history, log, server_name, @http_proxy, @https_proxy, @roles, @hostname, @environment) do |scout|
108
108
  scout.fetch_plan
109
109
  scout.run_plugins_by_plan
110
110
  end
@@ -10,7 +10,7 @@ module Scout
10
10
  log.debug("Running Scout [#{Scout::VERSION}] on #{@hostname}") if log
11
11
  log.debug("Configuration directory is #{configuration_directory} ") if log
12
12
  # TODO: too much external logic of command doing things TO server. This should be moved into the server class.
13
- @scout = Scout::Server.new(server, key, history, log, server_name, @http_proxy, @https_proxy, @roles, @hostname)
13
+ @scout = Scout::Server.new(server, key, history, log, server_name, @http_proxy, @https_proxy, @roles, @hostname, @environment)
14
14
  @scout.load_history
15
15
 
16
16
  unless $stdin.tty?
@@ -27,7 +27,7 @@ module Scout
27
27
  attr_reader :client_key
28
28
 
29
29
  # Creates a new Scout Server connection.
30
- def initialize(server, client_key, history_file, logger = nil, server_name=nil, http_proxy='', https_proxy='', roles='', hostname = nil)
30
+ def initialize(server, client_key, history_file, logger=nil, server_name=nil, http_proxy='', https_proxy='', roles='', hostname=nil, environment='')
31
31
  @server = server
32
32
  @client_key = client_key
33
33
  @history_file = history_file
@@ -38,6 +38,7 @@ module Scout
38
38
  @https_proxy = https_proxy
39
39
  @roles = roles || ''
40
40
  @hostname = hostname
41
+ @environment = environment
41
42
  @plugin_plan = []
42
43
  @plugins_with_signature_errors = []
43
44
  @directives = {} # take_snapshots, interval, sleep_interval
@@ -60,7 +61,7 @@ module Scout
60
61
  def refresh?
61
62
  return true if !ping_key or account_public_key_changed? # fetch the plan again if the account key is modified/created
62
63
 
63
- url=URI.join( @server.sub("https://","http://"), "/clients/#{ping_key}/ping.scout?roles=#{@roles}&hostname=#{URI.encode(@hostname)}")
64
+ url=URI.join( @server.sub("https://","http://"), "/clients/#{ping_key}/ping.scout?roles=#{@roles}&hostname=#{URI.encode(@hostname)}&env=#{URI.encode(@environment)}")
64
65
 
65
66
  headers = {"x-scout-tty" => ($stdin.tty? ? 'true' : 'false')}
66
67
  if @history["plan_last_modified"] and @history["old_plugins"]
@@ -28,7 +28,7 @@ module Scout
28
28
  "/clients/CLIENT_KEY/#{url_name}.scout".
29
29
  gsub(/\bCLIENT_KEY\b/, @client_key).
30
30
  gsub(/\b[A-Z_]+\b/) { |k| options[k.downcase.to_sym] || k })
31
- uri.query = ["roles=#{@roles}","hostname=#{URI.encode(@hostname)}","tty=#{$stdin.tty? ? 'y' : 'n'}"].join('&')
31
+ uri.query = ["roles=#{@roles}","hostname=#{URI.encode(@hostname)}","env=#{URI.encode(@environment)}","tty=#{$stdin.tty? ? 'y' : 'n'}"].join('&')
32
32
  uri
33
33
  end
34
34
 
@@ -1,3 +1,3 @@
1
1
  module Scout
2
- VERSION = "5.6.11"
2
+ VERSION = "5.7.0.pre"
3
3
  end
@@ -15,6 +15,11 @@ require 'newrelic_rpm'
15
15
  require "pty"
16
16
  require "expect"
17
17
  require 'test/unit'
18
+ begin
19
+ require 'pry'
20
+ rescue LoadError
21
+ # not using pry
22
+ end
18
23
  # must be loaded after
19
24
  $LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' )
20
25
  $LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/..' )
@@ -41,7 +46,7 @@ end
41
46
 
42
47
  class ScoutTest < Test::Unit::TestCase
43
48
  def setup
44
- load_fixtures :clients, :accounts, :plugins, :subscriptions, :plugin_metas, :roles, :plugin_templates, :notification_groups
49
+ load_fixtures :accounts, :notification_groups, :environments, :clients, :plugins, :subscriptions, :plugin_metas, :roles, :plugin_templates
45
50
  clear_tables :plugin_activities, :ar_descriptors, :summaries, :clients_roles
46
51
  clear_working_dir
47
52
 
@@ -603,6 +608,22 @@ myurl=http://foo.com?foo=bar
603
608
  assert_equal hostname_override, client.hostname
604
609
  end
605
610
 
611
+ def test_environment_argument_with_new_client
612
+ staging = @roles_account.environments.find_by_name("staging")
613
+ scout(@roles_account.key, "--environment", staging.name)
614
+ @client = @roles_account.clients.last
615
+ assert_equal staging, @client.environment
616
+ end
617
+
618
+ def test_environment_argument_with_existing_client
619
+ test_environment_argument_with_new_client
620
+ File.unlink(File.join(AGENT_DIR,"scout_client_pid.txt")) # needed because the "scout" test method leaves the PID file around
621
+ production = @roles_account.environments.find_by_name("production")
622
+ scout(@roles_account.key, "--environment", production.name, "--force")
623
+ @client.reload
624
+ assert_equal production, @client.environment
625
+ end
626
+
606
627
  def test_create_cron_script
607
628
  Scout::Environment.stubs(:rvm?).returns(true)
608
629
  Scout::Environment.stubs(:bundler?).returns(true)
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.11
5
- prerelease:
4
+ version: 5.7.0.pre
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andre Lewis
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-08-09 00:00:00.000000000 Z
14
+ date: 2013-08-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: elif
@@ -230,9 +230,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
230
230
  required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  none: false
232
232
  requirements:
233
- - - ! '>='
233
+ - - ! '>'
234
234
  - !ruby/object:Gem::Version
235
- version: '0'
235
+ version: 1.3.1
236
236
  requirements: []
237
237
  rubyforge_project: scout
238
238
  rubygems_version: 1.8.24