marty 1.0.53 → 1.0.54

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e29a8f6100cbc30a7a8207778d67566180324348
4
- data.tar.gz: 352aa2c3dfc43f0e59490f37219b8032669647b1
3
+ metadata.gz: b39a9aaf4fd1b9f90bdff0503ea509ae7b4e4232
4
+ data.tar.gz: 36f9283c373a1e5e1f0ab1c5e5a00efab731238c
5
5
  SHA512:
6
- metadata.gz: bf6c38998881fe010b0dc0231d2d12a572f84c7b69203caf573e5aafe986dd75815dd24ba26e70fd5a3c56645fa58d1ccfe12aa45339ca69b026778d3a42df97
7
- data.tar.gz: 071174651bea3b1018210e959e963ef4dc9c5ccf7c7a36a3cb9e11cee5a9f8a3f08fc31e7d538fac33249570c5f28edaabff778bf97c0e86f29a0987698cbed0
6
+ metadata.gz: a0212491f9ac246e2731fc2629d7543f49f0c814b597459cef568be5fc824ce891b56553f083f5de3a831ff8cd6585e118c82379f2512d74f08eff4913f08b40
7
+ data.tar.gz: abf2e69338e8f90b1f9dac8b15a31896d1ffab3681190adece922db454ac8dada1ecce411cef5c417f3d5d161d0a0e5f250bfa917de03e8ef17fe069163e9b77
data/Gemfile CHANGED
@@ -28,5 +28,5 @@ group :development, :test do
28
28
  gem 'netzke-testing'
29
29
 
30
30
  gem 'marty_rspec'
31
-
31
+ gem 'rspec-instafail', require: false
32
32
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- marty (1.0.53)
4
+ marty (1.0.54)
5
5
  axlsx (= 2.1.0pre)
6
6
  coderay
7
7
  delorean_lang (~> 0.1)
@@ -156,6 +156,10 @@ GEM
156
156
  rake (>= 0.8.7)
157
157
  thor (>= 0.18.1, < 2.0)
158
158
  rake (12.1.0)
159
+ rspec (3.6.0)
160
+ rspec-core (~> 3.6.0)
161
+ rspec-expectations (~> 3.6.0)
162
+ rspec-mocks (~> 3.6.0)
159
163
  rspec-by (0.0.7)
160
164
  rspec-core (>= 3)
161
165
  rspec-core (3.6.0)
@@ -163,6 +167,8 @@ GEM
163
167
  rspec-expectations (3.6.0)
164
168
  diff-lcs (>= 1.2.0, < 2.0)
165
169
  rspec-support (~> 3.6.0)
170
+ rspec-instafail (1.0.0)
171
+ rspec
166
172
  rspec-mocks (3.6.0)
167
173
  diff-lcs (>= 1.2.0, < 2.0)
168
174
  rspec-support (~> 3.6.0)
@@ -220,10 +226,11 @@ DEPENDENCIES
220
226
  pg (~> 0.18.4)
221
227
  pry-rails
222
228
  rails (~> 4.2.1)
229
+ rspec-instafail
223
230
  rspec-rails (~> 3.0)
224
231
  selenium-webdriver
225
232
  sqlite3
226
233
  timecop
227
234
 
228
235
  BUNDLED WITH
229
- 1.16.0.pre.2
236
+ 1.16.0
@@ -6,8 +6,10 @@ module Marty
6
6
  layout false
7
7
  def op
8
8
  begin
9
- # inject request into Base class of all diagnostics
10
- Base.request = request
9
+ # inject request object into base class of all diagnostics
10
+ Base.request = request
11
+
12
+ # determine if request is aggregate and return result
11
13
  params[:scope] = 'nodal' unless params[:scope]
12
14
  diag = self.class.get_sub_class(params[:op])
13
15
  @result = params[:scope] == 'local' ? diag.generate : diag.aggregate
@@ -32,23 +34,25 @@ module Marty
32
34
  #
33
35
  ############################################################################
34
36
  class Base
35
- @@request = nil
36
- @@read_only = Marty::Util.db_in_recovery?
37
-
38
- def self.request= req
39
- @@request = req
40
- end
37
+ @@request = nil
38
+ @@read_only = Marty::Util.db_in_recovery?
39
+ @@template = ActionController::Base.new.lookup_context.
40
+ find_template("marty/diagnostic/diag").identifier
41
41
 
42
42
  def self.request
43
43
  @@request
44
44
  end
45
45
 
46
+ def self.request= req
47
+ @@request = req
48
+ end
49
+
46
50
  def self.aggregate op_name=name.demodulize
47
51
  get_nodal_diags(op_name)
48
52
  end
49
53
 
50
54
  def self.get_nodal_diags op_name, scope='local'
51
- self.get_nodes.map do |n|
55
+ self.get_nodes.map do |n|
52
56
  ssl = ENV['HTTPS'] == 'on'
53
57
  uri = Addressable::URI.new(host: n, port: ssl ? 443 : @@request.port)
54
58
  uri.query_values = {op: op_name.underscore,
@@ -57,7 +61,7 @@ module Marty
57
61
  uri.path = '/marty/diag.json'
58
62
  opts = {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}
59
63
  {n => JSON.parse(open(uri, opts).readlines[0])}
60
- end.sum
64
+ end.sum
61
65
  end
62
66
 
63
67
  def self.find_failures data
@@ -85,36 +89,20 @@ module Marty
85
89
  "Failure: #{message}"
86
90
  end
87
91
 
92
+ # determine "target" (highest) value for tests
93
+ def self.get_targets data
94
+ data.each_with_object({}) do |(_, v), h|
95
+ v.each do |k, r|
96
+ r = r.to_s
97
+ h[k] ||= r
98
+ h[k] = r if h[k] < r
99
+ end
100
+ end
101
+ end
102
+
88
103
  def self.display data, type='nodal'
89
104
  data = {'local' => data} if type == 'local'
90
- display = <<-ERB
91
- <% inconsistent = diff(data) %>
92
- <h3><%=name.demodulize%></h3>
93
- <%='<h3 class="error">Issues Detected</h3>' if
94
- inconsistent%>
95
- <div class="wrapper">
96
- <% data.each do |node, result| %>
97
- <table>
98
- <% issues = ('error' if inconsistent) %>
99
- <th colspan="2" class="<%=issues%>">
100
- <small>
101
- <%=inconsistent ? node :
102
- (type == 'local' ? 'local' : 'consistent') %>
103
- </small>
104
- </th>
105
- <% result.each do |name, value| %>
106
- <tr class="<%=is_failure?(value) ? 'failed' :
107
- 'passed' %>">
108
- <td><%=name%></td>
109
- <td class="overflow"><%=simple_format(value.to_s)%></td>
110
- </tr>
111
- <% end %>
112
- </table>
113
- <% break unless inconsistent %>
114
- <% end %>
115
- </div>
116
- ERB
117
- ERB.new(display.html_safe).result(binding)
105
+ ERB.new(File.open(@@template).read).result(binding)
118
106
  end
119
107
 
120
108
  def self.get_pg_connections
@@ -170,7 +158,7 @@ module Marty
170
158
 
171
159
  class Database < Base
172
160
  def self.db_server_name
173
- ActiveRecord::Base.connection_config[:host] || 'undefined'
161
+ ActiveRecord::Base.connection_config[:host] || error('undefined')
174
162
  end
175
163
 
176
164
  def self.db_adapter_name
@@ -206,16 +194,18 @@ module Marty
206
194
  class Environment < Database
207
195
  def self.generate
208
196
  rbv = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_PLATFORM})"
209
- infos = {'Environment' => Rails.env,
210
- 'Rails' => Rails.version,
211
- 'Netzke Core' => Netzke::Core::VERSION,
212
- 'Netzke Basepack' => Netzke::Basepack::VERSION,
213
- 'Ruby' => rbv,
214
- 'RubyGems' => Gem::VERSION,
215
- 'Database Adapter' => db_adapter_name,
216
- 'Database Server' => db_server_name,
217
- 'Database Version' => db_version,
218
- 'Database Schema Version' => db_schema}
197
+ {
198
+ 'Environment' => Rails.env,
199
+ 'Rails' => Rails.version,
200
+ 'Netzke Core' => Netzke::Core::VERSION,
201
+ 'Netzke Basepack' => Netzke::Basepack::VERSION,
202
+ 'Ruby' => rbv,
203
+ 'RubyGems' => Gem::VERSION,
204
+ 'Database Adapter' => db_adapter_name,
205
+ 'Database Server' => db_server_name,
206
+ 'Database Version' => db_version,
207
+ 'Database Schema Version' => db_schema
208
+ }
219
209
  end
220
210
  end
221
211
 
@@ -269,15 +259,6 @@ module Marty
269
259
  c['name'].include?('delayed_job')}
270
260
  end
271
261
 
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
262
  def self.validate data
282
263
  data.each_with_object({}) do
283
264
  |(k,v), h|
@@ -288,7 +269,7 @@ module Marty
288
269
 
289
270
  def self.generate
290
271
  count = delayed_job_count
291
- return {'Status' => ['No delayed jobs are running.']} if count.zero?
272
+ return {'Issue' => ['No delayed jobs are running.']} if count.zero?
292
273
 
293
274
  # we will only iterate by half of the total delayed workers to avoid
294
275
  # excess use of delayed job time
@@ -306,17 +287,7 @@ module Marty
306
287
  end
307
288
 
308
289
  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)
290
+ package(validate(generate))
320
291
  end
321
292
 
322
293
  def self.diff data
@@ -0,0 +1,34 @@
1
+ <% inconsistent = diff(data) %>
2
+ <h3><%=name.demodulize%></h3>
3
+ <%='<h3 class="error">Issues Detected</h3>' if
4
+ inconsistent%>
5
+ <div class="wrapper">
6
+ <table>
7
+ <%# Create node table headers if applicable %>
8
+ <tr>
9
+ <%='<th></th>' if inconsistent %>
10
+ <% data.keys.each do |node| %>
11
+ <th <%='colspan="2"' unless inconsistent %> scope="col">
12
+ <%= inconsistent ? node :
13
+ (type == 'local' ? 'local' : 'consistent') %>
14
+ </th>
15
+ <% break unless inconsistent %>
16
+ <% end %>
17
+ </tr>
18
+ <%# Create row headers and display node results %>
19
+ <% data[data.keys.first].each do |key, value| %>
20
+ <tr>
21
+ <th scope="row"><%= key %></th>
22
+ <% targets = get_targets(data) %>
23
+ <% data.each do |_node, result| %>
24
+ <td class="overflow <%= (is_failure?(value) ||
25
+ (result[key].to_s != targets[key].to_s)) ? 'error' :
26
+ 'passed' %>">
27
+ <%= simple_format(result[key].to_s) %>
28
+ </td>
29
+ <% break unless inconsistent %>
30
+ <% end %>
31
+ </tr>
32
+ <% end %>
33
+ </table>
34
+ </div>
@@ -4,18 +4,18 @@
4
4
  <title><%=Rails.application.class.parent_name%> Diagnostic</title>
5
5
  <style type="text/css">
6
6
  body { margin: auto;
7
- margin-bottom: 50px;
8
- border: 0;
9
- background-color: #fff;
10
- color: #333333;
11
- font-family: Arial, Helvetica, Verdana, sans-serif;
12
- font-weight: normal;
13
- font-size: 9pt; }
7
+ margin-bottom: 50px;
8
+ border: 0;
9
+ background-color: #fff;
10
+ color: #333333;
11
+ font-family: Arial, Helvetica, Verdana, sans-serif;
12
+ font-weight: normal;
13
+ font-size: 9pt; }
14
14
  table { border: none;
15
- border-collapse: collapse;
16
- display: inline-block;
17
- margin: 0px 5px 0px 5px;
18
- text-align: left;
15
+ border-collapse: collapse;
16
+ display: inline-block;
17
+ margin: 0px 5px 0px 5px;
18
+ text-align: left;
19
19
  }
20
20
  th { padding: 9px;
21
21
  border: none;
@@ -23,14 +23,12 @@
23
23
  td { text-align: left;
24
24
  padding: 9px;
25
25
  }
26
- th.error { background-color: #ff5555;
27
- color: #ffffff;
28
- }
29
26
  tr { text-align: center;}
30
27
  tr.passed { background-color: #d0e9c6 }
31
- tr.failed { background-color: #ff5555;
32
- color: #ffffff
33
- }
28
+ td.passed { background-color: #d0e9c6 }
29
+ td.error { background-color: #ff5555;
30
+ color: #ffffff;}
31
+ th.error { background-color: #ff5555;}
34
32
  td.desc { font-size: 10pt; }
35
33
  p { white-space: pre-line;}
36
34
  h1 { display: block;
@@ -40,22 +38,25 @@
40
38
  font-size: 18pt;
41
39
  color: #ffffff;
42
40
  line-height: 1.5em; }
41
+ h1.error {background-color: #ff5555;}
43
42
  h2 {text-align: center;}
44
43
  h3.error {color: red;}
45
44
  h3 {text-align: center;}
46
45
  td.overflow { max-width: 350px;
47
- overflow: auto; }
46
+ overflow: auto; }
48
47
  .wrapper {
49
- overflow-x: auto;
50
- white-space: nowrap;
51
- display: block;}
48
+ overflow-x: auto;
49
+ white-space: nowrap;
50
+ display: block;}
52
51
  </style>
53
52
  </head>
54
53
  <body>
55
54
  <div style="text-align:center">
56
- <h1><%=Rails.application.class.parent_name%> Diagnostic</h1>
55
+ <h1 class="<%= 'error' if @result.to_s.include?('error') %>">
56
+ <%=Rails.application.class.parent_name%> Diagnostic
57
+ </h1>
57
58
  <h3><i><%= DateTime.now %></i></h3>
58
- <%== @result %>
59
- </div>
60
- </body>
59
+ <%== @result %>
60
+ </div>
61
+ </body>
61
62
  </html>
data/lib/marty/engine.rb CHANGED
@@ -9,7 +9,5 @@ module Marty
9
9
  config.generators do |g|
10
10
  g.test_framework :rspec, :view_specs => false
11
11
  end
12
-
13
- config.assets.precompile << 'marty/diagnostic.css'
14
12
  end
15
13
  end
data/lib/marty/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Marty
2
- VERSION = "1.0.53"
2
+ VERSION = "1.0.54"
3
3
  end
@@ -39,25 +39,31 @@ module Marty
39
39
  <<-ERB
40
40
  <h3>Version</h3>
41
41
  <div class="wrapper">
42
- <table>
43
- <th colspan="2" class=""><small>consistent</small></th>
44
- <tr class="passed">
45
- <td>Marty</td>
46
- <td class="overflow"><p>#{Marty::VERSION}</p></td>
47
- </tr>
48
- <tr class="passed">
49
- <td>Delorean</td>
50
- <td class="overflow"><p>#{Delorean::VERSION}</p></td>
51
- </tr>
52
- <tr class="passed">
53
- <td>Mcfly</td>
54
- <td class="overflow"><p>#{Mcfly::VERSION}</p></td>
55
- </tr>
56
- <tr class="passed">
57
- <td>Git</td>
58
- <td class="overflow"><p>#{git}</p></td>
59
- </tr>
60
- </table>
42
+ <table>
43
+ <tr>
44
+ <th colspan="2" scope="col">consistent</th>
45
+ </tr>
46
+ <tr>
47
+ <th scope="row">Marty</th>
48
+ <td class="overflow passed"><p>#{Marty::VERSION}</p>
49
+ </td>
50
+ </tr>
51
+ <tr>
52
+ <th scope="row">Delorean</th>
53
+ <td class="overflow passed"><p>#{Delorean::VERSION}</p>
54
+ </td>
55
+ </tr>
56
+ <tr>
57
+ <th scope="row">Mcfly</th>
58
+ <td class="overflow passed"><p>#{Mcfly::VERSION}</p>
59
+ </td>
60
+ </tr>
61
+ <tr>
62
+ <th scope="row">Git</th>
63
+ <td class="overflow passed"><p>#{git}</p>
64
+ </td>
65
+ </tr>
66
+ </table>
61
67
  </div>
62
68
  ERB
63
69
  end
@@ -68,42 +74,31 @@ module Marty
68
74
  <h3 class="error">Issues Detected </h3>
69
75
  <div class="wrapper">
70
76
  <table>
71
- <th colspan="2" class="error"><small>node1</small></th>
72
- <tr class="passed">
73
- <td>Marty</td>
74
- <td class="overflow"><p>#{Marty::VERSION}</p></td>
75
- </tr>
76
- <tr class="passed">
77
- <td>Delorean</td>
78
- <td class="overflow"><p>#{Delorean::VERSION}</p></td>
79
- </tr>
80
- <tr class="passed">
81
- <td>Mcfly</td>
82
- <td class="overflow"><p>#{Mcfly::VERSION}</p></td>
83
- </tr>
84
- <tr class="passed">
85
- <td>Git</td>
86
- <td class="overflow"><p>#{git}</p></td>
87
- </tr>
88
- </table>
89
- <table>
90
- <th colspan="2" class="error"><small>node2</small></th>
91
- <tr class="passed">
92
- <td>Marty</td>
93
- <td class="overflow"><p>#{val}</p></td>
94
- </tr>
95
- <tr class="passed">
96
- <td>Delorean</td>
97
- <td class="overflow"><p>#{Delorean::VERSION}</p></td>
98
- </tr>
99
- <tr class="passed">
100
- <td>Mcfly</td>
101
- <td class="overflow"><p>#{Mcfly::VERSION}</p></td>
102
- </tr>
103
- <tr class="passed">
104
- <td>Git</td>
105
- <td class="overflow"><p>#{git}</p></td>
106
- </tr>
77
+ <tr>
78
+ <th></th>
79
+ <th scope="col">node1</th>
80
+ <th scope="col">node2</th>
81
+ </tr>
82
+ <tr>
83
+ <th scope="row">Marty</th>
84
+ <td class="overflow passed"><p>#{Marty::VERSION}</p></td>
85
+ <td class="overflow error"><p>#{val}</p></td>
86
+ </tr>
87
+ <tr>
88
+ <th scope="row">Delorean</th>
89
+ <td class="overflow passed"><p>#{Delorean::VERSION}</p></td>
90
+ <td class="overflow passed"><p>#{Delorean::VERSION}</p></td>
91
+ </tr>
92
+ <tr>
93
+ <th scope="row">Mcfly</th>
94
+ <td class="overflow passed"><p>#{Mcfly::VERSION}</p></td>
95
+ <td class="overflow passed"><p>#{Mcfly::VERSION}</p></td>
96
+ </tr>
97
+ <tr>
98
+ <th scope="row">Git</th>
99
+ <td class="overflow passed"><p>#{git}</p></td>
100
+ <td class="overflow passed"><p>#{git}</p></td>
101
+ </tr>
107
102
  </table>
108
103
  </div>
109
104
  ERB
@@ -145,7 +140,7 @@ module Marty
145
140
  data = {'node1' => version, 'node2' => version + {'Marty' => ver}}
146
141
  expected = version_display_fail(ver)
147
142
  test = described_class::Version.display(data)
148
- expect(minimize(expected)).to eq(minimize(test))
143
+ expect(minimize(test)).to eq(minimize(expected))
149
144
  end
150
145
  end
151
146
 
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.53
4
+ version: 1.0.54
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-20 00:00:00.000000000 Z
17
+ date: 2017-11-28 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: pg
@@ -202,7 +202,6 @@ files:
202
202
  - Rakefile
203
203
  - app/assets/images/marty/.gitkeep
204
204
  - app/assets/stylesheets/marty/application.css
205
- - app/assets/stylesheets/marty/diagnostic.css
206
205
  - app/components/marty/api_auth_view.rb
207
206
  - app/components/marty/api_config_view.rb
208
207
  - app/components/marty/api_log_view.rb
@@ -439,7 +438,7 @@ files:
439
438
  - app/models/marty/user.rb
440
439
  - app/models/marty/user_role.rb
441
440
  - app/views/layouts/marty/application.html.erb
442
- - app/views/layouts/marty/diagnostic.html.erb
441
+ - app/views/marty/diagnostic/diag.html.erb
443
442
  - app/views/marty/diagnostic/op.html.erb
444
443
  - config/database.yml.travis
445
444
  - config/locales/en.yml
@@ -1,34 +0,0 @@
1
- body { margin: 0;
2
- padding: 0;
3
- border: 0;
4
- background-color: #fff;
5
- color: #333333;
6
- text-align: left;
7
- font-family: Arial, Helvetica, Verdana, sans-serif;
8
- font-weight: normal;
9
- font-size: 11pt; }
10
- table { border-width: 0px;
11
- margin-left: auto;
12
- margin-right: auto;
13
- border-spacing: 1px;
14
- width: 75% }
15
- th { padding: 9px;
16
- background-color: #d6d6d6 }
17
- td { padding: 9px;
18
- -moz-border-radius: 5px;
19
- border-radius: 5px;
20
- -webkit-border-radius: 5px;
21
- border-style: solid;
22
- border-width: 1px;
23
- border-color: #999999; }
24
- tr.passed { background-color: #9ed515 }
25
- tr.warning { background-color: #ffdb58 }
26
- tr.failed { background-color: #ff5555 }
27
- td.desc { font-size: 10pt; }
28
- h1 { display: block;
29
- margin: 0px auto 40px auto;
30
- padding: 8px;
31
- background-color: #3e2155;
32
- font-size: 18pt;
33
- color: #ffffff;
34
- line-height: 1.5em; }
@@ -1,11 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
- <title><%= Rails.application.class.parent %></title>
6
- <%= stylesheet_link_tag 'marty/diagnostic' %>
7
- </head>
8
- <body>
9
- <%= yield %>
10
- </body>
11
- </html>