rocketjob_mission_control 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/rocket_job_mission_control/application.js +1 -0
- data/app/assets/javascripts/rocket_job_mission_control/dirmon_entries.js.coffee +5 -8
- data/app/assets/javascripts/rocket_job_mission_control/selectize.js.coffee +5 -0
- data/app/assets/stylesheets/rocket_job_mission_control/application.scss +2 -0
- data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +58 -9
- data/app/controllers/rocket_job_mission_control/jobs_controller.rb +5 -1
- data/app/models/job_failures.rb +3 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/_form.html.haml +13 -16
- data/app/views/rocket_job_mission_control/dirmon_entries/_properties.html.haml +38 -8
- data/app/views/rocket_job_mission_control/dirmon_entries/_status.html.haml +13 -8
- data/app/views/rocket_job_mission_control/jobs/running.html.haml +1 -2
- data/app/views/rocket_job_mission_control/jobs/show.html.haml +1 -1
- data/lib/rocket_job_mission_control/engine.rb +1 -0
- data/lib/rocket_job_mission_control/version.rb +1 -1
- data/spec/controllers/dirmon_entries_controller_spec.rb +90 -65
- data/spec/dummy/log/development.log +2 -0
- data/spec/dummy/log/test.log +12275 -0
- data/spec/rails_helper.rb +2 -2
- metadata +17 -3
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../rails_helper'
|
2
2
|
|
3
3
|
class FakeButGoodJob < RocketJob::Job
|
4
4
|
|
@@ -29,11 +29,11 @@ module RocketJobMissionControl
|
|
29
29
|
|
30
30
|
let(:existing_dirmon) do
|
31
31
|
RocketJob::DirmonEntry.create!(
|
32
|
-
name:
|
33
|
-
job_class_name:
|
34
|
-
pattern:
|
35
|
-
arguments:
|
36
|
-
state:
|
32
|
+
name: 'Test',
|
33
|
+
job_class_name: 'FakeButGoodJob',
|
34
|
+
pattern: 'the_path',
|
35
|
+
arguments: ['42'],
|
36
|
+
state: starting_state,
|
37
37
|
)
|
38
38
|
end
|
39
39
|
|
@@ -61,11 +61,11 @@ module RocketJobMissionControl
|
|
61
61
|
describe 'PATCH #disable' do
|
62
62
|
let(:existing_dirmon) do
|
63
63
|
RocketJob::DirmonEntry.create!(
|
64
|
-
name:
|
65
|
-
job_class_name:
|
66
|
-
pattern:
|
67
|
-
arguments:
|
68
|
-
state:
|
64
|
+
name: 'Test',
|
65
|
+
job_class_name: 'FakeButGoodJob',
|
66
|
+
pattern: 'the_path',
|
67
|
+
arguments: ['42'],
|
68
|
+
state: starting_state,
|
69
69
|
)
|
70
70
|
end
|
71
71
|
|
@@ -78,7 +78,7 @@ module RocketJobMissionControl
|
|
78
78
|
|
79
79
|
it { expect(response).to redirect_to(dirmon_entry_path(existing_dirmon.id)) }
|
80
80
|
|
81
|
-
it
|
81
|
+
it 'changes the state to disabled' do
|
82
82
|
expect(existing_dirmon.reload.state).to eq(:disabled)
|
83
83
|
end
|
84
84
|
end
|
@@ -95,8 +95,10 @@ module RocketJobMissionControl
|
|
95
95
|
end
|
96
96
|
|
97
97
|
describe 'GET #new' do
|
98
|
+
let(:entry_params) { {} }
|
99
|
+
|
98
100
|
before do
|
99
|
-
get :new
|
101
|
+
get :new, entry_params
|
100
102
|
end
|
101
103
|
|
102
104
|
it { expect(response.status).to eq(200) }
|
@@ -105,15 +107,37 @@ module RocketJobMissionControl
|
|
105
107
|
expect(assigns(:dirmon_entry)).to be_present
|
106
108
|
expect(assigns(:dirmon_entry)).to_not be_persisted
|
107
109
|
end
|
110
|
+
|
111
|
+
context 'with a valid job_class_name' do
|
112
|
+
let(:entry_params) { { job_class_name: 'FakeButGoodJob' } }
|
113
|
+
|
114
|
+
it { expect(response.status).to eq(200) }
|
115
|
+
|
116
|
+
it 'assigns the job class' do
|
117
|
+
expect(assigns(:dirmon_entry)).to be_present
|
118
|
+
expect(assigns(:dirmon_entry).job_class).to eq(FakeButGoodJob)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'with an invalid job_class_name' do
|
123
|
+
let(:entry_params) { { job_class_name: 'BadJob' } }
|
124
|
+
|
125
|
+
it { expect(response.status).to eq(200) }
|
126
|
+
|
127
|
+
it 'adds an error' do
|
128
|
+
expect(assigns(:dirmon_entry)).to be_present
|
129
|
+
expect(assigns(:dirmon_entry).errors[:job_class_name]).to be_present
|
130
|
+
end
|
131
|
+
end
|
108
132
|
end
|
109
133
|
|
110
134
|
describe 'PATCH #update' do
|
111
135
|
let(:existing_dirmon) do
|
112
136
|
RocketJob::DirmonEntry.create!(
|
113
|
-
name:
|
114
|
-
job_class_name:
|
115
|
-
pattern:
|
116
|
-
arguments:
|
137
|
+
name: 'Test',
|
138
|
+
job_class_name: 'FakeButGoodJob',
|
139
|
+
pattern: 'the_path',
|
140
|
+
arguments: ['{"argument1":"value1", "argument2":"value2", "argument3":"value3"}']
|
117
141
|
)
|
118
142
|
end
|
119
143
|
|
@@ -124,9 +148,9 @@ module RocketJobMissionControl
|
|
124
148
|
context 'with valid parameters' do
|
125
149
|
let(:dirmon_params) do
|
126
150
|
{
|
127
|
-
pattern:
|
128
|
-
job_class_name:
|
129
|
-
arguments:
|
151
|
+
pattern: 'the_path2',
|
152
|
+
job_class_name: 'FakeButGoodJob',
|
153
|
+
arguments: ['42']
|
130
154
|
}
|
131
155
|
end
|
132
156
|
|
@@ -166,9 +190,9 @@ module RocketJobMissionControl
|
|
166
190
|
context 'with invalid arguments json' do
|
167
191
|
let(:dirmon_params) do
|
168
192
|
{
|
169
|
-
name:
|
193
|
+
name: 'Test',
|
170
194
|
job_class_name: 'FakeButGoodJob',
|
171
|
-
arguments:
|
195
|
+
arguments: [],
|
172
196
|
}
|
173
197
|
end
|
174
198
|
|
@@ -192,17 +216,18 @@ module RocketJobMissionControl
|
|
192
216
|
context 'with valid parameters' do
|
193
217
|
|
194
218
|
{
|
195
|
-
perform:
|
196
|
-
|
219
|
+
perform: {argument: ['42'], expected_value: [42]},
|
220
|
+
perform: {argument: ['{"argument1":"value1", "argument2":"value2", "argument3":"value3"}'], expected_value: [{"argument1" => "value1", "argument2" => "value2", "argument3" => "value3"}]},
|
221
|
+
perform_with_no_params: {argument: [], expected_value: []},
|
197
222
|
}.each_pair do |perform_method, arguments|
|
198
223
|
context "and arguments are '#{arguments}'" do
|
199
224
|
let(:dirmon_params) do
|
200
225
|
{
|
201
|
-
name:
|
202
|
-
pattern:
|
226
|
+
name: 'Test',
|
227
|
+
pattern: '/files/*',
|
203
228
|
job_class_name: 'FakeButGoodJob',
|
204
|
-
arguments:
|
205
|
-
properties:
|
229
|
+
arguments: arguments[:argument],
|
230
|
+
properties: {description: '', priority: 42},
|
206
231
|
perform_method: perform_method,
|
207
232
|
}
|
208
233
|
end
|
@@ -251,9 +276,9 @@ module RocketJobMissionControl
|
|
251
276
|
context 'with invalid parameters' do
|
252
277
|
let(:dirmon_params) do
|
253
278
|
{
|
254
|
-
name:
|
279
|
+
name: 'Test',
|
255
280
|
job_class_name: 'FakeAndBadJob',
|
256
|
-
arguments:
|
281
|
+
arguments: [[42].to_json],
|
257
282
|
}
|
258
283
|
end
|
259
284
|
|
@@ -279,9 +304,9 @@ module RocketJobMissionControl
|
|
279
304
|
context 'with invalid arguments json' do
|
280
305
|
let(:dirmon_params) do
|
281
306
|
{
|
282
|
-
name:
|
307
|
+
name: 'Test',
|
283
308
|
job_class_name: 'FakeButGoodJob',
|
284
|
-
arguments: "
|
309
|
+
arguments: ['{"bad" "json"}'],
|
285
310
|
}
|
286
311
|
end
|
287
312
|
|
@@ -304,10 +329,10 @@ module RocketJobMissionControl
|
|
304
329
|
describe 'GET #edit' do
|
305
330
|
before do
|
306
331
|
@entry = RocketJob::DirmonEntry.create(
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
332
|
+
name: 'Test',
|
333
|
+
pattern: '/files/',
|
334
|
+
job_class_name: 'FakeButGoodJob',
|
335
|
+
arguments: [42]
|
311
336
|
)
|
312
337
|
get :edit, id: @entry.id
|
313
338
|
end
|
@@ -321,40 +346,40 @@ module RocketJobMissionControl
|
|
321
346
|
end
|
322
347
|
|
323
348
|
describe 'GET #show' do
|
324
|
-
describe
|
349
|
+
describe 'with an invalid id' do
|
325
350
|
before do
|
326
351
|
allow(RocketJob::DirmonEntry).to receive(:find).and_return(nil)
|
327
352
|
get :show, id: 42
|
328
353
|
end
|
329
354
|
|
330
|
-
it
|
355
|
+
it 'redirects' do
|
331
356
|
expect(response).to redirect_to(dirmon_entries_path)
|
332
357
|
end
|
333
358
|
|
334
|
-
it
|
359
|
+
it 'adds a flash alert message' do
|
335
360
|
expect(flash[:alert]).to eq(I18n.t(:failure, scope: [:dirmon_entry, :find], id: 42))
|
336
361
|
end
|
337
362
|
end
|
338
363
|
|
339
|
-
describe
|
364
|
+
describe 'with a valid id' do
|
340
365
|
before do
|
341
366
|
allow(RocketJob::DirmonEntry).to receive(:find).and_return('entry')
|
342
367
|
get :show, id: 42
|
343
368
|
end
|
344
369
|
|
345
|
-
it
|
370
|
+
it 'succeeds' do
|
346
371
|
expect(response.status).to be(200)
|
347
372
|
end
|
348
373
|
|
349
|
-
it
|
374
|
+
it 'assigns the entry' do
|
350
375
|
expect(assigns(:dirmon_entry)).to be_present
|
351
376
|
end
|
352
377
|
|
353
|
-
it
|
378
|
+
it 'assigns the entries' do
|
354
379
|
expect(assigns(:dirmons)).to eq([])
|
355
380
|
end
|
356
381
|
|
357
|
-
it
|
382
|
+
it 'grabs a sorted list' do
|
358
383
|
expect(dirmon_list).to have_received(:sort).with(created_at: :desc)
|
359
384
|
end
|
360
385
|
end
|
@@ -363,10 +388,10 @@ module RocketJobMissionControl
|
|
363
388
|
describe 'DELETE #destroy' do
|
364
389
|
let(:existing_dirmon) do
|
365
390
|
RocketJob::DirmonEntry.create!(
|
366
|
-
name:
|
367
|
-
job_class_name:
|
368
|
-
pattern:
|
369
|
-
arguments:
|
391
|
+
name: 'Test',
|
392
|
+
job_class_name: 'FakeButGoodJob',
|
393
|
+
pattern: 'the_path',
|
394
|
+
arguments: [42].to_json
|
370
395
|
)
|
371
396
|
end
|
372
397
|
|
@@ -388,73 +413,73 @@ module RocketJobMissionControl
|
|
388
413
|
end
|
389
414
|
|
390
415
|
describe 'GET #index' do
|
391
|
-
describe
|
416
|
+
describe 'with no entries' do
|
392
417
|
before do
|
393
418
|
get :index
|
394
419
|
end
|
395
420
|
|
396
|
-
it
|
421
|
+
it 'succeeds' do
|
397
422
|
expect(response.status).to be(200)
|
398
423
|
end
|
399
424
|
|
400
|
-
it
|
425
|
+
it 'grabs a sorted list of entries' do
|
401
426
|
expect(dirmon_list).to have_received(:sort).with(created_at: :desc)
|
402
427
|
end
|
403
428
|
|
404
|
-
it
|
429
|
+
it 'returns no entries' do
|
405
430
|
expect(assigns(:dirmons)).to eq([])
|
406
431
|
end
|
407
432
|
end
|
408
433
|
|
409
|
-
describe
|
434
|
+
describe 'with jobs' do
|
410
435
|
let(:dirmon_list) { spy(sort: dirmons) }
|
411
436
|
let(:dirmons) { ['fake_dirmon1', 'fake_dirmon2'] }
|
412
437
|
|
413
|
-
describe
|
438
|
+
describe 'with no parameters' do
|
414
439
|
before { get :index }
|
415
440
|
|
416
|
-
it
|
441
|
+
it 'succeeds' do
|
417
442
|
expect(response.status).to be(200)
|
418
443
|
end
|
419
444
|
|
420
|
-
it
|
445
|
+
it 'grabs a sorted list of entries' do
|
421
446
|
expect(dirmon_list).to have_received(:sort).with(created_at: :desc)
|
422
447
|
end
|
423
448
|
|
424
|
-
it
|
449
|
+
it 'returns the entries' do
|
425
450
|
expect(assigns(:dirmons)).to match_array(dirmons)
|
426
451
|
end
|
427
452
|
end
|
428
453
|
|
429
|
-
describe
|
430
|
-
before { get :index, states: states}
|
454
|
+
describe 'with a state filter' do
|
455
|
+
before { get :index, states: states }
|
431
456
|
|
432
|
-
context
|
457
|
+
context 'that is empty' do
|
433
458
|
let(:states) { [] }
|
434
459
|
|
435
460
|
it { expect(response.status).to be(200) }
|
436
461
|
|
437
|
-
it
|
462
|
+
it 'grabs a sorted list' do
|
438
463
|
expect(dirmon_list).to have_received(:sort).with(created_at: :desc)
|
439
464
|
end
|
440
465
|
|
441
|
-
it
|
466
|
+
it 'returns the entries' do
|
442
467
|
expect(assigns(:dirmons)).to match_array(dirmons)
|
443
468
|
end
|
444
469
|
end
|
445
470
|
|
446
|
-
context
|
471
|
+
context 'with a state' do
|
447
472
|
let(:query_spy) { spy(where: dirmons) }
|
448
473
|
let(:dirmon_list) { spy(sort: query_spy) }
|
449
474
|
let(:states) { ['enabled'] }
|
450
475
|
|
451
476
|
it { expect(response.status).to be(200) }
|
452
477
|
|
453
|
-
it
|
478
|
+
it 'grabs a filtered list' do
|
454
479
|
expect(query_spy).to have_received(:where).with(state: ['enabled'])
|
455
480
|
end
|
456
481
|
|
457
|
-
it
|
482
|
+
it 'returns the entries' do
|
458
483
|
expect(assigns(:dirmons)).to match_array(dirmons)
|
459
484
|
end
|
460
485
|
end
|
@@ -1,2 +1,4 @@
|
|
1
1
|
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
2
2
|
MONGODB (0.5ms) admin['$cmd'].find({:isMaster=>1}).limit(-1)
|
3
|
+
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
4
|
+
MONGODB (0.4ms) admin['$cmd'].find({:isMaster=>1}).limit(-1)
|