kaya 0.0.1
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 +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,141 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module API
|
|
3
|
+
class Execution
|
|
4
|
+
def self.start suite_name, query_string
|
|
5
|
+
$K_LOG.debug "Starting suite #{suite_name}" if $K_LOG
|
|
6
|
+
|
|
7
|
+
suite_name.gsub!("%20", " ")
|
|
8
|
+
|
|
9
|
+
git_log = Kaya::Support::Configuration.use_git? ? Kaya::Support::Git.log_last_commit : ""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
unless query_string.empty?
|
|
13
|
+
|
|
14
|
+
execution_name = query_string.delete("execution_name") if query_string.has_key? "execution_name"
|
|
15
|
+
query_string.each_pair do |param, value|
|
|
16
|
+
query_string.delete(param) if (value =~ /Enter/ or value.nil? or value == "")
|
|
17
|
+
end
|
|
18
|
+
custom_params = query_string || {}
|
|
19
|
+
|
|
20
|
+
else
|
|
21
|
+
execution_name = nil
|
|
22
|
+
custom_params = {}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
if Kaya::Suites.is_there_suite_with? suite_name
|
|
26
|
+
$K_LOG.debug "Suite #{suite_name} found" if $K_LOG
|
|
27
|
+
|
|
28
|
+
# suite_id = Kaya::Suites.suite_id_for suite_name
|
|
29
|
+
|
|
30
|
+
suite = Kaya::Suites::Suite.get_suite_with(suite_name)
|
|
31
|
+
|
|
32
|
+
if suite.is_ready?
|
|
33
|
+
|
|
34
|
+
$K_LOG.debug "Suite #{suite_name} is ready to run" if $K_LOG
|
|
35
|
+
|
|
36
|
+
execution_request_data = {
|
|
37
|
+
"type" => "cucumber",
|
|
38
|
+
"suite" => {"id" => suite.id, "name" => suite.name},
|
|
39
|
+
"execution_name" => execution_name,
|
|
40
|
+
"custom_params" => custom_params,
|
|
41
|
+
"git_log" => git_log
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
suite.last_result = Kaya::Execution.run!(execution_request_data) # Returns result_id
|
|
46
|
+
|
|
47
|
+
suite.set_running!
|
|
48
|
+
|
|
49
|
+
$K_LOG.debug "Suite #{suite_name} setted as running" if $K_LOG
|
|
50
|
+
|
|
51
|
+
suite.save!
|
|
52
|
+
|
|
53
|
+
# Starts workers
|
|
54
|
+
Kaya::Workers::ExecutionChecker.perform_async(suite.id) # Work until execution finish
|
|
55
|
+
|
|
56
|
+
# Kaya::Workers::GarbageCleaner.perform_async # Clean all zombies files
|
|
57
|
+
|
|
58
|
+
# suite_id = suite.id
|
|
59
|
+
execution_id = suite.last_result
|
|
60
|
+
started = true
|
|
61
|
+
message = "Suite%20#{suite.name}%20started"
|
|
62
|
+
status = 200
|
|
63
|
+
$K_LOG.error "Suite #{suite.name} started" if $K_LOG
|
|
64
|
+
|
|
65
|
+
else
|
|
66
|
+
# suite_id = suite.id
|
|
67
|
+
execution_id = nil
|
|
68
|
+
started = false
|
|
69
|
+
status = 423
|
|
70
|
+
message = "Requested%20suite%20#{suite.name}%20is%20still%20running"
|
|
71
|
+
$K_LOG.error "Suite #{suite_name} not started. It is still running" if $K_LOG
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
else # No suite for suite_name
|
|
75
|
+
$K_LOG.error "Suite not found for name #{suite_name}" if $K_LOG
|
|
76
|
+
# suite_id = nil
|
|
77
|
+
started = false
|
|
78
|
+
execution_id = nil
|
|
79
|
+
status = 404
|
|
80
|
+
message = "Suite #{suite_name} not found"
|
|
81
|
+
end
|
|
82
|
+
{
|
|
83
|
+
"suite" => {
|
|
84
|
+
"name" => suite_name,
|
|
85
|
+
"id" => suite.id,
|
|
86
|
+
"started" => started
|
|
87
|
+
},
|
|
88
|
+
"execution_id" => execution_id,
|
|
89
|
+
"message" => message,
|
|
90
|
+
"status" => status
|
|
91
|
+
}
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# RESET EXECUTION
|
|
95
|
+
#
|
|
96
|
+
# Kill associated process to the running execution
|
|
97
|
+
# Sets as finished the result and associated suite as READY
|
|
98
|
+
#
|
|
99
|
+
def self.reset(result_id)
|
|
100
|
+
|
|
101
|
+
$K_LOG.debug "Reset execution request for #{result_id}"
|
|
102
|
+
|
|
103
|
+
result = Kaya::Results::Result.get(result_id)
|
|
104
|
+
|
|
105
|
+
suite = Kaya::Suites::Suite.get(result.suite_id)
|
|
106
|
+
|
|
107
|
+
if result.process_running? or !result.finished? or !result.stopped?
|
|
108
|
+
|
|
109
|
+
begin
|
|
110
|
+
Kaya::Support::Processes.kill_by_result_id(result.id)
|
|
111
|
+
killed = true
|
|
112
|
+
$K_LOG.debug "Execution (id=#{results.id}) killed"
|
|
113
|
+
rescue => e
|
|
114
|
+
$K_LOG.error "#{e}#{e.backtrace}"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
begin
|
|
118
|
+
Kaya::Support::FilesCleanner.delete_report_which_has(result.id)
|
|
119
|
+
$K_LOG.debug "Execution files(id=#{result.id}) cleanned"
|
|
120
|
+
cleanned = true
|
|
121
|
+
rescue
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
result.append_result_to_console_output!
|
|
125
|
+
result.save_report!
|
|
126
|
+
result.reset!("forced"); $K_LOG.debug "Execution stopped! Kaya restarted"
|
|
127
|
+
result.show_as = "pending"
|
|
128
|
+
result.save!
|
|
129
|
+
# Reset if suite is setted as "RUNNING" and its result_id value corresponds to the result reset request
|
|
130
|
+
suite.set_ready! if suite.last_result == result.id
|
|
131
|
+
if killed and cleanned
|
|
132
|
+
{"message" => "Execution stopped"}
|
|
133
|
+
else
|
|
134
|
+
{"message" => "Could not stop execution. Process killing: #{filled}. Files cleanned: #{celanned}"}
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module API
|
|
3
|
+
class Result
|
|
4
|
+
def self.get_for_suite(suite_id)
|
|
5
|
+
suite = Kaya::Suites::Suite.get(suite_id)
|
|
6
|
+
if suite
|
|
7
|
+
{
|
|
8
|
+
"project_name" => Dir.pwd.split("/").last,
|
|
9
|
+
"suite" => {id:suite.id, name:suite.name},
|
|
10
|
+
"results" => results_list_for(suite.id)
|
|
11
|
+
}
|
|
12
|
+
else
|
|
13
|
+
{"results" => results_list}
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.results_list_for(suite_id)
|
|
18
|
+
suite_results = Kaya::Results.results_ids_for(suite_id)
|
|
19
|
+
suite_results.map do |result_id|
|
|
20
|
+
info(result_id)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.info(result_id)
|
|
25
|
+
result = Kaya::Results::Result.get(result_id)
|
|
26
|
+
if result
|
|
27
|
+
result.api_response
|
|
28
|
+
else
|
|
29
|
+
{"message" => "Result #{result_id} not found"}
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.data result_id
|
|
34
|
+
result = self.info result_id
|
|
35
|
+
{"type" => "result", "_id" => result["_id"], "status" => result["status"], "execution_data" => result["execution_data"]}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.status result_id
|
|
39
|
+
result = self.info result_id
|
|
40
|
+
{"type" => "result", "status" => result["status"]}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# def self.results_list
|
|
44
|
+
|
|
45
|
+
# end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module API
|
|
3
|
+
module Results
|
|
4
|
+
|
|
5
|
+
# @param [Hash] options = {:msg}
|
|
6
|
+
def self.show(options = {})
|
|
7
|
+
|
|
8
|
+
response = self.structure
|
|
9
|
+
response["results"] = Kaya::Results.all_results.map{|result| Kaya::API::Result.info(result["_id"])}
|
|
10
|
+
response["message"] = "No results found" if (response["size"] = response["results"].size).zero?
|
|
11
|
+
response
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.find_by_key keyword
|
|
16
|
+
response = self.structure
|
|
17
|
+
response["results"] = Kaya::Results.find_for(keyword).map{|result| Kaya::API::Result.info(result["_id"])}
|
|
18
|
+
response["message"] = "No results found" if (response["size"] = response["results"].size).zero?
|
|
19
|
+
response
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.structure
|
|
23
|
+
response = {
|
|
24
|
+
"project_name" => Dir.pwd.split("/").last,
|
|
25
|
+
"results" => []
|
|
26
|
+
}
|
|
27
|
+
response
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module API
|
|
3
|
+
|
|
4
|
+
class Suite
|
|
5
|
+
|
|
6
|
+
def self.info(suite_id)
|
|
7
|
+
suite_id = suite_id.to_i if suite_id.respond_to? :to_i
|
|
8
|
+
response = {
|
|
9
|
+
"project_name" => Dir.pwd.split("/").last,
|
|
10
|
+
"suite" => nil,
|
|
11
|
+
"message" => nil
|
|
12
|
+
}
|
|
13
|
+
suite = Kaya::Suites::Suite.get(suite_id)
|
|
14
|
+
if suite.nil?
|
|
15
|
+
response["message"] = "Suite not found"
|
|
16
|
+
else
|
|
17
|
+
response["suite"] = suite.api_response
|
|
18
|
+
end
|
|
19
|
+
response
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def self.status suite_id
|
|
24
|
+
response = info(suite_id)
|
|
25
|
+
|
|
26
|
+
output = if response["message"]
|
|
27
|
+
{
|
|
28
|
+
"suite_id" => nil,
|
|
29
|
+
"message" => response["message"]
|
|
30
|
+
}
|
|
31
|
+
else
|
|
32
|
+
{
|
|
33
|
+
"suite_id" => response["suite"]["_id"],
|
|
34
|
+
"status" => response["suite"]["status"]
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
output
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module API
|
|
3
|
+
module Suites
|
|
4
|
+
|
|
5
|
+
# @param [hash] options = {:running, :active}
|
|
6
|
+
def self.list(options ={})
|
|
7
|
+
|
|
8
|
+
response = {
|
|
9
|
+
"project_name" => Dir.pwd.split("/").last,
|
|
10
|
+
"size" => 0,
|
|
11
|
+
"suites" => [],
|
|
12
|
+
"message" => nil
|
|
13
|
+
}
|
|
14
|
+
suites = if options[:running]
|
|
15
|
+
response["request"] = "Running Suites"
|
|
16
|
+
Kaya::Suites.all_running_suites
|
|
17
|
+
else
|
|
18
|
+
response["request"] = options[:active] ? "Active Suites" : "Suites"
|
|
19
|
+
Kaya::Suites.suite_ids options[:active]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if suites.size.zero?
|
|
24
|
+
response["message"] = options[:running] ? "No running suites found" : "No suites found"
|
|
25
|
+
else
|
|
26
|
+
suites.each do |suite_id|
|
|
27
|
+
suite = Kaya::Suites::Suite.get(suite_id)
|
|
28
|
+
response["suites"] << suite.api_response
|
|
29
|
+
end
|
|
30
|
+
response["size"] = suites.size
|
|
31
|
+
end
|
|
32
|
+
response
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module BackgroundJobs
|
|
3
|
+
class Sidekiq
|
|
4
|
+
def self.start
|
|
5
|
+
|
|
6
|
+
workers_dir = workers_dir = __FILE__.split("/")[0..-2].join("/")+ "/workers"
|
|
7
|
+
|
|
8
|
+
output = Kaya::Support::Console.execute "sidekiq -r #{workers_dir}/execution_checker.rb -d -L kaya/sidekiq_log -P kaya/sidekiq_pid"
|
|
9
|
+
|
|
10
|
+
print "\n* Sidekiq:"
|
|
11
|
+
raise "Could not start Sidekiq correctly. Read kaya/sidekiq_log file for more information" if not started?
|
|
12
|
+
|
|
13
|
+
print " Started!\n"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Existance of pid file means that sidekiq was started
|
|
17
|
+
def self.started?
|
|
18
|
+
begin
|
|
19
|
+
sec = 0
|
|
20
|
+
begin
|
|
21
|
+
print "."
|
|
22
|
+
return true if IO.read("#{Dir.pwd}/kaya/sidekiq_log") =~ /INFO: Booting Sidekiq \d+.\d+.\d+ with redis options {/
|
|
23
|
+
sec += sleep 1
|
|
24
|
+
end until sec == 10
|
|
25
|
+
|
|
26
|
+
puts "Cannot start sidekiq after 10 seconds"
|
|
27
|
+
false
|
|
28
|
+
|
|
29
|
+
rescue
|
|
30
|
+
false
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'kaya'
|
|
2
|
+
|
|
3
|
+
module Kaya
|
|
4
|
+
module Workers
|
|
5
|
+
class ExecutionChecker
|
|
6
|
+
include Sidekiq::Worker
|
|
7
|
+
def perform(suite_id)
|
|
8
|
+
|
|
9
|
+
Kaya::Support::Configuration.get
|
|
10
|
+
Kaya::Database::MongoConnector.new Kaya::Support::Configuration.db_connection_data
|
|
11
|
+
|
|
12
|
+
suite = Kaya::Suites::Suite.get(suite_id)
|
|
13
|
+
begin
|
|
14
|
+
suite.check_last_result!
|
|
15
|
+
sleep 10
|
|
16
|
+
end while not suite.is_ready?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'kaya'
|
|
2
|
+
|
|
3
|
+
module Kaya
|
|
4
|
+
module Workers
|
|
5
|
+
class GarbageCleaner
|
|
6
|
+
|
|
7
|
+
# This worker delete all zombies files
|
|
8
|
+
include Sidekiq::Worker
|
|
9
|
+
def perform
|
|
10
|
+
|
|
11
|
+
Kaya::Support::Configuration.get
|
|
12
|
+
Kaya::Database::MongoConnector.new(Kaya::Support::Configuration.db_connection_data)
|
|
13
|
+
|
|
14
|
+
get_present_output_files = Dir["#{Dir.pwd}/kaya/temp/*.out"].select{|file| file.start_with? "kaya_co_"}
|
|
15
|
+
get_present_report_files = Dir["#{Dir.pwd}/kaya/temp/*.html"].select{|file| file.start_with? "kaya_report_"}
|
|
16
|
+
|
|
17
|
+
get_present_output_files.each do |output_file|
|
|
18
|
+
if result = Kaya::Results::Result.get(output_file.scan(/\d+/).first)
|
|
19
|
+
File.delete("#{Dir.pwd}/kaya/temp/#{output_file}") if result.finished?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
get_present_report_files.each do |report_file|
|
|
24
|
+
if result = Kaya::Results::Result.get(report_file.scan(/\d+/).first)
|
|
25
|
+
File.delete("#{Dir.pwd}/kaya/temp/#{report_file}") if result.finished?
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module Commands
|
|
3
|
+
def self.help
|
|
4
|
+
$K_LOG.debug "#{self}:#{__method__}" if $K_LOG
|
|
5
|
+
puts "
|
|
6
|
+
If you shutdown kaya and then you want to get it up and the port you are using is already in use you could use the following commands (Ubunutu OS):
|
|
7
|
+
|
|
8
|
+
$sudo netstat -tapen | grep :8080
|
|
9
|
+
|
|
10
|
+
In this example we use the port 8080. This command will give you the app that is using the port. Then you could kill it getting its PID previously."
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module Commands
|
|
3
|
+
def self.install origin=nil
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
TaskRack.start([])
|
|
9
|
+
|
|
10
|
+
puts "
|
|
11
|
+
|
|
12
|
+
A new folder called kaya was created. Check the configuration file with the name kaya_conf.
|
|
13
|
+
You'll find some configuration values there. Take a look and set your preferences!
|
|
14
|
+
Enjoy Kaya
|
|
15
|
+
Thanks
|
|
16
|
+
"
|
|
17
|
+
|
|
18
|
+
puts "You don't have defined a cucumber.yml file. YOU SHOULD TO USE KAYA :)" if Kaya::Suites.cucumber_yml.empty?
|
|
19
|
+
puts "Now, you can run bundle install and then `kaya start` command"
|
|
20
|
+
|
|
21
|
+
rescue => e
|
|
22
|
+
puts "\n\nERROR: #{e}\n\n #{e.backtrace}"
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module Commands
|
|
3
|
+
def self.reset
|
|
4
|
+
$K_LOG.debug "#{self}:#{__method__}" if $K_LOG
|
|
5
|
+
begin
|
|
6
|
+
|
|
7
|
+
Kaya::Support::Configuration.get
|
|
8
|
+
Kaya::Database::MongoConnector.new(Kaya::Support::Configuration.db_connection_data)
|
|
9
|
+
|
|
10
|
+
print "\nCleanning database..."
|
|
11
|
+
|
|
12
|
+
Kaya::Database::MongoConnector.drop_collections
|
|
13
|
+
print "Done!\n\n"
|
|
14
|
+
|
|
15
|
+
print "\nCleanning project..."
|
|
16
|
+
|
|
17
|
+
Kaya::Support::FilesCleanner.start!
|
|
18
|
+
print "Done!\n\n"
|
|
19
|
+
|
|
20
|
+
if Kaya::Support::Configuration.use_git?
|
|
21
|
+
|
|
22
|
+
Kaya::Support::Git.pull
|
|
23
|
+
|
|
24
|
+
Kaya::Suites.update_suites
|
|
25
|
+
|
|
26
|
+
else # NO GIT USAGE
|
|
27
|
+
|
|
28
|
+
Kaya::Suites.update_suites
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
puts "PROFILES LOADED CORRECTLY \n\nRun `kaya start`"
|
|
33
|
+
|
|
34
|
+
rescue => e
|
|
35
|
+
puts "CANNOT CLEAN SYSTEM\n#{e}\n\n#{e.backtrace}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module Commands
|
|
3
|
+
def self.reset_suites
|
|
4
|
+
$K_LOG.debug "#{self}:#{__method__}" if $K_LOG
|
|
5
|
+
begin
|
|
6
|
+
|
|
7
|
+
Kaya::Support::Configuration.get
|
|
8
|
+
|
|
9
|
+
Kaya::Database::MongoConnector.new(Kaya::Support::Configuration.db_connection_data)
|
|
10
|
+
|
|
11
|
+
print "\nCleanning suites from database..."
|
|
12
|
+
|
|
13
|
+
Kaya::Database::MongoConnector.drop_collections
|
|
14
|
+
print "Done!\n\n"
|
|
15
|
+
|
|
16
|
+
print "\nCleanning project..."
|
|
17
|
+
|
|
18
|
+
Kaya::Support::FilesCleanner.start!
|
|
19
|
+
print "Done!\n\n"
|
|
20
|
+
|
|
21
|
+
if Kaya::Support::Configuration.use_git?
|
|
22
|
+
|
|
23
|
+
Kaya::Support::Git.pull
|
|
24
|
+
|
|
25
|
+
Kaya::Suites.update_suites
|
|
26
|
+
|
|
27
|
+
else # NO GIT USAGE
|
|
28
|
+
|
|
29
|
+
kaya::Suites.update_suites
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
puts "PROFILES LOADED CORRECTLY \n\nRun `kaya start`"
|
|
34
|
+
|
|
35
|
+
rescue => e
|
|
36
|
+
puts "CANNOT CLEAN SYSTEM\n#{e}\n\n#{e.backtrace}"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
module Kaya
|
|
2
|
+
module Commands
|
|
3
|
+
def self.start nodemon=false
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
$K_LOG.debug "Starting Kaya" if $K_LOG
|
|
7
|
+
begin
|
|
8
|
+
|
|
9
|
+
Kaya::Support::Configuration.new
|
|
10
|
+
|
|
11
|
+
$K_LOG.debug "Starting...\n\n#{Kaya::Support::Logo.logo}" if $K_LOG
|
|
12
|
+
|
|
13
|
+
$K_LOG.debug "Checking config.ru file existance" if $K_LOG
|
|
14
|
+
raise "ERROR --- kaya/config.ru file was not found. Try with `kaya prepare` command before `kaya start`" unless File.exist?("#{Dir.pwd}/kaya/config.ru")
|
|
15
|
+
|
|
16
|
+
$K_LOG.debug "Checking unicorn.rb file existance" if $K_LOG
|
|
17
|
+
raise "ERROR --- kaya/unicorn.rb file was not found. Try with `kaya prepare` command before `kaya start`" unless File.exist?("#{Dir.pwd}/kaya/unicorn.rb")
|
|
18
|
+
|
|
19
|
+
Kaya::Support::Logo.show
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Kaya::Support::Configuration.show_configuration_values
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
$K_LOG.debug "Connecting to database" if $K_LOG
|
|
26
|
+
Kaya::Database::MongoConnector.new(Kaya::Support::Configuration.db_connection_data)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
$K_LOG.debug "Loading doc" if $K_LOG
|
|
30
|
+
Kaya::Support::Documentation.load_documentation
|
|
31
|
+
|
|
32
|
+
if Kaya::Support::Configuration.headless?
|
|
33
|
+
$K_LOG.debug "Headless mode: ON - Checking xvfb existance" if $K_LOG
|
|
34
|
+
res = Kaya::Support::Console.execute "xvfb-run"
|
|
35
|
+
if res.include? "sudo apt-get install xvfb"
|
|
36
|
+
puts "
|
|
37
|
+
You have configured headless mode but xvfb package is not installed on your system.
|
|
38
|
+
Please, install xvfb package if you want to run browsers in headless mode
|
|
39
|
+
or set HEADLESS active value as false if you do not use browser in your tests."
|
|
40
|
+
return
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
puts "\n"
|
|
45
|
+
$K_LOG.debug "Cleanning old kaya report files" if $K_LOG
|
|
46
|
+
Kaya::Support::FilesCleanner.delete_kaya_reports()
|
|
47
|
+
$K_LOG.debug "Old kaya report files cleanned" if $K_LOG
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
$K_LOG.debug "Cleanning old kaya console files" if $K_LOG
|
|
51
|
+
Kaya::Support::FilesCleanner.delete_console_outputs_files()
|
|
52
|
+
$K_LOG.debug "Old kaya console files cleanned" if $K_LOG
|
|
53
|
+
|
|
54
|
+
$K_LOG.debug "Clearing kaya log file" if $K_LOG
|
|
55
|
+
Kaya::Support::FilesCleanner.clear_kaya_log
|
|
56
|
+
$K_LOG.debug "Kaya log file cleanned" if $K_LOG
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
$K_LOG.debug "Clearing sidekiq log file" if $K_LOG
|
|
60
|
+
Kaya::Support::FilesCleanner.clear_sidekiq_log
|
|
61
|
+
$K_LOG.debug "Sidekiq log file cleanned" if $K_LOG
|
|
62
|
+
|
|
63
|
+
# To prevent showing suites as runnnig when service started recently reset all suites
|
|
64
|
+
$K_LOG.debug "Reseting suites statuses" if $K_LOG
|
|
65
|
+
Kaya::Suites.reset_statuses
|
|
66
|
+
$K_LOG.debug "Suites statuses reseted" if $K_LOG
|
|
67
|
+
puts "\n* Suites Status: Reseted"
|
|
68
|
+
|
|
69
|
+
# Force results to reset or finished status
|
|
70
|
+
$K_LOG.debug "Reseting defunct executions" if $K_LOG
|
|
71
|
+
Kaya::Results.reset_defuncts
|
|
72
|
+
$K_LOG.debug "Defunct execution reseted" if $K_LOG
|
|
73
|
+
puts "\n* Results: Reseted".green
|
|
74
|
+
|
|
75
|
+
kaya_arg = "-D" unless nodemon
|
|
76
|
+
|
|
77
|
+
$K_LOG.debug "Starting Sidekiq" if $K_LOG
|
|
78
|
+
Kaya::BackgroundJobs::Sidekiq.start
|
|
79
|
+
$K_LOG.debug "Sidekiq Started" if $K_LOG
|
|
80
|
+
|
|
81
|
+
# Start kaya app
|
|
82
|
+
$K_LOG.debug "Starting Kaya" if $K_LOG
|
|
83
|
+
kaya_start_output = Kaya::Support::Console.execute "unicorn -c #{Dir.pwd}/kaya/unicorn.rb -p #{Kaya::Support::Configuration.port} #{kaya_arg} kaya/config.ru"
|
|
84
|
+
|
|
85
|
+
$K_LOG.debug "Kaya started" if $K_LOG
|
|
86
|
+
|
|
87
|
+
# Save all kaya pids
|
|
88
|
+
$K_LOG.debug "Saving PIDs for Kaya" if $K_LOG
|
|
89
|
+
File.open("#{Dir.pwd}/kaya/kaya_pids", "a"){ |f| f.write Kaya::Support::Processes.kaya_pids.join("\n")}
|
|
90
|
+
$K_LOG.debug "Kaya PIDs saved" if $K_LOG
|
|
91
|
+
|
|
92
|
+
puts "\n\n* Kaya is succesfully Started!\n".green
|
|
93
|
+
if $IP_ADDRESS
|
|
94
|
+
puts "\n\n You can go now to http://#{$IP_ADDRESS}:#{Kaya::Support::Configuration.port}/kaya\n\n"
|
|
95
|
+
$K_LOG.debug "You can go now to http://#{$IP_ADDRESS}:#{Kaya::Support::Configuration.port}/kaya" if $K_LOG
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
rescue => e
|
|
99
|
+
$K_LOG.error "Error starting Kaya: #{e}#{e.backtrace}" if $K_LOG
|
|
100
|
+
puts "An error ocurred while starting Kaya. See kaya log for more information.".red
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|