marty 1.0.52 → 1.0.53
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/marty/diagnostic_controller.rb +64 -0
- data/app/models/marty/helper.rb +21 -0
- data/delorean/diagnostics.dl +12 -0
- data/lib/marty/version.rb +1 -1
- data/spec/controllers/diagnostic_controller_spec.rb +1 -1
- data/spec/dummy/config/initializers/delayed_job.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e29a8f6100cbc30a7a8207778d67566180324348
|
4
|
+
data.tar.gz: 352aa2c3dfc43f0e59490f37219b8032669647b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf6c38998881fe010b0dc0231d2d12a572f84c7b69203caf573e5aafe986dd75815dd24ba26e70fd5a3c56645fa58d1ccfe12aa45339ca69b026778d3a42df97
|
7
|
+
data.tar.gz: 071174651bea3b1018210e959e963ef4dc9c5ccf7c7a36a3cb9e11cee5a9f8a3f08fc31e7d538fac33249570c5f28edaabff778bf97c0e86f29a0987698cbed0
|
data/Gemfile.lock
CHANGED
@@ -262,6 +262,70 @@ module Marty
|
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
265
|
+
class DelayedJob < Base
|
266
|
+
def self.delayed_job_count
|
267
|
+
db = ActiveRecord::Base.connection_config[:database]
|
268
|
+
get_pg_connections[db].count{|c| c['pid'] if
|
269
|
+
c['name'].include?('delayed_job')}
|
270
|
+
end
|
271
|
+
|
272
|
+
def self.pretty hash
|
273
|
+
hash.keys.map{|k| k + " => " + hash[k].to_s}.join("\n")
|
274
|
+
end
|
275
|
+
|
276
|
+
def self.verify_history delayed_versions
|
277
|
+
@@history ||= delayed_versions
|
278
|
+
@@history == delayed_versions
|
279
|
+
end
|
280
|
+
|
281
|
+
def self.validate data
|
282
|
+
data.each_with_object({}) do
|
283
|
+
|(k,v), h|
|
284
|
+
h[k] = v.count > 1 ? error("\n" + v.join("\n")) :
|
285
|
+
v[0] != ENV['DELAYED_VER'] ? error(v[0]) : v[0]
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
def self.generate
|
290
|
+
count = delayed_job_count
|
291
|
+
return {'Status' => ['No delayed jobs are running.']} if count.zero?
|
292
|
+
|
293
|
+
# we will only iterate by half of the total delayed workers to avoid
|
294
|
+
# excess use of delayed job time
|
295
|
+
count = (count/2).zero? ? 1 : count/2
|
296
|
+
|
297
|
+
d_engine = Marty::ScriptSet.new.get_engine("Diagnostics")
|
298
|
+
res = d_engine.evaluate('VersionDelay', 'result', {'count' => count-1})
|
299
|
+
|
300
|
+
# merge results and remove duplicates
|
301
|
+
res.each_with_object({}){
|
302
|
+
|r, h|
|
303
|
+
h[r[0]] ||= []
|
304
|
+
h[r[0]] << r[1]
|
305
|
+
}.each_with_object({}){|(k,v), h| h[k] = v.uniq}
|
306
|
+
end
|
307
|
+
|
308
|
+
def self.aggregate
|
309
|
+
d_vers = validate(generate)
|
310
|
+
|
311
|
+
unless verify_history(d_vers)
|
312
|
+
a = @@history.to_a
|
313
|
+
b = d_vers.to_a
|
314
|
+
@@history = d_vers
|
315
|
+
d_vers += {"WARN" => error(["Result different from "\
|
316
|
+
"#{Marty::Helper.my_ip}'s history.",
|
317
|
+
"#{pretty(Hash[a - b])}"].join("\n"))}
|
318
|
+
end
|
319
|
+
package(d_vers)
|
320
|
+
end
|
321
|
+
|
322
|
+
def self.diff data
|
323
|
+
data = data[name.demodulize] if data[name.demodulize]
|
324
|
+
data.keys.map{|k| data[k]}.flatten.uniq.count != 1 ||
|
325
|
+
data[data.keys[0]] != ENV['DELAYED_VER']
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
265
329
|
############################################################################
|
266
330
|
#
|
267
331
|
# Reports
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Marty::Helper
|
2
|
+
include Delorean::Model
|
3
|
+
|
4
|
+
delorean_fn :sleep, sig: 1 do
|
5
|
+
|seconds|
|
6
|
+
Kernel.sleep seconds
|
7
|
+
end
|
8
|
+
|
9
|
+
delorean_fn :my_ip, sig:0 do
|
10
|
+
Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address
|
11
|
+
end
|
12
|
+
|
13
|
+
delorean_fn :git, sig:0 do
|
14
|
+
[my_ip, ENV['DELAYED_VER']]
|
15
|
+
end
|
16
|
+
|
17
|
+
delorean_fn :range_step, sig: 3 do
|
18
|
+
|rstart, rend, step|
|
19
|
+
(rstart..rend).step(step).to_a
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Delay:
|
2
|
+
count =?
|
3
|
+
# the delay parameter delays the next created job so that a different
|
4
|
+
# worker is more likely to claim it
|
5
|
+
delay =? 2.6
|
6
|
+
ver = Marty::Helper.sleep(delay) && Marty::Helper.git
|
7
|
+
res = [(Delay() | "ver") for i in Marty::Helper.range_step(0, count, 1)]
|
8
|
+
result = [r.to_a for r in res]
|
9
|
+
|
10
|
+
VersionDelay:
|
11
|
+
count =?
|
12
|
+
result = Delay(count=count) | "result"
|
data/lib/marty/version.rb
CHANGED
@@ -162,7 +162,7 @@ module Marty
|
|
162
162
|
expected = nodes.each_with_object({}){|n, h| h[n] = version}
|
163
163
|
|
164
164
|
# mock nodes and diag request to node
|
165
|
-
allow(described_class::Base.request).to receive(:port).and_return(
|
165
|
+
allow(described_class::Base.request).to receive(:port).and_return(3000)
|
166
166
|
allow(described_class::Base).to receive(:get_nodes).and_return(nodes)
|
167
167
|
allow(described_class::Base).to receive_message_chain(uri_stub)
|
168
168
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2017-11-
|
17
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|
@@ -424,6 +424,7 @@ files:
|
|
424
424
|
- app/models/marty/grid_index_integer.rb
|
425
425
|
- app/models/marty/grid_index_numrange.rb
|
426
426
|
- app/models/marty/grid_index_string.rb
|
427
|
+
- app/models/marty/helper.rb
|
427
428
|
- app/models/marty/import_type.rb
|
428
429
|
- app/models/marty/log.rb
|
429
430
|
- app/models/marty/name_validator.rb
|
@@ -483,6 +484,7 @@ files:
|
|
483
484
|
- db/migrate/304_drop_marty_api_logs.rb
|
484
485
|
- db/migrate/400_create_dg_plv8_v1_fns.rb
|
485
486
|
- db/seeds.rb
|
487
|
+
- delorean/diagnostics.dl
|
486
488
|
- delorean/script_report.dl
|
487
489
|
- gemini_deprecations.md
|
488
490
|
- lib/marty.rb
|