rocketjob_mission_control 2.1.1 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/app/assets/stylesheets/rocket_job_mission_control/callout.scss +1 -1
  4. data/app/assets/stylesheets/rocket_job_mission_control/worker_processes.scss +2 -2
  5. data/app/controllers/rocket_job_mission_control/active_workers_controller.rb +15 -0
  6. data/app/controllers/rocket_job_mission_control/dirmon_entries/index_filters_controller.rb +8 -13
  7. data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +3 -14
  8. data/app/controllers/rocket_job_mission_control/jobs/failures_controller.rb +6 -11
  9. data/app/controllers/rocket_job_mission_control/jobs/index_filters_controller.rb +35 -14
  10. data/app/controllers/rocket_job_mission_control/jobs_controller.rb +12 -15
  11. data/app/controllers/rocket_job_mission_control/servers/index_filters_controller.rb +49 -0
  12. data/app/controllers/rocket_job_mission_control/servers_controller.rb +93 -0
  13. data/app/datatables/rocket_job_mission_control/abstract_datatable.rb +62 -0
  14. data/app/datatables/rocket_job_mission_control/active_workers_datatable.rb +47 -0
  15. data/app/datatables/rocket_job_mission_control/completed_jobs_datatable.rb +1 -1
  16. data/app/datatables/rocket_job_mission_control/dirmon_entries_datatable.rb +10 -72
  17. data/app/datatables/rocket_job_mission_control/interrupted_jobs_datatable.rb +1 -1
  18. data/app/datatables/rocket_job_mission_control/jobs_datatable.rb +16 -91
  19. data/app/datatables/rocket_job_mission_control/queued_jobs_datatable.rb +1 -1
  20. data/app/datatables/rocket_job_mission_control/running_jobs_datatable.rb +23 -12
  21. data/app/datatables/rocket_job_mission_control/scheduled_jobs_datatable.rb +1 -1
  22. data/app/datatables/rocket_job_mission_control/servers_datatable.rb +67 -0
  23. data/app/helpers/rocket_job_mission_control/{workers_helper.rb → servers_helper.rb} +9 -9
  24. data/app/models/job_failures.rb +3 -16
  25. data/app/models/rocket_job_mission_control/query.rb +51 -0
  26. data/app/views/layouts/rocket_job_mission_control/partials/_header.html.haml +3 -3
  27. data/app/views/layouts/rocket_job_mission_control/partials/_sidebar.html.haml +2 -2
  28. data/app/views/rocket_job_mission_control/{active_processes → active_workers}/index.html.haml +3 -3
  29. data/app/views/rocket_job_mission_control/dirmon_entries/_properties.html.haml +7 -18
  30. data/app/views/rocket_job_mission_control/dirmon_entries/_status.html.haml +0 -5
  31. data/app/views/rocket_job_mission_control/dirmon_entries/show.html.haml +4 -3
  32. data/app/views/rocket_job_mission_control/jobs/_status.html.haml +22 -17
  33. data/app/views/rocket_job_mission_control/jobs/edit.html.haml +1 -1
  34. data/app/views/rocket_job_mission_control/jobs/exceptions.html.haml +29 -0
  35. data/app/views/rocket_job_mission_control/jobs/failures/index.html.haml +7 -7
  36. data/app/views/rocket_job_mission_control/jobs/show.html.haml +23 -11
  37. data/app/views/rocket_job_mission_control/servers/_actions.html.haml +9 -0
  38. data/app/views/rocket_job_mission_control/servers/_sidebar.html.haml +20 -0
  39. data/app/views/rocket_job_mission_control/{workers → servers}/index.html.haml +9 -9
  40. data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/paused.html.haml +8 -8
  41. data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/running.html.haml +8 -8
  42. data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/starting.html.haml +8 -8
  43. data/app/views/rocket_job_mission_control/{workers → servers}/index_filters/stopping.html.haml +8 -8
  44. data/config/locales/en.yml +2 -2
  45. data/config/routes.rb +7 -6
  46. data/lib/rocket_job_mission_control/engine.rb +0 -12
  47. data/lib/rocket_job_mission_control/version.rb +1 -1
  48. data/spec/controllers/dirmon_entries/index_filters_controller_spec.rb +2 -4
  49. data/spec/controllers/dirmon_entries_controller_spec.rb +15 -72
  50. data/spec/controllers/jobs/index_filters_controller_spec.rb +1 -1
  51. data/spec/controllers/workers/index_filters_controller_spec.rb +9 -9
  52. data/spec/controllers/workers_controller_spec.rb +47 -47
  53. data/spec/dummy/config/mongoid.yml +88 -0
  54. data/spec/dummy/config/symmetric-encryption.yml +8 -0
  55. data/spec/dummy/log/test.log +89072 -0
  56. data/spec/helpers/servers_helper_spec.rb +16 -0
  57. data/spec/spec_helper.rb +3 -0
  58. metadata +31 -45
  59. data/app/controllers/rocket_job_mission_control/active_processes_controller.rb +0 -27
  60. data/app/controllers/rocket_job_mission_control/workers/index_filters_controller.rb +0 -50
  61. data/app/controllers/rocket_job_mission_control/workers_controller.rb +0 -93
  62. data/app/datatables/rocket_job_mission_control/active_processes_datatable.rb +0 -79
  63. data/app/datatables/rocket_job_mission_control/workers_datatable.rb +0 -127
  64. data/app/interactors/rocket_job_mission_control/dirmon_entries/search.rb +0 -19
  65. data/app/interactors/rocket_job_mission_control/jobs/search.rb +0 -19
  66. data/app/interactors/rocket_job_mission_control/workers/search.rb +0 -19
  67. data/app/views/rocket_job_mission_control/workers/_actions.html.haml +0 -9
  68. data/app/views/rocket_job_mission_control/workers/_sidebar.html.haml +0 -20
  69. data/spec/dummy/config/mongo.yml +0 -15
  70. data/spec/helpers/workers_helper_spec.rb +0 -16
  71. data/spec/interactors/jobs/search_spec.rb +0 -35
@@ -1,127 +0,0 @@
1
- module RocketJobMissionControl
2
- class WorkersDatatable
3
- delegate :params,
4
- :link_to,
5
- :worker_icon,
6
- :worker_path,
7
- :stop_worker_path,
8
- :resume_worker_path,
9
- :pause_worker_path,
10
- :worker_card_class,
11
- :render, to: :@view
12
-
13
- delegate :h, to: 'ERB::Util'
14
-
15
- def initialize(view, workers)
16
- @view = view
17
- @unfiltered_workers = workers
18
- end
19
-
20
- def as_json(options = {})
21
- {
22
- :draw => params[:draw].to_i,
23
- :recordsTotal => get_raw_records.count,
24
- :recordsFiltered => filter_records(get_raw_records).count,
25
- :data => data
26
- }
27
- end
28
-
29
- private
30
-
31
- def data
32
- workers.map do |worker|
33
- {
34
- '0' => name_with_icon(worker),
35
- '1' => h(threads(worker)),
36
- '2' => h(started_ago(worker)),
37
- '3' => h(time_since_heartbeat(worker)),
38
- '4' => action_links_html(worker),
39
- 'DT_RowClass' => "card callout #{worker_card_class(worker)}"
40
- }
41
- end
42
- end
43
-
44
- def get_raw_records
45
- @unfiltered_workers
46
- end
47
-
48
- def workers
49
- @workers ||= fetch_workers
50
- end
51
-
52
- def fetch_workers
53
- records = get_raw_records
54
- records = sort_records(records) if params[:order].present?
55
- records = filter_records(records) if params[:search].present?
56
- records = paginate_records(records) unless params[:length].present? && params[:length] == '-1'
57
- records
58
- end
59
-
60
- def page
61
- (params[:start].to_i / per_page) + 1
62
- end
63
-
64
- def per_page
65
- params.fetch(:length, 10).to_i
66
- end
67
-
68
- def sort_records(records)
69
- sort_by = {}
70
- params[:order].keys.each do |key|
71
- sort_by[sort_column(params[:order][key][:column])] = params[:order][key][:dir]
72
- end
73
- records.sort(sort_by)
74
- end
75
-
76
- def sort_column(index)
77
- columns = %w[name max_threads started_at heartbeat.updated_at]
78
- columns[index.to_i]
79
- end
80
-
81
- def filter_records(records)
82
- return records unless (params[:search].present? && params[:search][:value].present?)
83
- conditions = params[:search][:value]
84
- records = RocketJobMissionControl::Workers::Search.new(conditions, records).execute if conditions
85
- records
86
- end
87
-
88
- def paginate_records(records)
89
- Kaminari.paginate_array(records.all).page(page).per(per_page)
90
- end
91
-
92
- def name_with_icon(worker)
93
- <<-EOS
94
- <i class="fa #{worker_icon(worker)}" style="font-size: 75%" title="#{worker.state}"></i>
95
- #{worker.name}
96
- EOS
97
- end
98
-
99
- def threads(worker)
100
- "#{worker.heartbeat.current_threads.to_i}/#{worker.max_threads}"
101
- end
102
-
103
- def started_ago(worker)
104
- "#{RocketJob.seconds_as_duration(Time.now - worker.started_at)} ago"
105
- end
106
-
107
- def time_since_heartbeat(worker)
108
- "#{RocketJob.seconds_as_duration(Time.now - worker.heartbeat.updated_at)} ago"
109
- end
110
-
111
- def action_links_html(worker)
112
- actions = '<div class="actions">'
113
- if worker.stopping?
114
- actions += "Worker is stopping..."
115
- actions += "#{ link_to "destroy", worker_path(worker), method: :delete, class: 'btn btn-danger', data: { confirm: "Destroy this worker?"} }"
116
- else
117
- if worker.paused?
118
- actions += "#{ link_to "resume", resume_worker_path(worker), method: :patch, class: 'btn btn-default', data: { confirm: "Resume this worker?"} }"
119
- else
120
- actions += "#{ link_to "pause", pause_worker_path(worker), method: :patch, class: 'btn btn-default', data: { confirm: "Pause this worker?"} }"
121
- end
122
- actions += "#{ link_to "stop", stop_worker_path(worker), method: :patch, class: 'btn btn-danger', data: { confirm: "Stop this worker?"} }"
123
- end
124
- actions += '</div>'
125
- end
126
- end
127
- end
@@ -1,19 +0,0 @@
1
- module RocketJobMissionControl
2
- module DirmonEntries
3
- class Search
4
- attr_reader :results, :search_term
5
-
6
- def initialize(search_term, search_subset)
7
- @search_term = Regexp.escape(search_term)
8
- @results = search_subset
9
- end
10
-
11
- def execute
12
- if !search_term.blank?
13
- @results = @results.where('$or' => [{job_class_name: /#{search_term}/i}, {name: /#{search_term}/i}, {pattern: /#{search_term}/i}])
14
- end
15
- @results
16
- end
17
- end
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- module RocketJobMissionControl
2
- module Jobs
3
- class Search
4
- attr_reader :results, :search_term
5
-
6
- def initialize(search_term, search_subset)
7
- @search_term = Regexp.escape(search_term)
8
- @results = search_subset
9
- end
10
-
11
- def execute
12
- if !search_term.blank?
13
- @results = @results.where('$or' => [{_type: /#{search_term}/i}, {description: /#{search_term}/i}])
14
- end
15
- @results
16
- end
17
- end
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- module RocketJobMissionControl
2
- module Workers
3
- class Search
4
- attr_reader :results, :search_term
5
-
6
- def initialize(search_term, search_subset)
7
- @search_term = Regexp.escape(search_term)
8
- @results = search_subset
9
- end
10
-
11
- def execute
12
- if !search_term.blank?
13
- @results = @results.where('$or' => [{name: /#{search_term}/i}])
14
- end
15
- @results
16
- end
17
- end
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- - if worker.stopping?
2
- %p Worker is stopping...
3
- = link_to "destroy", rocket_job_mission_control.worker_path(worker), method: :delete, class: 'btn btn-danger'
4
- -else
5
- = link_to "stop", rocket_job_mission_control.stop_worker_path(worker), method: :patch, class: 'btn btn-danger'
6
- - if worker.paused?
7
- = link_to "resume", rocket_job_mission_control.resume_worker_path(worker), method: :patch, class: 'btn btn-default'
8
- - else
9
- = link_to "pause", rocket_job_mission_control.pause_worker_path(worker), method: :patch, class: 'btn btn-default'
@@ -1,20 +0,0 @@
1
- %ul#lg-menu.nav.hidden-xs
2
- %li
3
- = link_to(workers_path) do
4
- %i.fa.fa-list
5
- All
6
- - RocketJob::Worker.aasm.states.map { |s| s.name.to_s }.each do |state|
7
- %li{class: state}
8
- = link_to("#{state}_workers".to_sym) do
9
- %i.fa{class: state_icon(state)}
10
- = state.to_s.capitalize!
11
- = "(#{worker_counts_by_state(state)})"
12
- / tiny only nav
13
- %ul#xs-menu.nav.visible-xs
14
- %li
15
- = link_to(workers_path) do
16
- %i.fa.fa-list
17
- - RocketJob::Worker.aasm.states.map { |s| s.name.to_s }.each do |state|
18
- %li{class: state}
19
- = link_to("#{state}_workers".to_sym) do
20
- %i.fa{class: state_icon(state)}
@@ -1,15 +0,0 @@
1
- default_options: &default_options
2
- :w: 1
3
- :pool_size: 5
4
- :pool_timeout: 5
5
- :connect_timeout: 5
6
- :reconnect_attempts: 53
7
- :reconnect_retry_seconds: 0.1
8
- :reconnect_retry_multiplier: 2
9
- :reconnect_max_retry_seconds: 5
10
- :read: :nearest
11
-
12
- test:
13
- uri: mongodb://localhost:27017/rocket_job_mission_control
14
- options:
15
- <<: *default_options
@@ -1,16 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module RocketJobMissionControl
4
- RSpec.describe WorkersHelper, type: :helper do
5
- describe '#worker_card_class' do
6
- context 'when the worker is a zombie' do
7
- let(:worker) { spy(zombie?: true) }
8
-
9
- it 'returns the correct class' do
10
- expect(helper.worker_card_class(worker)).to eq('callout-zombie')
11
- end
12
- end
13
-
14
- end
15
- end
16
- end
@@ -1,35 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe RocketJobMissionControl::Jobs::Search do
4
-
5
- let(:search_term) { "bad[^$" }
6
- let(:expected_result) { [] }
7
- let(:search_subset) { spy("query_builder", where: expected_result) }
8
-
9
- subject { described_class.new(search_term, search_subset) }
10
-
11
- it 'escapes the search_term' do
12
- expect(subject.search_term).to eq('bad\\[\\^\\$')
13
- end
14
-
15
- describe '#execute' do
16
- before { subject.execute }
17
-
18
- describe 'with blank search terms' do
19
- let(:search_term) { "" }
20
-
21
- it 'does not search' do
22
- expect(search_subset).to_not have_received(:where)
23
- end
24
- end
25
-
26
- describe 'with search terms' do
27
- let(:search_term) { "job[" }
28
-
29
- it 'searches for the search term' do
30
- expect(search_subset).to have_received(:where).with({"$or"=>[{:_type=>/job\[/i}, {:description=>/job\[/i}]})
31
- end
32
- end
33
- end
34
-
35
- end