marty 2.5.2 → 2.5.4
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 +5 -5
- data/.gitignore +4 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +11 -589
- data/Gemfile +9 -9
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -3
- data/app/components/marty/api_auth_view.rb +3 -3
- data/app/components/marty/api_config_view.rb +8 -8
- data/app/components/marty/api_log_view.rb +16 -20
- data/app/components/marty/auth_app.rb +6 -6
- data/app/components/marty/base_rule_view.rb +27 -19
- data/app/components/marty/config_view.rb +12 -9
- data/app/components/marty/data_grid_view.rb +26 -26
- data/app/components/marty/delorean_rule_view.rb +0 -1
- data/app/components/marty/event_view.rb +27 -27
- data/app/components/marty/extras/layout.rb +26 -26
- data/app/components/marty/extras/misc.rb +2 -2
- data/app/components/marty/grid.rb +13 -13
- data/app/components/marty/grid_append_only.rb +0 -1
- data/app/components/marty/import_type_view.rb +13 -13
- data/app/components/marty/import_view.rb +17 -16
- data/app/components/marty/log_view.rb +16 -14
- data/app/components/marty/main_auth_app.rb +59 -59
- data/app/components/marty/main_auth_app/client/main_auth_app.js +3 -3
- data/app/components/marty/mcfly_grid_panel.rb +10 -10
- data/app/components/marty/new_posting_form.rb +11 -11
- data/app/components/marty/new_posting_window.rb +0 -1
- data/app/components/marty/posting_grid.rb +12 -13
- data/app/components/marty/promise_view.rb +6 -6
- data/app/components/marty/report_form.rb +50 -53
- data/app/components/marty/report_select.rb +27 -27
- data/app/components/marty/reporting.rb +4 -4
- data/app/components/marty/script_form.rb +40 -42
- data/app/components/marty/script_grid.rb +24 -24
- data/app/components/marty/script_tester.rb +40 -42
- data/app/components/marty/scripting.rb +25 -27
- data/app/components/marty/simple_app.rb +24 -9
- data/app/components/marty/tag_grid.rb +12 -13
- data/app/components/marty/user_view.rb +35 -35
- data/app/controllers/marty/application_controller.rb +3 -4
- data/app/controllers/marty/components_controller.rb +1 -1
- data/app/controllers/marty/delayed_job_controller.rb +1 -0
- data/app/controllers/marty/diagnostic/controller.rb +4 -6
- data/app/controllers/marty/job_controller.rb +6 -6
- data/app/controllers/marty/report_controller.rb +11 -11
- data/app/controllers/marty/rpc_controller.rb +15 -16
- data/app/helpers/marty/script_set.rb +4 -4
- data/app/models/marty/api_auth.rb +4 -5
- data/app/models/marty/api_config.rb +1 -1
- data/app/models/marty/base.rb +9 -8
- data/app/models/marty/base_rule.rb +18 -13
- data/app/models/marty/config.rb +4 -5
- data/app/models/marty/data_grid.rb +157 -181
- data/app/models/marty/delorean_rule.rb +63 -62
- data/app/models/marty/enum.rb +1 -1
- data/app/models/marty/event.rb +56 -59
- data/app/models/marty/helper.rb +38 -6
- data/app/models/marty/import_type.rb +6 -6
- data/app/models/marty/log.rb +3 -2
- data/app/models/marty/name_validator.rb +3 -2
- data/app/models/marty/pg_enum.rb +3 -4
- data/app/models/marty/posting.rb +20 -24
- data/app/models/marty/promise.rb +28 -30
- data/app/models/marty/script.rb +30 -28
- data/app/models/marty/tag.rb +8 -8
- data/app/models/marty/token.rb +2 -2
- data/app/models/marty/user.rb +24 -23
- data/app/models/marty/vw_promise.rb +10 -11
- data/config/routes.rb +2 -2
- data/delorean/blame_report.dl +268 -0
- data/{spec/dummy/delorean/fields.dl → delorean/marty_fields.dl} +8 -0
- data/delorean/table_report.dl +34 -0
- data/docker-compose.dummy.yml +2 -3
- data/lib/marty/aws/base.rb +8 -8
- data/lib/marty/aws/request.rb +4 -4
- data/lib/marty/cache_adapters/mcfly_ruby_cache.rb +1 -0
- data/lib/marty/content_handler.rb +25 -25
- data/lib/marty/data_change.rb +49 -71
- data/lib/marty/data_conversion.rb +20 -28
- data/lib/marty/data_exporter.rb +25 -28
- data/lib/marty/data_importer.rb +25 -27
- data/lib/marty/engine.rb +1 -2
- data/lib/marty/json_schema.rb +22 -24
- data/lib/marty/logger.rb +6 -9
- data/lib/marty/mcfly_model.rb +20 -24
- data/lib/marty/migrations.rb +37 -35
- data/lib/marty/monkey.rb +33 -33
- data/lib/marty/permissions.rb +18 -18
- data/lib/marty/promise_job.rb +17 -17
- data/lib/marty/promise_proxy.rb +6 -6
- data/lib/marty/relation.rb +6 -7
- data/lib/marty/rpc_call.rb +13 -12
- data/lib/marty/rule_script_set.rb +32 -28
- data/lib/marty/schema_helper.rb +37 -51
- data/lib/marty/util.rb +25 -24
- data/lib/marty/version.rb +1 -1
- data/lib/marty/xl.rb +121 -115
- data/make-dummy.mk +3 -0
- data/marty.gemspec +21 -21
- data/other/marty/api/base.rb +34 -35
- data/other/marty/diagnostic/aws/ec2_instance.rb +8 -8
- data/other/marty/diagnostic/base.rb +13 -14
- data/other/marty/diagnostic/collection.rb +2 -1
- data/other/marty/diagnostic/connections.rb +8 -6
- data/other/marty/diagnostic/database.rb +1 -0
- data/other/marty/diagnostic/delayed_job_version.rb +7 -9
- data/other/marty/diagnostic/delayed_job_worker_total_count.rb +1 -1
- data/other/marty/diagnostic/delayed_job_workers.rb +1 -1
- data/other/marty/diagnostic/environment_variables.rb +17 -15
- data/other/marty/diagnostic/fatal.rb +1 -1
- data/other/marty/diagnostic/node.rb +5 -9
- data/other/marty/diagnostic/nodes.rb +7 -5
- data/other/marty/diagnostic/packer.rb +7 -7
- data/other/marty/diagnostic/reporter.rb +24 -27
- data/other/marty/diagnostic/version.rb +3 -5
- data/script/rails +2 -1
- data/spec/controllers/application_controller_spec.rb +6 -6
- data/spec/controllers/delayed_job_controller_spec.rb +4 -4
- data/spec/controllers/diagnostic/controller_spec.rb +59 -60
- data/spec/controllers/job_controller_spec.rb +68 -69
- data/spec/controllers/rpc_controller_spec.rb +353 -359
- data/spec/controllers/rpc_import_spec.rb +15 -16
- data/spec/dummy/delorean/blame_report.dl +110 -15
- data/spec/dummy/delorean/data_report.dl +4 -4
- data/spec/dummy/delorean/marty_fields.dl +63 -0
- data/spec/dummy/delorean/table_report.dl +34 -0
- data/spec/features/auth_app_spec.rb +1 -2
- data/spec/features/data_import_spec.rb +2 -3
- data/spec/features/enum_spec.rb +42 -46
- data/spec/features/jobs_dashboard_spec.rb +14 -8
- data/spec/features/log_view_spec.rb +40 -43
- data/spec/features/reporting_spec.rb +15 -15
- data/spec/features/rule_spec.rb +195 -190
- data/spec/features/scripting_spec.rb +17 -20
- data/spec/features/scripting_test_spec.rb +32 -33
- data/spec/features/user_view_spec.rb +15 -17
- data/spec/job_helper.rb +11 -11
- data/spec/lib/data_blame_spec.rb +82 -0
- data/spec/lib/data_exporter_spec.rb +31 -32
- data/spec/lib/data_importer_spec.rb +382 -395
- data/spec/lib/delorean_query_spec.rb +117 -119
- data/spec/lib/json_schema_spec.rb +382 -392
- data/spec/lib/logger_spec.rb +23 -24
- data/spec/lib/mcfly_model_spec.rb +112 -109
- data/spec/lib/migrations_spec.rb +10 -10
- data/spec/lib/struct_compare_spec.rb +6 -6
- data/spec/lib/table_report_spec.rb +90 -0
- data/spec/lib/xl_spec.rb +63 -65
- data/spec/lib/xl_styles_spec.rb +16 -19
- data/spec/models/api_auth_spec.rb +30 -30
- data/spec/models/config_spec.rb +32 -32
- data/spec/models/data_grid_spec.rb +642 -655
- data/spec/models/event_spec.rb +96 -88
- data/spec/models/import_type_spec.rb +20 -20
- data/spec/models/posting_spec.rb +35 -35
- data/spec/models/promise_spec.rb +5 -5
- data/spec/models/rule_spec.rb +280 -269
- data/spec/models/script_spec.rb +27 -18
- data/spec/models/user_spec.rb +9 -9
- data/spec/other/diagnostic/base_spec.rb +20 -19
- data/spec/other/diagnostic/collection_spec.rb +6 -5
- data/spec/other/diagnostic/delayed_job_version_spec.rb +1 -1
- data/spec/other/diagnostic/delayed_job_workers_spec.rb +8 -8
- data/spec/other/diagnostic/reporter_spec.rb +31 -33
- data/spec/spec_helper.rb +5 -5
- data/spec/support/chromedriver.rb +3 -5
- data/spec/support/components/netzke_combobox.rb +1 -1
- data/spec/support/components/netzke_grid.rb +17 -17
- data/spec/support/custom_matchers.rb +2 -2
- data/spec/support/download_helper.rb +1 -1
- data/spec/support/helper.rb +1 -2
- data/spec/support/netzke.rb +31 -31
- data/spec/support/performance_helper.rb +8 -8
- data/spec/support/post_run_logger.rb +1 -2
- data/spec/support/setup.rb +1 -4
- data/spec/support/shared_connection.rb +2 -2
- data/spec/support/structure_compare.rb +21 -22
- data/spec/support/suite.rb +1 -2
- data/spec/support/users.rb +5 -6
- metadata +32 -26
data/spec/models/script_spec.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
s1
|
|
3
|
+
s1 = <<eof
|
|
4
4
|
NodeA:
|
|
5
5
|
attr = 123
|
|
6
6
|
eof
|
|
7
7
|
|
|
8
|
-
s2
|
|
8
|
+
s2 = <<eof
|
|
9
9
|
NodeB:
|
|
10
10
|
attr = 456
|
|
11
11
|
eof
|
|
@@ -22,7 +22,7 @@ describe Marty::Script do
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it "doesn't create a new script entry if it already exists and is the " +
|
|
25
|
-
|
|
25
|
+
'same as the existing' do
|
|
26
26
|
Marty::Script.load_a_script('TestExistsAndSame', s1)
|
|
27
27
|
expect { Marty::Script.load_a_script('TestExistsAndSame', s1) }.
|
|
28
28
|
not_to change(Marty::Script, :count)
|
|
@@ -35,12 +35,16 @@ describe Marty::Script do
|
|
|
35
35
|
to change(Marty::Script, :count).by(1)
|
|
36
36
|
|
|
37
37
|
Marty::Script.load_a_script('TestExistsAndDifferent2', s1, now - 1.minute)
|
|
38
|
-
expect
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
expect do
|
|
39
|
+
Marty::Script.load_a_script('TestExistsAndDifferent2',
|
|
40
|
+
s2, now)
|
|
41
|
+
end.
|
|
42
|
+
to change {
|
|
43
|
+
Marty::Script.where(name: 'TestExistsAndDifferent2',
|
|
44
|
+
obsoleted_dt: 'infinity').count
|
|
45
|
+
} .by(0)
|
|
42
46
|
expect(Marty::Script.find_by(
|
|
43
|
-
|
|
47
|
+
obsoleted_dt: 'infinity', name: 'TestExistsAndDifferent2').
|
|
44
48
|
created_dt.to_s).to eq(now.to_s)
|
|
45
49
|
end
|
|
46
50
|
end
|
|
@@ -53,7 +57,7 @@ describe Marty::Script do
|
|
|
53
57
|
let(:now) { Time.zone.now - 1.minute }
|
|
54
58
|
|
|
55
59
|
it 'loads each script given a hash' do
|
|
56
|
-
Marty::Script.load_script_bodies({'Test1' => s1, 'Test2' => s2}, now)
|
|
60
|
+
Marty::Script.load_script_bodies({ 'Test1' => s1, 'Test2' => s2 }, now)
|
|
57
61
|
expect(Marty::Script).to have_received(:load_a_script).
|
|
58
62
|
with('Test1', s1, now)
|
|
59
63
|
expect(Marty::Script).to have_received(:load_a_script).
|
|
@@ -71,32 +75,38 @@ describe Marty::Script do
|
|
|
71
75
|
end
|
|
72
76
|
|
|
73
77
|
it 'creates a new tag if none exist yet with provided datetime' do
|
|
74
|
-
expect
|
|
75
|
-
|
|
78
|
+
expect do
|
|
79
|
+
@tag = Marty::Script.load_script_bodies({ 'Test1' => s1,
|
|
80
|
+
'Test2' => s2 }, now)
|
|
81
|
+
end.
|
|
76
82
|
to change(Marty::Tag, :count).by(1)
|
|
77
83
|
expect(@tag.created_dt).to eq(now + 1.second)
|
|
78
84
|
end
|
|
79
85
|
|
|
80
86
|
it 'creates a new tag when there is an older one present' do
|
|
81
87
|
Marty::Tag.do_create(now - 1.minute, 'initial test tag')
|
|
82
|
-
expect
|
|
83
|
-
|
|
88
|
+
expect do
|
|
89
|
+
@tag = Marty::Script.load_script_bodies({ 'Test1' => s1,
|
|
90
|
+
'Test2' => s2 }, now)
|
|
91
|
+
end.
|
|
84
92
|
to change(Marty::Tag, :count).by(1)
|
|
85
93
|
expect(@tag.created_dt).to eq(now + 1.second)
|
|
86
94
|
end
|
|
87
95
|
|
|
88
96
|
it 'creates a new tag when no previous tag is present and no datetime ' +
|
|
89
97
|
'provided' do
|
|
90
|
-
expect
|
|
91
|
-
|
|
98
|
+
expect do
|
|
99
|
+
tag = Marty::Script.load_script_bodies('Test1' => s1,
|
|
100
|
+
'Test2' => s2)
|
|
101
|
+
end.
|
|
92
102
|
to change(Marty::Tag, :count).by(1)
|
|
93
103
|
end
|
|
94
104
|
|
|
95
105
|
it "doesn't create a new tag if one is present and the script wasn't" +
|
|
96
|
-
|
|
106
|
+
'modified' do
|
|
97
107
|
Marty::Script.create!(name: 'Test1', body: s1, created_dt: now)
|
|
98
108
|
Marty::Tag.do_create(now + 1.second, 'tag created by test')
|
|
99
|
-
expect { Marty::Script.load_script_bodies(
|
|
109
|
+
expect { Marty::Script.load_script_bodies('Test1' => s1) }.
|
|
100
110
|
not_to change(Marty::Tag, :count)
|
|
101
111
|
end
|
|
102
112
|
end
|
|
@@ -118,7 +128,6 @@ describe Marty::Script do
|
|
|
118
128
|
expect(Marty::Script).to have_received(:load_script_bodies).
|
|
119
129
|
with(match_array([['Script1', ls1], ['Script2', ls2]]), now)
|
|
120
130
|
end
|
|
121
|
-
|
|
122
131
|
end
|
|
123
132
|
|
|
124
133
|
describe '.get_script_filenames' do
|
data/spec/models/user_spec.rb
CHANGED
|
@@ -7,12 +7,12 @@ module Marty
|
|
|
7
7
|
system_user.login
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
let (:tuser)
|
|
10
|
+
let (:tuser) do
|
|
11
11
|
create_user('other_user')
|
|
12
|
-
|
|
12
|
+
end
|
|
13
13
|
|
|
14
|
-
describe
|
|
15
|
-
it
|
|
14
|
+
describe 'validations' do
|
|
15
|
+
it 'should require login, firstname and lastname' do
|
|
16
16
|
user = User.new
|
|
17
17
|
expect(user).to_not be_valid
|
|
18
18
|
expect(user.errors[:login].any?).to be true
|
|
@@ -20,7 +20,7 @@ module Marty
|
|
|
20
20
|
expect(user.errors[:lastname].any?).to be true
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
it
|
|
23
|
+
it 'should require unique login' do
|
|
24
24
|
expect(Mcfly.whodunnit).to_not be_nil
|
|
25
25
|
user = system_user.dup
|
|
26
26
|
expect(user).to_not be_valid
|
|
@@ -29,7 +29,7 @@ module Marty
|
|
|
29
29
|
expect(user).to be_valid
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
it
|
|
32
|
+
it 'should not allow Gemini account to be de-activated' do
|
|
33
33
|
user = system_user
|
|
34
34
|
user.active = false
|
|
35
35
|
expect(user).to_not be_valid
|
|
@@ -37,13 +37,13 @@ module Marty
|
|
|
37
37
|
to include('application system account cannot be deactivated')
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
it
|
|
40
|
+
it 'should not allow accounts to be deleted' do
|
|
41
41
|
user = system_user
|
|
42
42
|
user.destroy
|
|
43
43
|
expect(user.destroyed?).to be false
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
it
|
|
46
|
+
it 'should not allow user managers to edit the Gemini account' do
|
|
47
47
|
Mcfly.whodunnit = tuser
|
|
48
48
|
user = system_user
|
|
49
49
|
allow_any_instance_of(Marty::User).to receive(:user_manager_only).
|
|
@@ -54,7 +54,7 @@ module Marty
|
|
|
54
54
|
to include('cannot edit the application system account')
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
it
|
|
57
|
+
it 'should not allow user managers to edit their own account' do
|
|
58
58
|
Mcfly.whodunnit = tuser
|
|
59
59
|
allow_any_instance_of(Marty::User).to receive(:user_manager_only).
|
|
60
60
|
and_return(true)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe Marty::Diagnostic::Base do
|
|
4
|
-
def sample_data consistent=true
|
|
5
|
-
node_data_a = described_class.pack(include_ip=false){'A'}
|
|
6
|
-
node_data_b = described_class.pack(include_ip=false){'B'}
|
|
4
|
+
def sample_data consistent = true
|
|
5
|
+
node_data_a = described_class.pack(include_ip = false) { 'A' }
|
|
6
|
+
node_data_b = described_class.pack(include_ip = false) { 'B' }
|
|
7
7
|
|
|
8
8
|
data = {
|
|
9
9
|
'NodeA' => node_data_a,
|
|
@@ -11,12 +11,13 @@ describe Marty::Diagnostic::Base do
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
return data if consistent
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
data + { 'NodeB' => node_data_b }
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
it 'determines consistency of aggregate diagnostics' do
|
|
18
19
|
a = sample_data
|
|
19
|
-
b = sample_data(consistent=false)
|
|
20
|
+
b = sample_data(consistent = false)
|
|
20
21
|
|
|
21
22
|
expect(described_class.consistent?(a)).to eq(true)
|
|
22
23
|
expect(described_class.consistent?(b)).to eq(false)
|
|
@@ -31,20 +32,20 @@ describe Marty::Diagnostic::Base do
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
expect(described_class.pack(include_ip=false){'A'}).to eq(expected)
|
|
35
|
+
expect(described_class.pack(include_ip = false) { 'A' }).to eq(expected)
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
it 'can produce a valid diagnostic hash from a Hash' do
|
|
38
39
|
test_a = {
|
|
39
40
|
'ImportantA' => 'A',
|
|
40
41
|
'ImportantB' => 'B',
|
|
41
|
-
'ImportantC' => 'C'}
|
|
42
|
+
'ImportantC' => 'C' }
|
|
42
43
|
|
|
43
44
|
test_b = {
|
|
44
45
|
'ImportantA' => {
|
|
45
|
-
'description' => 'A', 'status' => true, 'consistent' => nil},
|
|
46
|
+
'description' => 'A', 'status' => true, 'consistent' => nil },
|
|
46
47
|
'ImportantB' => 'B',
|
|
47
|
-
'ImportantC' => 'C'}
|
|
48
|
+
'ImportantC' => 'C' }
|
|
48
49
|
|
|
49
50
|
expected = {
|
|
50
51
|
'ImportantA' => {
|
|
@@ -59,21 +60,21 @@ describe Marty::Diagnostic::Base do
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
expect(described_class.
|
|
62
|
-
pack(include_ip=false){test_a}).to eq(expected)
|
|
63
|
+
pack(include_ip = false) { test_a }).to eq(expected)
|
|
63
64
|
expect(described_class.
|
|
64
|
-
pack(include_ip=false){test_a}).to eq(expected)
|
|
65
|
+
pack(include_ip = false) { test_a }).to eq(expected)
|
|
65
66
|
end
|
|
66
67
|
|
|
67
68
|
it 'can produce a valid diagnostic hash from an error Hash' do
|
|
68
|
-
test = described_class.pack(include_ip=false)
|
|
69
|
+
test = described_class.pack(include_ip = false) do
|
|
69
70
|
described_class.error('E')
|
|
70
|
-
|
|
71
|
+
end
|
|
71
72
|
|
|
72
73
|
expected = {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
'Base' => {
|
|
75
|
+
'description' => 'E',
|
|
76
|
+
'status' => false,
|
|
77
|
+
'consistent' => nil }
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
expect(test).to eq(expected)
|
|
@@ -96,7 +97,7 @@ describe Marty::Diagnostic::Base do
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
expect{described_class.pack{test_a}}.to raise_error(RuntimeError)
|
|
100
|
-
expect{described_class.pack{test_b}}.to raise_error(RuntimeError)
|
|
100
|
+
expect { described_class.pack { test_a } }.to raise_error(RuntimeError)
|
|
101
|
+
expect { described_class.pack { test_b } }.to raise_error(RuntimeError)
|
|
101
102
|
end
|
|
102
103
|
end
|
|
@@ -2,18 +2,19 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe Marty::Diagnostic::Collection do
|
|
4
4
|
def sample_data consistent = true
|
|
5
|
-
node_a_data = described_class.pack(include_ip=false){'A'}
|
|
5
|
+
node_a_data = described_class.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
|
-
|
|
11
|
+
|
|
12
|
+
data + { 'NodeB' => { 'Base' => described_class.error('B') } }
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
it 'all diagnostics in diagnostics class attribute are generated' do
|
|
15
16
|
diags = [Marty::Diagnostic::Version, Marty::Diagnostic::Nodes]
|
|
16
|
-
expected = diags.map
|
|
17
|
+
expected = diags.map(&:generate).reduce(:deep_merge)
|
|
17
18
|
described_class.diagnostics = diags
|
|
18
19
|
expect(described_class.generate).to eq(expected)
|
|
19
20
|
end
|
|
@@ -21,9 +22,9 @@ describe Marty::Diagnostic::Collection do
|
|
|
21
22
|
it 'declares data consistency via status consistency' do
|
|
22
23
|
a = sample_data
|
|
23
24
|
b = sample_data + {
|
|
24
|
-
'NodeB' => described_class.pack(include_ip=false){'B'}
|
|
25
|
+
'NodeB' => described_class.pack(include_ip = false) { 'B' }
|
|
25
26
|
}
|
|
26
|
-
c = sample_data(consistent=false)
|
|
27
|
+
c = sample_data(consistent = false)
|
|
27
28
|
|
|
28
29
|
expect(described_class.consistent?(a)).to eq(true)
|
|
29
30
|
expect(described_class.consistent?(b)).to eq(true)
|
|
@@ -37,7 +37,7 @@ describe Marty::Diagnostic::DelayedJobVersion do
|
|
|
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{described_class.generate}.to raise_error(RuntimeError)
|
|
40
|
+
expect { described_class.generate }.to raise_error(RuntimeError)
|
|
41
41
|
stop_delayed_job
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
|
2
2
|
require 'job_helper'
|
|
3
3
|
|
|
4
4
|
describe Marty::Diagnostic::DelayedJobWorkers do
|
|
5
|
-
def sample_data ip=nil, error=false
|
|
5
|
+
def sample_data ip = nil, error = false
|
|
6
6
|
{
|
|
7
7
|
ip || Marty::Helper.my_ip => {
|
|
8
8
|
'Delayed Workers / Node' => {
|
|
9
|
-
'description' => error ?
|
|
9
|
+
'description' => error ? '3' : '4',
|
|
10
10
|
'status' => true,
|
|
11
11
|
'consistent' => nil
|
|
12
12
|
},
|
|
@@ -14,12 +14,12 @@ describe Marty::Diagnostic::DelayedJobWorkers do
|
|
|
14
14
|
}
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def sample_aggregate error=false
|
|
17
|
+
def sample_aggregate error = false
|
|
18
18
|
[
|
|
19
|
-
sample_data(ip='0.0.0.0'),
|
|
20
|
-
sample_data(ip='0.0.0.1'),
|
|
21
|
-
sample_data(ip='0.0.0.2', error=error),
|
|
22
|
-
sample_data(ip='0.0.0.3'),
|
|
19
|
+
sample_data(ip = '0.0.0.0'),
|
|
20
|
+
sample_data(ip = '0.0.0.1'),
|
|
21
|
+
sample_data(ip = '0.0.0.2', error = error),
|
|
22
|
+
sample_data(ip = '0.0.0.3'),
|
|
23
23
|
].reduce(:merge)
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -31,7 +31,7 @@ describe Marty::Diagnostic::DelayedJobWorkers do
|
|
|
31
31
|
|
|
32
32
|
it 'can determine if there are nodes with missing workers' do
|
|
33
33
|
consistent = sample_aggregate
|
|
34
|
-
inconsistent = sample_aggregate(error=true)
|
|
34
|
+
inconsistent = sample_aggregate(error = true)
|
|
35
35
|
|
|
36
36
|
expect(described_class.consistent?(consistent)).to eq(true)
|
|
37
37
|
expect(described_class.consistent?(inconsistent)).to eq(false)
|
|
@@ -7,19 +7,17 @@ describe Marty::Diagnostic::Reporter do
|
|
|
7
7
|
attr_accessor :params, :port
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def params diagnostic='base', scope=nil
|
|
11
|
-
{op: diagnostic, scope: scope}
|
|
10
|
+
def params diagnostic = 'base', scope = nil
|
|
11
|
+
{ op: diagnostic, scope: scope }
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def git
|
|
15
|
-
begin
|
|
16
15
|
message = `cd #{Rails.root.to_s}; git describe --tags --always;`.strip
|
|
17
|
-
|
|
18
|
-
message = error(
|
|
19
|
-
end
|
|
16
|
+
rescue StandardError
|
|
17
|
+
message = error('Failed accessing git')
|
|
20
18
|
end
|
|
21
19
|
|
|
22
|
-
def aggregate_data opts={}
|
|
20
|
+
def aggregate_data opts = {}
|
|
23
21
|
{
|
|
24
22
|
'Dummy' => {
|
|
25
23
|
'NodeA' => {
|
|
@@ -33,7 +31,7 @@ describe Marty::Diagnostic::Reporter do
|
|
|
33
31
|
}
|
|
34
32
|
end
|
|
35
33
|
|
|
36
|
-
def aggregate_consistency_data diagnostic='Base'
|
|
34
|
+
def aggregate_consistency_data diagnostic = 'Base'
|
|
37
35
|
original_a = Marty::Diagnostic::Base.create_info('A')
|
|
38
36
|
original_b = Marty::Diagnostic::Base.create_info('B')
|
|
39
37
|
|
|
@@ -75,12 +73,12 @@ describe Marty::Diagnostic::Reporter do
|
|
|
75
73
|
expected = {
|
|
76
74
|
diagnostic => {
|
|
77
75
|
'NodeA' => {
|
|
78
|
-
'CONSTANTA' => original_a + {'consistent' => true},
|
|
76
|
+
'CONSTANTA' => original_a + { 'consistent' => true },
|
|
79
77
|
'CONSTANTB' => inconsistent_b,
|
|
80
78
|
'CONSTANTB2' => inconsistent_b,
|
|
81
79
|
},
|
|
82
80
|
'NodeB' => {
|
|
83
|
-
'CONSTANTA' => original_a + {'consistent' => true},
|
|
81
|
+
'CONSTANTA' => original_a + { 'consistent' => true },
|
|
84
82
|
'CONSTANTB' => inconsistent_c,
|
|
85
83
|
'CONSTANTB2' => inconsistent_c,
|
|
86
84
|
},
|
|
@@ -95,18 +93,18 @@ describe Marty::Diagnostic::Reporter do
|
|
|
95
93
|
end
|
|
96
94
|
|
|
97
95
|
def version_data consistent = true
|
|
98
|
-
Marty::Diagnostic::Base.pack(include_ip=false)
|
|
96
|
+
Marty::Diagnostic::Base.pack(include_ip = false) do
|
|
99
97
|
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
'Marty' => info(Marty::VERSION, true, consistent),
|
|
99
|
+
'Delorean' => info(Delorean::VERSION, true, true),
|
|
100
|
+
'Mcfly' => info(Mcfly::VERSION, true, true),
|
|
101
|
+
'Git' => info(git, true, true),
|
|
104
102
|
}
|
|
105
|
-
|
|
103
|
+
end
|
|
106
104
|
end
|
|
107
105
|
|
|
108
106
|
def minimize(str)
|
|
109
|
-
str.gsub(/\s+/,
|
|
107
|
+
str.gsub(/\s+/, '')
|
|
110
108
|
end
|
|
111
109
|
|
|
112
110
|
describe 'display mechanism for version diagnostic' do
|
|
@@ -119,7 +117,7 @@ describe Marty::Diagnostic::Reporter do
|
|
|
119
117
|
end
|
|
120
118
|
|
|
121
119
|
it 'masks consistent nodes for display (version)' do
|
|
122
|
-
described_class.request.params = params(scope='local')
|
|
120
|
+
described_class.request.params = params(scope = 'local')
|
|
123
121
|
data = {
|
|
124
122
|
'Version' => {
|
|
125
123
|
'NodeA' => version_data,
|
|
@@ -164,18 +162,18 @@ describe Marty::Diagnostic::Reporter do
|
|
|
164
162
|
|
|
165
163
|
it 'displays all nodes when there is an inconsistent node (version)' do
|
|
166
164
|
Marty:: Diagnostic::Reporter.request.params = params
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
165
|
+
bad_ver = '0.0.0'
|
|
166
|
+
|
|
167
|
+
data = {
|
|
168
|
+
'Version' => {
|
|
169
|
+
'NodeA' => version_data(consistent = false),
|
|
170
|
+
'NodeB' => version_data + {
|
|
171
|
+
'Marty' => Marty::Diagnostic::Base.create_info(bad_ver, true, false)
|
|
172
|
+
},
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
expected = <<-ERB
|
|
179
177
|
<h3>Version</h3>
|
|
180
178
|
<h3 class="error">Inconsistency Detected </h3>
|
|
181
179
|
<div class="wrapper">
|
|
@@ -207,10 +205,10 @@ describe Marty::Diagnostic::Reporter do
|
|
|
207
205
|
</tr>
|
|
208
206
|
</table>
|
|
209
207
|
</div>
|
|
210
|
-
|
|
208
|
+
ERB
|
|
211
209
|
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
test = described_class.displays(data)
|
|
211
|
+
expect(minimize(test)).to eq(minimize(expected))
|
|
214
212
|
end
|
|
215
213
|
|
|
216
214
|
it 'can detect errors in diagnostic for display and api' do
|