foreman-tasks 0.8.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +35 -0
- data/.rubocop_todo.yml +138 -0
- data/app/controllers/foreman_tasks/api/recurring_logics_controller.rb +3 -4
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +56 -72
- data/app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb +2 -4
- data/app/controllers/foreman_tasks/recurring_logics_controller.rb +2 -5
- data/app/controllers/foreman_tasks/tasks_controller.rb +7 -8
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +44 -46
- data/app/helpers/foreman_tasks/tasks_helper.rb +1 -1
- data/app/lib/actions/action_with_sub_plans.rb +6 -8
- data/app/lib/actions/base.rb +6 -7
- data/app/lib/actions/bulk_action.rb +13 -9
- data/app/lib/actions/entry_action.rb +1 -3
- data/app/lib/actions/foreman/host/import_facts.rb +2 -5
- data/app/lib/actions/foreman/puppetclass/import.rb +1 -1
- data/app/lib/actions/helpers/args_serialization.rb +0 -1
- data/app/lib/actions/helpers/humanizer.rb +16 -21
- data/app/lib/actions/helpers/with_continuous_output.rb +0 -1
- data/app/lib/actions/helpers/with_delegated_action.rb +2 -2
- data/app/lib/actions/middleware/inherit_task_groups.rb +3 -5
- data/app/lib/actions/middleware/keep_current_user.rb +0 -3
- data/app/lib/actions/middleware/recurring_logic.rb +0 -1
- data/app/lib/actions/proxy_action.rb +8 -8
- data/app/lib/actions/serializers/active_record_serializer.rb +0 -3
- data/app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb +3 -3
- data/app/models/foreman_tasks/concerns/action_subject.rb +4 -6
- data/app/models/foreman_tasks/concerns/action_triggering.rb +20 -33
- data/app/models/foreman_tasks/concerns/host_action_subject.rb +5 -5
- data/app/models/foreman_tasks/lock.rb +29 -37
- data/app/models/foreman_tasks/recurring_logic.rb +23 -24
- data/app/models/foreman_tasks/task.rb +65 -39
- data/app/models/foreman_tasks/task/dynflow_task.rb +23 -24
- data/app/models/foreman_tasks/task/status_explicator.rb +3 -3
- data/app/models/foreman_tasks/task/summarizer.rb +3 -3
- data/app/models/foreman_tasks/task_group.rb +0 -2
- data/app/models/foreman_tasks/task_group_member.rb +0 -2
- data/app/models/foreman_tasks/task_groups/recurring_logic_task_group.rb +1 -4
- data/app/models/foreman_tasks/triggering.rb +19 -19
- data/app/models/setting/foreman_tasks.rb +8 -11
- data/app/services/foreman_tasks/proxy_selector.rb +4 -5
- data/app/views/foreman_tasks/tasks/_details.html.erb +1 -1
- data/bin/dynflow-executor +1 -1
- data/bin/foreman-tasks +1 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20150814204140_add_task_type_value_index.rb +1 -1
- data/db/migrate/20160924213030_change_tasks_widget_names.rb +8 -8
- data/db/seeds.d/61-foreman_tasks_bookmarks.rb +3 -3
- data/deploy/foreman-tasks.sysconfig +6 -0
- data/extra/dynflow-debug.sh +12 -0
- data/foreman-tasks.gemspec +1 -1
- data/lib/foreman_tasks.rb +3 -3
- data/lib/foreman_tasks/authorizer_ext.rb +1 -1
- data/lib/foreman_tasks/cleaner.rb +14 -16
- data/lib/foreman_tasks/dynflow.rb +11 -9
- data/lib/foreman_tasks/dynflow/configuration.rb +8 -10
- data/lib/foreman_tasks/dynflow/console_authorizer.rb +4 -5
- data/lib/foreman_tasks/dynflow/daemon.rb +17 -19
- data/lib/foreman_tasks/dynflow/persistence.rb +5 -8
- data/lib/foreman_tasks/engine.rb +30 -31
- data/lib/foreman_tasks/task_error.rb +1 -3
- data/lib/foreman_tasks/tasks/cleanup.rake +7 -19
- data/lib/foreman_tasks/tasks/dynflow.rake +1 -1
- data/lib/foreman_tasks/tasks/export_tasks.rake +51 -59
- data/lib/foreman_tasks/test_extensions.rb +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/lib/tasks/gettext.rake +10 -7
- data/locale/action_names.rb +3 -6
- data/locale/en/foreman_tasks.po +189 -177
- data/locale/foreman_tasks.pot +177 -137
- data/test/controllers/api/recurring_logics_controller_test.rb +3 -5
- data/test/controllers/api/tasks_controller_test.rb +5 -7
- data/test/factories/task_factory.rb +8 -8
- data/test/factories/triggering_factory.rb +2 -3
- data/test/helpers/foreman_tasks/tasks_helper_test.rb +11 -11
- data/test/support/dummy_proxy_action.rb +3 -4
- data/test/unit/actions/action_with_sub_plans_test.rb +5 -6
- data/test/unit/actions/proxy_action_test.rb +5 -8
- data/test/unit/cleaner_test.rb +11 -12
- data/test/unit/dynflow_console_authorizer_test.rb +4 -4
- data/test/unit/proxy_selector_test.rb +3 -3
- data/test/unit/recurring_logic_test.rb +19 -17
- data/test/unit/task_groups_test.rb +3 -4
- data/test/unit/task_test.rb +72 -5
- data/test/unit/triggering_test.rb +0 -1
- metadata +7 -6
- data/app/controllers/foreman_tasks/concerns/environments_extension.rb +0 -24
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'foreman_tasks_test_helper'
|
2
2
|
|
3
3
|
module ForemanTasks
|
4
4
|
class TaskGroupsTest < ActiveSupport::TestCase
|
@@ -15,7 +15,6 @@ module ForemanTasks
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class ParentAction < Actions::ActionWithSubPlans
|
18
|
-
|
19
18
|
middleware.use ::Actions::Middleware::InheritTaskGroups
|
20
19
|
|
21
20
|
def plan(count)
|
@@ -25,9 +24,9 @@ module ForemanTasks
|
|
25
24
|
task.add_missing_task_groups(task_group)
|
26
25
|
plan_self :count => count
|
27
26
|
end
|
28
|
-
|
27
|
+
|
29
28
|
def create_sub_plans
|
30
|
-
input[:count]
|
29
|
+
Array.new(input[:count]) { |i| trigger InheritingChildAction, i + 2 }
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
data/test/unit/task_test.rb
CHANGED
@@ -5,15 +5,15 @@ class TasksTest < ActiveSupport::TestCase
|
|
5
5
|
before { @original_current_user = User.current }
|
6
6
|
after { User.current = @original_current_user }
|
7
7
|
|
8
|
-
test
|
8
|
+
test 'can search the tasks by current_user' do
|
9
9
|
user_one = FactoryGirl.create(:user)
|
10
10
|
user_two = FactoryGirl.create(:user)
|
11
11
|
|
12
12
|
task_one = FactoryGirl.create(:some_task, :set_owner => user_one)
|
13
|
-
|
13
|
+
FactoryGirl.create(:some_task, :set_owner => user_two)
|
14
14
|
|
15
15
|
User.current = user_one
|
16
|
-
assert_equal [task_one], ForemanTasks::Task.search_for(
|
16
|
+
assert_equal [task_one], ForemanTasks::Task.search_for('owner.id = current_user')
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -30,13 +30,12 @@ class TasksTest < ActiveSupport::TestCase
|
|
30
30
|
User.current = user
|
31
31
|
task = FactoryGirl.create(:dynflow_task)
|
32
32
|
|
33
|
-
auth
|
33
|
+
auth = Authorizer.new(user)
|
34
34
|
assert auth.can?(permission.name.to_sym, task)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe 'consistency check' do
|
39
|
-
|
40
39
|
let(:consistent_task) { FactoryGirl.create(:dynflow_task, :sync_with_dynflow => true) }
|
41
40
|
let(:inconsistent_task) { FactoryGirl.create(:dynflow_task, :inconsistent_dynflow_task) }
|
42
41
|
|
@@ -52,4 +51,72 @@ class TasksTest < ActiveSupport::TestCase
|
|
52
51
|
inconsistent_task.reload.state.must_equal 'planned'
|
53
52
|
end
|
54
53
|
end
|
54
|
+
|
55
|
+
describe 'subtask count querying' do
|
56
|
+
let(:result_base) do
|
57
|
+
{
|
58
|
+
:error => 0,
|
59
|
+
:warning => 0,
|
60
|
+
:total => 0,
|
61
|
+
:success => 0,
|
62
|
+
:cancelled => 0,
|
63
|
+
:pending => 0
|
64
|
+
}
|
65
|
+
end
|
66
|
+
let(:task) { FactoryGirl.create(:dynflow_task) }
|
67
|
+
|
68
|
+
describe 'without sub tasks' do
|
69
|
+
it 'calculates the progress report correctly' do
|
70
|
+
task.sub_tasks_counts.must_equal result_base
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'with sub tasks' do
|
75
|
+
let(:failed) { FactoryGirl.create(:dynflow_task).tap { |t| t.result = :error } }
|
76
|
+
let(:success) { FactoryGirl.create(:dynflow_task).tap { |t| t.result = :success } }
|
77
|
+
before { task.sub_tasks = [success, failed] }
|
78
|
+
|
79
|
+
it 'calculate the progress report correctly' do
|
80
|
+
expected_result = result_base.merge(:success => 1, :error => 1, :total => 2)
|
81
|
+
task.sub_tasks_counts.must_equal expected_result
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'calculates the progress report correctly when using batch planning' do
|
85
|
+
result_base = result_base.merge(:success => 1, :error => 1, :total => 25)
|
86
|
+
fake_action = OpenStruct.new(:total_count => 25)
|
87
|
+
task.stubs(:main_action).returns(fake_action)
|
88
|
+
|
89
|
+
task.state = 'stopped'
|
90
|
+
expected_result = result_base.merge(:cancelled => 23)
|
91
|
+
task.sub_tasks_counts.must_equal expected_result
|
92
|
+
|
93
|
+
task.state = 'pending'
|
94
|
+
expected_result = result_base.merge(:pending => 23)
|
95
|
+
task.sub_tasks_counts.must_equal expected_result
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe 'recurring task' do
|
101
|
+
let(:logic) { FactoryGirl.build(:recurring_logic) }
|
102
|
+
let(:task) { FactoryGirl.create(:some_task) }
|
103
|
+
|
104
|
+
it 'can indicate it is recurring' do
|
105
|
+
refute task.recurring?
|
106
|
+
task.add_missing_task_groups(logic.task_group)
|
107
|
+
assert task.recurring?
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'delayed task' do
|
112
|
+
let(:task) { FactoryGirl.create(:some_task) }
|
113
|
+
|
114
|
+
it 'can indicate it is delayed' do
|
115
|
+
refute task.delayed?
|
116
|
+
task.execution_type.must_equal 'Immediate'
|
117
|
+
task.start_at = Time.now.utc + 100
|
118
|
+
assert task.delayed?
|
119
|
+
task.execution_type.must_equal 'Delayed'
|
120
|
+
end
|
121
|
+
end
|
55
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman-tasks-core
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.8.
|
33
|
+
version: 0.8.22
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.8.
|
40
|
+
version: 0.8.22
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sequel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,8 @@ extra_rdoc_files:
|
|
108
108
|
- LICENSE
|
109
109
|
files:
|
110
110
|
- ".gitignore"
|
111
|
+
- ".rubocop.yml"
|
112
|
+
- ".rubocop_todo.yml"
|
111
113
|
- ".tx/config"
|
112
114
|
- Gemfile
|
113
115
|
- LICENSE
|
@@ -118,7 +120,6 @@ files:
|
|
118
120
|
- app/assets/stylesheets/foreman_tasks/trigger_form.css
|
119
121
|
- app/controllers/foreman_tasks/api/recurring_logics_controller.rb
|
120
122
|
- app/controllers/foreman_tasks/api/tasks_controller.rb
|
121
|
-
- app/controllers/foreman_tasks/concerns/environments_extension.rb
|
122
123
|
- app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb
|
123
124
|
- app/controllers/foreman_tasks/concerns/parameters/triggering.rb
|
124
125
|
- app/controllers/foreman_tasks/recurring_logics_controller.rb
|
@@ -267,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
268
|
version: '0'
|
268
269
|
requirements: []
|
269
270
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.
|
271
|
+
rubygems_version: 2.5.1
|
271
272
|
signing_key:
|
272
273
|
specification_version: 4
|
273
274
|
summary: Foreman plugin for showing tasks information for resoruces and users
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module ForemanTasks
|
2
|
-
module Concerns
|
3
|
-
module EnvironmentsExtension
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
alias_method_chain :obsolete_and_new, :dynflow
|
8
|
-
end
|
9
|
-
|
10
|
-
def obsolete_and_new_with_dynflow
|
11
|
-
task = ForemanTasks.async_task(::Actions::Foreman::Puppetclass::Import,
|
12
|
-
params)
|
13
|
-
|
14
|
-
notice _("Added import task to queue, it will be run shortly")
|
15
|
-
rescue ::Foreman::Exception => e
|
16
|
-
error _("Failed to add task to queue: %s") % e.to_s
|
17
|
-
ensure
|
18
|
-
redirect_to :controller => controller_path
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|