flapjack 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a77bb89c8999f6a11d0931654c29d4a6208a7d1
4
+ data.tar.gz: c9521efb2b1aa33e615efdecc288c51f90b887b6
5
+ SHA512:
6
+ metadata.gz: eb0351065fe36a2e797fac51f027fcc9e2582d773da07c0c961f21e0903a263ce2e903dcb7aee73e6ed7dd9a92328d7ac038f51c5a2ab8b39116a3adb71c3f21
7
+ data.tar.gz: 350d40dd04d845138c71bc08fec42b2633f871b145db7acd10f9a083f9aaae32ee73e8d5073bb577a8ca690fcbb1a516941e370a903a04af3a5e2f2589fded05
data/.rspec CHANGED
@@ -2,9 +2,3 @@
2
2
  --format Fuubar
3
3
  --format html
4
4
  --out tmp/spec.html
5
- --require ./spec/support/uncolored_doc_formatter.rb
6
- --format UncoloredDocFormatter
7
- --out tmp/spec_doc.txt
8
- --require ./spec/support/profile_all_formatter.rb
9
- --format ProfileAllFormatter
10
- --out tmp/spec_profile.txt
data/.travis.yml CHANGED
@@ -1,12 +1,16 @@
1
1
  language: ruby
2
- rvm:
3
- - "1.9.3"
4
- - "2.0"
5
- - "2.1"
6
- env:
7
- - ENTITIES=10 INTERVAL=120
8
- gemfile:
9
- - Gemfile
2
+ matrix:
3
+ include:
4
+ - rvm: 1.9.3
5
+ gemfile: Gemfile-ruby1.9
6
+ script: "bundle exec rspec spec && bundle exec cucumber features"
7
+ env: BUNDLE_GEMFILE=Gemfile-ruby1.9
8
+ - rvm: '2.0'
9
+ gemfile: Gemfile
10
+ script: "bundle exec rspec spec && bundle exec cucumber features"
11
+ - rvm: '2.1'
12
+ gemfile: Gemfile
13
+ script: "bundle exec rspec spec && bundle exec cucumber features"
10
14
  services:
11
15
  - redis-server
12
16
  before_script:
@@ -14,4 +18,3 @@ before_script:
14
18
  before_install:
15
19
  - git submodule update --init --recursive
16
20
  - gem install bundler
17
- script: bundle exec rspec spec && bundle exec cucumber features
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Flapjack Changelog
2
2
 
3
+ # 0.9.6 - 2014-10-21
4
+ - Feature: make 0.9 compatible with new event mirroring logic in 1.2 (fixes #687) #688 (@ali-graham, @jessereynolds)
5
+
3
6
  # 0.9.5 - 2014-10-08
4
7
  - Bug: fix api_url handling in the web ui (@jessereynolds)
5
8
 
data/Gemfile CHANGED
@@ -20,6 +20,9 @@ group :test do
20
20
  gem 'guard-cucumber'
21
21
  gem 'fuubar'
22
22
  gem 'simplecov', :require => false
23
- gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools
24
- gem 'perftools.rb'
23
+
24
+ if RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
25
+ gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools.rb
26
+ gem 'perftools.rb'
27
+ end
25
28
  end
data/Gemfile-ruby1.9 ADDED
@@ -0,0 +1,28 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :name => 'flapjack'
4
+
5
+ group :development do
6
+ gem 'ruby-prof'
7
+ end
8
+
9
+ group :test do
10
+ gem 'rspec', '~> 3.0.0.beta1'
11
+ gem 'cucumber'
12
+ gem 'delorean'
13
+ gem 'rack-test'
14
+ gem 'async_rack_test', '>= 0.0.5'
15
+ gem 'resque_spec'
16
+ gem 'webmock'
17
+ gem 'guard'
18
+ gem 'rb-fsevent'
19
+ gem 'guard-rspec'
20
+ gem 'guard-cucumber'
21
+ gem 'fuubar'
22
+ gem 'simplecov', :require => false
23
+
24
+ if RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
25
+ gem 'debugger-ruby_core_source', '>= 1.3.4' # required for perftools.rb
26
+ gem 'perftools.rb'
27
+ end
28
+ end
@@ -0,0 +1,227 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ flapjack (0.9.6)
5
+ activesupport (~> 3.2.14)
6
+ blather (~> 0.8.3)
7
+ chronic
8
+ chronic_duration
9
+ dante
10
+ em-http-request
11
+ em-resque
12
+ em-synchrony (~> 1.0.2)
13
+ eventmachine (~> 1.0.0)
14
+ hiredis
15
+ ice_cube
16
+ mail
17
+ oj (>= 2.9.0)
18
+ rack-fiber_pool
19
+ rake
20
+ rbtrace
21
+ redis (~> 3.0.6)
22
+ resque (~> 1.23.0)
23
+ sinatra
24
+ thin (~> 1.6.1)
25
+ tzinfo (~> 1.0.1)
26
+ tzinfo-data
27
+
28
+ GEM
29
+ remote: https://rubygems.org/
30
+ specs:
31
+ activesupport (3.2.19)
32
+ i18n (~> 0.6, >= 0.6.4)
33
+ multi_json (~> 1.0)
34
+ addressable (2.3.6)
35
+ async_rack_test (0.0.5)
36
+ blather (0.8.8)
37
+ activesupport (>= 2.3.11)
38
+ eventmachine (>= 1.0.0)
39
+ girl_friday
40
+ niceogiri (~> 1.0)
41
+ nokogiri (~> 1.5, >= 1.5.6)
42
+ builder (3.2.2)
43
+ celluloid (0.16.0)
44
+ timers (~> 4.0.0)
45
+ chronic (0.10.2)
46
+ chronic_duration (0.10.6)
47
+ numerizer (~> 0.1.1)
48
+ coderay (1.1.0)
49
+ connection_pool (1.2.0)
50
+ cookiejar (0.3.2)
51
+ crack (0.4.2)
52
+ safe_yaml (~> 1.0.0)
53
+ cucumber (1.3.17)
54
+ builder (>= 2.1.2)
55
+ diff-lcs (>= 1.1.3)
56
+ gherkin (~> 2.12)
57
+ multi_json (>= 1.7.5, < 2.0)
58
+ multi_test (>= 0.1.1)
59
+ daemons (1.1.9)
60
+ dante (0.2.0)
61
+ debugger-ruby_core_source (1.3.5)
62
+ delorean (2.1.0)
63
+ chronic
64
+ diff-lcs (1.2.5)
65
+ docile (1.1.5)
66
+ em-hiredis (0.1.1)
67
+ hiredis (~> 0.4.0)
68
+ em-http-request (1.1.2)
69
+ addressable (>= 2.3.4)
70
+ cookiejar
71
+ em-socksify (>= 0.3)
72
+ eventmachine (>= 1.0.3)
73
+ http_parser.rb (>= 0.6.0)
74
+ em-resque (1.1.1)
75
+ em-hiredis (~> 0.1.0)
76
+ em-synchrony (~> 1.0.0)
77
+ resque (~> 1.2)
78
+ em-socksify (0.3.0)
79
+ eventmachine (>= 1.0.0.beta.4)
80
+ em-synchrony (1.0.3)
81
+ eventmachine (>= 1.0.0.beta.1)
82
+ eventmachine (1.0.3)
83
+ ffi (1.9.6)
84
+ formatador (0.2.5)
85
+ fuubar (2.0.0)
86
+ rspec (~> 3.0)
87
+ ruby-progressbar (~> 1.4)
88
+ gherkin (2.12.2)
89
+ multi_json (~> 1.3)
90
+ girl_friday (0.11.2)
91
+ connection_pool (~> 1.0)
92
+ rubinius-actor
93
+ guard (2.6.1)
94
+ formatador (>= 0.2.4)
95
+ listen (~> 2.7)
96
+ lumberjack (~> 1.0)
97
+ pry (>= 0.9.12)
98
+ thor (>= 0.18.1)
99
+ guard-cucumber (1.4.1)
100
+ cucumber (>= 1.2.0)
101
+ guard (>= 1.1.0)
102
+ guard-rspec (4.3.1)
103
+ guard (~> 2.1)
104
+ rspec (>= 2.14, < 4.0)
105
+ hiredis (0.4.5)
106
+ hitimes (1.2.2)
107
+ http_parser.rb (0.6.0)
108
+ i18n (0.6.11)
109
+ ice_cube (0.12.1)
110
+ listen (2.7.11)
111
+ celluloid (>= 0.15.2)
112
+ rb-fsevent (>= 0.9.3)
113
+ rb-inotify (>= 0.9)
114
+ lumberjack (1.0.9)
115
+ mail (2.6.1)
116
+ mime-types (>= 1.16, < 3)
117
+ method_source (0.8.2)
118
+ mime-types (2.4.2)
119
+ mini_portile (0.6.0)
120
+ msgpack (0.5.9)
121
+ multi_json (1.10.1)
122
+ multi_test (0.1.1)
123
+ niceogiri (1.1.2)
124
+ nokogiri (~> 1.5)
125
+ nokogiri (1.6.3.1)
126
+ mini_portile (= 0.6.0)
127
+ numerizer (0.1.1)
128
+ oj (2.10.3)
129
+ perftools.rb (2.0.1)
130
+ pry (0.10.1)
131
+ coderay (~> 1.1.0)
132
+ method_source (~> 0.8.1)
133
+ slop (~> 3.4)
134
+ rack (1.5.2)
135
+ rack-fiber_pool (0.9.3)
136
+ rack-protection (1.5.3)
137
+ rack
138
+ rack-test (0.6.2)
139
+ rack (>= 1.0)
140
+ rake (10.3.2)
141
+ rb-fsevent (0.9.4)
142
+ rb-inotify (0.9.5)
143
+ ffi (>= 0.5.0)
144
+ rbtrace (0.4.5)
145
+ ffi (>= 1.0.6)
146
+ msgpack (>= 0.4.3)
147
+ trollop (>= 1.16.2)
148
+ redis (3.0.7)
149
+ redis-namespace (1.5.1)
150
+ redis (~> 3.0, >= 3.0.4)
151
+ resque (1.23.1)
152
+ multi_json (~> 1.0)
153
+ redis-namespace (~> 1.0)
154
+ sinatra (>= 0.9.2)
155
+ vegas (~> 0.1.2)
156
+ resque_spec (0.16.0)
157
+ resque (>= 1.19.0)
158
+ rspec-core (>= 3.0.0)
159
+ rspec-expectations (>= 3.0.0)
160
+ rspec-mocks (>= 3.0.0)
161
+ rspec (3.0.0)
162
+ rspec-core (~> 3.0.0)
163
+ rspec-expectations (~> 3.0.0)
164
+ rspec-mocks (~> 3.0.0)
165
+ rspec-core (3.0.4)
166
+ rspec-support (~> 3.0.0)
167
+ rspec-expectations (3.0.4)
168
+ diff-lcs (>= 1.2.0, < 2.0)
169
+ rspec-support (~> 3.0.0)
170
+ rspec-mocks (3.0.4)
171
+ rspec-support (~> 3.0.0)
172
+ rspec-support (3.0.4)
173
+ rubinius-actor (0.0.2)
174
+ rubinius-core-api
175
+ rubinius-core-api (0.0.1)
176
+ ruby-prof (0.15.1)
177
+ ruby-progressbar (1.6.0)
178
+ safe_yaml (1.0.4)
179
+ simplecov (0.9.1)
180
+ docile (~> 1.1.0)
181
+ multi_json (~> 1.0)
182
+ simplecov-html (~> 0.8.0)
183
+ simplecov-html (0.8.0)
184
+ sinatra (1.4.5)
185
+ rack (~> 1.4)
186
+ rack-protection (~> 1.4)
187
+ tilt (~> 1.3, >= 1.3.4)
188
+ slop (3.6.0)
189
+ thin (1.6.3)
190
+ daemons (~> 1.0, >= 1.0.9)
191
+ eventmachine (~> 1.0)
192
+ rack (~> 1.0)
193
+ thor (0.19.1)
194
+ tilt (1.4.1)
195
+ timers (4.0.1)
196
+ hitimes
197
+ trollop (2.0)
198
+ tzinfo (1.0.1)
199
+ tzinfo-data (1.2014.8)
200
+ tzinfo (>= 1.0.0)
201
+ vegas (0.1.11)
202
+ rack (>= 1.0.0)
203
+ webmock (1.19.0)
204
+ addressable (>= 2.3.6)
205
+ crack (>= 0.3.2)
206
+
207
+ PLATFORMS
208
+ ruby
209
+
210
+ DEPENDENCIES
211
+ async_rack_test (>= 0.0.5)
212
+ cucumber
213
+ debugger-ruby_core_source (>= 1.3.4)
214
+ delorean
215
+ flapjack!
216
+ fuubar
217
+ guard
218
+ guard-cucumber
219
+ guard-rspec
220
+ perftools.rb
221
+ rack-test
222
+ rb-fsevent
223
+ resque_spec
224
+ rspec (~> 3.0.0.beta1)
225
+ ruby-prof
226
+ simplecov
227
+ webmock
@@ -3,6 +3,8 @@
3
3
  require 'oj'
4
4
  require 'flapjack/data/tag_set'
5
5
 
6
+ require 'flapjack/data/migration'
7
+
6
8
  module Flapjack
7
9
  module Data
8
10
  class Event
@@ -78,24 +80,27 @@ module Flapjack
78
80
  :events_archive_maxage => (3 * 60 * 60) }
79
81
  options = defaults.merge(opts)
80
82
 
81
- archive_dest = nil
83
+ archive_dest = nil
82
84
  base_time_str = Time.now.utc.strftime("%Y%m%d%H")
83
85
 
84
86
  if options[:archive_events]
85
87
  archive_dest = "events_archive:#{base_time_str}"
88
+ unless @previous_base_time_str == base_time_str
89
+ Flapjack::Data::Migration.purge_expired_archive_index(:redis => redis)
90
+ end
91
+ @previous_base_time_str = base_time_str
86
92
  if options[:block]
87
93
  raw = redis.brpoplpush(queue, archive_dest, 0)
88
94
  else
89
95
  raw = redis.rpoplpush(queue, archive_dest)
90
96
  return unless raw
91
97
  end
98
+ redis.sadd("known_events_archive_keys", archive_dest)
99
+ elsif options[:block]
100
+ raw = redis.brpop(queue, 0)[1]
92
101
  else
93
- if options[:block]
94
- raw = redis.brpop(queue, 0)[1]
95
- else
96
- raw = redis.rpop(queue)
97
- return unless raw
98
- end
102
+ raw = redis.rpop(queue)
103
+ return unless raw
99
104
  end
100
105
  parsed = parse_and_validate(raw, :logger => options[:logger])
101
106
  if parsed.nil?
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module Flapjack
4
+ module Data
5
+ class Migration
6
+
7
+ def self.refresh_archive_index(options = {})
8
+ raise "Redis connection not set" unless redis = options[:redis]
9
+ archive_keys = redis.keys('events_archive:*')
10
+ if archive_keys.empty?
11
+ redis.del('known_events_archive_keys')
12
+ return
13
+ end
14
+
15
+ grouped_keys = archive_keys.group_by do |ak|
16
+ (redis.llen(ak) > 0) ? 'add' : 'remove'
17
+ end
18
+
19
+ {'remove' => :srem, 'add' => :sadd}.each_pair do |k, cmd|
20
+ next unless grouped_keys.has_key?(k) && !grouped_keys[k].empty?
21
+ redis.send(cmd, 'known_events_archive_keys', grouped_keys[k])
22
+ end
23
+ end
24
+
25
+ def self.purge_expired_archive_index(options = {})
26
+ raise "Redis connection not set" unless redis = options[:redis]
27
+ return unless redis.exists('known_events_archive_keys')
28
+
29
+ redis.smembers('known_events_archive_keys').each do |ak|
30
+ redis.srem('known_events_archive_keys', ak) unless redis.exists(ak)
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -10,14 +10,18 @@ require 'redis'
10
10
 
11
11
  require 'em-synchrony/connection_pool'
12
12
 
13
+ require 'flapjack/data/migration'
14
+
13
15
  module Flapjack
14
16
  class RedisPool < EventMachine::Synchrony::ConnectionPool
15
17
 
16
18
  def initialize(opts = {})
17
19
  config = opts.delete(:config)
18
- @size = opts[:size] || 5
20
+ @size = opts[:size] || 5
19
21
  super(:size => @size) {
20
- ::Redis.new(config)
22
+ redis = ::Redis.new(config)
23
+ Flapjack::Data::Migration.refresh_archive_index(:redis => redis)
24
+ redis
21
25
  }
22
26
  end
23
27
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Flapjack
4
- VERSION = "0.9.5"
4
+ VERSION = "0.9.6"
5
5
  end
6
6
 
@@ -33,7 +33,7 @@ describe Flapjack::Coordinator do
33
33
  and_return(processor)
34
34
 
35
35
  expect(EM).to receive(:stop)
36
- expect(EM::Synchrony).to receive(:sleep).and_return {
36
+ expect(EM::Synchrony).to receive(:sleep) {
37
37
  fc.instance_variable_set('@received_signals', ['INT'])
38
38
  }
39
39
 
@@ -102,7 +102,7 @@ describe Flapjack::Coordinator do
102
102
  and_return(notifier)
103
103
 
104
104
  expect(EM).to receive(:stop)
105
- expect(EM::Synchrony).to receive(:sleep).and_return {
105
+ expect(EM::Synchrony).to receive(:sleep) {
106
106
  fc.instance_variable_set('@received_signals', ['INT'])
107
107
  }
108
108
 
@@ -136,7 +136,7 @@ describe Flapjack::Coordinator do
136
136
  and_return(processor)
137
137
 
138
138
  expect(EM).to receive(:stop)
139
- expect(EM::Synchrony).to receive(:sleep).and_return {
139
+ expect(EM::Synchrony).to receive(:sleep) {
140
140
  fc.instance_variable_set('@received_signals', ['INT'])
141
141
  }
142
142
 
@@ -22,11 +22,18 @@ describe Flapjack::Data::Event do
22
22
  'tags' => ['dev'] }
23
23
  }
24
24
 
25
+ before(:each) do
26
+ Flapjack::Data::Event.instance_variable_set('@previous_base_time_str', nil)
27
+ end
28
+
25
29
  context 'class' do
26
30
 
27
31
  it "returns the next event (blocking, archiving)" do
28
32
  expect(mock_redis).to receive(:brpoplpush).
29
33
  with('events', /^events_archive:/, 0).and_return(event_data.to_json)
34
+ expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => mock_redis)
35
+ expect(mock_redis).to receive(:sadd).
36
+ with('known_events_archive_keys', /^events_archive:/)
30
37
  expect(mock_redis).to receive(:expire)
31
38
 
32
39
  result = Flapjack::Data::Event.next('events', :block => true,
@@ -46,6 +53,9 @@ describe Flapjack::Data::Event do
46
53
  it "returns the next event (non-blocking, archiving)" do
47
54
  expect(mock_redis).to receive(:rpoplpush).
48
55
  with('events', /^events_archive:/).and_return(event_data.to_json)
56
+ expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => mock_redis)
57
+ expect(mock_redis).to receive(:sadd).
58
+ with('known_events_archive_keys', /^events_archive:/)
49
59
  expect(mock_redis).to receive(:expire)
50
60
 
51
61
  result = Flapjack::Data::Event.next('events', :block => false,
@@ -66,6 +76,9 @@ describe Flapjack::Data::Event do
66
76
  bad_event_json = '{{{'
67
77
  expect(mock_redis).to receive(:brpoplpush).
68
78
  with('events', /^events_archive:/, 0).and_return(bad_event_json)
79
+ expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => mock_redis)
80
+ expect(mock_redis).to receive(:sadd).
81
+ with('known_events_archive_keys', /^events_archive:/)
69
82
  expect(mock_redis).to receive(:multi)
70
83
  expect(mock_redis).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
71
84
  expect(mock_redis).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
@@ -94,6 +107,9 @@ describe Flapjack::Data::Event do
94
107
  bad_event_data = event_data.clone
95
108
  bad_event_data.delete(required_key)
96
109
  bad_event_json = bad_event_data.to_json
110
+ expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => mock_redis)
111
+ expect(mock_redis).to receive(:sadd).
112
+ with('known_events_archive_keys', /^events_archive:/)
97
113
  expect(mock_redis).to receive(:brpoplpush).
98
114
  with('events', /^events_archive:/, 0).and_return(bad_event_json)
99
115
  expect(mock_redis).to receive(:multi)
@@ -126,6 +142,9 @@ describe Flapjack::Data::Event do
126
142
  bad_event_json = bad_event_data.to_json
127
143
  expect(mock_redis).to receive(:brpoplpush).
128
144
  with('events', /^events_archive:/, 0).and_return(bad_event_json)
145
+ expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => mock_redis)
146
+ expect(mock_redis).to receive(:sadd).
147
+ with('known_events_archive_keys', /^events_archive:/)
129
148
  expect(mock_redis).to receive(:multi)
130
149
  expect(mock_redis).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
131
150
  expect(mock_redis).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
@@ -156,6 +175,9 @@ describe Flapjack::Data::Event do
156
175
  bad_event_data = event_data.clone
157
176
  bad_event_data[optional_key] = {'hello' => 'there'}
158
177
  bad_event_json = bad_event_data.to_json
178
+ expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => mock_redis)
179
+ expect(mock_redis).to receive(:sadd).
180
+ with('known_events_archive_keys', /^events_archive:/)
159
181
  expect(mock_redis).to receive(:brpoplpush).
160
182
  with('events', /^events_archive:/, 0).and_return(bad_event_json)
161
183
  expect(mock_redis).to receive(:multi)
@@ -188,6 +210,9 @@ describe Flapjack::Data::Event do
188
210
  it "it matches case-insensitively for #{key} (archiving)" do
189
211
  case_event_data = event_data.clone
190
212
  case_event_data[key] = event_data[key].upcase
213
+ expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => mock_redis)
214
+ expect(mock_redis).to receive(:sadd).
215
+ with('known_events_archive_keys', /^events_archive:/)
191
216
  expect(mock_redis).to receive(:brpoplpush).
192
217
  with('events', /^events_archive:/, 0).and_return(case_event_data.to_json)
193
218
  expect(mock_redis).to receive(:expire)
@@ -214,6 +239,9 @@ describe Flapjack::Data::Event do
214
239
  it "it accepts an event with a numeric #{key} key (archiving)" do
215
240
  num_event_data = event_data.clone
216
241
  num_event_data[key] = event_data[key].to_i.to_s
242
+ expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => mock_redis)
243
+ expect(mock_redis).to receive(:sadd).
244
+ with('known_events_archive_keys', /^events_archive:/)
217
245
  expect(mock_redis).to receive(:brpoplpush).
218
246
  with('events', /^events_archive:/, 0).and_return(num_event_data.to_json)
219
247
  expect(mock_redis).to receive(:expire)
@@ -240,6 +268,9 @@ describe Flapjack::Data::Event do
240
268
  bad_event_json = bad_event_data.to_json
241
269
  expect(mock_redis).to receive(:brpoplpush).
242
270
  with('events', /^events_archive:/, 0).and_return(bad_event_json)
271
+ expect(Flapjack::Data::Migration).to receive(:purge_expired_archive_index).with(:redis => mock_redis)
272
+ expect(mock_redis).to receive(:sadd).
273
+ with('known_events_archive_keys', /^events_archive:/)
243
274
  expect(mock_redis).to receive(:multi)
244
275
  expect(mock_redis).to receive(:lrem).with(/^events_archive:/, 1, bad_event_json)
245
276
  expect(mock_redis).to receive(:lpush).with(/^events_rejected:/, bad_event_json)
@@ -174,7 +174,7 @@ describe Flapjack::Gateways::Jabber, :logger => true do
174
174
 
175
175
  expect(EventMachine::Synchrony).to receive(:sleep).with(5).exactly(1).times
176
176
  expect(EventMachine::Synchrony).to receive(:sleep).with(2).exactly(3).times
177
- expect(fj).to receive(:connect).exactly(4).times.and_return {
177
+ expect(fj).to receive(:connect).exactly(4).times {
178
178
  attempts +=1
179
179
  raise StandardError.new unless attempts > 3
180
180
  }
@@ -182,7 +182,7 @@ describe Flapjack::Gateways::Pagerduty, :logger => true do
182
182
 
183
183
  EM.synchrony do
184
184
  ret = fp.send(:send_pagerduty_event, evt)
185
- expect { ret }.not_to be_nil
185
+ expect(ret).not_to be_nil
186
186
  expect(ret).to eq([200, nil])
187
187
  EM.stop
188
188
  end
@@ -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(:refresh_archive_index).exactly(redis_count).times
15
16
 
16
17
  frp = Flapjack::RedisPool.new(:size => redis_count)
17
18
 
@@ -94,6 +94,10 @@ namespace :benchmarks do
94
94
  # - time to failure varies evenly between 1 hour and 1 month
95
95
  # - time to recovery varies evenly between 10 seconds and 1 week
96
96
  task :benchmark do
97
+ unless RUBY_VERSION.split('.')[0] == '1' && RUBY_VERSION.split('.')[1] == '9'
98
+ # Flapjack doesn't support 1.8 or below, so just checking for 1.9 is OK
99
+ raise "perftools.rb doesn't work on Ruby 2.0 or greater"
100
+ end
97
101
 
98
102
  num_checks_per_entity = (ENV['CHECKS_PER_ENTITY'] || 5).to_i
99
103
  num_entities = (ENV['ENTITIES'] || 100).to_i
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
5
- prerelease:
4
+ version: 0.9.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lindsay Holmwood
@@ -11,358 +10,314 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2014-10-07 00:00:00.000000000 Z
13
+ date: 2014-10-21 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: dante
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - ">="
22
20
  - !ruby/object:Gem::Version
23
21
  version: '0'
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
- - - ! '>='
26
+ - - ">="
30
27
  - !ruby/object:Gem::Version
31
28
  version: '0'
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: oj
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
- - - ! '>='
33
+ - - ">="
38
34
  - !ruby/object:Gem::Version
39
35
  version: 2.9.0
40
36
  type: :runtime
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
- - - ! '>='
40
+ - - ">="
46
41
  - !ruby/object:Gem::Version
47
42
  version: 2.9.0
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: eventmachine
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
- - - ~>
47
+ - - "~>"
54
48
  - !ruby/object:Gem::Version
55
49
  version: 1.0.0
56
50
  type: :runtime
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
- - - ~>
54
+ - - "~>"
62
55
  - !ruby/object:Gem::Version
63
56
  version: 1.0.0
64
57
  - !ruby/object:Gem::Dependency
65
58
  name: hiredis
66
59
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
60
  requirements:
69
- - - ! '>='
61
+ - - ">="
70
62
  - !ruby/object:Gem::Version
71
63
  version: '0'
72
64
  type: :runtime
73
65
  prerelease: false
74
66
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
67
  requirements:
77
- - - ! '>='
68
+ - - ">="
78
69
  - !ruby/object:Gem::Version
79
70
  version: '0'
80
71
  - !ruby/object:Gem::Dependency
81
72
  name: em-synchrony
82
73
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
74
  requirements:
85
- - - ~>
75
+ - - "~>"
86
76
  - !ruby/object:Gem::Version
87
77
  version: 1.0.2
88
78
  type: :runtime
89
79
  prerelease: false
90
80
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
81
  requirements:
93
- - - ~>
82
+ - - "~>"
94
83
  - !ruby/object:Gem::Version
95
84
  version: 1.0.2
96
85
  - !ruby/object:Gem::Dependency
97
86
  name: em-http-request
98
87
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
88
  requirements:
101
- - - ! '>='
89
+ - - ">="
102
90
  - !ruby/object:Gem::Version
103
91
  version: '0'
104
92
  type: :runtime
105
93
  prerelease: false
106
94
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
95
  requirements:
109
- - - ! '>='
96
+ - - ">="
110
97
  - !ruby/object:Gem::Version
111
98
  version: '0'
112
99
  - !ruby/object:Gem::Dependency
113
100
  name: redis
114
101
  requirement: !ruby/object:Gem::Requirement
115
- none: false
116
102
  requirements:
117
- - - ~>
103
+ - - "~>"
118
104
  - !ruby/object:Gem::Version
119
105
  version: 3.0.6
120
106
  type: :runtime
121
107
  prerelease: false
122
108
  version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
109
  requirements:
125
- - - ~>
110
+ - - "~>"
126
111
  - !ruby/object:Gem::Version
127
112
  version: 3.0.6
128
113
  - !ruby/object:Gem::Dependency
129
114
  name: em-resque
130
115
  requirement: !ruby/object:Gem::Requirement
131
- none: false
132
116
  requirements:
133
- - - ! '>='
117
+ - - ">="
134
118
  - !ruby/object:Gem::Version
135
119
  version: '0'
136
120
  type: :runtime
137
121
  prerelease: false
138
122
  version_requirements: !ruby/object:Gem::Requirement
139
- none: false
140
123
  requirements:
141
- - - ! '>='
124
+ - - ">="
142
125
  - !ruby/object:Gem::Version
143
126
  version: '0'
144
127
  - !ruby/object:Gem::Dependency
145
128
  name: resque
146
129
  requirement: !ruby/object:Gem::Requirement
147
- none: false
148
130
  requirements:
149
- - - ~>
131
+ - - "~>"
150
132
  - !ruby/object:Gem::Version
151
133
  version: 1.23.0
152
134
  type: :runtime
153
135
  prerelease: false
154
136
  version_requirements: !ruby/object:Gem::Requirement
155
- none: false
156
137
  requirements:
157
- - - ~>
138
+ - - "~>"
158
139
  - !ruby/object:Gem::Version
159
140
  version: 1.23.0
160
141
  - !ruby/object:Gem::Dependency
161
142
  name: sinatra
162
143
  requirement: !ruby/object:Gem::Requirement
163
- none: false
164
144
  requirements:
165
- - - ! '>='
145
+ - - ">="
166
146
  - !ruby/object:Gem::Version
167
147
  version: '0'
168
148
  type: :runtime
169
149
  prerelease: false
170
150
  version_requirements: !ruby/object:Gem::Requirement
171
- none: false
172
151
  requirements:
173
- - - ! '>='
152
+ - - ">="
174
153
  - !ruby/object:Gem::Version
175
154
  version: '0'
176
155
  - !ruby/object:Gem::Dependency
177
156
  name: rack-fiber_pool
178
157
  requirement: !ruby/object:Gem::Requirement
179
- none: false
180
158
  requirements:
181
- - - ! '>='
159
+ - - ">="
182
160
  - !ruby/object:Gem::Version
183
161
  version: '0'
184
162
  type: :runtime
185
163
  prerelease: false
186
164
  version_requirements: !ruby/object:Gem::Requirement
187
- none: false
188
165
  requirements:
189
- - - ! '>='
166
+ - - ">="
190
167
  - !ruby/object:Gem::Version
191
168
  version: '0'
192
169
  - !ruby/object:Gem::Dependency
193
170
  name: thin
194
171
  requirement: !ruby/object:Gem::Requirement
195
- none: false
196
172
  requirements:
197
- - - ~>
173
+ - - "~>"
198
174
  - !ruby/object:Gem::Version
199
175
  version: 1.6.1
200
176
  type: :runtime
201
177
  prerelease: false
202
178
  version_requirements: !ruby/object:Gem::Requirement
203
- none: false
204
179
  requirements:
205
- - - ~>
180
+ - - "~>"
206
181
  - !ruby/object:Gem::Version
207
182
  version: 1.6.1
208
183
  - !ruby/object:Gem::Dependency
209
184
  name: mail
210
185
  requirement: !ruby/object:Gem::Requirement
211
- none: false
212
186
  requirements:
213
- - - ! '>='
187
+ - - ">="
214
188
  - !ruby/object:Gem::Version
215
189
  version: '0'
216
190
  type: :runtime
217
191
  prerelease: false
218
192
  version_requirements: !ruby/object:Gem::Requirement
219
- none: false
220
193
  requirements:
221
- - - ! '>='
194
+ - - ">="
222
195
  - !ruby/object:Gem::Version
223
196
  version: '0'
224
197
  - !ruby/object:Gem::Dependency
225
198
  name: blather
226
199
  requirement: !ruby/object:Gem::Requirement
227
- none: false
228
200
  requirements:
229
- - - ~>
201
+ - - "~>"
230
202
  - !ruby/object:Gem::Version
231
203
  version: 0.8.3
232
204
  type: :runtime
233
205
  prerelease: false
234
206
  version_requirements: !ruby/object:Gem::Requirement
235
- none: false
236
207
  requirements:
237
- - - ~>
208
+ - - "~>"
238
209
  - !ruby/object:Gem::Version
239
210
  version: 0.8.3
240
211
  - !ruby/object:Gem::Dependency
241
212
  name: chronic
242
213
  requirement: !ruby/object:Gem::Requirement
243
- none: false
244
214
  requirements:
245
- - - ! '>='
215
+ - - ">="
246
216
  - !ruby/object:Gem::Version
247
217
  version: '0'
248
218
  type: :runtime
249
219
  prerelease: false
250
220
  version_requirements: !ruby/object:Gem::Requirement
251
- none: false
252
221
  requirements:
253
- - - ! '>='
222
+ - - ">="
254
223
  - !ruby/object:Gem::Version
255
224
  version: '0'
256
225
  - !ruby/object:Gem::Dependency
257
226
  name: chronic_duration
258
227
  requirement: !ruby/object:Gem::Requirement
259
- none: false
260
228
  requirements:
261
- - - ! '>='
229
+ - - ">="
262
230
  - !ruby/object:Gem::Version
263
231
  version: '0'
264
232
  type: :runtime
265
233
  prerelease: false
266
234
  version_requirements: !ruby/object:Gem::Requirement
267
- none: false
268
235
  requirements:
269
- - - ! '>='
236
+ - - ">="
270
237
  - !ruby/object:Gem::Version
271
238
  version: '0'
272
239
  - !ruby/object:Gem::Dependency
273
240
  name: activesupport
274
241
  requirement: !ruby/object:Gem::Requirement
275
- none: false
276
242
  requirements:
277
- - - ~>
243
+ - - "~>"
278
244
  - !ruby/object:Gem::Version
279
245
  version: 3.2.14
280
246
  type: :runtime
281
247
  prerelease: false
282
248
  version_requirements: !ruby/object:Gem::Requirement
283
- none: false
284
249
  requirements:
285
- - - ~>
250
+ - - "~>"
286
251
  - !ruby/object:Gem::Version
287
252
  version: 3.2.14
288
253
  - !ruby/object:Gem::Dependency
289
254
  name: ice_cube
290
255
  requirement: !ruby/object:Gem::Requirement
291
- none: false
292
256
  requirements:
293
- - - ! '>='
257
+ - - ">="
294
258
  - !ruby/object:Gem::Version
295
259
  version: '0'
296
260
  type: :runtime
297
261
  prerelease: false
298
262
  version_requirements: !ruby/object:Gem::Requirement
299
- none: false
300
263
  requirements:
301
- - - ! '>='
264
+ - - ">="
302
265
  - !ruby/object:Gem::Version
303
266
  version: '0'
304
267
  - !ruby/object:Gem::Dependency
305
268
  name: tzinfo
306
269
  requirement: !ruby/object:Gem::Requirement
307
- none: false
308
270
  requirements:
309
- - - ~>
271
+ - - "~>"
310
272
  - !ruby/object:Gem::Version
311
273
  version: 1.0.1
312
274
  type: :runtime
313
275
  prerelease: false
314
276
  version_requirements: !ruby/object:Gem::Requirement
315
- none: false
316
277
  requirements:
317
- - - ~>
278
+ - - "~>"
318
279
  - !ruby/object:Gem::Version
319
280
  version: 1.0.1
320
281
  - !ruby/object:Gem::Dependency
321
282
  name: tzinfo-data
322
283
  requirement: !ruby/object:Gem::Requirement
323
- none: false
324
284
  requirements:
325
- - - ! '>='
285
+ - - ">="
326
286
  - !ruby/object:Gem::Version
327
287
  version: '0'
328
288
  type: :runtime
329
289
  prerelease: false
330
290
  version_requirements: !ruby/object:Gem::Requirement
331
- none: false
332
291
  requirements:
333
- - - ! '>='
292
+ - - ">="
334
293
  - !ruby/object:Gem::Version
335
294
  version: '0'
336
295
  - !ruby/object:Gem::Dependency
337
296
  name: rbtrace
338
297
  requirement: !ruby/object:Gem::Requirement
339
- none: false
340
298
  requirements:
341
- - - ! '>='
299
+ - - ">="
342
300
  - !ruby/object:Gem::Version
343
301
  version: '0'
344
302
  type: :runtime
345
303
  prerelease: false
346
304
  version_requirements: !ruby/object:Gem::Requirement
347
- none: false
348
305
  requirements:
349
- - - ! '>='
306
+ - - ">="
350
307
  - !ruby/object:Gem::Version
351
308
  version: '0'
352
309
  - !ruby/object:Gem::Dependency
353
310
  name: rake
354
311
  requirement: !ruby/object:Gem::Requirement
355
- none: false
356
312
  requirements:
357
- - - ! '>='
313
+ - - ">="
358
314
  - !ruby/object:Gem::Version
359
315
  version: '0'
360
316
  type: :runtime
361
317
  prerelease: false
362
318
  version_requirements: !ruby/object:Gem::Requirement
363
- none: false
364
319
  requirements:
365
- - - ! '>='
320
+ - - ">="
366
321
  - !ruby/object:Gem::Version
367
322
  version: '0'
368
323
  description: Flapjack is a distributed monitoring notification system that provides
@@ -381,14 +336,16 @@ executables:
381
336
  extensions: []
382
337
  extra_rdoc_files: []
383
338
  files:
384
- - .gitignore
385
- - .gitmodules
386
- - .rspec
387
- - .ruby-version
388
- - .travis.yml
339
+ - ".gitignore"
340
+ - ".gitmodules"
341
+ - ".rspec"
342
+ - ".ruby-version"
343
+ - ".travis.yml"
389
344
  - CHANGELOG.md
390
345
  - CONTRIBUTING.md
391
346
  - Gemfile
347
+ - Gemfile-ruby1.9
348
+ - Gemfile-ruby1.9.lock
392
349
  - Guardfile
393
350
  - LICENCE
394
351
  - README.md
@@ -437,6 +394,7 @@ files:
437
394
  - lib/flapjack/data/entity_check.rb
438
395
  - lib/flapjack/data/event.rb
439
396
  - lib/flapjack/data/message.rb
397
+ - lib/flapjack/data/migration.rb
440
398
  - lib/flapjack/data/notification.rb
441
399
  - lib/flapjack/data/notification_rule.rb
442
400
  - lib/flapjack/data/semaphore.rb
@@ -595,8 +553,6 @@ files:
595
553
  - spec/spec_helper.rb
596
554
  - spec/support/erb_view_helper.rb
597
555
  - spec/support/jsonapi_helper.rb
598
- - spec/support/profile_all_formatter.rb
599
- - spec/support/uncolored_doc_formatter.rb
600
556
  - tasks/benchmarks.rake
601
557
  - tasks/events.rake
602
558
  - tasks/profile.rake
@@ -621,33 +577,26 @@ files:
621
577
  homepage: http://flapjack.io/
622
578
  licenses:
623
579
  - MIT
580
+ metadata: {}
624
581
  post_install_message:
625
582
  rdoc_options: []
626
583
  require_paths:
627
584
  - lib
628
585
  required_ruby_version: !ruby/object:Gem::Requirement
629
- none: false
630
586
  requirements:
631
- - - ! '>='
587
+ - - ">="
632
588
  - !ruby/object:Gem::Version
633
589
  version: '0'
634
- segments:
635
- - 0
636
- hash: 3444506708991125351
637
590
  required_rubygems_version: !ruby/object:Gem::Requirement
638
- none: false
639
591
  requirements:
640
- - - ! '>='
592
+ - - ">="
641
593
  - !ruby/object:Gem::Version
642
594
  version: '0'
643
- segments:
644
- - 0
645
- hash: 3444506708991125351
646
595
  requirements: []
647
596
  rubyforge_project:
648
- rubygems_version: 1.8.23
597
+ rubygems_version: 2.2.2
649
598
  signing_key:
650
- specification_version: 3
599
+ specification_version: 4
651
600
  summary: Intelligent, scalable, distributed monitoring notification system.
652
601
  test_files:
653
602
  - features/cli.feature
@@ -719,5 +668,3 @@ test_files:
719
668
  - spec/spec_helper.rb
720
669
  - spec/support/erb_view_helper.rb
721
670
  - spec/support/jsonapi_helper.rb
722
- - spec/support/profile_all_formatter.rb
723
- - spec/support/uncolored_doc_formatter.rb
@@ -1,44 +0,0 @@
1
- require 'rspec/core/formatters/base_formatter'
2
-
3
- class ProfileAllFormatter < RSpec::Core::Formatters::BaseFormatter
4
-
5
- def initialize(output)
6
- super(output)
7
- @example_times = []
8
- end
9
-
10
- def start(count)
11
- super(count)
12
- @output.puts "Profiling enabled."
13
- end
14
-
15
- def example_started(example)
16
- super(example)
17
- @time = ((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now)
18
- end
19
-
20
- def example_passed(example)
21
- @example_times << [
22
- example_group.description,
23
- example.description,
24
- ((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now) - @time
25
- ]
26
- super(example)
27
- end
28
-
29
- def start_dump
30
- super
31
- @output.puts "\n\nExample times:\n"
32
-
33
- @example_times = @example_times.sort_by do |description, example, time|
34
- time
35
- end.reverse
36
-
37
- @example_times.each do |description, example, time|
38
- @output.print sprintf("%.7f", time)
39
- @output.puts " #{description} #{example}"
40
- end
41
- @output.flush
42
- end
43
-
44
- end
@@ -1,9 +0,0 @@
1
- require 'rspec/core/formatters/documentation_formatter'
2
-
3
- class UncoloredDocFormatter < RSpec::Core::Formatters::DocumentationFormatter
4
-
5
- def color(text, color_code)
6
- text
7
- end
8
-
9
- end