foreman-tasks 0.17.3 → 0.17.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -6
- data/.rubocop_todo.yml +3 -0
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +1 -1
- data/app/lib/actions/helpers/with_delegated_action.rb +2 -2
- data/app/models/foreman_tasks/lock.rb +1 -1
- data/app/views/foreman_tasks/api/tasks/show.json.rabl +1 -1
- data/foreman-tasks.gemspec +1 -0
- data/lib/foreman_tasks/tasks/cleanup.rake +3 -3
- data/lib/foreman_tasks/version.rb +1 -1
- data/test/controllers/api/tasks_controller_test.rb +18 -0
- data/test/unit/cleaner_test.rb +4 -4
- data/test/unit/recurring_logic_test.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d2cab32dfa0f863a101a5d4e6edfe28bc25c5f76c4fac5718856de5a7a4c489
|
4
|
+
data.tar.gz: 1ecc4c1acc4f1b02a7915602a6248b0b0523ff678f60e7d2b51020c3182996a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6e35951542561fa3adff4efd4e92f519b0d4b723599d587bcb29b0575f1f46aa941c76500b91c71749478888615f0eacd4e11a1f170e92cd06a2dbdf7733ae3
|
7
|
+
data.tar.gz: bad6ba1e5959c8b8ab28e4461f36e0a1294bfc286c333b60e575ae7c2df12a92a8ebaabb27a5843012f4378bf64687b1d26f9f7ea7ec3b6347d0c3c8985d38d0
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require: rubocop-rails
|
2
|
+
|
1
3
|
# TODO: remove this file by either moving cops here or fixing code
|
2
4
|
inherit_from:
|
3
5
|
- .rubocop_todo.yml
|
@@ -34,9 +36,6 @@ Style/StringLiterals:
|
|
34
36
|
Style/FrozenStringLiteralComment:
|
35
37
|
Enabled: false
|
36
38
|
|
37
|
-
Style/FormatStringToken:
|
38
|
-
EnforcedStyle: template
|
39
|
-
|
40
39
|
Rails/SkipsModelValidations:
|
41
40
|
Enabled: false
|
42
41
|
|
@@ -87,9 +86,6 @@ Style/IfUnlessModifier:
|
|
87
86
|
Style/NumericPredicate:
|
88
87
|
Enabled: false
|
89
88
|
|
90
|
-
Style/IfUnlessModifier:
|
91
|
-
Enabled: false
|
92
|
-
|
93
89
|
Style/SafeNavigation:
|
94
90
|
Enabled: false
|
95
91
|
|
@@ -116,3 +112,6 @@ Rails/HelperInstanceVariable:
|
|
116
112
|
|
117
113
|
Naming/RescuedExceptionsVariableName:
|
118
114
|
Enabled: false
|
115
|
+
|
116
|
+
Style/WordArray:
|
117
|
+
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -240,7 +240,7 @@ module ForemanTasks
|
|
240
240
|
sort_by = ordering_params[:sort_by] || 'started_at'
|
241
241
|
sort_order = ordering_params[:sort_order] || 'DESC'
|
242
242
|
scope = scope.select("*, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration")
|
243
|
-
scope.order(
|
243
|
+
scope.order(sort_by => sort_order)
|
244
244
|
end
|
245
245
|
|
246
246
|
def task_hash(task)
|
@@ -46,9 +46,9 @@ module Actions
|
|
46
46
|
|
47
47
|
def delegated_action
|
48
48
|
# TODO: make it easier in dynflow to load action data
|
49
|
-
delegated_step = task.execution_plan.steps.values.
|
49
|
+
delegated_step = task.execution_plan.steps.values.reverse.find do |step|
|
50
50
|
step.action_id == input[:delegated_action_id]
|
51
|
-
end
|
51
|
+
end
|
52
52
|
return unless delegated_step
|
53
53
|
world.persistence.load_action(delegated_step)
|
54
54
|
end
|
@@ -19,7 +19,7 @@ module ForemanTasks
|
|
19
19
|
| #{_('Required lock: %s') % required_lock.name}
|
20
20
|
| #{_('Conflicts with tasks:')}
|
21
21
|
HEADER
|
22
|
-
url_helpers
|
22
|
+
url_helpers = Rails.application.routes.url_helpers
|
23
23
|
conflicting_tasks = conflicting_locks
|
24
24
|
.map(&:task)
|
25
25
|
.uniq
|
@@ -3,4 +3,4 @@ object @task if @task
|
|
3
3
|
attributes :id, :label, :pending, :action
|
4
4
|
attributes :username, :started_at, :ended_at, :state, :result, :progress
|
5
5
|
attributes :input, :output, :humanized, :cli_example
|
6
|
-
node(:available_actions) { |t| {cancellable: t.execution_plan&.cancellable?, resumable: t.resumable? }}
|
6
|
+
node(:available_actions) { |t| { cancellable: t.execution_plan&.cancellable?, resumable: t.resumable? } }
|
data/foreman-tasks.gemspec
CHANGED
@@ -4,15 +4,15 @@ namespace :foreman_tasks do
|
|
4
4
|
Clean tasks based on filter and age. ENV variables:
|
5
5
|
|
6
6
|
* TASK_SEARCH : scoped search filter (example: 'label = "Actions::Foreman::Host::ImportFacts"')
|
7
|
-
* AFTER : delete tasks
|
7
|
+
* AFTER : delete tasks started after *AFTER* period. Expected format is a number followed by the time unit (s = seconds, m = minutes, h = hours, d = days, y = years), such as '10d' for 10 days
|
8
8
|
* STATES : comma separated list of task states to touch with the cleanup, by default only stopped tasks are covered, special value all can be used to clean the tasks, disregarding their states
|
9
9
|
* NOOP : set to "true" if the task should not actually perform the deletion
|
10
10
|
* VERBOSE : set to "true" for more verbose output
|
11
11
|
* BATCH_SIZE : the size of batches the tasks get processed in (1000 by default)
|
12
12
|
* TASK_BACKUP : set to "true" or "false" to enable/disable task backup
|
13
13
|
|
14
|
-
If
|
15
|
-
configuration
|
14
|
+
If TASK_SEARCH is set then AFTER, STATES can be set and it's used for cleanup. If TASK_SEARCH is not set then
|
15
|
+
the cleanup respects the configuration file and setting AFTER or STATES will throw exception.
|
16
16
|
DESC
|
17
17
|
task :run => 'environment' do
|
18
18
|
options = {}
|
@@ -11,6 +11,24 @@ module ForemanTasks
|
|
11
11
|
@request.env['CONTENT_TYPE'] = 'application/json'
|
12
12
|
end
|
13
13
|
|
14
|
+
describe 'GET /api/tasks' do
|
15
|
+
it 'lists all tasks with default sorting' do
|
16
|
+
FactoryBot.create_list(:dynflow_task, 5, :user_create_task)
|
17
|
+
get :index
|
18
|
+
assert_response :success
|
19
|
+
data = JSON.parse(response.body)
|
20
|
+
_(data['results'].count).must_equal 5
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'supports searching' do
|
24
|
+
FactoryBot.create_list(:dynflow_task, 5, :user_create_task)
|
25
|
+
get :index, params: { :search => 'label = Actions::User::Create' }
|
26
|
+
assert_response :success
|
27
|
+
data = JSON.parse(response.body)
|
28
|
+
_(data['results'].count).must_equal 5
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
14
32
|
describe 'GET /api/tasks/show' do
|
15
33
|
it 'searches for task' do
|
16
34
|
task = FactoryBot.create(:dynflow_task, :user_create_task)
|
data/test/unit/cleaner_test.rb
CHANGED
@@ -79,10 +79,10 @@ class TasksTest < ActiveSupport::TestCase
|
|
79
79
|
tasks_to_delete = [FactoryBot.create(:dynflow_task, :user_create_task),
|
80
80
|
FactoryBot.create(:dynflow_task, :product_create_task)]
|
81
81
|
|
82
|
-
tasks_to_keep
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
tasks_to_keep = [FactoryBot.create(:dynflow_task, :user_create_task) do |task|
|
83
|
+
task.started_at = task.ended_at = Time.zone.now
|
84
|
+
task.save
|
85
|
+
end]
|
86
86
|
cleaner.expects(:tasks_to_csv)
|
87
87
|
cleaner.delete
|
88
88
|
ForemanTasks::Task.where(id: tasks_to_delete).must_be_empty
|
@@ -44,9 +44,9 @@ class RecurringLogicsTest < ActiveSupport::TestCase
|
|
44
44
|
days = '11'
|
45
45
|
days_of_week = { '1' => '1', '2' => '0', '3' => '0', '4' => '1', '5' => '0', '6' => '1', '7' => '0' }
|
46
46
|
time_hash = { '0' => '2015', '1' => '12', '2' => '10', '3' => hours, '4' => minutes }
|
47
|
-
expected_result_hourly
|
48
|
-
expected_result_daily
|
49
|
-
expected_result_weekly
|
47
|
+
expected_result_hourly = { :minutes => minutes }
|
48
|
+
expected_result_daily = { :minutes => minutes, :hours => hours }
|
49
|
+
expected_result_weekly = { :minutes => minutes, :hours => hours, :days_of_week => '1,4,6' }
|
50
50
|
expected_result_monthly = { :minutes => minutes, :hours => hours, :days => days }
|
51
51
|
ForemanTasks::RecurringLogic.cronline_hash(:hourly, time_hash, days, days_of_week).must_equal expected_result_hourly
|
52
52
|
ForemanTasks::RecurringLogic.cronline_hash(:daily, time_hash, days, days_of_week).must_equal expected_result_daily
|
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.17.
|
4
|
+
version: 0.17.4
|
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: 2019-
|
11
|
+
date: 2019-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foreman-tasks-core
|