kaya 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +26 -0
- data/CHANGELOG +52 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/NOTAS +19 -0
- data/README.md +279 -0
- data/Rakefile +1 -0
- data/bin/kaya +4 -0
- data/documentation/api.md +47 -0
- data/documentation/api_execution_data.md +47 -0
- data/documentation/configuration.md +13 -0
- data/documentation/custom_parameters.md +117 -0
- data/documentation/document_kaya.md +122 -0
- data/documentation/link.md +12 -0
- data/documentation/results.md +119 -0
- data/documentation/start.md +19 -0
- data/documentation/suites.md +60 -0
- data/documentation/test_suite_information.md +9 -0
- data/kaya.gemspec +42 -0
- data/lib/generators/task_rack.rb +160 -0
- data/lib/generators/templates/Gemfile.tt +2 -0
- data/lib/generators/templates/config.ru.tt +2 -0
- data/lib/generators/templates/kaya_conf.tt +49 -0
- data/lib/generators/templates/kaya_log.tt +0 -0
- data/lib/generators/templates/sidekiq_log.tt +0 -0
- data/lib/generators/templates/tasks.kaya.tt +10 -0
- data/lib/generators/templates/unicorn.rb.tt +21 -0
- data/lib/kaya/API/error.rb +17 -0
- data/lib/kaya/API/execution.rb +141 -0
- data/lib/kaya/API/result.rb +49 -0
- data/lib/kaya/API/results.rb +31 -0
- data/lib/kaya/API/suite.rb +42 -0
- data/lib/kaya/API/suites.rb +36 -0
- data/lib/kaya/background_jobs/sidekiq.rb +35 -0
- data/lib/kaya/background_jobs/workers/execution_checker.rb +20 -0
- data/lib/kaya/background_jobs/workers/garbage_cleaner.rb +31 -0
- data/lib/kaya/commands/bye.rb +12 -0
- data/lib/kaya/commands/help.rb +13 -0
- data/lib/kaya/commands/install.rb +27 -0
- data/lib/kaya/commands/reset.rb +39 -0
- data/lib/kaya/commands/reset_suites.rb +40 -0
- data/lib/kaya/commands/restart.rb +9 -0
- data/lib/kaya/commands/start.rb +104 -0
- data/lib/kaya/commands/stop.rb +53 -0
- data/lib/kaya/cuba.rb +287 -0
- data/lib/kaya/cucumber/features.rb +15 -0
- data/lib/kaya/cucumber/task.rb +64 -0
- data/lib/kaya/custom/execution_data.rb +50 -0
- data/lib/kaya/custom/params.rb +34 -0
- data/lib/kaya/database/mongo_connector.rb +285 -0
- data/lib/kaya/error/errors.rb +55 -0
- data/lib/kaya/execution.rb +57 -0
- data/lib/kaya/results/result.rb +493 -0
- data/lib/kaya/results/results.rb +47 -0
- data/lib/kaya/suites/custom/params.rb +151 -0
- data/lib/kaya/suites/suite.rb +177 -0
- data/lib/kaya/suites/suites.rb +130 -0
- data/lib/kaya/support/clean.rb +12 -0
- data/lib/kaya/support/configuration.rb +254 -0
- data/lib/kaya/support/console.rb +11 -0
- data/lib/kaya/support/documentation.rb +34 -0
- data/lib/kaya/support/error_handler_helper.rb +24 -0
- data/lib/kaya/support/files_cleanner.rb +136 -0
- data/lib/kaya/support/git.rb +161 -0
- data/lib/kaya/support/if_config.rb +14 -0
- data/lib/kaya/support/logo.rb +23 -0
- data/lib/kaya/support/logs.rb +37 -0
- data/lib/kaya/support/notification.rb +127 -0
- data/lib/kaya/support/processes.rb +96 -0
- data/lib/kaya/support/query_string.rb +22 -0
- data/lib/kaya/support/request.rb +32 -0
- data/lib/kaya/support/risk.rb +9 -0
- data/lib/kaya/support/time_helper.rb +11 -0
- data/lib/kaya/support/update.rb +65 -0
- data/lib/kaya/version.rb +3 -0
- data/lib/kaya/view/body.mote +60 -0
- data/lib/kaya/view/custom/params/select_list.mote +14 -0
- data/lib/kaya/view/custom/params/text.mote +9 -0
- data/lib/kaya/view/custom/params.mote +9 -0
- data/lib/kaya/view/error_handler.mote +40 -0
- data/lib/kaya/view/features/feature.mote +14 -0
- data/lib/kaya/view/features/features_list.mote +10 -0
- data/lib/kaya/view/features.mote +57 -0
- data/lib/kaya/view/footer.mote +10 -0
- data/lib/kaya/view/git_information.mote +21 -0
- data/lib/kaya/view/help/main.mote +21 -0
- data/lib/kaya/view/help/page.mote +2 -0
- data/lib/kaya/view/help/search_result.mote +29 -0
- data/lib/kaya/view/help.mote +72 -0
- data/lib/kaya/view/javascript.mote +96 -0
- data/lib/kaya/view/logs/log.mote +3 -0
- data/lib/kaya/view/modals.mote +31 -0
- data/lib/kaya/view/navigation_bar.mote +48 -0
- data/lib/kaya/view/not_found.mote +40 -0
- data/lib/kaya/view/parser.rb +79 -0
- data/lib/kaya/view/results/all.mote +59 -0
- data/lib/kaya/view/results/console.mote +106 -0
- data/lib/kaya/view/results/detailed_info.mote +112 -0
- data/lib/kaya/view/results/report.mote +1 -0
- data/lib/kaya/view/results/result.mote +23 -0
- data/lib/kaya/view/results/results.mote +52 -0
- data/lib/kaya/view/screenshot.mote +42 -0
- data/lib/kaya/view/sections.rb +25 -0
- data/lib/kaya/view/styles.mote +58 -0
- data/lib/kaya/view/suites/suite.mote +73 -0
- data/lib/kaya/view/suites/suites.mote +9 -0
- data/lib/kaya/view/view.rb +72 -0
- data/lib/kaya.rb +175 -0
- data/test/features/install.feature +18 -0
- data/test/features/support/env.rb +3 -0
- metadata +395 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
module Kaya
|
2
|
+
module Commands
|
3
|
+
def self.stop
|
4
|
+
|
5
|
+
$K_LOG.debug "#{self}:#{__method__}" if $K_LOG
|
6
|
+
|
7
|
+
Kaya::Support::Configuration.get
|
8
|
+
|
9
|
+
# Get pids from saved file on start process
|
10
|
+
if File.exist? "#{Dir.pwd}/kaya/kaya_pids"
|
11
|
+
|
12
|
+
kaya_pids = IO.read("#{Dir.pwd}/kaya/kaya_pids").split("\n")
|
13
|
+
# Kill all pids specified on file
|
14
|
+
|
15
|
+
begin
|
16
|
+
Kaya::Support::Processes.kill_all_these kaya_pids
|
17
|
+
rescue
|
18
|
+
end
|
19
|
+
|
20
|
+
# Delete pid file
|
21
|
+
File.delete("#{Dir.pwd}/kaya/kaya_pids")
|
22
|
+
end
|
23
|
+
|
24
|
+
if File.exist? "#{Dir.pwd}/kaya/sidekiq_pid"
|
25
|
+
|
26
|
+
sidekiq_pid = IO.read("#{Dir.pwd}/kaya/sidekiq_pid").split("\n")
|
27
|
+
|
28
|
+
begin
|
29
|
+
Kaya::Support::Processes.kill_all_these sidekiq_pid
|
30
|
+
rescue
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
File.delete("#{Dir.pwd}/kaya/sidekiq_pid")
|
35
|
+
end
|
36
|
+
|
37
|
+
# Evaluates if any pid could not be killed (retry)
|
38
|
+
Kaya::Support::Processes.kill_all_these(Kaya::Support::Processes.kaya_pids)
|
39
|
+
|
40
|
+
if Kaya::Support::Processes.kaya_pids.empty?
|
41
|
+
|
42
|
+
puts "
|
43
|
+
Kaya stopped!"
|
44
|
+
|
45
|
+
else
|
46
|
+
puts "
|
47
|
+
Could not stop Kaya.
|
48
|
+
If Kaya is still running please type `kaya help` to get some help"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
data/lib/kaya/cuba.rb
ADDED
@@ -0,0 +1,287 @@
|
|
1
|
+
require "cuba"
|
2
|
+
|
3
|
+
include Mote::Helpers
|
4
|
+
|
5
|
+
Cuba.define do
|
6
|
+
|
7
|
+
$suites_counter = 0
|
8
|
+
|
9
|
+
request = Kaya::Support::Request.new(req)
|
10
|
+
|
11
|
+
$K_LOG.debug "REQUEST '#{request.path}#{request.path_info}' FROM IP: '#{request.ip}'" if $K_LOG
|
12
|
+
|
13
|
+
begin
|
14
|
+
|
15
|
+
|
16
|
+
# ========================================================================
|
17
|
+
# COMMON INIT
|
18
|
+
#
|
19
|
+
#
|
20
|
+
Kaya::Support::Configuration.get
|
21
|
+
|
22
|
+
Kaya::Database::MongoConnector.new Kaya::Support::Configuration.db_connection_data
|
23
|
+
|
24
|
+
on get do
|
25
|
+
|
26
|
+
HOSTNAME = Kaya::Support::Configuration.hostname
|
27
|
+
|
28
|
+
# ========================================================================
|
29
|
+
# HELP
|
30
|
+
#
|
31
|
+
#
|
32
|
+
on "#{HOSTNAME}/kaya/help/:page" do |page|
|
33
|
+
query_string = Kaya::Support::QueryString.new req
|
34
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/help.mote"),self, [:page, :query_string])
|
35
|
+
res.write template.call(page:page, query_string:query_string.s)
|
36
|
+
end
|
37
|
+
|
38
|
+
on "#{HOSTNAME}/kaya/help" do
|
39
|
+
res.redirect "/#{HOSTNAME}/kaya/help/main"
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# ========================================================================
|
44
|
+
# VIEW ROUTES
|
45
|
+
#
|
46
|
+
#
|
47
|
+
#
|
48
|
+
on "#{HOSTNAME}/kaya/results/log/:result_id" do |result_id|
|
49
|
+
result = Kaya::Results::Result.get(result_id)
|
50
|
+
res.redirect "/#{HOSTNAME}/kaya/404/There%20is%20no%20result%20for%20id=#{result_id}" if result.nil?
|
51
|
+
result.mark_as_saw! if (result.finished? or result.stopped?)
|
52
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/results/console.mote"),self, [:result])
|
53
|
+
res.write template.call(result:result)
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
on "#{HOSTNAME}/kaya/results/report/:result_id" do |result_id|
|
58
|
+
result = Kaya::Results::Result.get(result_id)
|
59
|
+
res.redirect "/#{HOSTNAME}/kaya/404/There%20is%20no%20result%20for%20id=#{result_id}" if result.nil?
|
60
|
+
result.mark_as_saw! if (result.finished? or result.stopped?)
|
61
|
+
if result.finished? and !result.stopped? and result.html_report.size > 0
|
62
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/results/report.mote"),self, [:result])
|
63
|
+
res.write template.call(result:result)
|
64
|
+
else
|
65
|
+
res.redirect "#{HOSTNAME}/kaya/results/log/result_id"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
on "#{HOSTNAME}/kaya/results/:result_id/reset" do |result_id|
|
70
|
+
result = Kaya::API::Execution.reset(result_id)
|
71
|
+
res.redirect "/#{HOSTNAME}/kaya/results?msg=#{result['message']}"
|
72
|
+
end
|
73
|
+
|
74
|
+
on "#{HOSTNAME}/kaya/results/suite/:suite_name" do |suite_name|
|
75
|
+
query_string = Kaya::Support::QueryString.new req
|
76
|
+
suite_name.gsub!("%20"," ")
|
77
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/body.mote"),self, [:section, :query_string, :suite_name, :log_name])
|
78
|
+
res.write template.call(section:"Results", query_string:query_string, suite_name:suite_name, log_name:nil)
|
79
|
+
end
|
80
|
+
|
81
|
+
on "#{HOSTNAME}/kaya/results/all" do
|
82
|
+
query_string = Kaya::Support::QueryString.new req
|
83
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/body.mote"),self, [:section, :query_string, :suite_name, :log_name])
|
84
|
+
res.write template.call(section:"All Results", query_string:query_string, suite_name:nil, log_name:nil)
|
85
|
+
end
|
86
|
+
|
87
|
+
on "#{HOSTNAME}/kaya/results" do
|
88
|
+
query_string = Kaya::Support::QueryString.new req
|
89
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/body.mote"),self, [:section, :query_string, :suite_name, :log_name])
|
90
|
+
res.write template.call(section:"Results", query_string:query_string, suite_name:nil, log_name:nil)
|
91
|
+
end
|
92
|
+
|
93
|
+
on "#{HOSTNAME}/kaya/suites/:suite/run" do |suite_name|
|
94
|
+
query_string = Kaya::Support::QueryString.new req
|
95
|
+
result = Kaya::API::Execution.start suite_name, query_string.values
|
96
|
+
|
97
|
+
path = "/#{HOSTNAME}/kaya/suites"
|
98
|
+
path += "?msg=#{result['message']}. " if result["message"]
|
99
|
+
path += "Execution id=#{result["execution_id"]}" if result["execution_id"]
|
100
|
+
|
101
|
+
res.status= result["status"]
|
102
|
+
res.redirect path
|
103
|
+
end
|
104
|
+
|
105
|
+
on "#{HOSTNAME}/kaya/suites/:suite_name" do |suite_name|
|
106
|
+
query_string = Kaya::Support::QueryString.new req
|
107
|
+
(Kaya::Support::Git.reset_hard and Kaya::Support::Git.pull) if Kaya::Support::Configuration.use_git?
|
108
|
+
Kaya::Suites.update_suites
|
109
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/body.mote"),self, [:section, :query_string, :suite_name, :log_name])
|
110
|
+
res.write template.call(section:"Test Suites", query_string:query_string, suite_name:suite_name, log_name:nil)
|
111
|
+
end
|
112
|
+
|
113
|
+
on "#{HOSTNAME}/kaya/suites" do
|
114
|
+
query_string = Kaya::Support::QueryString.new req
|
115
|
+
(Kaya::Support::Git.reset_hard and Kaya::Support::Git.pull) if Kaya::Support::Configuration.use_git?
|
116
|
+
Kaya::Suites.update_suites
|
117
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/body.mote"),self, [:section, :query_string, :suite_name, :log_name])
|
118
|
+
res.write template.call(section:"Test Suites", query_string:query_string, suite_name:nil, log_name:nil)
|
119
|
+
end
|
120
|
+
|
121
|
+
on "#{HOSTNAME}/kaya/logs/:log_name" do |log_name|
|
122
|
+
query_string = Kaya::Support::QueryString.new req
|
123
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/body.mote"),self, [:section, :query_string, :suite_name, :log_name])
|
124
|
+
res.write template.call(section:"Logs", query_string:query_string, suite_name:nil, log_name:log_name)
|
125
|
+
end
|
126
|
+
|
127
|
+
# ========================================================================
|
128
|
+
# SCREENSHOTS
|
129
|
+
#
|
130
|
+
#
|
131
|
+
|
132
|
+
on "#{HOSTNAME}/kaya/screenshot/:file_name" do |file_name|
|
133
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/screenshot.mote"),self, [:file_name])
|
134
|
+
res.write template.call(file_name:file_name)
|
135
|
+
end
|
136
|
+
|
137
|
+
# ========================================================================
|
138
|
+
# FEATURE SHOW
|
139
|
+
#
|
140
|
+
#
|
141
|
+
on "#{HOSTNAME}/kaya/features/file" do
|
142
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/features.mote"),self, [:query_string])
|
143
|
+
res.write template.call(query_string:Kaya::Support::QueryString.new(req))
|
144
|
+
end
|
145
|
+
|
146
|
+
# ========================================================================
|
147
|
+
# FEATURES / LIST
|
148
|
+
#
|
149
|
+
#
|
150
|
+
on "#{HOSTNAME}/kaya/features" do
|
151
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/features.mote"),self, [:query_string])
|
152
|
+
res.write template.call(query_string:Kaya::Support::QueryString.new(req))
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
# ========================================================================
|
157
|
+
# API ROUTES
|
158
|
+
#
|
159
|
+
#
|
160
|
+
#
|
161
|
+
on "#{HOSTNAME}/kaya/api/version" do
|
162
|
+
output = { "version" => Kaya::VERSION}
|
163
|
+
res.write output.to_json
|
164
|
+
end
|
165
|
+
|
166
|
+
on "#{HOSTNAME}/kaya/api/results/:id/data" do |result_id|
|
167
|
+
output = Kaya::API::Result.data(result_id)
|
168
|
+
res.write output.to_json
|
169
|
+
end
|
170
|
+
|
171
|
+
on "#{HOSTNAME}/kaya/api/results/:id/status" do |result_id|
|
172
|
+
output = Kaya::API::Result.status(result_id)
|
173
|
+
res.write output.to_json
|
174
|
+
end
|
175
|
+
|
176
|
+
on "#{HOSTNAME}/kaya/api/results/:id" do |result_id|
|
177
|
+
res.write(Kaya::API::Result.info(result_id).to_json)
|
178
|
+
end
|
179
|
+
|
180
|
+
on "#{HOSTNAME}/kaya/api/results/:id/reset" do |result_id|
|
181
|
+
result = Kaya::API::Execution.reset(result_id)
|
182
|
+
res.write result.to_json
|
183
|
+
end
|
184
|
+
|
185
|
+
on "#{HOSTNAME}/kaya/api/suites/:suite/run" do |suite_name|
|
186
|
+
query_string = Kaya::Support::QueryString.new req
|
187
|
+
result = Kaya::API::Execution.start suite_name, query_string.values
|
188
|
+
res.write result.to_json
|
189
|
+
end
|
190
|
+
|
191
|
+
on "#{HOSTNAME}/kaya/api/suites/:id/status" do |suite_id|
|
192
|
+
output = Kaya::API::Suite.status(suite_id.to_i)
|
193
|
+
res.write output.to_json
|
194
|
+
end
|
195
|
+
|
196
|
+
on "#{HOSTNAME}/kaya/api/suites/running" do
|
197
|
+
output = Kaya::API::Suites.list({running:true})
|
198
|
+
res.write output
|
199
|
+
end
|
200
|
+
|
201
|
+
on "#{HOSTNAME}/kaya/api/suites/active" do
|
202
|
+
output = Kaya::API::Suites.list({"active" => true})
|
203
|
+
res.write output.to_json
|
204
|
+
end
|
205
|
+
|
206
|
+
on "#{HOSTNAME}/kaya/api/suites/unactive" do
|
207
|
+
output = Kaya::API::Suites.list({"active" => false})
|
208
|
+
res.write output.to_json
|
209
|
+
end
|
210
|
+
|
211
|
+
on "#{HOSTNAME}/kaya/api/suites/:id" do |suite_id|
|
212
|
+
output = Kaya::API::Suite.info(suite_id)
|
213
|
+
res.write output.to_json
|
214
|
+
end
|
215
|
+
|
216
|
+
on "#{HOSTNAME}/kaya/api/suites" do
|
217
|
+
(Kaya::Support::Git.reset_hard and Kaya::Support::Git.pull) if Kaya::Support::Configuration.use_git?
|
218
|
+
Kaya::Suites.update_suites
|
219
|
+
output = Kaya::API::Suites.list({"active" => true})
|
220
|
+
res.write output.to_json
|
221
|
+
end
|
222
|
+
|
223
|
+
on "#{HOSTNAME}/kaya/api/results" do
|
224
|
+
output = Kaya::API::Results.show()
|
225
|
+
res.write output.to_json
|
226
|
+
end
|
227
|
+
|
228
|
+
on "#{HOSTNAME}/kaya/api/error" do
|
229
|
+
query_string = Kaya::Support::QueryString.new req
|
230
|
+
output = Kaya::API::Error.show(query_string)
|
231
|
+
res.write output.to_json
|
232
|
+
end
|
233
|
+
|
234
|
+
on "#{HOSTNAME}/kaya/api" do
|
235
|
+
response = {"message" => "Please, refer to /#{HOSTNAME}/kaya/help/api for more information"}
|
236
|
+
res.write response.to_json
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
# ========================================================================
|
242
|
+
# CLEAN
|
243
|
+
#
|
244
|
+
#
|
245
|
+
on "#{HOSTNAME}/kaya/clean" do
|
246
|
+
Kaya::Support::Clean.start
|
247
|
+
res.redirect "/#{HOSTNAME}/kaya/suites?msg=Suites and results cleanned"
|
248
|
+
end
|
249
|
+
|
250
|
+
# ========================================================================
|
251
|
+
# REDIRECTS
|
252
|
+
#
|
253
|
+
on "#{HOSTNAME}/kaya/help" do
|
254
|
+
res.redirect "/#{HOSTNAME}/kaya/help/main"
|
255
|
+
end
|
256
|
+
|
257
|
+
on "#{HOSTNAME}/kaya/404" do
|
258
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/not_found.mote"),self, [])
|
259
|
+
res.write template.call()
|
260
|
+
end
|
261
|
+
|
262
|
+
on "#{HOSTNAME}/kaya/:any" do
|
263
|
+
res.redirect("/#{HOSTNAME}/kaya/suites")
|
264
|
+
end
|
265
|
+
|
266
|
+
on "#{HOSTNAME}/kaya" do
|
267
|
+
res.redirect "/#{HOSTNAME}/kaya/suites"
|
268
|
+
end
|
269
|
+
|
270
|
+
on "favicon" do
|
271
|
+
res.write ""
|
272
|
+
end
|
273
|
+
|
274
|
+
on "#{HOSTNAME}" do
|
275
|
+
res.redirect "/#{HOSTNAME}/kaya/suites"
|
276
|
+
end
|
277
|
+
|
278
|
+
on root do
|
279
|
+
res.redirect "/#{HOSTNAME}/kaya/suites"
|
280
|
+
end
|
281
|
+
end
|
282
|
+
rescue => e
|
283
|
+
$K_LOG.error "Cuba: #{e} #{e.backtrace}" if $K_LOG
|
284
|
+
template = Mote.parse(File.read("#{Kaya::View.path}/error_handler.mote"),self, [:exception])
|
285
|
+
res.write template.call(exception:e)
|
286
|
+
end
|
287
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Kaya
|
2
|
+
module Cucumber
|
3
|
+
module Features
|
4
|
+
|
5
|
+
# Returns an array of all feature files paths (only feature files)
|
6
|
+
# @return [Array]
|
7
|
+
def self.feature_files_names
|
8
|
+
Dir['**/*.*'].select do |file_path_name|
|
9
|
+
file_path_name.start_with? "features/" and file_path_name.end_with? ".feature"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
|
6
|
+
module Kaya
|
7
|
+
module Cucumber
|
8
|
+
class Task
|
9
|
+
|
10
|
+
def self.run result
|
11
|
+
|
12
|
+
result.kaya_report_file_name= "kaya_report_#{result.id}.html"
|
13
|
+
|
14
|
+
begin
|
15
|
+
File.delete("#{Dir.pwd}/Gemfile.lock")
|
16
|
+
rescue
|
17
|
+
end
|
18
|
+
|
19
|
+
bundle_output = Kaya::Support::Console.execute "bundle install"
|
20
|
+
$K_LOG.debug "[result:#{result.id}] Bundle install performed" if $K_LOG
|
21
|
+
|
22
|
+
result.save_to_bundle_output bundle_output
|
23
|
+
|
24
|
+
unless bundle_output.include? "Could not find"
|
25
|
+
|
26
|
+
# Adding _id=result.id to use inside execution the posiibility to add information to the result
|
27
|
+
result.kaya_command= "#{Kaya::Support::Configuration.headless?} bundle exec cucumber #{result.command} -f pretty -f html -o kaya/temp/#{result.kaya_report_file_name} #{result.custom_params_values} _id=#{result.id} "
|
28
|
+
|
29
|
+
result.console_output_file_name= "kaya_co_#{result.id}.out"
|
30
|
+
|
31
|
+
result.save!
|
32
|
+
|
33
|
+
command = "#{result.kaya_command} 2>&1 | tee -a kaya/temp/#{result.console_output_file_name}"
|
34
|
+
|
35
|
+
$K_LOG.debug "[result:#{result.id}] Running in headless mode" if $K_LOG and Kaya::Support::Configuration.headless?
|
36
|
+
|
37
|
+
Dir.mkdir "#{Dir.pwd}/kaya/temp" unless Dir.exist? "#{Dir.pwd}/kaya/temp"
|
38
|
+
|
39
|
+
|
40
|
+
$K_LOG.debug "[result:#{result.id}] Creating process" if $K_LOG
|
41
|
+
result.pid= Kaya::Support::Processes.fork_this command
|
42
|
+
$K_LOG.debug "[result:#{result.id}] Process (#{result.pid}) exec'in" if $K_LOG
|
43
|
+
|
44
|
+
$K_LOG.debug "[result:#{result.id}] Running saved command}" if $K_LOG
|
45
|
+
|
46
|
+
result.running!
|
47
|
+
|
48
|
+
$K_LOG.debug "[result:#{result.id}] Result setted as running" if $K_LOG
|
49
|
+
|
50
|
+
result.append_result_to_console_output!
|
51
|
+
|
52
|
+
result.save_report!
|
53
|
+
|
54
|
+
result.save!
|
55
|
+
|
56
|
+
result.append_result_to_console_output!
|
57
|
+
|
58
|
+
end # unless
|
59
|
+
|
60
|
+
end # end self.run
|
61
|
+
|
62
|
+
end #end Task class
|
63
|
+
end # enc Cucumber module
|
64
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Kaya
|
2
|
+
module Custom
|
3
|
+
class ExecutionData
|
4
|
+
|
5
|
+
# This class is used from execution code. It means that user can call this method to store information
|
6
|
+
# during exdecution.
|
7
|
+
|
8
|
+
# Returns execution id
|
9
|
+
def self.id
|
10
|
+
ENV["_id"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.is_there_result?
|
14
|
+
Kaya::Database::MongoConnector.result_data_for_id(self.id)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Stores a key => value pair to the result
|
18
|
+
# @param [String or Symbol] key
|
19
|
+
# @param [Any] value
|
20
|
+
# @return hash if stored, nil if not
|
21
|
+
def self.add key=nil, value=nil
|
22
|
+
self.ensure_db_connection
|
23
|
+
if self.is_there_result?
|
24
|
+
result = self.get_result
|
25
|
+
if result and result.running?
|
26
|
+
result.add_execution_data key, value if key
|
27
|
+
{key => value}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.get_result
|
33
|
+
Kaya::Results::Result.get(self.id)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns result execution data if exist. Else returns an empty hash
|
37
|
+
def self.get_data
|
38
|
+
self.is_there_result? ? self.get_result.execution_data : {}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Conntects to database if not connected
|
42
|
+
def self.ensure_db_connection
|
43
|
+
Kaya::Support::Configuration.get
|
44
|
+
Kaya::Database::MongoConnector.new(Kaya::Support::Configuration.db_connection_data) unless Kaya::Database::MongoConnector.connected?
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Kaya
|
2
|
+
module Custom
|
3
|
+
class Params
|
4
|
+
|
5
|
+
# This class is used to provide to user in his code access to the custom params sent
|
6
|
+
# from Kaya
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
params = ENV || {}
|
10
|
+
@custom_params = if params["kaya_custom_params"]
|
11
|
+
JSON.parse(params["kaya_custom_params"])
|
12
|
+
else
|
13
|
+
params
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get
|
18
|
+
self.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def all_params
|
22
|
+
@custom_params
|
23
|
+
end
|
24
|
+
|
25
|
+
def raw; all_params; end
|
26
|
+
|
27
|
+
# All custom params can be called as methods
|
28
|
+
def method_missing(param, *args, &block)
|
29
|
+
@custom_params[param.to_s]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|