marty 1.1.8 → 1.1.9
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/marty/diagnostic/controller.rb +40 -0
- data/app/models/{diagnostic → marty/diagnostic}/aws/ec2_instance.rb +1 -1
- data/app/models/{diagnostic → marty/diagnostic}/base.rb +6 -5
- data/app/models/{diagnostic → marty/diagnostic}/collection.rb +2 -1
- data/app/models/{diagnostic → marty/diagnostic}/delayed_job.rb +4 -2
- data/app/models/{diagnostic/env.rb → marty/diagnostic/environment_variables.rb} +4 -3
- data/app/models/{diagnostic → marty/diagnostic}/fatal.rb +4 -3
- data/app/models/{diagnostic → marty/diagnostic}/nodes.rb +7 -4
- data/app/models/{diagnostic → marty/diagnostic}/reporter.rb +19 -14
- data/app/models/{diagnostic → marty/diagnostic}/request.rb +2 -1
- data/app/models/{diagnostic/environment.rb → marty/diagnostic/version.rb} +14 -15
- data/app/models/marty/helper.rb +8 -0
- data/config/routes.rb +1 -1
- data/delorean/diagnostics.dl +1 -1
- data/lib/{diagnostic → marty/diagnostic}/database.rb +2 -2
- data/lib/{diagnostic → marty/diagnostic}/node.rb +2 -2
- data/lib/{diagnostic → marty/diagnostic}/packer.rb +6 -8
- data/lib/marty/monkey.rb +5 -1
- data/lib/marty/version.rb +1 -1
- data/spec/controllers/diagnostic/controller_spec.rb +152 -0
- data/spec/models/diagnostic/base_spec.rb +17 -13
- data/spec/models/diagnostic/collection_spec.rb +10 -10
- data/spec/models/diagnostic/delayed_job_spec.rb +5 -5
- data/spec/models/diagnostic/reporter_spec.rb +42 -43
- metadata +17 -20
- data/app/controllers/marty/diagnostic_controller.rb +0 -32
- data/app/models/diagnostic/base_collection.rb +0 -10
- data/app/models/diagnostic/helper.rb +0 -11
- data/app/models/diagnostic/version.rb +0 -17
- data/spec/controllers/diagnostic_controller_spec.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbf4105fb28ba2f431e2b8a8e0e68f6774ff6792
|
4
|
+
data.tar.gz: 20367feadccdd5e9de0e441837da1ee8916f5838
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f5617f786e53cf0e543a1594c7d50022b4b55bb25be508c9ec5ffd4a9ca4b1a5b4de4968151d022bd11f8f6b4efdec9a8c2bf1cd29138cb59ed4625b6a41a36
|
7
|
+
data.tar.gz: 5cddaced6b94fcdfdc9d42c2d6723137a36967022d59f0da2a2792f6968ceb1b27efb8ad95f1573c3265626d124fcf13ceb90677c3d3a83f7f3f2d644ea6fae6
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Marty::Diagnostic; class Controller < ActionController::Base
|
2
|
+
def self.inherited(klass)
|
3
|
+
Reporter.namespaces.unshift(klass.name.deconstantize)
|
4
|
+
super
|
5
|
+
end
|
6
|
+
|
7
|
+
def op
|
8
|
+
begin
|
9
|
+
@result = Reporter.run(request)
|
10
|
+
rescue NameError
|
11
|
+
render file: 'public/400', formats: [:html], status: 400, layout: false
|
12
|
+
else
|
13
|
+
respond_to do |format|
|
14
|
+
format.html {@result = display_parameters}
|
15
|
+
format.json {render json: process_result_for_api}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def process_result_for_api
|
21
|
+
@result.delete('data') unless request.params['data'] == 'true'
|
22
|
+
@result.delete('errors') if @result['errors'] && @result['errors'].empty?
|
23
|
+
@result
|
24
|
+
end
|
25
|
+
|
26
|
+
def display_parameters
|
27
|
+
local = params[:scope] == 'local'
|
28
|
+
data = local ? @result : @result['data']
|
29
|
+
errors = local ? Reporter.errors(data) : @result['errors']
|
30
|
+
{
|
31
|
+
'display' => Reporter.displays(data),
|
32
|
+
'errors' => errors
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.add_report name, diagnostics
|
37
|
+
Reporter.reports[name] = diagnostics
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class
|
2
|
-
extend
|
1
|
+
module Marty::Diagnostic; class Base < Request
|
2
|
+
extend Packer
|
3
3
|
include ActionView::Helpers::TextHelper
|
4
4
|
|
5
5
|
# all diagnostics have `aggregatable` set to true.
|
@@ -10,16 +10,16 @@ class Diagnostic::Base < Diagnostic::Request
|
|
10
10
|
self.aggregatable = true
|
11
11
|
self.status_only = false
|
12
12
|
|
13
|
-
@@read_only =
|
13
|
+
@@read_only = Util.db_in_recovery?
|
14
14
|
@@template = ActionController::Base.new.lookup_context.
|
15
|
-
|
15
|
+
find_template("marty/diagnostic/diag").identifier
|
16
16
|
|
17
17
|
def self.generate
|
18
18
|
raise "generate has not been defined for #{name}"
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.fatal?
|
22
|
-
name
|
22
|
+
name.include?('Fatal')
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.process_status_only infos
|
@@ -67,3 +67,4 @@ class Diagnostic::Base < Diagnostic::Request
|
|
67
67
|
new.simple_format(info ? info['description'] : 'N/A')
|
68
68
|
end
|
69
69
|
end
|
70
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
module Marty::Diagnostic; class Collection < Base
|
2
2
|
class_attribute :diagnostics
|
3
3
|
self.diagnostics = []
|
4
4
|
self.status_only = true
|
@@ -8,3 +8,4 @@ class Diagnostic::Collection < Diagnostic::Base
|
|
8
8
|
diagnostics.map{|d| d.generate}.reduce(:deep_merge)
|
9
9
|
end
|
10
10
|
end
|
11
|
+
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# `DELAYED_VER` environment variable should be set in the
|
6
6
|
# delayed jobs initializer.
|
7
7
|
#
|
8
|
-
class
|
8
|
+
module Marty::Diagnostic; class DelayedJob < Base
|
9
9
|
self.aggregatable = false
|
10
10
|
|
11
11
|
def self.generate
|
@@ -42,7 +42,9 @@ class Diagnostic::DelayedJob < Diagnostic::Base
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.delayed_worker_count
|
45
|
-
|
45
|
+
db = Database.db_name
|
46
|
+
Node.get_postgres_connections[db].
|
46
47
|
count{|conn| conn['application_name'].include?('delayed_job')}
|
47
48
|
end
|
48
49
|
end
|
50
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
def self.
|
1
|
+
module Marty::Diagnostic; class EnvironmentVariables < Base
|
2
|
+
def self.env filter=''
|
3
3
|
env = ENV.clone
|
4
4
|
|
5
5
|
# obfuscate SECRET_KEY_BASE for comparison
|
@@ -16,7 +16,7 @@ class Diagnostic::Env < Diagnostic::Base
|
|
16
16
|
|
17
17
|
def self.generate
|
18
18
|
pack do
|
19
|
-
|
19
|
+
env
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -33,3 +33,4 @@ class Diagnostic::Env < Diagnostic::Base
|
|
33
33
|
}
|
34
34
|
end
|
35
35
|
end
|
36
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
|
-
class
|
1
|
+
module Marty::Diagnostic; class Fatal < Base
|
2
2
|
def self.display_alert_message
|
3
3
|
'<h3 class="error">Something went wrong.</br>'\
|
4
4
|
'Consistency is checked between remaining nodes if applicable.</h3>'
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.message msg, opts = {}
|
8
|
-
node = opts[:node] ||
|
8
|
+
node = opts[:node] || Node.my_ip
|
9
9
|
type = opts[:type] || 'RuntimeError'
|
10
|
-
{name => {node => {type => error(msg)}}}
|
10
|
+
{name.demodulize => {node => {type => error(msg)}}}
|
11
11
|
end
|
12
12
|
end
|
13
|
+
end
|
@@ -1,13 +1,15 @@
|
|
1
|
-
|
1
|
+
require_relative 'aws/ec2_instance'
|
2
|
+
|
3
|
+
module Marty::Diagnostic; class Nodes < Base
|
2
4
|
def self.generate
|
3
5
|
pack do
|
4
6
|
begin
|
5
|
-
a_nodes =
|
6
|
-
|
7
|
+
a_nodes = Aws::Ec2Instance.new.nodes.sort if
|
8
|
+
Aws::Ec2Instance.is_aws?
|
7
9
|
rescue => e
|
8
10
|
a_nodes = [e.message]
|
9
11
|
end
|
10
|
-
pg_nodes =
|
12
|
+
pg_nodes = Node.get_nodes.sort
|
11
13
|
a_nodes.nil? || pg_nodes == a_nodes ? pg_nodes.join("\n") :
|
12
14
|
error("There is a discrepancy between nodes connected to "\
|
13
15
|
"Postgres and those discovered through AWS EC2.\n"\
|
@@ -16,3 +18,4 @@ class Diagnostic::Nodes < Diagnostic::Base
|
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
21
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
|
-
class
|
2
|
-
class_attribute :reports, :diagnostics
|
1
|
+
module Marty::Diagnostic; class Reporter < Request
|
2
|
+
class_attribute :reports, :diagnostics, :namespaces
|
3
3
|
|
4
4
|
self.reports = {}
|
5
5
|
self.diagnostics = []
|
6
|
+
self.namespaces = ['Marty']
|
6
7
|
|
7
8
|
def self.run request
|
8
9
|
self.request = request
|
@@ -17,9 +18,16 @@ class Diagnostic::Reporter < Diagnostic::Request
|
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
20
|
-
def self.resolve_diagnostic
|
21
|
-
|
22
|
-
|
21
|
+
def self.resolve_diagnostic diag_name
|
22
|
+
diag_name = diag_name.camelize
|
23
|
+
klass = nil
|
24
|
+
self.namespaces.each do |n|
|
25
|
+
klass = (n + '::Diagnostic::' + diag_name).constantize rescue nil
|
26
|
+
break if klass
|
27
|
+
end
|
28
|
+
raise NameError.new("#{diag_name} could not be resolved by #{name}") if
|
29
|
+
klass.nil?
|
30
|
+
klass
|
23
31
|
end
|
24
32
|
|
25
33
|
def self.unresolve_diagnostic klass
|
@@ -30,9 +38,9 @@ class Diagnostic::Reporter < Diagnostic::Request
|
|
30
38
|
diagnostics.each_with_object({}){
|
31
39
|
|d, h|
|
32
40
|
begin
|
33
|
-
h[d.name] = d.generate
|
41
|
+
h[d.name.demodulize] = d.generate
|
34
42
|
rescue => e
|
35
|
-
h.deep_merge!(
|
43
|
+
h.deep_merge!(Fatal.message(e.message, type: d.name.demodulize))
|
36
44
|
end
|
37
45
|
}
|
38
46
|
end
|
@@ -73,7 +81,7 @@ class Diagnostic::Reporter < Diagnostic::Request
|
|
73
81
|
ops = diagnostics.map{|d| unresolve_diagnostic(d) if d.aggregatable}.compact
|
74
82
|
return {} if ops.empty?
|
75
83
|
|
76
|
-
nodes =
|
84
|
+
nodes = Node.get_nodes - [Node.my_ip]
|
77
85
|
remote = nodes.sort.map do |n|
|
78
86
|
Thread.new do
|
79
87
|
uri = Addressable::URI.new(host: n, port: request.port)
|
@@ -92,13 +100,9 @@ class Diagnostic::Reporter < Diagnostic::Request
|
|
92
100
|
response = req.start {|http| http.get(uri.to_s)}
|
93
101
|
next JSON.parse(response.body) if response.code == "200"
|
94
102
|
|
95
|
-
|
96
|
-
type: response.message,
|
97
|
-
node: uri.host)
|
103
|
+
Fatal.message(response.body, type: response.message, node: uri.host)
|
98
104
|
rescue => e
|
99
|
-
|
100
|
-
type: e.class,
|
101
|
-
node: uri.host)
|
105
|
+
Fatal.message(e.message, type: e.class, node: uri.host)
|
102
106
|
end
|
103
107
|
end
|
104
108
|
end
|
@@ -106,3 +110,4 @@ class Diagnostic::Reporter < Diagnostic::Request
|
|
106
110
|
remote.empty? ? {} : remote.map(&:join).map(&:value).reduce(:deep_merge)
|
107
111
|
end
|
108
112
|
end
|
113
|
+
end
|
@@ -1,35 +1,34 @@
|
|
1
|
-
|
1
|
+
module Marty::Diagnostic; class Version < Base
|
2
2
|
def self.generate
|
3
3
|
pack do
|
4
|
+
begin
|
5
|
+
message = `cd #{Rails.root.to_s}; git describe --tags --always;`.strip
|
6
|
+
rescue
|
7
|
+
message = error("Failed accessing git")
|
8
|
+
end
|
4
9
|
rbv = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_PLATFORM})"
|
5
10
|
{
|
6
|
-
'
|
11
|
+
'Marty' => Marty::VERSION,
|
12
|
+
'Delorean' => Delorean::VERSION,
|
13
|
+
'Mcfly' => Mcfly::VERSION,
|
14
|
+
'Git' => message,
|
7
15
|
'Rails' => Rails.version,
|
8
16
|
'Netzke Core' => Netzke::Core::VERSION,
|
9
17
|
'Netzke Basepack' => Netzke::Basepack::VERSION,
|
10
18
|
'Ruby' => rbv,
|
11
19
|
'RubyGems' => Gem::VERSION,
|
12
|
-
'Database
|
13
|
-
'
|
14
|
-
'Database Version' => db_version,
|
15
|
-
'Database Schema Version' => db_schema
|
20
|
+
'Database Schema Version' => db_schema,
|
21
|
+
'Environment' => Rails.env,
|
16
22
|
}
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
20
|
-
def self.db_version
|
21
|
-
begin
|
22
|
-
Diagnostic::Database.db_version
|
23
|
-
rescue => e
|
24
|
-
error(e.message)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
26
|
def self.db_schema
|
29
27
|
begin
|
30
|
-
|
28
|
+
Database.db_schema
|
31
29
|
rescue => e
|
32
30
|
error(e.message)
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
34
|
+
end
|
data/app/models/marty/helper.rb
CHANGED
data/config/routes.rb
CHANGED
@@ -6,5 +6,5 @@ Marty::Engine.routes.draw do
|
|
6
6
|
match via: [:get, :post], "rpc/:action(.:format)" => "rpc", as: :rpc
|
7
7
|
get "job/:action" => "job", as: :job
|
8
8
|
match via: [:get, :post], "report(.:format)" => "report#index", as: :report
|
9
|
-
get 'diag', to: 'diagnostic
|
9
|
+
get 'diag', to: 'diagnostic/#op'
|
10
10
|
end
|
data/delorean/diagnostics.dl
CHANGED
@@ -3,7 +3,7 @@ Delay:
|
|
3
3
|
# the delay parameter delays the next created job so that a different
|
4
4
|
# worker is more likely to claim it
|
5
5
|
delay =? 2.6
|
6
|
-
ver = Marty::Helper.sleep(delay) &&
|
6
|
+
ver = Marty::Helper.sleep(delay) && Marty::Helper.git
|
7
7
|
res = [(Delay() | "ver") for i in Marty::Helper.range_step(0, count, 1)]
|
8
8
|
result = [r.to_a for r in res]
|
9
9
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Diagnostic::Database
|
1
|
+
module Marty::Diagnostic::Database
|
2
2
|
def self.db_name
|
3
3
|
ActiveRecord::Base.connection_config[:database]
|
4
4
|
end
|
@@ -23,6 +23,6 @@ module Diagnostic::Database
|
|
23
23
|
current = ActiveRecord::Migrator.current_version
|
24
24
|
raise "Migration is needed.\nCurrent Version: #{current}" if
|
25
25
|
ActiveRecord::Migrator.needs_migration?
|
26
|
-
current
|
26
|
+
current.to_s
|
27
27
|
end
|
28
28
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Diagnostic::Node
|
1
|
+
module Marty::Diagnostic::Node
|
2
2
|
def self.my_ip
|
3
3
|
begin
|
4
4
|
Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address
|
@@ -21,7 +21,7 @@ module Diagnostic::Node
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.get_target_connections target
|
24
|
-
get_postgres_connections[Diagnostic::Database.db_name].select{|conn|
|
24
|
+
get_postgres_connections[Marty::Diagnostic::Database.db_name].select{|conn|
|
25
25
|
conn['application_name'].include?(target)
|
26
26
|
}.map{|conn|
|
27
27
|
conn['client_addr'] == '127.0.0.1' ? my_ip : conn['client_addr']
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Diagnostic
|
1
|
+
module Marty::Diagnostic; module Packer
|
2
2
|
# expects a block that returns either a String or a Hash value and formats
|
3
3
|
# it into a diagnostic info object.
|
4
4
|
def pack include_ip=true
|
@@ -10,22 +10,19 @@ module Diagnostic::Packer
|
|
10
10
|
data.each_with_object({}) do
|
11
11
|
|(key, value), hash|
|
12
12
|
case value
|
13
|
-
when String
|
14
|
-
hash[key] = create_info(value)
|
15
13
|
when Hash
|
16
14
|
raise "Invalid Diagnostic Info #{value}" unless
|
17
15
|
is_valid_info?(value)
|
18
16
|
|
19
17
|
hash[key] = value
|
18
|
+
else
|
19
|
+
hash[key] = create_info(value.to_s)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
when String
|
23
|
-
{name.demodulize => create_info(data)}
|
24
22
|
else
|
25
|
-
|
26
|
-
"`package` expects a String or Hash value."
|
23
|
+
{name.demodulize => create_info(data.to_s)}
|
27
24
|
end
|
28
|
-
include_ip ? {
|
25
|
+
include_ip ? {Node.my_ip => info} : info
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
@@ -45,3 +42,4 @@ module Diagnostic::Packer
|
|
45
42
|
create_info(description, false)
|
46
43
|
end
|
47
44
|
end
|
45
|
+
end
|
data/lib/marty/monkey.rb
CHANGED
@@ -239,7 +239,11 @@ module ActiveRecord
|
|
239
239
|
def pg_enum(*args)
|
240
240
|
options = args.extract_options!
|
241
241
|
column_names = args
|
242
|
-
|
242
|
+
|
243
|
+
enum = options.delete(:enum)
|
244
|
+
|
245
|
+
column_names.each { |name|
|
246
|
+
column(name, enum || name.to_s.pluralize, options) }
|
243
247
|
end
|
244
248
|
end
|
245
249
|
module PostgreSQL
|
data/lib/marty/version.rb
CHANGED
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# used for testing controller inheritance
|
4
|
+
module Test
|
5
|
+
module Diagnostic; end
|
6
|
+
end
|
7
|
+
|
8
|
+
module Marty::Diagnostic
|
9
|
+
RSpec.describe Controller, type: :controller do
|
10
|
+
before(:each) { @routes = Marty::Engine.routes }
|
11
|
+
let(:json_response) { JSON.parse(response.body) }
|
12
|
+
|
13
|
+
def my_ip
|
14
|
+
Node.my_ip
|
15
|
+
end
|
16
|
+
|
17
|
+
def git
|
18
|
+
`cd #{Rails.root.to_s}; git describe --tags --always;`.
|
19
|
+
strip rescue "Failed accessing git"
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'GET #op' do
|
23
|
+
it 'returns http success' do
|
24
|
+
get :op, format: :json, op: 'version'
|
25
|
+
expect(response).to have_http_status(:success)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'a request injects the request object into Diagnostic classes' do
|
29
|
+
get :op, format: :json, op: 'version'
|
30
|
+
expect(Reporter.request).not_to eq(nil)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns the current version JSON' do
|
34
|
+
get :op, format: :json, op: 'version', data: 'true'
|
35
|
+
|
36
|
+
# generate version data and declare all values consistent
|
37
|
+
versions = Version.generate.each_with_object({}){
|
38
|
+
|(n, v),h|
|
39
|
+
h[n] = v.each{|t, r| r['consistent'] = true}
|
40
|
+
}
|
41
|
+
|
42
|
+
expected = {
|
43
|
+
'data' => {
|
44
|
+
'Version' => versions
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
expect(assigns('result')).to eq(expected)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'returns the expected cummulative diagnostic' do
|
52
|
+
expected = {
|
53
|
+
"data" => {
|
54
|
+
"Version" => {
|
55
|
+
my_ip => {
|
56
|
+
"Marty" => {
|
57
|
+
"description" => Marty::VERSION,
|
58
|
+
"status" => true,
|
59
|
+
"consistent" => true
|
60
|
+
},
|
61
|
+
"Delorean" => {
|
62
|
+
"description" => Delorean::VERSION,
|
63
|
+
"status" => true,
|
64
|
+
"consistent" => true
|
65
|
+
},
|
66
|
+
"Mcfly" => {
|
67
|
+
"description" => Mcfly::VERSION,
|
68
|
+
"status" => true,
|
69
|
+
"consistent" => true
|
70
|
+
},
|
71
|
+
"Git" => {
|
72
|
+
"description" => git,
|
73
|
+
"status" => true,
|
74
|
+
"consistent" => true
|
75
|
+
},
|
76
|
+
"Rails" => {
|
77
|
+
"description" => Rails.version,
|
78
|
+
"status" => true,
|
79
|
+
"consistent" => true
|
80
|
+
},
|
81
|
+
"Netzke Core" => {
|
82
|
+
"description" => Netzke::Core::VERSION,
|
83
|
+
"status" => true,
|
84
|
+
"consistent" => true
|
85
|
+
},
|
86
|
+
"Netzke Basepack" => {
|
87
|
+
"description" => Netzke::Basepack::VERSION,
|
88
|
+
"status" => true,
|
89
|
+
"consistent" => true
|
90
|
+
},
|
91
|
+
"Ruby" => {
|
92
|
+
"description" => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} "\
|
93
|
+
"(#{RUBY_PLATFORM})",
|
94
|
+
"status" => true,
|
95
|
+
"consistent" => true
|
96
|
+
},
|
97
|
+
"RubyGems" => {
|
98
|
+
"description" => Gem::VERSION,
|
99
|
+
"status" => true,
|
100
|
+
"consistent" => true
|
101
|
+
},
|
102
|
+
"Database Schema Version" => {
|
103
|
+
"description" => Database.db_schema,
|
104
|
+
"status" => true,
|
105
|
+
"consistent" => true
|
106
|
+
},
|
107
|
+
"Environment" => {
|
108
|
+
"description" => Rails.env,
|
109
|
+
"status" => true,
|
110
|
+
"consistent" => true
|
111
|
+
}
|
112
|
+
}
|
113
|
+
},
|
114
|
+
"EnvironmentVariables" => {
|
115
|
+
my_ip => {
|
116
|
+
}
|
117
|
+
},
|
118
|
+
"Nodes" => {
|
119
|
+
my_ip => {
|
120
|
+
"Nodes"=> {
|
121
|
+
"description" => my_ip,
|
122
|
+
"status" => true,
|
123
|
+
"consistent" => true
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
get :op,
|
131
|
+
format: :json,
|
132
|
+
op: 'version, environment_variables, nodes',
|
133
|
+
data: 'true'
|
134
|
+
|
135
|
+
expect(JSON.parse(response.body)).to eq(expected)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe 'Inheritance behavior' do
|
140
|
+
it 'appends namespace to reporter and resolves in order of inheritance' do
|
141
|
+
class Test::SomeController < Controller; end
|
142
|
+
expect(Reporter.namespaces).to include('Test')
|
143
|
+
|
144
|
+
class Test::Diagnostic::Version; end
|
145
|
+
expect(Reporter.resolve_diagnostic('Version').name).
|
146
|
+
to include('Test')
|
147
|
+
|
148
|
+
Reporter.namespaces.shift
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Diagnostic::Base do
|
3
|
+
describe Marty::Diagnostic::Base do
|
4
4
|
def sample_data consistent=true
|
5
|
-
node_data_a = Diagnostic::Base.pack(include_ip=false){'A'}
|
6
|
-
node_data_b = Diagnostic::Base.pack(include_ip=false){'B'}
|
5
|
+
node_data_a = Marty::Diagnostic::Base.pack(include_ip=false){'A'}
|
6
|
+
node_data_b = Marty::Diagnostic::Base.pack(include_ip=false){'B'}
|
7
7
|
|
8
8
|
data = {
|
9
9
|
'NodeA' => node_data_a,
|
@@ -18,8 +18,8 @@ describe Diagnostic::Base do
|
|
18
18
|
a = sample_data
|
19
19
|
b = sample_data(consistent=false)
|
20
20
|
|
21
|
-
expect(Diagnostic::Base.consistent?(a)).to eq(true)
|
22
|
-
expect(Diagnostic::Base.consistent?(b)).to eq(false)
|
21
|
+
expect(Marty::Diagnostic::Base.consistent?(a)).to eq(true)
|
22
|
+
expect(Marty::Diagnostic::Base.consistent?(b)).to eq(false)
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'can produce a valid diagnostic hash from a String' do
|
@@ -31,7 +31,7 @@ describe Diagnostic::Base do
|
|
31
31
|
}
|
32
32
|
}
|
33
33
|
|
34
|
-
expect(Diagnostic::Base.pack(include_ip=false){'A'}).to eq(expected)
|
34
|
+
expect(Marty::Diagnostic::Base.pack(include_ip=false){'A'}).to eq(expected)
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'can produce a valid diagnostic hash from a Hash' do
|
@@ -58,13 +58,15 @@ describe Diagnostic::Base do
|
|
58
58
|
},
|
59
59
|
}
|
60
60
|
|
61
|
-
expect(Diagnostic::Base.
|
62
|
-
|
61
|
+
expect(Marty::Diagnostic::Base.
|
62
|
+
pack(include_ip=false){test_a}).to eq(expected)
|
63
|
+
expect(Marty::Diagnostic::Base.
|
64
|
+
pack(include_ip=false){test_a}).to eq(expected)
|
63
65
|
end
|
64
66
|
|
65
67
|
it 'can produce a valid diagnostic hash from an error Hash' do
|
66
|
-
test = Diagnostic::Base.pack(include_ip=false){
|
67
|
-
Diagnostic::Base.error('E')
|
68
|
+
test = Marty::Diagnostic::Base.pack(include_ip=false){
|
69
|
+
Marty::Diagnostic::Base.error('E')
|
68
70
|
}
|
69
71
|
|
70
72
|
expected = {
|
@@ -81,7 +83,9 @@ describe Diagnostic::Base do
|
|
81
83
|
test_a = {
|
82
84
|
'ImportantA' => 'A',
|
83
85
|
'ImportantB' => 'B',
|
84
|
-
'ImportantC' => Diagnostic::Base.create_info('C') + {
|
86
|
+
'ImportantC' => Marty::Diagnostic::Base.create_info('C') + {
|
87
|
+
'extra' => 'D'
|
88
|
+
}
|
85
89
|
}
|
86
90
|
|
87
91
|
test_b = {
|
@@ -92,7 +96,7 @@ describe Diagnostic::Base do
|
|
92
96
|
}
|
93
97
|
}
|
94
98
|
|
95
|
-
expect{Diagnostic::Base.pack{test_a}}.to raise_error(RuntimeError)
|
96
|
-
expect{Diagnostic::Base.pack{test_b}}.to raise_error(RuntimeError)
|
99
|
+
expect{Marty::Diagnostic::Base.pack{test_a}}.to raise_error(RuntimeError)
|
100
|
+
expect{Marty::Diagnostic::Base.pack{test_b}}.to raise_error(RuntimeError)
|
97
101
|
end
|
98
102
|
end
|
@@ -1,32 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Diagnostic::Collection do
|
3
|
+
describe Marty::Diagnostic::Collection do
|
4
4
|
def sample_data consistent = true
|
5
|
-
node_a_data = Diagnostic::Collection.pack(include_ip=false){'A'}
|
5
|
+
node_a_data = Marty::Diagnostic::Collection.pack(include_ip=false){'A'}
|
6
6
|
data = {
|
7
7
|
'NodeA' => node_a_data,
|
8
8
|
'NodeB' => node_a_data,
|
9
9
|
}
|
10
10
|
return data if consistent
|
11
|
-
data + {'NodeB' => {'Base' => Diagnostic::Collection.error('B')}}
|
11
|
+
data + {'NodeB' => {'Base' => Marty::Diagnostic::Collection.error('B')}}
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'all diagnostics in diagnostics class attribute are generated' do
|
15
|
-
diags = [Diagnostic::Version, Diagnostic::
|
15
|
+
diags = [Marty::Diagnostic::Version, Marty::Diagnostic::Nodes]
|
16
16
|
expected = diags.map{|d| d.generate}.reduce(:deep_merge)
|
17
|
-
Diagnostic::Collection.diagnostics = diags
|
18
|
-
expect(Diagnostic::Collection.generate).to eq(expected)
|
17
|
+
Marty::Diagnostic::Collection.diagnostics = diags
|
18
|
+
expect(Marty::Diagnostic::Collection.generate).to eq(expected)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'declares data consistency via status consistency' do
|
22
22
|
a = sample_data
|
23
23
|
b = sample_data + {
|
24
|
-
'NodeB' => Diagnostic::Collection.pack(include_ip=false){'B'}
|
24
|
+
'NodeB' => Marty::Diagnostic::Collection.pack(include_ip=false){'B'}
|
25
25
|
}
|
26
26
|
c = sample_data(consistent=false)
|
27
27
|
|
28
|
-
expect(Diagnostic::Collection.consistent?(a)).to eq(true)
|
29
|
-
expect(Diagnostic::Collection.consistent?(b)).to eq(true)
|
30
|
-
expect(Diagnostic::Collection.consistent?(c)).to eq(false)
|
28
|
+
expect(Marty::Diagnostic::Collection.consistent?(a)).to eq(true)
|
29
|
+
expect(Marty::Diagnostic::Collection.consistent?(b)).to eq(true)
|
30
|
+
expect(Marty::Diagnostic::Collection.consistent?(c)).to eq(false)
|
31
31
|
end
|
32
32
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'job_helper'
|
3
3
|
|
4
|
-
describe Diagnostic::DelayedJob do
|
4
|
+
describe Marty::Diagnostic::DelayedJob do
|
5
5
|
# used to stub request object
|
6
6
|
class DummyRequest
|
7
7
|
attr_accessor :params, :port
|
@@ -12,12 +12,12 @@ describe Diagnostic::DelayedJob do
|
|
12
12
|
|
13
13
|
before(:each) do
|
14
14
|
Marty::Script.load_scripts(nil, Date.today)
|
15
|
-
allow(Diagnostic::DelayedJob).to receive(:scope).and_return(nil)
|
15
|
+
allow(Marty::Diagnostic::DelayedJob).to receive(:scope).and_return(nil)
|
16
16
|
end
|
17
17
|
|
18
18
|
def sample_data
|
19
19
|
{
|
20
|
-
|
20
|
+
Marty::Helper.my_ip => {
|
21
21
|
'Version' => {
|
22
22
|
'description' => Marty::VERSION,
|
23
23
|
'status' => true,
|
@@ -30,14 +30,14 @@ describe Diagnostic::DelayedJob do
|
|
30
30
|
it 'can detect if all workers are running correct application version' do
|
31
31
|
ENV['DELAYED_VER'] = Marty::VERSION
|
32
32
|
start_delayed_job
|
33
|
-
expect(Diagnostic::DelayedJob.generate).to eq(sample_data)
|
33
|
+
expect(Marty::Diagnostic::DelayedJob.generate).to eq(sample_data)
|
34
34
|
stop_delayed_job
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'will fail if DELAYED_VER is not set' do
|
38
38
|
ENV.delete('DELAYED_VER')
|
39
39
|
start_delayed_job
|
40
|
-
expect{Diagnostic::DelayedJob.generate}.to raise_error(RuntimeError)
|
40
|
+
expect{Marty::Diagnostic::DelayedJob.generate}.to raise_error(RuntimeError)
|
41
41
|
stop_delayed_job
|
42
42
|
end
|
43
43
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'job_helper'
|
3
3
|
|
4
|
-
describe Diagnostic::Reporter do
|
4
|
+
describe Marty::Diagnostic::Reporter do
|
5
5
|
# used to stub request object
|
6
6
|
class DummyRequest
|
7
7
|
attr_accessor :params, :port
|
@@ -21,7 +21,7 @@ describe Diagnostic::Reporter do
|
|
21
21
|
|
22
22
|
def aggregate_data opts={}
|
23
23
|
{
|
24
|
-
'
|
24
|
+
'Dummy' => {
|
25
25
|
'NodeA' => {
|
26
26
|
'ImportantTest' => {
|
27
27
|
'description' => 'A',
|
@@ -34,8 +34,8 @@ describe Diagnostic::Reporter do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def aggregate_consistency_data diagnostic='Base'
|
37
|
-
original_a = Diagnostic::Base.create_info('A')
|
38
|
-
original_b = Diagnostic::Base.create_info('B')
|
37
|
+
original_a = Marty::Diagnostic::Base.create_info('A')
|
38
|
+
original_b = Marty::Diagnostic::Base.create_info('B')
|
39
39
|
|
40
40
|
data = {
|
41
41
|
'CONSTANTA' => original_a,
|
@@ -43,11 +43,10 @@ describe Diagnostic::Reporter do
|
|
43
43
|
'CONSTANTB2' => original_b,
|
44
44
|
}
|
45
45
|
|
46
|
-
different_b = Diagnostic::Base.create_info('C')
|
46
|
+
different_b = Marty::Diagnostic::Base.create_info('C')
|
47
47
|
|
48
|
-
key = "Diagnostic::" + diagnostic
|
49
48
|
test = {
|
50
|
-
|
49
|
+
diagnostic => {
|
51
50
|
'NodeA' => data,
|
52
51
|
'NodeB' => data + {
|
53
52
|
'CONSTANTB' => different_b,
|
@@ -56,12 +55,12 @@ describe Diagnostic::Reporter do
|
|
56
55
|
}
|
57
56
|
}
|
58
57
|
|
59
|
-
inconsistent_b = Diagnostic::Base.create_info('B', true, false)
|
60
|
-
inconsistent_c = Diagnostic::Base.create_info('C', true, false)
|
58
|
+
inconsistent_b = Marty::Diagnostic::Base.create_info('B', true, false)
|
59
|
+
inconsistent_c = Marty::Diagnostic::Base.create_info('C', true, false)
|
61
60
|
|
62
|
-
if diagnostic == '
|
61
|
+
if diagnostic == 'EnvironmentVariables'
|
63
62
|
expected = {
|
64
|
-
|
63
|
+
diagnostic => {
|
65
64
|
'NodeA' => {
|
66
65
|
'CONSTANTB' => inconsistent_b,
|
67
66
|
'CONSTANTB2' => inconsistent_b,
|
@@ -74,7 +73,7 @@ describe Diagnostic::Reporter do
|
|
74
73
|
}
|
75
74
|
else
|
76
75
|
expected = {
|
77
|
-
|
76
|
+
diagnostic => {
|
78
77
|
'NodeA' => {
|
79
78
|
'CONSTANTA' => original_a + {'consistent' => true},
|
80
79
|
'CONSTANTB' => inconsistent_b,
|
@@ -92,11 +91,11 @@ describe Diagnostic::Reporter do
|
|
92
91
|
end
|
93
92
|
|
94
93
|
def info v, status, consistent
|
95
|
-
Diagnostic::Base.create_info(v, status, consistent)
|
94
|
+
Marty::Diagnostic::Base.create_info(v, status, consistent)
|
96
95
|
end
|
97
96
|
|
98
97
|
def version_data consistent = true
|
99
|
-
Diagnostic::Base.pack(include_ip=false){
|
98
|
+
Marty::Diagnostic::Base.pack(include_ip=false){
|
100
99
|
{
|
101
100
|
"Marty" => info(Marty::VERSION, true, consistent),
|
102
101
|
"Delorean" => info(Delorean::VERSION, true, true),
|
@@ -112,17 +111,17 @@ describe Diagnostic::Reporter do
|
|
112
111
|
|
113
112
|
describe 'display mechanism for version diagnostic' do
|
114
113
|
before(:all) do
|
115
|
-
Diagnostic::Reporter.diagnostics = [Diagnostic::Version]
|
114
|
+
Marty::Diagnostic::Reporter.diagnostics = [Marty::Diagnostic::Version]
|
116
115
|
end
|
117
116
|
|
118
117
|
before(:each) do
|
119
|
-
Diagnostic::Reporter.request = DummyRequest.new
|
118
|
+
Marty::Diagnostic::Reporter.request = DummyRequest.new
|
120
119
|
end
|
121
120
|
|
122
121
|
it 'masks consistent nodes for display (version)' do
|
123
|
-
Diagnostic::Reporter.request.params = params(scope='local')
|
122
|
+
Marty::Diagnostic::Reporter.request.params = params(scope='local')
|
124
123
|
data = {
|
125
|
-
'
|
124
|
+
'Version' => {
|
126
125
|
'NodeA' => version_data,
|
127
126
|
'NodeB' => version_data,
|
128
127
|
}
|
@@ -159,19 +158,19 @@ describe Diagnostic::Reporter do
|
|
159
158
|
</div>
|
160
159
|
ERB
|
161
160
|
|
162
|
-
test = Diagnostic::Reporter.displays(data)
|
161
|
+
test = Marty::Diagnostic::Reporter.displays(data)
|
163
162
|
expect(minimize(test)).to eq(minimize(expected))
|
164
163
|
end
|
165
164
|
|
166
165
|
it 'displays all nodes when there is an inconsistent node (version)' do
|
167
|
-
|
166
|
+
Marty:: Diagnostic::Reporter.request.params = params
|
168
167
|
bad_ver = '0.0.0'
|
169
168
|
|
170
169
|
data = {
|
171
|
-
'
|
170
|
+
'Version' => {
|
172
171
|
'NodeA' => version_data(consistent=false),
|
173
172
|
'NodeB' => version_data + {
|
174
|
-
'Marty' => Diagnostic::Base.create_info(bad_ver, true, false)
|
173
|
+
'Marty' => Marty::Diagnostic::Base.create_info(bad_ver, true, false)
|
175
174
|
},
|
176
175
|
}
|
177
176
|
}
|
@@ -210,41 +209,41 @@ describe Diagnostic::Reporter do
|
|
210
209
|
</div>
|
211
210
|
ERB
|
212
211
|
|
213
|
-
test = Diagnostic::Reporter.displays(data)
|
212
|
+
test = Marty::Diagnostic::Reporter.displays(data)
|
214
213
|
expect(minimize(test)).to eq(minimize(expected))
|
215
214
|
end
|
216
215
|
|
217
216
|
it 'can detect errors in diagnostic for display and api' do
|
218
|
-
Diagnostic::Reporter.request.params = params
|
217
|
+
Marty::Diagnostic::Reporter.request.params = params
|
219
218
|
n = aggregate_data
|
220
219
|
e = aggregate_data(status: false)
|
221
220
|
c = aggregate_data(consistent: false)
|
222
221
|
ce = aggregate_data(status: false, consistent: false)
|
223
222
|
|
224
223
|
aggregate_failures do
|
225
|
-
expect(Diagnostic::Reporter.errors(n)).to eq({})
|
226
|
-
expect(Diagnostic::Reporter.errors(e)).not_to eq({})
|
227
|
-
expect(Diagnostic::Reporter.errors(c)).not_to eq({})
|
228
|
-
expect(Diagnostic::Reporter.errors(ce)).not_to eq({})
|
224
|
+
expect(Marty::Diagnostic::Reporter.errors(n)).to eq({})
|
225
|
+
expect(Marty::Diagnostic::Reporter.errors(e)).not_to eq({})
|
226
|
+
expect(Marty::Diagnostic::Reporter.errors(c)).not_to eq({})
|
227
|
+
expect(Marty::Diagnostic::Reporter.errors(ce)).not_to eq({})
|
229
228
|
end
|
230
229
|
end
|
231
230
|
|
232
231
|
it 'can survive and display fatal errors' do
|
233
|
-
Diagnostic::Reporter.request.params = params
|
232
|
+
Marty::Diagnostic::Reporter.request.params = params
|
234
233
|
|
235
|
-
a_err_a = Diagnostic::Fatal.message('A',
|
236
|
-
|
234
|
+
a_err_a = Marty::Diagnostic::Fatal.message('A',
|
235
|
+
node: 'NodeA')
|
237
236
|
|
238
|
-
a_err_b = Diagnostic::Fatal.message('B',
|
239
|
-
|
237
|
+
a_err_b = Marty::Diagnostic::Fatal.message('B',
|
238
|
+
node: 'NodeA')
|
240
239
|
|
241
|
-
b_err_c = Diagnostic::Fatal.message('C',
|
242
|
-
|
243
|
-
|
240
|
+
b_err_c = Marty::Diagnostic::Fatal.message('C',
|
241
|
+
node: 'NodeB',
|
242
|
+
type: 'OtherError')
|
244
243
|
|
245
|
-
c_err_d = Diagnostic::Fatal.message('D',
|
246
|
-
|
247
|
-
|
244
|
+
c_err_d = Marty::Diagnostic::Fatal.message('D',
|
245
|
+
node: 'NodeC',
|
246
|
+
type: 'OtherOtherError')
|
248
247
|
|
249
248
|
data = [a_err_a, a_err_b, b_err_c, c_err_d].reduce(:deep_merge)
|
250
249
|
|
@@ -300,20 +299,20 @@ describe Diagnostic::Reporter do
|
|
300
299
|
</h3>
|
301
300
|
ERB
|
302
301
|
|
303
|
-
result = Diagnostic::Reporter.displays(data)
|
302
|
+
result = Marty::Diagnostic::Reporter.displays(data)
|
304
303
|
expect(minimize(result)).to eq(minimize(expected))
|
305
304
|
end
|
306
305
|
end
|
307
306
|
|
308
307
|
describe 'aggregation consistency functionality' do
|
309
308
|
it 'env diagnostic' do
|
310
|
-
test, expected = aggregate_consistency_data('
|
311
|
-
expect(Diagnostic::Reporter.consistency(test)).to eq(expected)
|
309
|
+
test, expected = aggregate_consistency_data('EnvironmentVariables')
|
310
|
+
expect(Marty::Diagnostic::Reporter.consistency(test)).to eq(expected)
|
312
311
|
end
|
313
312
|
|
314
313
|
it 'marks data as consistent/inconsistent' do
|
315
314
|
test, expected = aggregate_consistency_data
|
316
|
-
expect(Diagnostic::Reporter.consistency(test)).to eq(expected)
|
315
|
+
expect(Marty::Diagnostic::Reporter.consistency(test)).to eq(expected)
|
317
316
|
end
|
318
317
|
end
|
319
318
|
end
|
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.1.
|
4
|
+
version: 1.1.9
|
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: 2018-01-
|
17
|
+
date: 2018-01-23 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|
@@ -404,30 +404,27 @@ files:
|
|
404
404
|
- app/components/marty/user_view.rb
|
405
405
|
- app/controllers/marty/application_controller.rb
|
406
406
|
- app/controllers/marty/components_controller.rb
|
407
|
-
- app/controllers/marty/
|
407
|
+
- app/controllers/marty/diagnostic/controller.rb
|
408
408
|
- app/controllers/marty/job_controller.rb
|
409
409
|
- app/controllers/marty/report_controller.rb
|
410
410
|
- app/controllers/marty/rpc_controller.rb
|
411
411
|
- app/helpers/marty/application_helper.rb
|
412
412
|
- app/helpers/marty/script_set.rb
|
413
|
-
- app/models/diagnostic/aws/ec2_instance.rb
|
414
|
-
- app/models/diagnostic/base.rb
|
415
|
-
- app/models/diagnostic/base_collection.rb
|
416
|
-
- app/models/diagnostic/collection.rb
|
417
|
-
- app/models/diagnostic/delayed_job.rb
|
418
|
-
- app/models/diagnostic/env.rb
|
419
|
-
- app/models/diagnostic/environment.rb
|
420
|
-
- app/models/diagnostic/fatal.rb
|
421
|
-
- app/models/diagnostic/helper.rb
|
422
|
-
- app/models/diagnostic/nodes.rb
|
423
|
-
- app/models/diagnostic/reporter.rb
|
424
|
-
- app/models/diagnostic/request.rb
|
425
|
-
- app/models/diagnostic/version.rb
|
426
413
|
- app/models/marty/api_auth.rb
|
427
414
|
- app/models/marty/api_config.rb
|
428
415
|
- app/models/marty/base.rb
|
429
416
|
- app/models/marty/config.rb
|
430
417
|
- app/models/marty/data_grid.rb
|
418
|
+
- app/models/marty/diagnostic/aws/ec2_instance.rb
|
419
|
+
- app/models/marty/diagnostic/base.rb
|
420
|
+
- app/models/marty/diagnostic/collection.rb
|
421
|
+
- app/models/marty/diagnostic/delayed_job.rb
|
422
|
+
- app/models/marty/diagnostic/environment_variables.rb
|
423
|
+
- app/models/marty/diagnostic/fatal.rb
|
424
|
+
- app/models/marty/diagnostic/nodes.rb
|
425
|
+
- app/models/marty/diagnostic/reporter.rb
|
426
|
+
- app/models/marty/diagnostic/request.rb
|
427
|
+
- app/models/marty/diagnostic/version.rb
|
431
428
|
- app/models/marty/enum.rb
|
432
429
|
- app/models/marty/enum_event_operation.rb
|
433
430
|
- app/models/marty/event.rb
|
@@ -499,15 +496,15 @@ files:
|
|
499
496
|
- delorean/diagnostics.dl
|
500
497
|
- delorean/script_report.dl
|
501
498
|
- gemini_deprecations.md
|
502
|
-
- lib/diagnostic/database.rb
|
503
|
-
- lib/diagnostic/node.rb
|
504
|
-
- lib/diagnostic/packer.rb
|
505
499
|
- lib/marty.rb
|
506
500
|
- lib/marty/content_handler.rb
|
507
501
|
- lib/marty/data_change.rb
|
508
502
|
- lib/marty/data_conversion.rb
|
509
503
|
- lib/marty/data_exporter.rb
|
510
504
|
- lib/marty/data_importer.rb
|
505
|
+
- lib/marty/diagnostic/database.rb
|
506
|
+
- lib/marty/diagnostic/node.rb
|
507
|
+
- lib/marty/diagnostic/packer.rb
|
511
508
|
- lib/marty/engine.rb
|
512
509
|
- lib/marty/json_schema.rb
|
513
510
|
- lib/marty/lazy_column_loader.rb
|
@@ -533,7 +530,7 @@ files:
|
|
533
530
|
- marty.gemspec
|
534
531
|
- script/rails
|
535
532
|
- spec/controllers/application_controller_spec.rb
|
536
|
-
- spec/controllers/
|
533
|
+
- spec/controllers/diagnostic/controller_spec.rb
|
537
534
|
- spec/controllers/job_controller_spec.rb
|
538
535
|
- spec/controllers/rpc_controller_spec.rb
|
539
536
|
- spec/controllers/rpc_import_spec.rb
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module Marty
|
2
|
-
class DiagnosticController < ActionController::Base
|
3
|
-
def op
|
4
|
-
begin
|
5
|
-
@result = Diagnostic::Reporter.run(request)
|
6
|
-
rescue NameError
|
7
|
-
render file: 'public/400', formats: [:html], status: 400, layout: false
|
8
|
-
else
|
9
|
-
respond_to do |format|
|
10
|
-
format.html {@result = display_parameters}
|
11
|
-
format.json {render json: process_result_for_api}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def process_result_for_api
|
17
|
-
@result.delete('data') unless request.params['data'] == 'true'
|
18
|
-
@result.delete('errors') if @result['errors'] && @result['errors'].empty?
|
19
|
-
@result
|
20
|
-
end
|
21
|
-
|
22
|
-
def display_parameters
|
23
|
-
local = params[:scope] == 'local'
|
24
|
-
data = local ? @result : @result['data']
|
25
|
-
errors = local ? Diagnostic::Reporter.errors(data) : @result['errors']
|
26
|
-
{
|
27
|
-
'display' => Diagnostic::Reporter.displays(data),
|
28
|
-
'errors' => errors
|
29
|
-
}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# used to group separate diagnostics into one diagnostic
|
2
|
-
class Diagnostic::Collection < Diagnostic::Base
|
3
|
-
class_attribute :diagnostics
|
4
|
-
self.diagnostics = []
|
5
|
-
|
6
|
-
def self.generate
|
7
|
-
raise 'No diagnostics assigned to collection.' if diagnostics.empty?
|
8
|
-
diagnostics.map{|diagnostic| diagnostic.generate}.reduce(:deep_merge)
|
9
|
-
end
|
10
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class Diagnostic::Version < Diagnostic::Base
|
2
|
-
def self.generate
|
3
|
-
pack do
|
4
|
-
begin
|
5
|
-
message = `cd #{Rails.root.to_s}; git describe --tags --always;`.strip
|
6
|
-
rescue
|
7
|
-
message = error("Failed accessing git")
|
8
|
-
end
|
9
|
-
{
|
10
|
-
'Marty' => Marty::VERSION,
|
11
|
-
'Delorean' => Delorean::VERSION,
|
12
|
-
'Mcfly' => Mcfly::VERSION,
|
13
|
-
'Git' => message,
|
14
|
-
}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
module Marty
|
3
|
-
RSpec.describe DiagnosticController, type: :controller do
|
4
|
-
before(:each) { @routes = Marty::Engine.routes }
|
5
|
-
let(:json_response) { JSON.parse(response.body) }
|
6
|
-
|
7
|
-
describe 'GET #op' do
|
8
|
-
it 'returns http success' do
|
9
|
-
get :op, format: :json, op: 'version'
|
10
|
-
expect(response).to have_http_status(:success)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'a request injects the request object into Diagnostic classes' do
|
14
|
-
get :op, format: :json, op: 'version'
|
15
|
-
expect(Diagnostic::Reporter.request).not_to eq(nil)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'returns the current version JSON' do
|
19
|
-
get :op, format: :json, op: 'version', data: 'true'
|
20
|
-
|
21
|
-
# generate version data and declare all values consistent
|
22
|
-
versions = Diagnostic::Version.generate.each_with_object({}){
|
23
|
-
|(n, v),h|
|
24
|
-
h[n] = v.each{|t, r| r['consistent'] = true}
|
25
|
-
}
|
26
|
-
|
27
|
-
expected = {
|
28
|
-
'data' => {
|
29
|
-
'Diagnostic::Version' => versions
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
expect(assigns('result')).to eq(expected)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|