kuroko2 0.4.3 → 0.4.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 +4 -4
- data/README.md +1 -0
- data/app/controllers/kuroko2/api/application_controller.rb +4 -0
- data/app/controllers/kuroko2/api/job_definitions_controller.rb +64 -0
- data/app/controllers/kuroko2/job_definitions_controller.rb +9 -2
- data/app/errors/http/unprocessable_entity.rb +4 -0
- data/app/models/kuroko2/api/job_definition_resource.rb +11 -0
- data/app/models/kuroko2/job_definition.rb +1 -1
- data/app/views/kuroko2/job_definitions/_alert.html.slim +1 -1
- data/app/views/kuroko2/job_definitions/_list.html.slim +4 -1
- data/app/views/kuroko2/job_definitions/_search_results.html.slim +4 -1
- data/app/views/kuroko2/job_definitions/show.html.slim +4 -2
- data/app/views/kuroko2/job_timelines/dataset.json.jbuilder +1 -1
- data/app/views/kuroko2/users/index.html.slim +1 -1
- data/config/routes.rb +2 -2
- data/db/migrate/030_add_notify_back_to_normal.rb +5 -0
- data/lib/autoload/kuroko2/workflow/engine.rb +6 -2
- data/lib/autoload/kuroko2/workflow/notifier/concerns/chat_message_builder.rb +4 -0
- data/lib/autoload/kuroko2/workflow/notifier/hipchat.rb +5 -0
- data/lib/autoload/kuroko2/workflow/notifier/mail.rb +4 -0
- data/lib/autoload/kuroko2/workflow/notifier/slack.rb +7 -0
- data/lib/autoload/kuroko2/workflow/notifier/webhook.rb +10 -0
- data/lib/kuroko2/version.rb +1 -1
- data/spec/controllers/job_definitions_controller_spec.rb +62 -0
- data/spec/dummy/db/schema.rb +133 -132
- data/spec/dummy/log/test.log +667 -0
- data/spec/features/job_instance_spec.rb +4 -5
- data/spec/requests/api/job_definitions_spec.rb +178 -0
- data/spec/workflow/engine_spec.rb +2 -0
- data/spec/workflow/notifier/hipchat_spec.rb +11 -0
- data/spec/workflow/notifier/mail_spec.rb +8 -0
- data/spec/workflow/notifier/slack_spec.rb +9 -0
- data/spec/workflow/notifier/webhook_spec.rb +11 -0
- metadata +9 -3
@@ -21,14 +21,13 @@ RSpec.describe "Launches a job instace and Management job instances on the web c
|
|
21
21
|
|
22
22
|
expect(page).to have_content('Job Definition Details')
|
23
23
|
expect(page).to have_content(job_definition.name)
|
24
|
-
|
24
|
+
find_button('Launch').trigger(:click)
|
25
25
|
|
26
26
|
expect(page).to have_selector('#launchAdHocModal .modal-dialog', visible: true)
|
27
27
|
within '#launchAdHocModal .modal-dialog' do
|
28
|
-
|
28
|
+
find_button('Launch').trigger(:click)
|
29
29
|
end
|
30
30
|
|
31
|
-
sleep 1
|
32
31
|
expect(page).to have_content('Job Instance Details')
|
33
32
|
expect(page).to have_selector('#instance-status .label', text: 'WORKING')
|
34
33
|
|
@@ -58,7 +57,7 @@ RSpec.describe "Launches a job instace and Management job instances on the web c
|
|
58
57
|
visit kuroko2.job_definition_job_instance_path(job_definition, job_definition.job_instances.first)
|
59
58
|
expect(page).to have_selector('#instance-status .label', text: 'ERROR')
|
60
59
|
|
61
|
-
|
60
|
+
find_button('Skip').trigger(:click)
|
62
61
|
|
63
62
|
sleep(2) # wait for setInterval, 2000
|
64
63
|
expect(page).to have_selector('#instance-status .label', text: 'SUCCESS')
|
@@ -85,7 +84,7 @@ RSpec.describe "Launches a job instace and Management job instances on the web c
|
|
85
84
|
expect(page).to have_selector('#instance-status .label', text: 'ERROR')
|
86
85
|
|
87
86
|
within '#instance' do
|
88
|
-
|
87
|
+
find_link('Cancel').trigger(:click)
|
89
88
|
end
|
90
89
|
|
91
90
|
sleep(2) # wait for setInterval, 2000
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'job_definitions' do
|
4
|
+
let(:service_name) { :test_client_name }
|
5
|
+
let(:secret_key) { 'secret_key' }
|
6
|
+
let(:env) do
|
7
|
+
{
|
8
|
+
accept: 'application/json',
|
9
|
+
authorization: "Basic #{Base64.encode64("#{service_name}:#{secret_key}")}",
|
10
|
+
}
|
11
|
+
end
|
12
|
+
let(:result) { JSON.parse(response.body) }
|
13
|
+
|
14
|
+
describe 'POST /v1/definitions' do
|
15
|
+
|
16
|
+
let(:user) do
|
17
|
+
create(:user)
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with valid parameters' do
|
21
|
+
let(:params) do
|
22
|
+
{
|
23
|
+
name: "test",
|
24
|
+
description: "description",
|
25
|
+
script: "noop:",
|
26
|
+
notify_cancellation: 1,
|
27
|
+
hipchat_room: "",
|
28
|
+
hipchat_notify_finished: 1,
|
29
|
+
suspended: false,
|
30
|
+
prevent_multi: 1,
|
31
|
+
hipchat_additional_text: "",
|
32
|
+
text_tags: "",
|
33
|
+
api_allowed: 1,
|
34
|
+
slack_channel: "",
|
35
|
+
webhook_url: "",
|
36
|
+
user_id: [user.id],
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'creates a new definition' do
|
41
|
+
expect {
|
42
|
+
post "/v1/definitions", params: params, env: env
|
43
|
+
}.to change {
|
44
|
+
Kuroko2::JobDefinition.count
|
45
|
+
}.by(1)
|
46
|
+
expect(result['name']).to eq(params[:name])
|
47
|
+
expect(result['description']).to eq(params[:description])
|
48
|
+
expect(result['script']).to eq(params[:script])
|
49
|
+
expect(response.status).to eq(201)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with invalid parameters' do
|
54
|
+
let(:params) do
|
55
|
+
{
|
56
|
+
description: "description",
|
57
|
+
script: "noop:",
|
58
|
+
notify_cancellation: 1,
|
59
|
+
hipchat_room: "",
|
60
|
+
hipchat_notify_finished: 1,
|
61
|
+
suspended: false,
|
62
|
+
prevent_multi: 1,
|
63
|
+
hipchat_additional_text: "",
|
64
|
+
text_tags: "",
|
65
|
+
api_allowed: 1,
|
66
|
+
slack_channel: "",
|
67
|
+
webhook_url: "",
|
68
|
+
user_id: [user.id],
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns Http Status: 422' do
|
73
|
+
post "/v1/definitions", params: params, env: env
|
74
|
+
expect(response.status).to eq(422)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe 'GET /v1/definitions/:id' do
|
80
|
+
let(:definition) do
|
81
|
+
create(:job_definition, script: 'noop:', api_allowed: true)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'returns a definition' do
|
85
|
+
get "/v1/definitions/#{definition.id}", params: {}, env: env
|
86
|
+
expect(result).to eq(
|
87
|
+
{
|
88
|
+
'id' => definition.id,
|
89
|
+
'name' => definition.name,
|
90
|
+
'description' => definition.description,
|
91
|
+
'script' => definition.script
|
92
|
+
}
|
93
|
+
)
|
94
|
+
expect(response.status).to eq(200)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe 'PUT /v1/definitions/:id' do
|
99
|
+
let(:definition) do
|
100
|
+
create(:job_definition, script: 'noop:', api_allowed: true)
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'with valid parameters' do
|
104
|
+
let(:params) do
|
105
|
+
{
|
106
|
+
name: "test",
|
107
|
+
description: "description",
|
108
|
+
script: "echo: Hello",
|
109
|
+
notify_cancellation: 1,
|
110
|
+
hipchat_room: "",
|
111
|
+
hipchat_notify_finished: 1,
|
112
|
+
suspended: false,
|
113
|
+
prevent_multi: 1,
|
114
|
+
hipchat_additional_text: "",
|
115
|
+
text_tags: "",
|
116
|
+
api_allowed: 1,
|
117
|
+
slack_channel: "",
|
118
|
+
webhook_url: "",
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'updates a definition' do
|
123
|
+
put "/v1/definitions/#{definition.id}", params: params, env: env
|
124
|
+
expect(response.status).to eq(204)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'with invalid parameters' do
|
129
|
+
let(:params) do
|
130
|
+
{
|
131
|
+
name: "test",
|
132
|
+
description: "description",
|
133
|
+
script: "noop",
|
134
|
+
notify_cancellation: 1,
|
135
|
+
hipchat_room: "",
|
136
|
+
hipchat_notify_finished: 1,
|
137
|
+
suspended: false,
|
138
|
+
prevent_multi: 1,
|
139
|
+
hipchat_additional_text: "",
|
140
|
+
text_tags: "",
|
141
|
+
api_allowed: 1,
|
142
|
+
slack_channel: "",
|
143
|
+
webhook_url: "",
|
144
|
+
}
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'returns Http Status: 422' do
|
148
|
+
put "/v1/definitions/#{definition.id}", params: params, env: env
|
149
|
+
expect(response.status).to eq(422)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'with a undefined definition' do
|
154
|
+
let(:params) do
|
155
|
+
{
|
156
|
+
name: "test",
|
157
|
+
description: "description",
|
158
|
+
script: "echo: Hello",
|
159
|
+
notify_cancellation: 1,
|
160
|
+
hipchat_room: "",
|
161
|
+
hipchat_notify_finished: 1,
|
162
|
+
suspended: false,
|
163
|
+
prevent_multi: 1,
|
164
|
+
hipchat_additional_text: "",
|
165
|
+
text_tags: "",
|
166
|
+
api_allowed: 1,
|
167
|
+
slack_channel: "",
|
168
|
+
webhook_url: "",
|
169
|
+
}
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'returns Http Status: 404' do
|
173
|
+
put "/v1/definitions/#{definition.id + 1}", params: params, env: env
|
174
|
+
expect(response.status).to eq(404)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -125,6 +125,17 @@ module Kuroko2::Workflow
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
describe '#notify_back_to_normal' do
|
129
|
+
it 'sends back_to_normal message' do
|
130
|
+
expect(hipchat_room_object).to receive(:send) do |_, message, option|
|
131
|
+
expect(message).to include('SUCCESS')
|
132
|
+
expect(option[:color]).to eq('green')
|
133
|
+
end
|
134
|
+
|
135
|
+
notifier.notify_back_to_normal
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
128
139
|
describe '#notify_retrying' do
|
129
140
|
context 'with notify_finished' do
|
130
141
|
before do
|
@@ -67,6 +67,14 @@ module Kuroko2::Workflow
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
describe '#notify_back_to_normal' do
|
71
|
+
it 'does not send mail' do
|
72
|
+
expect { notifier.notify_back_to_normal }.not_to change {
|
73
|
+
ActionMailer::Base.deliveries.size
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
70
78
|
describe '#notify_long_elapsed_time' do
|
71
79
|
it 'sends warning mesasge' do
|
72
80
|
expect { notifier.notify_long_elapsed_time }.to change {
|
@@ -90,6 +90,15 @@ module Kuroko2::Workflow
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
+
describe '#notify_back_to_normal' do
|
94
|
+
it 'sends back_to_normal mesasge' do
|
95
|
+
expect(notifier).to receive(:send_to_slack).
|
96
|
+
with(hash_including(channel: slack_channel)).and_call_original
|
97
|
+
|
98
|
+
notifier.notify_back_to_normal
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
93
102
|
describe '#notify_retrying' do
|
94
103
|
context 'with notify_finished' do
|
95
104
|
before do
|
@@ -72,6 +72,17 @@ module Kuroko2::Workflow
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
describe '#notify_back_to_normal' do
|
76
|
+
it 'sends back_to_normal message' do
|
77
|
+
stub.with { |req|
|
78
|
+
expect(JSON.parse(req.body)).to include("action"=>"notify_back_to_normal")
|
79
|
+
}
|
80
|
+
|
81
|
+
notifier.notify_back_to_normal
|
82
|
+
expect(stub).to have_been_requested
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
75
86
|
describe '#notify_retrying' do
|
76
87
|
context 'with notify_finished' do
|
77
88
|
before do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuroko2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naoto Takai
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -561,6 +561,7 @@ files:
|
|
561
561
|
- app/assets/stylesheets/kuroko2/job_definitions.scss
|
562
562
|
- app/assets/stylesheets/kuroko2/users.scss
|
563
563
|
- app/controllers/kuroko2/api/application_controller.rb
|
564
|
+
- app/controllers/kuroko2/api/job_definitions_controller.rb
|
564
565
|
- app/controllers/kuroko2/api/job_instances_controller.rb
|
565
566
|
- app/controllers/kuroko2/api/stats_controller.rb
|
566
567
|
- app/controllers/kuroko2/application_controller.rb
|
@@ -582,6 +583,7 @@ files:
|
|
582
583
|
- app/errors/http/bad_request.rb
|
583
584
|
- app/errors/http/forbidden.rb
|
584
585
|
- app/errors/http/unauthorized.rb
|
586
|
+
- app/errors/http/unprocessable_entity.rb
|
585
587
|
- app/helpers/kuroko2/application_helper.rb
|
586
588
|
- app/helpers/kuroko2/dashboard_helper.rb
|
587
589
|
- app/helpers/kuroko2/executions_helper.rb
|
@@ -600,6 +602,7 @@ files:
|
|
600
602
|
- app/models/concerns/kuroko2/table_name_customizable.rb
|
601
603
|
- app/models/kuroko2/admin_assignment.rb
|
602
604
|
- app/models/kuroko2/api/application_resource.rb
|
605
|
+
- app/models/kuroko2/api/job_definition_resource.rb
|
603
606
|
- app/models/kuroko2/api/job_instance_resource.rb
|
604
607
|
- app/models/kuroko2/application_record.rb
|
605
608
|
- app/models/kuroko2/execution.rb
|
@@ -693,6 +696,7 @@ files:
|
|
693
696
|
- db/migrate/027_drop_uniq_constraint_user_email.rb
|
694
697
|
- db/migrate/028_change_exit_status_to_unsigned_tinyint.rb
|
695
698
|
- db/migrate/029_add_execution_id_to_process_signals.rb
|
699
|
+
- db/migrate/030_add_notify_back_to_normal.rb
|
696
700
|
- lib/autoload/kuroko2/command/executor.rb
|
697
701
|
- lib/autoload/kuroko2/command/kill.rb
|
698
702
|
- lib/autoload/kuroko2/command/monitor.rb
|
@@ -1773,6 +1777,7 @@ files:
|
|
1773
1777
|
- spec/models/user_spec.rb
|
1774
1778
|
- spec/models/worker_spec.rb
|
1775
1779
|
- spec/rails_helper.rb
|
1780
|
+
- spec/requests/api/job_definitions_spec.rb
|
1776
1781
|
- spec/requests/api/job_instances_spec.rb
|
1777
1782
|
- spec/requests/api/stats_spec.rb
|
1778
1783
|
- spec/return_to_validator_spec.rb
|
@@ -1822,7 +1827,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1822
1827
|
version: '0'
|
1823
1828
|
requirements: []
|
1824
1829
|
rubyforge_project:
|
1825
|
-
rubygems_version: 2.
|
1830
|
+
rubygems_version: 2.5.2.1
|
1826
1831
|
signing_key:
|
1827
1832
|
specification_version: 4
|
1828
1833
|
summary: Kuroko2 is a web-based job scheduler/workflow manager.
|
@@ -2852,6 +2857,7 @@ test_files:
|
|
2852
2857
|
- spec/models/user_spec.rb
|
2853
2858
|
- spec/models/worker_spec.rb
|
2854
2859
|
- spec/rails_helper.rb
|
2860
|
+
- spec/requests/api/job_definitions_spec.rb
|
2855
2861
|
- spec/requests/api/job_instances_spec.rb
|
2856
2862
|
- spec/requests/api/stats_spec.rb
|
2857
2863
|
- spec/return_to_validator_spec.rb
|