kuroko2 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/app/controllers/kuroko2/api/application_controller.rb +4 -0
  4. data/app/controllers/kuroko2/api/job_definitions_controller.rb +64 -0
  5. data/app/controllers/kuroko2/job_definitions_controller.rb +9 -2
  6. data/app/errors/http/unprocessable_entity.rb +4 -0
  7. data/app/models/kuroko2/api/job_definition_resource.rb +11 -0
  8. data/app/models/kuroko2/job_definition.rb +1 -1
  9. data/app/views/kuroko2/job_definitions/_alert.html.slim +1 -1
  10. data/app/views/kuroko2/job_definitions/_list.html.slim +4 -1
  11. data/app/views/kuroko2/job_definitions/_search_results.html.slim +4 -1
  12. data/app/views/kuroko2/job_definitions/show.html.slim +4 -2
  13. data/app/views/kuroko2/job_timelines/dataset.json.jbuilder +1 -1
  14. data/app/views/kuroko2/users/index.html.slim +1 -1
  15. data/config/routes.rb +2 -2
  16. data/db/migrate/030_add_notify_back_to_normal.rb +5 -0
  17. data/lib/autoload/kuroko2/workflow/engine.rb +6 -2
  18. data/lib/autoload/kuroko2/workflow/notifier/concerns/chat_message_builder.rb +4 -0
  19. data/lib/autoload/kuroko2/workflow/notifier/hipchat.rb +5 -0
  20. data/lib/autoload/kuroko2/workflow/notifier/mail.rb +4 -0
  21. data/lib/autoload/kuroko2/workflow/notifier/slack.rb +7 -0
  22. data/lib/autoload/kuroko2/workflow/notifier/webhook.rb +10 -0
  23. data/lib/kuroko2/version.rb +1 -1
  24. data/spec/controllers/job_definitions_controller_spec.rb +62 -0
  25. data/spec/dummy/db/schema.rb +133 -132
  26. data/spec/dummy/log/test.log +667 -0
  27. data/spec/features/job_instance_spec.rb +4 -5
  28. data/spec/requests/api/job_definitions_spec.rb +178 -0
  29. data/spec/workflow/engine_spec.rb +2 -0
  30. data/spec/workflow/notifier/hipchat_spec.rb +11 -0
  31. data/spec/workflow/notifier/mail_spec.rb +8 -0
  32. data/spec/workflow/notifier/slack_spec.rb +9 -0
  33. data/spec/workflow/notifier/webhook_spec.rb +11 -0
  34. metadata +9 -3
@@ -10,194 +10,195 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 29) do
13
+ ActiveRecord::Schema.define(version: 30) do
14
14
 
15
- create_table "admin_assignments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
16
- t.integer "user_id", null: false
17
- t.integer "job_definition_id", null: false
15
+ create_table "admin_assignments", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
16
+ t.integer "user_id", null: false
17
+ t.integer "job_definition_id", null: false
18
18
  t.datetime "created_at"
19
19
  t.datetime "updated_at"
20
- t.index ["user_id", "job_definition_id"], name: "user_id", unique: true, using: :btree
21
- end
22
-
23
- create_table "executions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
24
- t.string "uuid", limit: 36, null: false
25
- t.integer "job_definition_id"
26
- t.integer "job_definition_version"
27
- t.integer "job_instance_id"
28
- t.integer "token_id"
29
- t.string "queue", limit: 180, default: "@default", null: false
30
- t.text "shell", limit: 65535, null: false
31
- t.text "context", limit: 65535, null: false
32
- t.integer "pid"
33
- t.text "output", limit: 4294967295
34
- t.integer "exit_status", limit: 2
35
- t.integer "term_signal", limit: 1
20
+ t.index ["user_id", "job_definition_id"], name: "user_id", unique: true
21
+ end
22
+
23
+ create_table "executions", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
24
+ t.string "uuid", limit: 36, null: false
25
+ t.integer "job_definition_id"
26
+ t.integer "job_definition_version"
27
+ t.integer "job_instance_id"
28
+ t.integer "token_id"
29
+ t.string "queue", limit: 180, default: "@default", null: false
30
+ t.text "shell", null: false
31
+ t.text "context", null: false
32
+ t.integer "pid"
33
+ t.text "output", limit: 4294967295
34
+ t.integer "exit_status", limit: 2
35
+ t.integer "term_signal", limit: 1
36
36
  t.datetime "started_at"
37
37
  t.datetime "finished_at"
38
38
  t.datetime "mailed_at"
39
39
  t.datetime "created_at"
40
40
  t.datetime "updated_at"
41
- t.index ["job_definition_id", "token_id"], name: "job_definition_id", unique: true, using: :btree
42
- t.index ["started_at"], name: "started_at", using: :btree
43
- end
44
-
45
- create_table "job_definition_tags", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
46
- t.integer "job_definition_id", null: false
47
- t.integer "tag_id", null: false
48
- t.datetime "created_at", null: false
49
- t.datetime "updated_at", null: false
50
- t.index ["job_definition_id", "tag_id"], name: "job_definition_id", unique: true, using: :btree
51
- t.index ["tag_id"], name: "job_definition_tags_tag_id", using: :btree
52
- end
53
-
54
- create_table "job_definitions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
55
- t.integer "version", default: 0, null: false
56
- t.string "name", limit: 180, null: false
57
- t.text "description", limit: 65535, null: false
58
- t.text "script", limit: 65535, null: false
59
- t.boolean "suspended", default: false, null: false
60
- t.integer "prevent_multi", default: 1, null: false
61
- t.boolean "notify_cancellation", default: true, null: false
62
- t.string "hipchat_room", limit: 180, default: "", null: false
63
- t.boolean "hipchat_notify_finished", default: true, null: false
64
- t.string "hipchat_additional_text", limit: 180
65
- t.string "slack_channel", limit: 180, default: "", null: false
66
- t.boolean "api_allowed", default: false, null: false
41
+ t.index ["job_definition_id", "token_id"], name: "index_kuroko2_executions_on_job_definition_id_and_token_id", unique: true
42
+ t.index ["started_at"], name: "started_at"
43
+ end
44
+
45
+ create_table "job_definition_tags", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
46
+ t.integer "job_definition_id", null: false
47
+ t.integer "tag_id", null: false
48
+ t.datetime "created_at", null: false
49
+ t.datetime "updated_at", null: false
50
+ t.index ["job_definition_id", "tag_id"], name: "kuroko2_definition_tag_idx", unique: true
51
+ t.index ["tag_id"], name: "job_definition_tags_tag_id"
52
+ end
53
+
54
+ create_table "job_definitions", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
55
+ t.integer "version", default: 0, null: false
56
+ t.string "name", limit: 180, null: false
57
+ t.text "description", null: false
58
+ t.text "script", null: false
59
+ t.boolean "suspended", default: false, null: false
60
+ t.integer "prevent_multi", default: 1, null: false
61
+ t.boolean "notify_cancellation", default: true, null: false
62
+ t.string "hipchat_room", limit: 180, default: "", null: false
63
+ t.boolean "hipchat_notify_finished", default: true, null: false
64
+ t.string "hipchat_additional_text", limit: 180
65
+ t.string "slack_channel", limit: 180, default: "", null: false
66
+ t.boolean "api_allowed", default: false, null: false
67
67
  t.datetime "created_at"
68
68
  t.datetime "updated_at"
69
- t.text "webhook_url", limit: 65535
70
- t.index ["name"], name: "name", using: :btree
69
+ t.text "webhook_url"
70
+ t.index ["name"], name: "name"
71
71
  end
72
72
 
73
- create_table "job_instances", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
74
- t.integer "job_definition_id"
75
- t.integer "job_definition_version"
76
- t.text "script", limit: 65535
73
+ create_table "job_instances", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
74
+ t.integer "job_definition_id"
75
+ t.integer "job_definition_version"
76
+ t.text "script"
77
77
  t.datetime "finished_at"
78
78
  t.datetime "canceled_at"
79
79
  t.datetime "error_at"
80
80
  t.datetime "created_at"
81
81
  t.datetime "updated_at"
82
- t.index ["finished_at", "canceled_at", "job_definition_id"], name: "finished_at", using: :btree
83
- t.index ["job_definition_id"], name: "job_definition_id", using: :btree
82
+ t.boolean "retrying", default: false, null: false
83
+ t.index ["finished_at", "canceled_at", "job_definition_id"], name: "job_instance_idx"
84
+ t.index ["job_definition_id"], name: "index_kuroko2_job_instances_on_job_definition_id"
84
85
  end
85
86
 
86
- create_table "job_schedules", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
87
- t.integer "job_definition_id"
88
- t.string "cron", limit: 180
87
+ create_table "job_schedules", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
88
+ t.integer "job_definition_id"
89
+ t.string "cron", limit: 180
89
90
  t.datetime "created_at"
90
91
  t.datetime "updated_at"
91
- t.index ["job_definition_id", "cron"], name: "job_definition_id", unique: true, using: :btree
92
+ t.index ["job_definition_id", "cron"], name: "kuroko2_schedules_definition_id_cron_idx", unique: true
92
93
  end
93
94
 
94
- create_table "job_suspend_schedules", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
95
- t.integer "job_definition_id"
96
- t.string "cron", limit: 180
97
- t.datetime "created_at", null: false
98
- t.datetime "updated_at", null: false
99
- t.index ["job_definition_id", "cron"], name: "job_definition_id", unique: true, using: :btree
95
+ create_table "job_suspend_schedules", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
96
+ t.integer "job_definition_id"
97
+ t.string "cron", limit: 180
98
+ t.datetime "created_at", null: false
99
+ t.datetime "updated_at", null: false
100
+ t.index ["job_definition_id", "cron"], name: "kuroko2_suspend_schedules_definition_id_cron_idx", unique: true
100
101
  end
101
102
 
102
- create_table "logs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
103
- t.integer "job_instance_id"
104
- t.string "level", limit: 10
105
- t.text "message", limit: 4294967295
103
+ create_table "logs", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
104
+ t.integer "job_instance_id"
105
+ t.string "level", limit: 10
106
+ t.text "message", limit: 4294967295
106
107
  t.datetime "created_at"
107
108
  t.datetime "updated_at"
108
- t.index ["job_instance_id"], name: "job_instance_id", using: :btree
109
+ t.index ["job_instance_id"], name: "job_instance_id"
109
110
  end
110
111
 
111
- create_table "memory_consumption_logs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
112
- t.integer "job_instance_id"
113
- t.integer "value", null: false
114
- t.datetime "created_at", null: false
115
- t.datetime "updated_at", null: false
116
- t.index ["job_instance_id"], name: "index_memory_consumption_logs_on_job_instance_id", using: :btree
112
+ create_table "memory_consumption_logs", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
113
+ t.integer "job_instance_id"
114
+ t.integer "value", null: false
115
+ t.datetime "created_at", null: false
116
+ t.datetime "updated_at", null: false
117
+ t.index ["job_instance_id"], name: "index_kuroko2_memory_consumption_logs_on_job_instance_id"
117
118
  end
118
119
 
119
- create_table "memory_expectancies", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
120
- t.integer "expected_value", default: 0, null: false
121
- t.integer "job_definition_id"
122
- t.datetime "created_at", null: false
123
- t.datetime "updated_at", null: false
124
- t.index ["job_definition_id"], name: "index_memory_expectancies_on_job_definition_id", using: :btree
120
+ create_table "memory_expectancies", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
121
+ t.integer "expected_value", default: 0, null: false
122
+ t.integer "job_definition_id"
123
+ t.datetime "created_at", null: false
124
+ t.datetime "updated_at", null: false
125
+ t.index ["job_definition_id"], name: "index_kuroko2_memory_expectancies_on_job_definition_id"
125
126
  end
126
127
 
127
- create_table "process_signals", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
128
- t.string "hostname", limit: 180, default: "", null: false
129
- t.integer "pid", null: false
130
- t.integer "number", limit: 1, default: 15, null: false
128
+ create_table "process_signals", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
129
+ t.string "hostname", limit: 180, default: "", null: false
130
+ t.integer "pid", null: false
131
+ t.integer "number", limit: 1, default: 15, null: false
131
132
  t.datetime "started_at"
132
133
  t.datetime "created_at"
133
134
  t.datetime "updated_at"
134
- t.text "message", limit: 65535
135
- t.integer "execution_id"
136
- t.index ["execution_id"], name: "index_kuroko2_process_signals_on_execution_id", using: :btree
137
- t.index ["hostname", "started_at"], name: "hostname_started_at", using: :btree
135
+ t.text "message"
136
+ t.integer "execution_id"
137
+ t.index ["execution_id"], name: "index_kuroko2_process_signals_on_execution_id"
138
+ t.index ["hostname", "started_at"], name: "hostname_started_at"
138
139
  end
139
140
 
140
- create_table "stars", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
141
- t.integer "user_id", null: false
142
- t.integer "job_definition_id", null: false
141
+ create_table "stars", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
142
+ t.integer "user_id", null: false
143
+ t.integer "job_definition_id", null: false
143
144
  t.datetime "created_at"
144
145
  t.datetime "updated_at"
145
- t.index ["user_id", "job_definition_id"], name: "user_id", unique: true, using: :btree
146
+ t.index ["user_id", "job_definition_id"], name: "index_kuroko2_stars_on_user_id_and_job_definition_id", unique: true
146
147
  end
147
148
 
148
- create_table "tags", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
149
- t.string "name", limit: 100, null: false
150
- t.datetime "created_at", null: false
151
- t.datetime "updated_at", null: false
152
- t.index ["name"], name: "name", unique: true, using: :btree
149
+ create_table "tags", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
150
+ t.string "name", limit: 100, null: false
151
+ t.datetime "created_at", null: false
152
+ t.datetime "updated_at", null: false
153
+ t.index ["name"], name: "index_kuroko2_tags_on_name", unique: true
153
154
  end
154
155
 
155
- create_table "ticks", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
156
+ create_table "ticks", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
156
157
  t.datetime "at"
157
158
  end
158
159
 
159
- create_table "tokens", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
160
- t.string "uuid", limit: 36, null: false
161
- t.integer "job_definition_id"
162
- t.integer "job_definition_version"
163
- t.integer "job_instance_id"
164
- t.integer "parent_id"
165
- t.text "script", limit: 65535, null: false
166
- t.string "path", limit: 180, default: "/", null: false
167
- t.integer "status", default: 0, null: false
168
- t.text "message", limit: 65535, null: false
169
- t.text "context", limit: 65535, null: false
160
+ create_table "tokens", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
161
+ t.string "uuid", limit: 36, null: false
162
+ t.integer "job_definition_id"
163
+ t.integer "job_definition_version"
164
+ t.integer "job_instance_id"
165
+ t.integer "parent_id"
166
+ t.text "script", null: false
167
+ t.string "path", limit: 180, default: "/", null: false
168
+ t.integer "status", default: 0, null: false
169
+ t.text "message", null: false
170
+ t.text "context", null: false
170
171
  t.datetime "created_at"
171
172
  t.datetime "updated_at"
172
- t.index ["parent_id"], name: "parent_id", using: :btree
173
- t.index ["status"], name: "status", using: :btree
174
- end
175
-
176
- create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
177
- t.string "provider", limit: 180, default: "google_oauth2", null: false
178
- t.string "uid", limit: 180, null: false
179
- t.string "name", limit: 180, default: "", null: false
180
- t.string "email", limit: 180, null: false
181
- t.string "first_name", limit: 180, default: "", null: false
182
- t.string "last_name", limit: 180, default: "", null: false
183
- t.string "image", limit: 180, default: "", null: false
173
+ t.index ["parent_id"], name: "parent_id"
174
+ t.index ["status"], name: "status"
175
+ end
176
+
177
+ create_table "users", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
178
+ t.string "provider", limit: 180, default: "google_oauth2", null: false
179
+ t.string "uid", limit: 180, null: false
180
+ t.string "name", limit: 180, default: "", null: false
181
+ t.string "email", limit: 180, null: false
182
+ t.string "first_name", limit: 180, default: "", null: false
183
+ t.string "last_name", limit: 180, default: "", null: false
184
+ t.string "image", limit: 180, default: "", null: false
184
185
  t.datetime "suspended_at"
185
186
  t.datetime "created_at"
186
187
  t.datetime "updated_at"
187
- t.index ["email"], name: "email", using: :btree
188
- t.index ["uid", "suspended_at"], name: "uid_2", using: :btree
189
- t.index ["uid"], name: "uid", unique: true, using: :btree
188
+ t.index ["email"], name: "email"
189
+ t.index ["uid", "suspended_at"], name: "uid_2"
190
+ t.index ["uid"], name: "uid", unique: true
190
191
  end
191
192
 
192
- create_table "workers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
193
- t.string "hostname", limit: 180, null: false
194
- t.integer "worker_id", limit: 1, null: false
195
- t.string "queue", limit: 180, default: "@default", null: false
196
- t.boolean "working", default: false, null: false
197
- t.integer "execution_id"
193
+ create_table "workers", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
194
+ t.string "hostname", limit: 180, null: false
195
+ t.integer "worker_id", limit: 1, null: false
196
+ t.string "queue", limit: 180, default: "@default", null: false
197
+ t.boolean "working", default: false, null: false
198
+ t.integer "execution_id"
198
199
  t.datetime "created_at"
199
200
  t.datetime "updated_at"
200
- t.index ["hostname", "worker_id"], name: "hostname", unique: true, using: :btree
201
+ t.index ["hostname", "worker_id"], name: "hostname", unique: true
201
202
  end
202
203
 
203
204
  end