foreman-tasks 4.0.1 → 4.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bb66102c3571249534dc929d2f1515666d393d4d9f7987c098e529849bfeca7
4
- data.tar.gz: 01c53850b401aaf7c50f4807a5947956bdfe0fa99582c778bd615fba922286f9
3
+ metadata.gz: 99321b6a250c3166881128f05a88feb20cf24cc14e6ccbf813e5cc1853f4447a
4
+ data.tar.gz: 99ce5e8f81c1dbbdf41a6980b0ff4cb98529928dfd0769676821e6c71f8e2302
5
5
  SHA512:
6
- metadata.gz: bc272bf14fd55504672179272d3b26123b0d3c68cc6ddd97a8181bf9cfc1dd257e809501b9cb4d94cfe5730e8098c2fa0232fe26b35d227921520a66d976ae39
7
- data.tar.gz: 4b264080240f04e2544af9d026026df2c70f126f4168cef1f74a21fd0d810c21b7696f8fc7520c107d4402ea5bfad0762c75c93d6679c841e406e4d0898c23bd
6
+ metadata.gz: 7284f7dd3ff25480f57f697ebe57cbff5f6b865afd1e6792c710ea880bc23f0a6f261333c727a7917be9a30c9d1de54d7e4bfeebc9bc43635244fdd1ca8f5d79
7
+ data.tar.gz: 6580dd94504e0d9c5cf8f2d070bb42da3782feadbdba59ee9f1275e526b5b53b1cb34106163807f99eac09b59ba8991ea2f51bb224184007f7aee4bf30808553
@@ -12,7 +12,7 @@ jobs:
12
12
  - name: Setup Ruby
13
13
  uses: ruby/setup-ruby@v1
14
14
  with:
15
- ruby-version: 2.6
15
+ ruby-version: 2.7
16
16
  - name: Setup
17
17
  run: |
18
18
  gem install bundler
@@ -31,7 +31,7 @@ jobs:
31
31
  fail-fast: false
32
32
  matrix:
33
33
  foreman-core-branch: [develop]
34
- ruby-version: [2.5, 2.6]
34
+ ruby-version: [2.5, 2.6, 2.7]
35
35
  node-version: [12]
36
36
  steps:
37
37
  - run: sudo apt-get update
@@ -60,6 +60,7 @@ jobs:
60
60
  - name: Setup Bundler
61
61
  run: |
62
62
  echo "gem 'foreman-tasks', path: './foreman-tasks'" > bundler.d/foreman-tasks.local.rb
63
+ echo "gem 'sqlite3'" >> bundler.d/foreman-tasks.local.rb
63
64
  gem install bundler
64
65
  bundle config set without journald development console libvirt
65
66
  bundle config set path vendor/bundle
@@ -70,5 +71,6 @@ jobs:
70
71
  bundle exec rake db:migrate
71
72
  - name: Run plugin tests
72
73
  run: |
73
- bundle exec rake test:foreman-tasks
74
+ bundle exec rake test:foreman_tasks
75
+ bundle exec rake test:foreman_tasks_core
74
76
  bundle exec rake test TEST="test/unit/foreman/access_permissions_test.rb"
@@ -218,10 +218,8 @@ module Actions
218
218
  end
219
219
 
220
220
  def get_proxy_data(response)
221
- proxy_data = response['actions'].detect do |action|
222
- action['class'] == proxy_action_name || action.fetch('input', {})['proxy_operation_name'] == proxy_operation_name
223
- end
224
- proxy_data.fetch('output', {})
221
+ response['actions'].detect { |action| action.fetch('input', {})['task_id'] == task.id }
222
+ .try(:fetch, 'output', {})
225
223
  end
226
224
 
227
225
  def proxy_version(proxy)
@@ -89,7 +89,7 @@ module ForemanTasks
89
89
  property :ended_at, ActiveSupport::TimeWithZone, desc: 'Returns date with time the task ended at'
90
90
  end
91
91
  class Jail < Safemode::Jail
92
- allow :started_at, :ended_at, :result, :state, :label, :main_action, :action_output
92
+ allow :started_at, :ended_at, :result, :state, :label, :main_action, :action_continuous_output
93
93
  end
94
94
 
95
95
  def input
@@ -249,7 +249,7 @@ module ForemanTasks
249
249
  parts.join(' ').strip
250
250
  end
251
251
 
252
- def action_output
252
+ def action_continuous_output
253
253
  return unless main_action.is_a?(Actions::Helpers::WithContinuousOutput)
254
254
  main_action.continuous_output.sort!
255
255
  main_action.continuous_output.raw_outputs
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '4.0.1'.freeze
2
+ VERSION = '4.1.0'.freeze
3
3
  end
@@ -53,7 +53,7 @@ module ForemanTasksCore
53
53
  describe '#initialize_continuous_outputs' do
54
54
  it 'initializes outputs for targets and parent' do
55
55
  outputs = runner.initialize_continuous_outputs
56
- _(outputs.keys.count).must_equal 3
56
+ _(outputs.keys.count).must_equal 2
57
57
  outputs.values.each { |output| _(output).must_be_instance_of ContinuousOutput }
58
58
  end
59
59
  end
@@ -66,23 +66,10 @@ module ForemanTasksCore
66
66
  _(updates.keys.count).must_equal 1
67
67
  end
68
68
 
69
- it 'works in compatibility mode' do
70
- runner = Parent.new targets
71
- _(runner.generate_updates).must_equal({})
72
- runner.broadcast_data('something', 'stdout')
73
- updates = runner.generate_updates
74
- _(updates.keys.count).must_equal 3
75
- # One of the keys is nil in compatibility mode
76
- _(updates.keys.compact.count).must_equal 2
77
- updates.keys.compact.each do |key|
78
- _(key).must_be_instance_of ::Dynflow::Action::Suspended
79
- end
80
- end
81
-
82
69
  it 'works without compatibility mode' do
83
70
  runner.broadcast_data('something', 'stdout')
84
71
  updates = runner.generate_updates
85
- _(updates.keys.count).must_equal 3
72
+ _(updates.keys.count).must_equal 2
86
73
  updates.keys.each do |key|
87
74
  _(key).must_be_instance_of ::Dynflow::Action::Suspended
88
75
  end
@@ -99,7 +86,7 @@ module ForemanTasksCore
99
86
  describe '#broadcast_data' do
100
87
  it 'publishes data for all hosts' do
101
88
  runner.broadcast_data('message', 'stdout')
102
- _(runner.generate_updates.keys.count).must_equal 3
89
+ _(runner.generate_updates.keys.count).must_equal 2
103
90
  end
104
91
  end
105
92
 
@@ -115,7 +102,7 @@ module ForemanTasksCore
115
102
  it 'broadcasts the exception to all targets' do
116
103
  runner.expects(:publish_exit_status).never
117
104
  runner.publish_exception('general failure', exception, false)
118
- _(runner.generate_updates.keys.count).must_equal 3
105
+ _(runner.generate_updates.keys.count).must_equal 2
119
106
  end
120
107
 
121
108
  it 'publishes exit status if fatal' do
@@ -42,11 +42,34 @@ FactoryBot.define do
42
42
  end
43
43
  end
44
44
 
45
+ factory :task_with_links do
46
+ # posts_count is declared as a transient attribute and available in
47
+ # attributes on the factory, as well as the callback via the evaluator
48
+ transient do
49
+ locks_count { 1 }
50
+ resource_id { 1 }
51
+ resource_type { 'type1' }
52
+ end
53
+
54
+ # the after(:create) yields two values; the user instance itself and the
55
+ # evaluator, which stores all values from the factory, including transient
56
+ # attributes; `create_list`'s second argument is the number of records
57
+ # to create and we make sure the user is associated properly to the post
58
+ after(:create) do |task, evaluator|
59
+ create_list(
60
+ :link,
61
+ 1,
62
+ task: task,
63
+ resource_type: evaluator.resource_type,
64
+ resource_id: evaluator.resource_id
65
+ )
66
+ end
67
+ end
68
+
45
69
  factory :task_with_locks do
46
70
  # posts_count is declared as a transient attribute and available in
47
71
  # attributes on the factory, as well as the callback via the evaluator
48
72
  transient do
49
- locks_count { 3 }
50
73
  resource_id { 1 }
51
74
  resource_type { 'type1' }
52
75
  end
@@ -58,7 +81,7 @@ FactoryBot.define do
58
81
  after(:create) do |task, evaluator|
59
82
  create_list(
60
83
  :lock,
61
- evaluator.locks_count,
84
+ 1,
62
85
  task: task,
63
86
  resource_type: evaluator.resource_type,
64
87
  resource_id: evaluator.resource_id
@@ -68,11 +91,15 @@ FactoryBot.define do
68
91
  end
69
92
  end
70
93
 
94
+ factory :link, :class => ForemanTasks::Link do
95
+ resource_type { 'Katello::Repository' }
96
+ resource_id { 1 }
97
+ association :task, factory: :task_with_links
98
+ end
99
+
71
100
  factory :lock, :class => ForemanTasks::Lock do
72
- name { 'read' }
73
101
  resource_type { 'Katello::Repository' }
74
102
  resource_id { 1 }
75
- exclusive { true }
76
103
  association :task, factory: :task_with_locks
77
104
  end
78
105
  end
@@ -107,7 +107,7 @@ module ForemanTasks
107
107
  _(action.world.clock.pending_pings.length).must_equal 1
108
108
  _(action.output[:metadata][:failed_proxy_tasks].length).must_equal 1
109
109
  2.times { action.output[:metadata][:failed_proxy_tasks] << {} }
110
- _ { proc { action = run_stubbed_action.call action } }.must_raise(Errno::ECONNREFUSED)
110
+ _(proc { action = run_stubbed_action.call action }).must_raise(Errno::ECONNREFUSED)
111
111
  _(action.state).must_equal :error
112
112
  end
113
113
 
@@ -31,9 +31,9 @@ class TasksTest < ActiveSupport::TestCase
31
31
  assert_equal [@task_one], ForemanTasks::Task.search_for("user = #{@user_one.login}")
32
32
  end
33
33
 
34
- test 'cannot search by arbitrary key' do
35
- _ { proc { ForemanTasks::Task.search_for('user.my_key ~ 5') } }.must_raise(ScopedSearch::QueryNotSupported)
36
- _ { proc { ForemanTasks::Task.search_for('user. = 5') } }.must_raise(ScopedSearch::QueryNotSupported)
34
+ it 'cannot search by arbitrary key' do
35
+ _(proc { ForemanTasks::Task.search_for('user.my_key ~ 5') }).must_raise(ScopedSearch::QueryNotSupported)
36
+ _(proc { ForemanTasks::Task.search_for('user. = 5') }).must_raise(ScopedSearch::QueryNotSupported)
37
37
  end
38
38
 
39
39
  test 'can search the tasks by negated user' do
@@ -59,8 +59,8 @@ class TasksTest < ActiveSupport::TestCase
59
59
  end
60
60
 
61
61
  test 'cannot glob on user\'s id' do
62
- _ { proc { ForemanTasks::Task.search_for("user.id ~ something") } }.must_raise(ScopedSearch::QueryNotSupported)
63
- _ { proc { ForemanTasks::Task.search_for("user.id ~ 5") } }.must_raise(ScopedSearch::QueryNotSupported)
62
+ _(proc { ForemanTasks::Task.search_for("user.id ~ something") }).must_raise(ScopedSearch::QueryNotSupported)
63
+ _(proc { ForemanTasks::Task.search_for("user.id ~ 5") }).must_raise(ScopedSearch::QueryNotSupported)
64
64
  end
65
65
 
66
66
  test 'can search the tasks by user with wildcards' do
@@ -126,17 +126,17 @@ class TasksTest < ActiveSupport::TestCase
126
126
  end
127
127
 
128
128
  it 'raises an exception if duration is unknown' do
129
- _ { proc { ForemanTasks::Task.search_for('duration = "25 potatoes"') } }.must_raise ScopedSearch::QueryNotSupported
129
+ _(proc { ForemanTasks::Task.search_for('duration = "25 potatoes"') }).must_raise ScopedSearch::QueryNotSupported
130
130
  end
131
131
  end
132
132
 
133
133
  context 'by taxonomies' do
134
134
  test 'can search by taxonomies using IN' do
135
- assert_nothing_raised(PG::SyntaxError) { ForemanTasks::Task.search_for('location_id ^ (1)').first }
136
- assert_nothing_raised(PG::SyntaxError) { ForemanTasks::Task.search_for('organization_id ^ (1)').first }
137
- assert_nothing_raised(PG::SyntaxError) { ForemanTasks::Task.search_for('location_id ^ (1,2)').first }
138
- assert_nothing_raised(PG::SyntaxError) { ForemanTasks::Task.search_for('organization_id ^ (1,2)').first }
139
- assert_nothing_raised(PG::SyntaxError) { ForemanTasks::Task.search_for('organization_id = 1').first }
135
+ assert_nothing_raised { ForemanTasks::Task.search_for('location_id ^ (1)').first }
136
+ assert_nothing_raised { ForemanTasks::Task.search_for('organization_id ^ (1)').first }
137
+ assert_nothing_raised { ForemanTasks::Task.search_for('location_id ^ (1,2)').first }
138
+ assert_nothing_raised { ForemanTasks::Task.search_for('organization_id ^ (1,2)').first }
139
+ assert_nothing_raised { ForemanTasks::Task.search_for('organization_id = 1').first }
140
140
  end
141
141
  end
142
142
  end
@@ -302,7 +302,7 @@ class TasksTest < ActiveSupport::TestCase
302
302
  resource_type = 'restype1'
303
303
 
304
304
  task1_old = FactoryBot.create(
305
- :task_with_locks,
305
+ :task_with_links,
306
306
  started_at: '2019-10-01 11:15:55',
307
307
  ended_at: '2019-10-01 11:15:57',
308
308
  resource_id: 1,
@@ -310,7 +310,7 @@ class TasksTest < ActiveSupport::TestCase
310
310
  resource_type: resource_type
311
311
  )
312
312
  task1_new = FactoryBot.create(
313
- :task_with_locks,
313
+ :task_with_links,
314
314
  started_at: '2019-10-02 11:15:55',
315
315
  ended_at: '2019-10-02 11:15:57',
316
316
  resource_id: 1,
@@ -318,7 +318,7 @@ class TasksTest < ActiveSupport::TestCase
318
318
  resource_type: resource_type
319
319
  )
320
320
  task2 = FactoryBot.create(
321
- :task_with_locks,
321
+ :task_with_links,
322
322
  started_at: '2019-10-03 11:15:55',
323
323
  ended_at: '2019-10-03 11:15:57',
324
324
  resource_id: 2,
@@ -326,7 +326,7 @@ class TasksTest < ActiveSupport::TestCase
326
326
  resource_type: resource_type
327
327
  )
328
328
  task3 = FactoryBot.create(
329
- :task_with_locks,
329
+ :task_with_links,
330
330
  started_at: '2019-10-03 11:15:55',
331
331
  ended_at: '2019-10-03 11:15:57',
332
332
  resource_id: 3,
@@ -24,7 +24,7 @@ class TriggeringTest < ActiveSupport::TestCase
24
24
  it 'cannot have mode set to arbitrary value' do
25
25
  triggering = FactoryBot.build(:triggering)
26
26
  _(triggering).must_be :valid?
27
- _ { proc { triggering.mode = 'bogus' } }.must_raise ArgumentError
28
- _ { proc { triggering.mode = 27 } }.must_raise ArgumentError
27
+ _(proc { triggering.mode = 'bogus' }).must_raise ArgumentError
28
+ _(proc { triggering.mode = 27 }).must_raise ArgumentError
29
29
  end
30
30
  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: 4.0.1
4
+ version: 4.1.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: 2021-04-13 00:00:00.000000000 Z
11
+ date: 2021-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynflow