scout 5.6.0.alpha.3 → 5.6.0.alpha.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/scout/server.rb CHANGED
@@ -36,7 +36,7 @@ module Scout
36
36
  @server_name = server_name
37
37
  @http_proxy = http_proxy
38
38
  @https_proxy = https_proxy
39
- @roles = roles || ''
39
+ @roles = (roles || '').gsub(/[^a-zA-Z0-9,]/,'')
40
40
  @plugin_plan = []
41
41
  @plugins_with_signature_errors = []
42
42
  @directives = {} # take_snapshots, interval, sleep_interval
@@ -60,10 +60,9 @@ module Scout
60
60
  def refresh?
61
61
  return true if !ping_key or account_public_key_changed? # fetch the plan again if the account key is modified/created
62
62
 
63
- url=URI.join( @server.sub("https://","http://"), "/clients/#{ping_key}/ping.scout")
63
+ url=URI.join( @server.sub("https://","http://"), "/clients/#{ping_key}/ping.scout?roles=#{@roles}&host=#{Socket.gethostname}")
64
64
 
65
65
  headers = {"x-scout-tty" => ($stdin.tty? ? 'true' : 'false')}
66
- headers["x-scout-roles"] = @roles
67
66
  if @history["plan_last_modified"] and @history["old_plugins"]
68
67
  headers["If-Modified-Since"] = @history["plan_last_modified"]
69
68
  end
@@ -28,7 +28,8 @@ module Scout
28
28
  URI.join(@server,
29
29
  "/clients/CLIENT_KEY/#{url_name}.scout".
30
30
  gsub(/\bCLIENT_KEY\b/, @client_key).
31
- gsub(/\b[A-Z_]+\b/) { |k| options[k.downcase.to_sym] || k })
31
+ gsub(/\b[A-Z_]+\b/) { |k| options[k.downcase.to_sym] || k },
32
+ "?roles=#{@roles}&host=#{Socket.gethostname}")
32
33
  end
33
34
 
34
35
  def post(url, error, body, headers = Hash.new, &response_handler)
data/lib/scout/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Scout
2
- VERSION = "5.6.0.alpha.3"
2
+ VERSION = "5.6.0.alpha.4"
3
3
  end
data/test/scout_test.rb CHANGED
@@ -31,8 +31,8 @@ PATH_TO_TEST_PLUGIN = File.expand_path( File.dirname(__FILE__) ) + '/plugins/tem
31
31
 
32
32
  class ScoutTest < Test::Unit::TestCase
33
33
  def setup
34
- load_fixtures :clients, :accounts, :plugins, :subscriptions, :plugin_metas
35
- clear_tables :plugin_activities, :ar_descriptors, :summaries
34
+ load_fixtures :clients, :accounts, :plugins, :subscriptions, :plugin_metas, :roles, :plugin_definitions, :notification_groups
35
+ clear_tables :plugin_activities, :ar_descriptors, :summaries, :clients_roles
36
36
  clear_working_dir
37
37
 
38
38
 
@@ -45,6 +45,12 @@ class ScoutTest < Test::Unit::TestCase
45
45
  @plugin=@client.plugins.first
46
46
  # avoid client limit issues
47
47
  assert @client.account.subscription.update_attribute(:clients,100)
48
+
49
+ # roles-related
50
+ @roles_account = Account.find_by_name "beta"
51
+ @db_role=@roles_account.roles.find_by_name("db")
52
+ @app_role=@roles_account.roles.find_by_name("app")
53
+ @hostname = `hostname`.chomp
48
54
  end
49
55
 
50
56
  def test_should_checkin_during_interactive_install
@@ -503,6 +509,62 @@ mybar=100
503
509
  assert_not_equal streams.first[:plugins][0][:fields][:v], streams.last[:plugins][0][:fields][:v]
504
510
  end
505
511
 
512
+
513
+ # Roles related
514
+
515
+ def test_roles_enabled_account
516
+ scout(@roles_account.key)
517
+ client=@roles_account.clients.last
518
+ assert_equal @hostname, client.hostname
519
+ assert_equal 0, client.plugins.count, "the all servers role should have 0 plugins"
520
+ assert_equal 1, client.roles.count
521
+ assert_equal @roles_account.primary_role, client.roles.first
522
+ end
523
+
524
+ def test_specify_role
525
+ scout(@roles_account.key, "-rapp")
526
+ client=@roles_account.clients.last
527
+ assert_equal @hostname, client.hostname
528
+ assert_equal 2, client.plugins.count
529
+ assert_equal 2, client.roles.count
530
+ end
531
+
532
+ def test_change_roles_on_existing_server
533
+ # first checkin
534
+ exec_scout(@roles_account.key, "-rapp")
535
+ client=@roles_account.clients.last
536
+ assert_equal @hostname, client.hostname
537
+ assert_equal 2, client.roles.count
538
+ assert_equal 2, client.plugins.count
539
+
540
+ client.plugins.each do |plugin|
541
+ assert @app_role.plugin_definitions.include?(plugin.plugin_definition), "#{plugin} should be included in the app role"
542
+ end
543
+
544
+ # second checkin - add a role
545
+ exec_scout(@roles_account.key, "-rapp,db --force")
546
+ client=@roles_account.clients.last
547
+ assert_equal 3, client.roles.count
548
+ assert_equal 4, client.plugins.count
549
+
550
+ # 3rd checkin - remove a role
551
+ exec_scout(@roles_account.key, "-rdb --force")
552
+ client=@roles_account.clients.last
553
+ assert_equal 2, client.roles.count
554
+ assert_equal 2, client.plugins.count
555
+
556
+ client.plugins.each do |plugin|
557
+ assert @db_role.plugin_definitions.include?(plugin.plugin_definition), "#{plugin} should be included in the db role"
558
+ end
559
+
560
+ # 4th checking -- remove all roles
561
+ exec_scout(@roles_account.key, "--force")
562
+ client=@roles_account.clients.last
563
+ assert_equal 1, client.roles.count
564
+ assert_equal 0, client.plugins.count
565
+
566
+ end
567
+
506
568
  ######################
507
569
  ### Helper Methods ###
508
570
  ######################
metadata CHANGED
@@ -1,44 +1,40 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: scout
3
- version: !ruby/object:Gem::Version
4
- version: 5.6.0.alpha.3
5
- prerelease: 6
3
+ version: !ruby/object:Gem::Version
4
+ version: 5.6.0.alpha.4
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Andre Lewis
9
8
  - Derek Haynes
10
9
  - James Edward Gray II
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2012-11-14 00:00:00.000000000 Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
13
+
14
+ date: 2012-11-14 00:00:00 -08:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
17
18
  name: elif
18
- requirement: !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ! '>='
22
- - !ruby/object:Gem::Version
23
- version: '0'
24
19
  type: :runtime
25
- prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
- requirements:
29
- - - ! '>='
30
- - !ruby/object:Gem::Version
31
- version: '0'
32
- description: ! 'The scout gem reports metrics to scoutapp.com, an easy-to-use hosted
33
- server monitoring service.
20
+ version_requirement:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: "0"
26
+ version:
27
+ description: |
28
+ The scout gem reports metrics to scoutapp.com, an easy-to-use hosted server monitoring service.
34
29
 
35
- '
36
30
  email: support@scoutapp.com
37
- executables:
31
+ executables:
38
32
  - scout
39
33
  extensions: []
34
+
40
35
  extra_rdoc_files: []
41
- files:
36
+
37
+ files:
42
38
  - .gitignore
43
39
  - CHANGELOG.markdown
44
40
  - Gemfile
@@ -223,32 +219,34 @@ files:
223
219
  - vendor/signature/spec/signature_spec.rb
224
220
  - vendor/signature/spec/spec_helper.rb
225
221
  - vendor/util/lib/core_extensions.rb
222
+ has_rdoc: true
226
223
  homepage: http://scoutapp.com
227
224
  licenses: []
225
+
228
226
  post_install_message:
229
227
  rdoc_options: []
230
- require_paths:
228
+
229
+ require_paths:
231
230
  - lib
232
- required_ruby_version: !ruby/object:Gem::Requirement
233
- none: false
234
- requirements:
235
- - - ! '>='
236
- - !ruby/object:Gem::Version
237
- version: '0'
238
- required_rubygems_version: !ruby/object:Gem::Requirement
239
- none: false
240
- requirements:
241
- - - ! '>'
242
- - !ruby/object:Gem::Version
231
+ required_ruby_version: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: "0"
236
+ version:
237
+ required_rubygems_version: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - ">"
240
+ - !ruby/object:Gem::Version
243
241
  version: 1.3.1
242
+ version:
244
243
  requirements: []
244
+
245
245
  rubyforge_project: scout
246
- rubygems_version: 1.8.24
246
+ rubygems_version: 1.3.5
247
247
  signing_key:
248
248
  specification_version: 3
249
- summary: Scout is an easy-to-use hosted server monitoring service. The scout Ruby
250
- gem reports metrics to our service. The agent runs plugins, configured via the Scout
251
- web interface, to monitor a server.
252
- test_files:
249
+ summary: Scout is an easy-to-use hosted server monitoring service. The scout Ruby gem reports metrics to our service. The agent runs plugins, configured via the Scout web interface, to monitor a server.
250
+ test_files:
253
251
  - test/plugins/disk_usage.rb
254
252
  - test/scout_test.rb