flapjack 1.2.0rc2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'flapjack/data/migration'
3
+ require 'flapjack/data/notification_rule'
4
+
5
+ describe Flapjack::Data::Migration, :redis => true do
6
+
7
+ it "fixes a notification rule wih no contact association" do
8
+ contact = Flapjack::Data::Contact.add( {
9
+ 'id' => 'c362',
10
+ 'first_name' => 'John',
11
+ 'last_name' => 'Johnson',
12
+ 'email' => 'johnj@example.com',
13
+ 'media' => {
14
+ 'pagerduty' => {
15
+ 'service_key' => '123456789012345678901234',
16
+ 'subdomain' => 'flpjck',
17
+ 'username' => 'flapjack',
18
+ 'password' => 'very_secure'
19
+ },
20
+ },
21
+ },
22
+ :redis => @redis)
23
+
24
+ rule = contact.add_notification_rule(
25
+ :tags => ["database","physical"],
26
+ :entities => ["foo-app-01.example.com"],
27
+ :time_restrictions => [],
28
+ :unknown_media => [],
29
+ :warning_media => ["email"],
30
+ :critical_media => ["sms", "email"],
31
+ :unknown_blackhole => false,
32
+ :warning_blackhole => false,
33
+ :critical_blackhole => false
34
+ )
35
+
36
+ rule_id = rule.id
37
+
38
+ # degrade as the bug had previously
39
+ @redis.hset("notification_rule:#{rule.id}", 'contact_id', '')
40
+
41
+ rule = Flapjack::Data::NotificationRule.find_by_id(rule_id, :redis => @redis)
42
+ expect(rule).not_to be_nil
43
+ expect(rule.contact_id).to be_empty
44
+
45
+ Flapjack::Data::Migration.correct_notification_rule_contact_linkages(:redis => @redis)
46
+
47
+ rule = Flapjack::Data::NotificationRule.find_by_id(rule_id, :redis => @redis)
48
+ expect(rule).not_to be_nil
49
+ expect(rule.contact_id).to eq(contact.id)
50
+ end
51
+
52
+ end
@@ -83,6 +83,16 @@ describe 'Flapjack::Gateways::JSONAPI::CheckMethods', :sinatra => true, :logger
83
83
  expect(last_response).to be_ok
84
84
  expect(last_response.body).to eq({:checks => [check_data, check_data_2]}.to_json)
85
85
  end
86
+
87
+ it "does not find a check" do
88
+ expect(Flapjack::Data::EntityCheck).to receive(:for_event_id).
89
+ with('www.example.com:SSH', :logger => @logger, :redis => redis).
90
+ and_return(nil)
91
+
92
+ aget '/checks/www.example.com:SSH'
93
+ expect(last_response).to be_not_found
94
+ end
95
+
86
96
  it "creates checks from a submitted list" do
87
97
  checks = {'checks' =>
88
98
  [
@@ -168,12 +168,9 @@ describe 'Flapjack::Gateways::JSONAPI::ReportMethods', :sinatra => true, :logger
168
168
  expect(last_response).to be_not_found
169
169
  end
170
170
 
171
- it "should not show the status for a check that's not found on an entity" do
172
- expect(Flapjack::Data::EntityCheck).to receive(:for_entity_name).
173
- with(entity_name, 'SSH', :redis => redis).and_return(nil)
174
-
175
- aget "/status_report/checks/#{entity_name}:SSH"
176
- expect(last_response).to be_not_found
171
+ it "should not show the status for a check with a malformed name" do
172
+ aget "/status_report/checks/SSH"
173
+ expect(last_response.status).to eq(500)
177
174
  end
178
175
 
179
176
  it "returns a list of scheduled maintenance periods for an entity" do
@@ -12,6 +12,7 @@ describe Flapjack::RedisPool do
12
12
  redis
13
13
  }
14
14
  expect(::Redis).to receive(:new).exactly(redis_count).times.and_return(*redis_conns)
15
+ expect(Flapjack::Data::Migration).to receive(:correct_notification_rule_contact_linkages).exactly(redis_count).times
15
16
  expect(Flapjack::Data::Migration).to receive(:migrate_entity_check_data_if_required).exactly(redis_count).times
16
17
  expect(Flapjack::Data::Migration).to receive(:refresh_archive_index).exactly(redis_count).times
17
18
 
@@ -97,7 +97,7 @@ namespace :benchmarks do
97
97
  # - time to failure varies evenly between 1 hour and 1 month
98
98
  # - time to recovery varies evenly between 10 seconds and 1 week
99
99
  task :benchmark do
100
- unless RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '8'
100
+ unless RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
101
101
  # Flapjack doesn't support 1.8 or below, so just checking for 1.9 is OK
102
102
  raise "perftools.rb doesn't work on Ruby 2.0 or greater"
103
103
  end
@@ -129,10 +129,10 @@ namespace :entities do
129
129
 
130
130
  if id.nil? || entity.nil?
131
131
  id ||= SecureRandom.uuid
132
- redis.multi
133
- redis.hset('all_entity_ids_by_name', name, id)
134
- redis.hset('all_entity_names_by_id', id, name)
135
- redis.exec
132
+ redis.multi do
133
+ multi.hset('all_entity_ids_by_name', name, id)
134
+ multi.hset('all_entity_names_by_id', id, name)
135
+ end
136
136
  puts "Set id '#{id}' for entity #{name}'"
137
137
  elsif entity.name.eql?(name)
138
138
  puts "'#{name}' entity already exists with the provided id"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0rc2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindsay Holmwood
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-10-17 00:00:00.000000000 Z
14
+ date: 2014-11-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: dante
@@ -55,6 +55,20 @@ dependencies:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
57
  version: 1.0.0
58
+ - !ruby/object:Gem::Dependency
59
+ name: redis
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: 3.0.6
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: 3.0.6
58
72
  - !ruby/object:Gem::Dependency
59
73
  name: hiredis
60
74
  requirement: !ruby/object:Gem::Requirement
@@ -97,20 +111,6 @@ dependencies:
97
111
  - - ">="
98
112
  - !ruby/object:Gem::Version
99
113
  version: '0'
100
- - !ruby/object:Gem::Dependency
101
- name: redis
102
- requirement: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - "~>"
105
- - !ruby/object:Gem::Version
106
- version: 3.0.6
107
- type: :runtime
108
- prerelease: false
109
- version_requirements: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - "~>"
112
- - !ruby/object:Gem::Version
113
- version: 3.0.6
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: em-resque
116
116
  requirement: !ruby/object:Gem::Requirement
@@ -552,6 +552,7 @@ files:
552
552
  - spec/lib/flapjack/data/entity_spec.rb
553
553
  - spec/lib/flapjack/data/event_spec.rb
554
554
  - spec/lib/flapjack/data/message_spec.rb
555
+ - spec/lib/flapjack/data/migration_spec.rb
555
556
  - spec/lib/flapjack/data/notification_rule_spec.rb
556
557
  - spec/lib/flapjack/data/notification_spec.rb
557
558
  - spec/lib/flapjack/data/semaphore_spec.rb
@@ -635,9 +636,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
635
636
  version: '0'
636
637
  required_rubygems_version: !ruby/object:Gem::Requirement
637
638
  requirements:
638
- - - ">"
639
+ - - ">="
639
640
  - !ruby/object:Gem::Version
640
- version: 1.3.1
641
+ version: '0'
641
642
  requirements: []
642
643
  rubyforge_project:
643
644
  rubygems_version: 2.2.2
@@ -674,6 +675,7 @@ test_files:
674
675
  - spec/lib/flapjack/data/entity_spec.rb
675
676
  - spec/lib/flapjack/data/event_spec.rb
676
677
  - spec/lib/flapjack/data/message_spec.rb
678
+ - spec/lib/flapjack/data/migration_spec.rb
677
679
  - spec/lib/flapjack/data/notification_rule_spec.rb
678
680
  - spec/lib/flapjack/data/notification_spec.rb
679
681
  - spec/lib/flapjack/data/semaphore_spec.rb