mutx 0.1.69 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/documentation/repos.md +21 -24
- data/lib/generators/task_rack.rb +8 -2
- data/lib/generators/templates/config.ru.tt +1 -1
- data/lib/mutx/API/execution.rb +8 -44
- data/lib/mutx/API/repo.rb +7 -10
- data/lib/mutx/background_jobs/workers/executor.rb +44 -38
- data/lib/mutx/commands/install.rb +1 -1
- data/lib/mutx/commands/start.rb +1 -1
- data/lib/mutx/custom/execution.rb +1 -1
- data/lib/mutx/database/mongo_connector.rb +19 -22
- data/lib/mutx/execution.rb +1 -0
- data/lib/mutx/lib/authentication.rb +23 -0
- data/lib/mutx/lib/helpers.rb +52 -0
- data/lib/mutx/lib/middlewares/database_middleware.rb +16 -0
- data/lib/mutx/lib/middlewares/flash_middleware.rb +31 -0
- data/lib/mutx/lib/middlewares/logger_middleware.rb +13 -0
- data/lib/mutx/lib/monkey_patch.rb +28 -0
- data/lib/mutx/lib/paths.rb +80 -0
- data/lib/mutx/platforms/ruby.rb +8 -0
- data/lib/mutx/public/css/bootstrap.min.css +7 -0
- data/lib/mutx/public/css/font-awesome.min.css +4 -0
- data/lib/mutx/public/css/jquery.json-viewer.css +44 -0
- data/{favicon.ico → lib/mutx/public/img/favicon.ico} +0 -0
- data/lib/mutx/public/js/bootstrap.min.js +6 -0
- data/lib/mutx/public/js/jquery.json-viewer.js +148 -0
- data/lib/mutx/public/js/jquery.min.js +6 -0
- data/lib/mutx/{view/javascript.mote → public/js/mutx.js} +0 -5
- data/lib/mutx/public/js/notify.min.js +1 -0
- data/lib/mutx/results/result.rb +60 -68
- data/lib/mutx/results/results.rb +4 -0
- data/lib/mutx/routes.rb +85 -883
- data/lib/mutx/routes/admin_routes.rb +16 -0
- data/lib/mutx/routes/admin_routes/custom_params_routes.rb +97 -0
- data/lib/mutx/routes/admin_routes/repositories_routes.rb +35 -0
- data/lib/mutx/routes/admin_routes/tasks_routes.rb +110 -0
- data/lib/mutx/routes/api_routes.rb +49 -0
- data/lib/mutx/routes/api_routes/custom_params_routes.rb +41 -0
- data/lib/mutx/routes/api_routes/input_routes.rb +48 -0
- data/lib/mutx/routes/api_routes/repos_routes.rb +74 -0
- data/lib/mutx/routes/api_routes/results_routes.rb +50 -0
- data/lib/mutx/routes/api_routes/tasks_routes.rb +47 -0
- data/lib/mutx/routes/api_routes/tests_routes.rb +42 -0
- data/lib/mutx/routes/features_routes.rb +24 -0
- data/lib/mutx/routes/help_routes.rb +23 -0
- data/lib/mutx/routes/logs_routes.rb +22 -0
- data/lib/mutx/routes/message_routes.rb +24 -0
- data/lib/mutx/routes/repositories_routes.rb +25 -0
- data/lib/mutx/routes/results_routes.rb +53 -0
- data/lib/mutx/routes/task_results_routes.rb +25 -0
- data/lib/mutx/routes/tasks_routes.rb +67 -0
- data/lib/mutx/routes/tests_routes.rb +66 -0
- data/lib/mutx/support/change_inspector.rb +3 -3
- data/lib/mutx/support/files_cleanner.rb +12 -3
- data/lib/mutx/support/git.rb +11 -2
- data/lib/mutx/support/processes.rb +2 -2
- data/lib/mutx/support/project_type.rb +12 -0
- data/lib/mutx/tasks/task.rb +8 -2
- data/lib/mutx/version.rb +1 -1
- data/lib/mutx/view/{custom/params/delete_form.mote → admin/custom-params/_delete_form.mote} +2 -4
- data/lib/mutx/view/{custom/params/create_edit_form.mote → admin/custom-params/_form.mote} +5 -9
- data/lib/mutx/view/{custom/params/custom_param_task_deleting_box.mote → admin/custom-params/_task_deleting_box.mote} +1 -2
- data/lib/mutx/view/{custom/params → admin/custom-params}/delete.mote +1 -3
- data/lib/mutx/view/{custom/params → admin/custom-params}/edit.mote +1 -5
- data/lib/mutx/view/{custom/params/list.mote → admin/custom-params/index.mote} +8 -13
- data/lib/mutx/view/{custom/params → admin/custom-params}/new.mote +1 -5
- data/lib/mutx/view/{custom/params/custom_param_selection_box.mote → admin/custom-params/selection_box.mote} +2 -3
- data/lib/mutx/view/{list_repos.mote → admin/repositories/index.mote} +2 -6
- data/lib/mutx/view/{repos.mote → admin/repositories/new.mote} +2 -6
- data/lib/mutx/view/{tasks/admin/delete_form.mote → admin/tasks/_delete_form.mote} +2 -12
- data/lib/mutx/view/{tasks/admin/create_edit_form.mote → admin/tasks/_form.mote} +6 -9
- data/lib/mutx/view/{tasks/admin → admin/tasks}/delete.mote +1 -3
- data/lib/mutx/view/{tasks/admin → admin/tasks}/edit.mote +1 -4
- data/lib/mutx/view/{tasks/admin/list.mote → admin/tasks/index.mote} +5 -10
- data/lib/mutx/view/{tasks/admin → admin/tasks}/new.mote +1 -5
- data/lib/mutx/view/{tasks/admin/view.mote → admin/tasks/show.mote} +1 -3
- data/lib/mutx/view/body.mote +13 -51
- data/lib/mutx/view/{custom/params.mote → custom-params/_custom_params.mote} +3 -4
- data/lib/mutx/view/{custom/params → custom-params/types}/json.mote +0 -0
- data/lib/mutx/view/{custom/params → custom-params/types}/select_list.mote +0 -0
- data/lib/mutx/view/{custom/params → custom-params/types}/text.mote +0 -0
- data/lib/mutx/view/error_handler.mote +4 -54
- data/lib/mutx/view/features/{feature.mote → file.mote} +0 -0
- data/lib/mutx/view/features/index.mote +9 -0
- data/lib/mutx/view/git_information.mote +2 -8
- data/lib/mutx/view/help/{main.mote → _main.mote} +0 -0
- data/lib/mutx/view/help/{page.mote → _page.mote} +0 -0
- data/lib/mutx/view/help/{search_result.mote → _search_result.mote} +0 -0
- data/lib/mutx/view/help/index.mote +38 -0
- data/lib/mutx/view/layout/flash.mote +7 -0
- data/lib/mutx/view/{footer.mote → layout/footer.mote} +1 -1
- data/lib/mutx/view/layout/javascript.mote +6 -0
- data/lib/mutx/view/{modals.mote → layout/modals.mote} +0 -0
- data/lib/mutx/view/layout/navigation_bar.mote +88 -0
- data/lib/mutx/view/{styles.mote → layout/styles.mote} +10 -0
- data/lib/mutx/view/logs/{logs.mote → index.mote} +1 -1
- data/lib/mutx/view/logs/show.mote +3 -0
- data/lib/mutx/view/repositories/_repository.mote +7 -0
- data/lib/mutx/view/repositories/index.mote +23 -0
- data/lib/mutx/view/repositories/show.mote +21 -0
- data/lib/mutx/view/results/{detailed_info.mote → _result.mote} +5 -5
- data/lib/mutx/view/results/console.mote +63 -106
- data/lib/mutx/view/results/{all.mote → index.mote} +18 -24
- data/lib/mutx/view/sections.rb +36 -24
- data/lib/mutx/view/task_results/_result.mote +57 -0
- data/lib/mutx/view/{results/result.mote → task_results/_result_item.mote} +6 -5
- data/lib/mutx/view/task_results/index.mote +35 -0
- data/lib/mutx/view/tasks/_task.mote +90 -0
- data/lib/mutx/view/tasks/index.mote +61 -0
- data/lib/mutx/view/tasks/show.mote +167 -0
- data/lib/mutx/view/tests/_test.mote +90 -0
- data/lib/mutx/view/tests/index.mote +59 -0
- data/lib/mutx/view/tests/show.mote +172 -0
- data/lib/mutx/view/view.rb +172 -10
- metadata +89 -50
- data/lib/mutx/database/middleware.rb +0 -18
- data/lib/mutx/view/features.mote +0 -57
- data/lib/mutx/view/features/features_list.mote +0 -10
- data/lib/mutx/view/help.mote +0 -75
- data/lib/mutx/view/logs/log.mote +0 -3
- data/lib/mutx/view/message.mote +0 -8
- data/lib/mutx/view/navigation_bar.mote +0 -67
- data/lib/mutx/view/results/results.mote +0 -112
- data/lib/mutx/view/tasks/message.mote +0 -37
- data/lib/mutx/view/tasks/task.mote +0 -167
- data/lib/mutx/view/tasks/task_item.mote +0 -77
- data/lib/mutx/view/tasks/tasks.mote +0 -74
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19f6e7d0eb47b0ee32ffdb142e5dc33c86c6f7d0
|
4
|
+
data.tar.gz: 941938ef3a9e3dd9ea2bbf96e8aa3b786542a3e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a46f7a2224a197531f00718a204fe2f295ccbfb01d8968caef7a4b3987952fa6b9c8bc0d0beeb822546a57b3238e14b7d48a95336667fb7ed48b2b23963414a9
|
7
|
+
data.tar.gz: 2ae2115ea7647dd42cf28bf7b0284618cb0ac5971a250b89b095e9d0556643fc6552f4affc8fde368ec3ffd629f817b205dc7dff049522b1ee023f8b79cbedd8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mutx (0.
|
4
|
+
mutx (0.2.0)
|
5
5
|
basica
|
6
6
|
bson_ext
|
7
7
|
byebug
|
@@ -97,7 +97,7 @@ GEM
|
|
97
97
|
redcarpet (3.4.0)
|
98
98
|
redis (3.3.3)
|
99
99
|
require_all (1.4.0)
|
100
|
-
rufus-scheduler (3.3.
|
100
|
+
rufus-scheduler (3.3.4)
|
101
101
|
tzinfo
|
102
102
|
shotgun (0.9.2)
|
103
103
|
rack (>= 1.0)
|
data/documentation/repos.md
CHANGED
@@ -1,32 +1,29 @@
|
|
1
|
-
|
2
|
-
=====================================
|
1
|
+
# Repositories
|
3
2
|
|
4
|
-
|
3
|
+
## Concept
|
4
|
+
Repositories are units of information storage. With Repositories, you can save data to be queried later as you need.
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
## How to use repositories
|
7
|
+
#### Creation
|
8
|
+
First, a repository must be created by admin section to be used. Repo creation provide (only admin view) a unique token to be used.
|
9
|
+
Repo token is a value to be used on putting data into a repo. Without a token, you won't be able to put data.
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
How to save info inside a repo
|
12
|
-
=============================
|
13
|
-
|
14
|
-
When we create a repo, we have to copy the token that the new repo has (with and invalid token or repo name Mutx will reject the request). To save info we have to make a PUT to an existing repo, for example:
|
15
|
-
|
16
|
-
PATH/api/<repo_token>/<repo_name>/
|
17
|
-
|
18
|
-
The value to save must be a JSON in the body of the request, for example:
|
11
|
+
Go to Admin > Repositories to configure repos
|
19
12
|
|
13
|
+
#### Putting data into a repo
|
14
|
+
To put data into a repo, you have to perform a PUT request to the mutx api url
|
15
|
+
|
16
|
+
http://host:port/api/repos/<:token>/<:reponame>
|
17
|
+
|
18
|
+
And data has to be passed as the body in JSON format
|
19
|
+
|
20
20
|
{
|
21
|
-
|
22
|
-
|
21
|
+
"fav_food":"Asado",
|
22
|
+
"fav_drink":"Beer"
|
23
23
|
}
|
24
24
|
|
25
|
-
How to get the info of a repo
|
26
|
-
============================
|
27
|
-
|
28
|
-
Using the API we can make a GET request to view the info of a repository, for example:
|
29
|
-
|
30
|
-
PATH/api/repos/<repo_name>
|
31
25
|
|
32
|
-
|
26
|
+
### Getting data from a repo
|
27
|
+
To get repository data, you have to go to the following url like:
|
28
|
+
|
29
|
+
http://host:port/api/repos/<:reponame>
|
data/lib/generators/task_rack.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'erb'
|
3
3
|
require 'zip'
|
4
4
|
require 'fileutils'
|
5
|
+
require 'colorize'
|
5
6
|
|
6
7
|
module Mutx
|
7
8
|
class TaskRack < Thor::Group
|
@@ -22,9 +23,14 @@ module Mutx
|
|
22
23
|
Mutx::Support::Logo.show
|
23
24
|
puts "
|
24
25
|
You have to choose one of the following branches to tell Mutx where to work with:"
|
25
|
-
# Print the
|
26
|
+
# Print the existing branches
|
26
27
|
branch_list.each_with_index do |branch_name, index|
|
27
|
-
|
28
|
+
line = "\t(#{index + 1}) - #{branch_name}"
|
29
|
+
if branch_name == "master"
|
30
|
+
puts line.green
|
31
|
+
else
|
32
|
+
puts line
|
33
|
+
end
|
28
34
|
end
|
29
35
|
print "\n\t Your option:"; option = STDIN.gets
|
30
36
|
|
data/lib/mutx/API/execution.rb
CHANGED
@@ -25,9 +25,8 @@ module Mutx
|
|
25
25
|
|
26
26
|
running_started = []
|
27
27
|
running_started = Mutx::Database::MongoConnector.running_for_task task_name
|
28
|
-
is_there_task = Mutx::Tasks.is_there_task_with? task_name, type
|
29
28
|
|
30
|
-
if
|
29
|
+
if Mutx::Tasks.is_there_task_with? task_name, type
|
31
30
|
Mutx::Support::Log.debug "Starting working with task #{task_name}" if Mutx::Support::Log
|
32
31
|
|
33
32
|
task = Mutx::Tasks::Task.get_task_with(task_name)
|
@@ -51,9 +50,7 @@ module Mutx
|
|
51
50
|
|
52
51
|
execution_id = Mutx::Execution.run!(execution_request_data)
|
53
52
|
|
54
|
-
task.push_exec execution_id
|
55
|
-
|
56
|
-
task.save!
|
53
|
+
task.push_exec! execution_id
|
57
54
|
|
58
55
|
Mutx::Support::Log.debug "Task #{task_name} setted as running" if Mutx::Support::Log
|
59
56
|
|
@@ -101,46 +98,13 @@ module Mutx
|
|
101
98
|
# Sets as finished the result and associated task as READY
|
102
99
|
#
|
103
100
|
def self.reset(result_id)
|
104
|
-
|
105
|
-
Mutx::Support::Log.debug "Reset execution request for #{result_id}"
|
106
|
-
|
107
101
|
result = Mutx::Results::Result.get(result_id)
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
killed = true
|
115
|
-
Mutx::Support::Processes.kill_p(result.pid)
|
116
|
-
Mutx::Support::Log.debug "Execution (id=#{result.id}) killed: #{killed}"
|
117
|
-
end
|
118
|
-
rescue => e
|
119
|
-
Mutx::Support::Log.error "#{e}#{e.backtrace}"
|
120
|
-
end
|
121
|
-
|
122
|
-
begin
|
123
|
-
Mutx::Support::FilesCleanner.delete_report_which_has(result.id)
|
124
|
-
Mutx::Support::Log.debug "Execution files(id=#{result.id}) cleanned"
|
125
|
-
cleanned = true
|
126
|
-
rescue
|
127
|
-
end
|
128
|
-
|
129
|
-
result.save_report
|
130
|
-
result.reset!("forced");
|
131
|
-
Mutx::Support::Log.debug "Execution stopped!"
|
132
|
-
result.show_as = "pending"
|
133
|
-
result.save!
|
134
|
-
|
135
|
-
if killed
|
136
|
-
message = "Execution: Stopped (forced) "
|
137
|
-
message += " Files: Cleanned" if cleanned
|
138
|
-
else
|
139
|
-
message = "Could not stop execution. Process killing: #{killed}. Files cleanned: #{cleanned}"
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
102
|
+
|
103
|
+
message = if result.reset!
|
104
|
+
"[#{result.id}] Execution stopped"
|
105
|
+
else
|
106
|
+
"[#{result.id}] Could not stop execution"
|
107
|
+
end
|
144
108
|
{"message" => message}
|
145
109
|
end
|
146
110
|
|
data/lib/mutx/API/repo.rb
CHANGED
@@ -34,19 +34,16 @@ module Mutx
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def self.all
|
38
|
+
Mutx::Database::MongoConnector.all_repos
|
39
|
+
end
|
40
|
+
|
37
41
|
#GET
|
38
|
-
def self.get_data
|
39
|
-
|
40
|
-
|
41
|
-
result
|
42
|
-
else
|
43
|
-
{action:"get", success:false, message:"Repo get was nok"}
|
44
|
-
end
|
42
|
+
def self.get_data id, query_string=nil
|
43
|
+
result = Mutx::Database::MongoConnector.repo_data_for_id(id)
|
44
|
+
result || { action: 'get', success: false, message: 'Repo get was nok' }
|
45
45
|
end
|
46
46
|
|
47
|
-
def self.info name
|
48
|
-
result = Mutx::Database::MongoConnector.repo_data_for_name(name)
|
49
|
-
end
|
50
47
|
#GET
|
51
48
|
|
52
49
|
def self.delete_this data
|
@@ -3,8 +3,7 @@ require 'mutx'
|
|
3
3
|
require 'socket'
|
4
4
|
require 'pty'
|
5
5
|
require 'colorize'
|
6
|
-
|
7
|
-
#require 'byebug'
|
6
|
+
|
8
7
|
|
9
8
|
module Mutx
|
10
9
|
module Workers
|
@@ -23,22 +22,25 @@ module Mutx
|
|
23
22
|
Mutx::Support::ChangeInspector.is_there_a_change?
|
24
23
|
|
25
24
|
result = Mutx::Results::Result.get(result_id)
|
25
|
+
puts "[#{result.id}] Execution created"
|
26
26
|
task = Mutx::Tasks::Task.get(result.task_id)
|
27
27
|
|
28
28
|
result.mutx_report_file_name= "mutx_report_#{result_id}.html"
|
29
29
|
|
30
30
|
if result.is_ruby_platform?
|
31
31
|
if Mutx::Platforms::Ruby.using_bundler?
|
32
|
-
bundle_output = Mutx::Support::Console.execute "bundle
|
32
|
+
bundle_output = Mutx::Support::Console.execute "bundle update"
|
33
|
+
puts "[#{result.id}] bundle: #{bundle_output}"
|
33
34
|
bundle_output.slice! "fatal: Not a git repository (or any of the parent directories): .git"
|
34
35
|
end
|
35
36
|
if bundle_output
|
36
|
-
result.append_output bundle_output if bundle_output.include? "Installing"
|
37
|
+
result.append_output! bundle_output if bundle_output.include? "Installing"
|
37
38
|
if bundle_output.include? "Could not find"
|
39
|
+
puts "[#{result.id}] Finished because of Could not find gem"
|
38
40
|
result.finish!
|
39
41
|
raise "An error ocurred installing gem while executing bundler"
|
40
42
|
else
|
41
|
-
result.append_output "All GEMS are installed and running!\nEXECUTION OUTPUT:\n\n--"
|
43
|
+
result.append_output! "All GEMS are installed and running!\nEXECUTION OUTPUT:\n\n--"
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
@@ -51,69 +53,71 @@ module Mutx
|
|
51
53
|
efective_command << "-f pretty -f html -o mutx/temp/#{result.mutx_report_file_name}" if result.is_cucumber?
|
52
54
|
efective_command << result.custom_params_values
|
53
55
|
efective_command << "_id=#{result.id}" # to use inside execution the possibility to add information to the result
|
54
|
-
|
56
|
+
puts "[#{result.id}] Command: #{efective_command.join(" ")}"
|
55
57
|
result.mutx_command= efective_command.join(" ")
|
56
58
|
|
57
59
|
attach_folder = "#{Dir.pwd}/mutx/out/#{result.id}/attachment"
|
58
60
|
|
59
|
-
# To Be Deleted on prod
|
60
|
-
Mutx::Support::Log.debug "[result:#{result.id}] #{efective_command.join(' ')}" if Mutx::Support::Log
|
61
|
-
|
62
61
|
result.running!
|
63
|
-
|
64
|
-
Mutx::Support::Log.debug "[result:#{result.id}] setted as running" if Mutx::Support::Log
|
62
|
+
puts "[#{result.id}] setted as running"
|
65
63
|
|
66
64
|
@output = ""
|
67
65
|
|
68
|
-
#################
|
69
|
-
# POPEN3 ref
|
70
|
-
# http://blog.honeybadger.io/capturing-stdout-stderr-from-shell-commands-via-ruby/?utm_source=rubyweekly&utm_medium=email
|
71
|
-
##################
|
72
66
|
@count = 0
|
73
67
|
|
74
|
-
# Update repo if changes are found
|
75
|
-
##if Mutx::Support::Configuration.use_git?
|
76
|
-
## Mutx::Support::Git.pull unless Mutx::Support::Git.up_to_date?
|
77
|
-
##end # PULL COMMENTED
|
78
|
-
|
79
68
|
if !Mutx::Support::Configuration.proxys.empty?
|
80
69
|
Mutx::Support::Configuration.proxys.detect{|proxy| Mutx::Support::Console.execute proxy}
|
81
70
|
end
|
82
71
|
|
83
72
|
Mutx::Support::TimeHelper.start # Sets timestamp before start process
|
84
|
-
Mutx::Support::Log.debug "[result:#{result.id}] Creating process" if Mutx::Support::Log
|
85
73
|
|
86
|
-
#USE 'PTY' GEM INSTEAD POPEN TO READ OUTPUT IN REAL TIME
|
87
74
|
@start_time = Time.now
|
88
75
|
begin
|
76
|
+
|
77
|
+
|
78
|
+
|
89
79
|
PTY.spawn("#{result.mutx_command}") do |stdout, stdin, pid|
|
90
|
-
result.pid ="#{`ps -fea | grep #{Process.pid} | grep -v grep | awk '$2!=#{Process.pid} && $8!~/awk/ && $3==#{Process.pid}{print $2}'`}"
|
91
|
-
result.save!
|
92
80
|
begin
|
81
|
+
if result.pid.nil?
|
82
|
+
puts "[#{result.id}] pid #{pid}"
|
83
|
+
result.pid = pid
|
84
|
+
result.save!
|
85
|
+
end
|
93
86
|
stdout.each { |line|
|
94
|
-
@output
|
87
|
+
@output = line
|
95
88
|
@output.slice! "fatal: Not a git repository (or any of the parent directories): .git"
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
#end
|
100
|
-
if result.seconds_without_changes > Mutx::Support::Configuration.execution_time_to_live
|
89
|
+
result.append_output! @output.gsub(/(\[\d{1,2}\m)/, "")
|
90
|
+
|
91
|
+
if result.time_to_live_reached?
|
101
92
|
result.finished_by_timeout! and break
|
102
93
|
end
|
103
94
|
}
|
104
|
-
result.append_output @output unless @output.empty?
|
105
|
-
result.append_output "=========================\n"
|
95
|
+
result.append_output! @output unless @output.empty?
|
106
96
|
rescue Errno::EIO, Errno::ENOENT => e
|
97
|
+
puts "[#{result_id}] Errno::EIO, Errno::ENOENT => e"
|
98
|
+
rescue PTY::ChildExited, Errno::ENOENT => e
|
99
|
+
cmd = result.mutx_command.match(/(\D*)\_/)[0].delete"_"
|
100
|
+
exception_message = "EXCEPTION: #{e.message} for the command requested for you: #{cmd.upcase}"
|
101
|
+
puts "[#{result.id}] exception_message: #{exception_message}"
|
102
|
+
@output = exception_message
|
103
|
+
result.append_output! @output unless @output.empty?
|
104
|
+
rescue => e
|
105
|
+
puts "[#{result_id}] Unknown exception"
|
107
106
|
end
|
107
|
+
|
108
108
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
result.
|
113
|
-
result.
|
109
|
+
|
110
|
+
rescue => e
|
111
|
+
puts "#######################}WTF #{e} #{e.backtrace}"
|
112
|
+
# result.reset!
|
113
|
+
puts "[#{result.id}] Reseted"
|
114
114
|
end
|
115
115
|
|
116
|
+
result = Mutx::Results::Result.get(result_id)
|
117
|
+
puts "[#{result.id}] Status before ensure finish => #{result.status}"
|
116
118
|
result.ensure_finished!
|
119
|
+
result.eval_regex!
|
120
|
+
puts "[#{result.id}] ensure finished"
|
117
121
|
|
118
122
|
puts result.summary
|
119
123
|
|
@@ -130,6 +134,8 @@ module Mutx
|
|
130
134
|
id = task[:_id]
|
131
135
|
cucumber = task[:cucumber]
|
132
136
|
notify_on = task[:notify_on]
|
137
|
+
|
138
|
+
result.eval_regex!
|
133
139
|
|
134
140
|
if ( (task["notifications"].eql? "on") && (!task["stop_bots"].eql? "on") && (!task["stop_bots"].eql? "off") && (!result.regex.empty?) && (result.console_output.to_s.include? "#{result.regex.to_s}") )
|
135
141
|
Mutx::Database::MongoConnector.mark_notified (result_id)
|
@@ -149,7 +155,7 @@ module Mutx
|
|
149
155
|
puts "****Result not to being notified, because regex #{result.regex.to_s} not included on output****"
|
150
156
|
end
|
151
157
|
|
152
|
-
|
158
|
+
puts "[result:#{result.id}]| command => #{result.mutx_command} | result as => #{result.status}"
|
153
159
|
|
154
160
|
Mutx::Database::MongoConnector.force_close
|
155
161
|
end
|
data/lib/mutx/commands/start.rb
CHANGED
@@ -7,7 +7,7 @@ module Mutx
|
|
7
7
|
pids = (Mutx::Support::Processes.sidekiq_pids).concat(Mutx::Support::Processes.mutx_pids)
|
8
8
|
|
9
9
|
if pids.size > 0
|
10
|
-
puts "It seems that MuTX is already running"
|
10
|
+
puts "It seems that MuTX is already running. pids found [#{pids}]"
|
11
11
|
puts "Please, run `mutx stop` command before starting MuTX"
|
12
12
|
else
|
13
13
|
Mutx::Support::Log.start
|
@@ -39,16 +39,6 @@ module Mutx
|
|
39
39
|
$db_name = "#{project_name}_mutx"
|
40
40
|
end
|
41
41
|
|
42
|
-
def set_client opts
|
43
|
-
Mutx::Support::Log.debug "Setting db client" if Mutx::Support::Log
|
44
|
-
if !$client
|
45
|
-
#$client = Mongo::Client.new("mongodb://#{opts[:host]}:#{opts[:port]}/#{set_db_name}")
|
46
|
-
$client = Mongo::Client.new([ "#{opts[:host]}:#{opts[:port]}" ], :database => "#{set_db_name}")
|
47
|
-
else
|
48
|
-
$client
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
42
|
def self.force_close
|
53
43
|
$client.close if $client
|
54
44
|
end
|
@@ -57,13 +47,6 @@ module Mutx
|
|
57
47
|
MongoConnection.instance.close
|
58
48
|
end
|
59
49
|
|
60
|
-
def set_db
|
61
|
-
Mutx::Support::Log.debug "Setting db" if Mutx::Support::Log
|
62
|
-
$db = $client.database
|
63
|
-
$client.close
|
64
|
-
$client = nil
|
65
|
-
end
|
66
|
-
|
67
50
|
def authenticate opts
|
68
51
|
Mutx::Support::Log.debug "db authenticating" if Mutx::Support::Log
|
69
52
|
$auth = $db.authenticate(opts[:username], opts[:pass]) if opts[:username] and opts[:pass]
|
@@ -72,14 +55,12 @@ module Mutx
|
|
72
55
|
def set_task_collection
|
73
56
|
Mutx::Support::Log.debug "Setting db tasks collection" if Mutx::Support::Log
|
74
57
|
$tasks = $db.collection("tasks")
|
75
|
-
|
76
|
-
# $tasks.indexes.create_one({ "name" => 1 }, :unique => true)
|
58
|
+
$tasks.indexes.create_one({ "name" => 1 }, :unique => true)
|
77
59
|
end
|
78
60
|
|
79
61
|
def set_custom_param_collection
|
80
62
|
Mutx::Support::Log.debug "Setting db custom param collection" if Mutx::Support::Log
|
81
63
|
$custom_params = $db.collection("custom_params")
|
82
|
-
# $custom_params.ensure_index({"name" => 1})
|
83
64
|
end
|
84
65
|
|
85
66
|
def set_input_collection
|
@@ -101,8 +82,10 @@ module Mutx
|
|
101
82
|
def set_results_collection
|
102
83
|
Mutx::Support::Log.debug "Setting db results collection" if Mutx::Support::Log
|
103
84
|
$results = $db.collection("results")
|
104
|
-
|
105
|
-
|
85
|
+
$results.indexes.create_many([
|
86
|
+
{ :key => { "_id" => 1 }, unique: true },
|
87
|
+
{ :key => { "started_at": -1 } }
|
88
|
+
])
|
106
89
|
end
|
107
90
|
|
108
91
|
def set_documentation_collection
|
@@ -447,6 +430,12 @@ module Mutx
|
|
447
430
|
res
|
448
431
|
end
|
449
432
|
|
433
|
+
def self.repo_data_for_id(id)
|
434
|
+
res = $repos.find({"_id" => id})
|
435
|
+
res = res.to_a.first if res.respond_to? :to_a
|
436
|
+
res
|
437
|
+
end
|
438
|
+
|
450
439
|
|
451
440
|
########################################
|
452
441
|
# CUSTOM PARAMS
|
@@ -620,6 +609,14 @@ module Mutx
|
|
620
609
|
$results.find({$or => [{"summary" => /#{status}/}, {"status" => /#{status}/ }]},{"_id" => 1}).to_a
|
621
610
|
end
|
622
611
|
|
612
|
+
def self.status_for_result result_id
|
613
|
+
begin
|
614
|
+
$results.find({"_id" => result_id}).to_a.first["status"]
|
615
|
+
rescue
|
616
|
+
nil
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
623
620
|
######################################3
|
624
621
|
# CONFIG
|
625
622
|
#
|