foreman-tasks 9.1.0 → 9.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 959e8a5bbb07d3d1b6b0d1f0b57f502b4397d5797ccc3037b1e9f77a8229b06a
4
- data.tar.gz: f0bef4b1aca4d471a2616e6b41751f1da2165eb23d9da65be87bf055bc4fab05
3
+ metadata.gz: 5280ef80f012ccdd9210e1dadd08a201a20cecba8158d78e6c4820cb367c007e
4
+ data.tar.gz: bba5cbfeadb51c5bd8f998a3f3439e53d52775d86703535c6359b808149ef24f
5
5
  SHA512:
6
- metadata.gz: 2740338c22e5f0371358d037212a2964d4a46119dd2d2275dc290b91742be20bdd2b74ef8b9b036f60e975b4e798424b20776eabfeaa9f49049f24a2389d48c7
7
- data.tar.gz: 43ae242cf9b8d2e7e873ab9fa99b5be157d1f9467e931d163ccf0e831d1e1969cd81ceb0391d1397f1d6606ee159b62e88e97202ddeac112579a34cc74f3d698
6
+ metadata.gz: 2226e22a486c65df96a9dd672b1a360a727482b5038a47d6405ff10fc23849b12077978d898c92467e8c911a79558be1be1004685d7abe99d311d9100677ca56
7
+ data.tar.gz: 9c3d1498b4aa19d45242ebfc333ccad9d4d2b4b09f1b8d466c9f5dfda9ad09b4ff3d45decd083617a5719ca738ada5f2992915f74a96b8c79a14347997d5afc4
@@ -42,6 +42,9 @@ module ForemanTasks
42
42
  end
43
43
 
44
44
  def update_from_batch_trigger(data, parent = {})
45
+ # The ID might get overwritten later, but it is a sane default in case of async
46
+ # triggering where we only get an id of a remote parent
47
+ self.remote_task_id = execution_plan_id
45
48
  if data['result'] == 'success'
46
49
  self.remote_task_id = data['task_id']
47
50
  self.state = 'triggered'
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '9.1.0'.freeze
2
+ VERSION = '9.1.1'.freeze
3
3
  end
@@ -17,14 +17,14 @@ module ForemanTasks
17
17
  get :index
18
18
  assert_response :success
19
19
  data = JSON.parse(response.body)
20
- _(data['results'].count).must_equal 5
20
+ assert_equal 5, data['results'].count
21
21
  end
22
22
 
23
23
  it 'supports searching' do
24
24
  get :index, params: { :search => 'label = Actions::User::Create' }
25
25
  assert_response :success
26
26
  data = JSON.parse(response.body)
27
- _(data['results'].count).must_equal 5
27
+ assert_equal 5, data['results'].count
28
28
  end
29
29
 
30
30
  it 'renders task ids when searching by resource id' do
@@ -33,15 +33,15 @@ module ForemanTasks
33
33
  get :index, params: { :search => "label = Actions::Katello::Product::Create and resource_id = 1" }
34
34
  assert_response :success
35
35
  data = JSON.parse(response.body)
36
- _(data['results'].first["id"]).must_equal task.id
36
+ assert_equal task.id, data['results'].first["id"]
37
37
  end
38
38
 
39
39
  it 'supports ordering by duration' do
40
40
  get :index, params: { :sort_by => 'duration' }
41
41
  assert_response :success
42
42
  data = JSON.parse(response.body)
43
- _(data.dig('sort', 'by')).must_equal 'duration'
44
- _(data['results'].count).must_equal 5
43
+ assert_equal 'duration', data.dig('sort', 'by')
44
+ assert_equal 5, data['results'].count
45
45
  end
46
46
 
47
47
  context 'with current taxonomies' do
@@ -53,9 +53,9 @@ module ForemanTasks
53
53
  get :index, params: { organization_id: org1.id }
54
54
  assert_response :success
55
55
  results = JSON.parse(response.body)['results']
56
- _(results.count).must_equal 6
57
- _(results.map { |r| r['id'] }).must_include org1_task.id
58
- _(results.map { |r| r['id'] }).wont_include org2_task.id
56
+ assert_equal 6, results.count
57
+ assert_includes results.map { |r| r['id'] }, org1_task.id
58
+ assert_not_includes results.map { |r| r['id'] }, org2_task.id
59
59
  end
60
60
  end
61
61
  end
@@ -66,7 +66,7 @@ module ForemanTasks
66
66
  post :bulk_search, params: { :searches => [{ :type => "task", :task_id => task.id, :search_id => "1" }] }
67
67
  assert_response :success
68
68
  data = JSON.parse(response.body)
69
- _(data[0]['results'][0]['id']).must_equal task.id
69
+ assert_equal task.id, data[0]['results'][0]['id']
70
70
  end
71
71
 
72
72
  it 'can search for a specific resource' do
@@ -77,7 +77,7 @@ module ForemanTasks
77
77
 
78
78
  assert_response :success
79
79
  data = JSON.parse(response.body)
80
- _(data[0]['results'][0]['id']).must_equal task.id
80
+ assert_equal task.id, data[0]['results'][0]['id']
81
81
  end
82
82
  end
83
83
 
@@ -108,7 +108,7 @@ module ForemanTasks
108
108
  get :show, params: { id: task.id }, session: set_session_user
109
109
  assert_response :success
110
110
  data = JSON.parse(response.body)
111
- _(data['duration']).must_equal task.duration.in_seconds.to_s
111
+ assert_equal task.duration.in_seconds.to_s, data['duration']
112
112
  end
113
113
  end
114
114
 
@@ -118,7 +118,7 @@ module ForemanTasks
118
118
  get :index, session: set_session_user
119
119
  assert_response :success
120
120
  data = JSON.parse(response.body)
121
- _(data['results'][0]['duration']).must_equal task.duration.in_seconds.to_s
121
+ assert_equal task.duration.in_seconds.to_s, data['results'][0]['duration']
122
122
  end
123
123
  end
124
124
 
@@ -189,17 +189,17 @@ module ForemanTasks
189
189
  wait_for { ForemanTasks::Task.find_by(external_id: triggered.id).state == 'running' }
190
190
 
191
191
  task = ForemanTasks::Task.where(:external_id => triggered.id).first
192
- _(task.state).must_equal 'running'
193
- _(task.result).must_equal 'pending'
192
+ assert_equal 'running', task.state
193
+ assert_equal 'pending', task.result
194
194
 
195
195
  callback = Support::DummyProxyAction.proxy.log[:trigger_task].first[1].first[1][:action_input][:callback]
196
196
  post :callback, params: { 'callback' => callback, 'data' => { 'result' => 'success' } }
197
197
  triggered.finished.wait(5)
198
198
 
199
199
  task.reload
200
- _(task.state).must_equal 'stopped'
201
- _(task.result).must_equal 'success'
202
- _(task.main_action.output['proxy_output']).must_equal('result' => 'success')
200
+ assert_equal 'stopped', task.state
201
+ assert_equal 'success', task.result
202
+ assert_equal({ 'result' => 'success' }, task.main_action.output['proxy_output'])
203
203
  end
204
204
  end
205
205
  end
@@ -141,30 +141,30 @@ module ForemanTasks
141
141
  @controller.stubs(:params).returns(:search => "id = #{task.id}")
142
142
  in_taxonomy_scope(organizations.first) do |_o, _l|
143
143
  results = @controller.send(:filter, ForemanTasks::Task)
144
- _(results.map(&:id).sort).must_equal [task.id]
144
+ assert_equal [task.id], results.map(&:id).sort
145
145
  end
146
146
  end
147
147
 
148
148
  it 'does not scope by taxonomy if unset' do
149
149
  organizations
150
150
  tasks
151
- _(@controller.send(:current_taxonomy_search)).must_equal ''
151
+ assert_equal '', @controller.send(:current_taxonomy_search)
152
152
  results = @controller.send(:filter, ForemanTasks::Task)
153
- _(results.map(&:id).sort).must_equal tasks.map(&:id).sort
153
+ assert_equal tasks.map(&:id).sort, results.map(&:id).sort
154
154
  end
155
155
 
156
156
  it 'scopes by organization if set' do
157
157
  scoped, _, unscoped = tasks
158
158
  in_taxonomy_scope(organizations.first) do |o, _l|
159
- _(@controller.send(:current_taxonomy_search)).must_equal "(organization_id = #{o.id})"
159
+ assert_equal "(organization_id = #{o.id})", @controller.send(:current_taxonomy_search)
160
160
  results = @controller.send(:filter, ForemanTasks::Task)
161
- _(results.map(&:id).sort).must_equal [scoped, unscoped].map(&:id).sort
161
+ assert_equal [scoped, unscoped].map(&:id).sort, results.map(&:id).sort
162
162
  end
163
163
  end
164
164
 
165
165
  it 'scopes by org and location if set' do
166
166
  in_taxonomy_scope(organizations.first, FactoryBot.create(:location)) do |o, l|
167
- _(@controller.send(:current_taxonomy_search)).must_equal "(organization_id = #{o.id} AND location_id = #{l.id})"
167
+ assert_equal "(organization_id = #{o.id} AND location_id = #{l.id})", @controller.send(:current_taxonomy_search)
168
168
  end
169
169
  end
170
170
  end
@@ -10,9 +10,9 @@ module ForemanTasks
10
10
  it 'prepares items for index correctly' do
11
11
  stubs(:action_name).returns('index')
12
12
  items = breadcrumb_items
13
- _(items.count).must_equal 1
14
- _(items.first[:caption]).must_equal 'Tasks'
15
- _(items.first[:url]).must_be_nil
13
+ assert_equal 1, items.count
14
+ assert_equal 'Tasks', items.first[:caption]
15
+ assert_nil items.first[:url]
16
16
  end
17
17
 
18
18
  it 'prepares items for show correctly' do
@@ -20,8 +20,8 @@ module ForemanTasks
20
20
  @task.action = 'A task'
21
21
  stubs(:action_name).returns('show')
22
22
  items = breadcrumb_items
23
- _(items.map { |i| i[:caption] }).must_equal ['Tasks', 'A task']
24
- _(items.last[:url]).must_be_nil
23
+ assert_equal(['Tasks', 'A task'], items.map { |i| i[:caption] })
24
+ assert_nil items.last[:url]
25
25
  end
26
26
 
27
27
  it 'prepares items for sub tasks correctly' do
@@ -31,8 +31,8 @@ module ForemanTasks
31
31
  @task.action = 'A task'
32
32
  stubs(:action_name).returns('sub_tasks')
33
33
  items = breadcrumb_items
34
- _(items.map { |i| i[:caption] }).must_equal ['Tasks', 'A task', 'Sub tasks']
35
- _(items.last[:url]).must_be_nil
34
+ assert_equal(['Tasks', 'A task', 'Sub tasks'], items.map { |i| i[:caption] })
35
+ assert_nil items.last[:url]
36
36
  end
37
37
  end
38
38
  end
@@ -12,11 +12,11 @@ module ForemanTasks
12
12
  end
13
13
 
14
14
  it 'formats the task input properly' do
15
- _(format_task_input(@task)).must_equal("Create user 'Anonymous Admin'")
15
+ assert_equal "Create user 'Anonymous Admin'", format_task_input(@task)
16
16
  end
17
17
 
18
18
  it 'displays the dash if task is nil' do
19
- _(format_task_input(nil)).must_equal('-')
19
+ assert_equal '-', format_task_input(nil)
20
20
  end
21
21
  end
22
22
 
@@ -37,7 +37,7 @@ module ForemanTasks
37
37
 
38
38
  it 'formats the task input properly' do
39
39
  response = "product 'product-2'; organization 'test-0'"
40
- _(format_task_input(@task)).must_equal("Create #{response}")
40
+ assert_equal("Create #{response}", format_task_input(@task))
41
41
  end
42
42
  end
43
43
  end
@@ -29,21 +29,21 @@ module ForemanTasks
29
29
  it 'stores the id on planning' do
30
30
  ::Logging.mdc['request'] = expected_id
31
31
  action = create_and_plan_action(DummyAction)
32
- _(action.input[:current_request_id]).must_equal expected_id
32
+ assert_equal expected_id, action.input[:current_request_id]
33
33
  end
34
34
 
35
35
  it 'restores the id for run' do
36
36
  ::Logging.mdc['request'] = expected_id
37
37
  action = create_and_plan_action(DummyAction, true)
38
38
  action = run_action action
39
- _(action.output[:run_result]).must_equal expected_id
39
+ assert_equal expected_id, action.output[:run_result]
40
40
  end
41
41
 
42
42
  it 'restores the id for finalize' do
43
43
  ::Logging.mdc['request'] = expected_id
44
44
  action = create_and_plan_action(DummyAction, true)
45
45
  action = finalize_action(run_action(action))
46
- _(action.output[:finalize_result]).must_equal expected_id
46
+ assert_equal expected_id, action.output[:finalize_result]
47
47
  end
48
48
  end
49
49
  end
@@ -11,22 +11,22 @@ module ForemanTasks
11
11
  let(:default_intervals) { [0.5, 1, 2, 4, 8, 16] }
12
12
 
13
13
  it 'is extends the polling action module' do
14
- _(::Dynflow::Action::Polling.ancestors.first).must_equal ForemanTasks::Concerns::PollingActionExtensions
14
+ assert_equal ForemanTasks::Concerns::PollingActionExtensions, ::Dynflow::Action::Polling.ancestors.first
15
15
  end
16
16
 
17
17
  it 'does not modify polling intervals by default' do
18
- _(Action.allocate.poll_intervals).must_equal default_intervals
18
+ assert_equal default_intervals, Action.allocate.poll_intervals
19
19
  end
20
20
 
21
21
  it 'cannot make intervals shorter than 0.5 seconds' do
22
22
  Setting.expects(:[]).with(:foreman_tasks_polling_multiplier).returns 0
23
- _(Action.allocate.poll_intervals).must_equal(default_intervals.map { 0.5 })
23
+ assert_equal default_intervals.map { 0.5 }, Action.allocate.poll_intervals
24
24
  end
25
25
 
26
26
  it 'can be used to make the intervals longer' do
27
27
  value = 5
28
28
  Setting.expects(:[]).with(:foreman_tasks_polling_multiplier).returns value
29
- _(Action.allocate.poll_intervals).must_equal(default_intervals.map { |i| i * value })
29
+ assert_equal default_intervals.map { |i| i * value }, Action.allocate.poll_intervals
30
30
  end
31
31
  end
32
32
  end
@@ -26,7 +26,7 @@ class GenerateTaskActionsTest < ActiveSupport::TestCase
26
26
  end
27
27
 
28
28
  assert_match(%r{Generating action for #{tasks.count} tasks}, stdout)
29
- _(ForemanTasks::Task.where(:action => label).count).must_equal tasks.count
29
+ assert_equal tasks.count, ForemanTasks::Task.where(:action => label).count
30
30
  assert_match(%r{Processed #{tasks.count}/#{tasks.count} tasks}, stdout)
31
31
  end
32
32
 
@@ -48,15 +48,15 @@ module ForemanTasks
48
48
  end
49
49
 
50
50
  specify 'the sub-plan stores the information about its parent' do
51
- _(task.sub_tasks.size).must_equal 1
52
- _(task.sub_tasks.first.label).must_equal ChildAction.name
51
+ assert_equal 1, task.sub_tasks.size
52
+ assert_equal ChildAction.name, task.sub_tasks.first.label
53
53
  end
54
54
 
55
55
  specify "the locks of the sub-plan don't colide with the locks of its parent" do
56
56
  child_task = task.sub_tasks.first
57
- assert_not(child_task.locks.any?, "the lock is ensured by the parent")
57
+ assert_not child_task.locks.any?, "the lock is ensured by the parent"
58
58
  found = ForemanTasks::Link.for_resource(user).where(:task_id => child_task.id).any?
59
- assert(found, "the action is linked properly")
59
+ assert found, "the action is linked properly"
60
60
  end
61
61
  end
62
62
  end
@@ -37,20 +37,20 @@ module ForemanTasks
37
37
  Target.expects(:unscoped).returns(Target)
38
38
  Target.expects(:where).with(:id => targets.map(&:id)).returns(targets)
39
39
 
40
- _(task.sub_tasks.count).must_equal targets.count
40
+ assert_equal targets.count, task.sub_tasks.count
41
41
  success, failed = task.sub_tasks.partition { |sub_task| sub_task.result == 'success' }
42
- _(failed).must_be :empty?
43
- _(success.count).must_equal 5
42
+ assert_empty failed
43
+ assert_equal 5, success.count
44
44
  end
45
45
 
46
46
  specify 'it plans a task for each target even if target cannot be found' do
47
47
  Target.expects(:unscoped).returns(Target)
48
48
  Target.expects(:where).with(:id => targets.map(&:id)).returns(targets.take(4))
49
49
 
50
- _(task.sub_tasks.count).must_equal targets.count
50
+ assert_equal targets.count, task.sub_tasks.count
51
51
  success, failed = task.sub_tasks.partition { |sub_task| sub_task.result == 'success' }
52
- _(success.count).must_equal 4
53
- _(failed.count).must_equal 1
52
+ assert_equal 4, success.count
53
+ assert_equal 1, failed.count
54
54
  end
55
55
 
56
56
  specify "it handles keyword arguments as indifferent hashes when they're being flattened" do
@@ -61,8 +61,8 @@ module ForemanTasks
61
61
  task = ForemanTasks::Task.where(:external_id => triggered.id).first
62
62
  wait_for { task.reload.state == 'stopped' }
63
63
  task = task.sub_tasks.first
64
- _(task.input[:kw_string]).must_equal 7
65
- _(task.input[:kw_symbol]).must_equal 7
64
+ assert_equal 7, task.input[:kw_string]
65
+ assert_equal 7, task.input[:kw_symbol]
66
66
  end
67
67
 
68
68
  specify 'it allows setting concurrency limit' do
@@ -71,7 +71,7 @@ module ForemanTasks
71
71
 
72
72
  triggered = ForemanTasks.trigger(ParentAction, ChildAction, targets, concurrency_limit: 25)
73
73
  task = ForemanTasks::Task.where(:external_id => triggered.id).first
74
- _(task.execution_plan.entry_action.concurrency_limit).must_equal 25
74
+ assert_equal 25, task.execution_plan.entry_action.concurrency_limit
75
75
  end
76
76
  end
77
77
  end
@@ -46,17 +46,17 @@ module ForemanTasks
46
46
  'proxy_action_name' => 'Proxy::DummyAction',
47
47
  'callback' => { 'task_id' => Support::DummyProxyAction.proxy.uuid, 'step_id' => @run_step_id } } }
48
48
  expected_call = ['support', { @action.execution_plan_id => action_input }]
49
- _(proxy_call).must_equal(expected_call)
49
+ assert_equal expected_call, proxy_call
50
50
  end
51
51
 
52
52
  describe 'with batch triggering' do
53
53
  let(:batch_triggering) { true }
54
54
  it 'create remote tasks for batch triggering' do
55
55
  task = RemoteTask.first
56
- _(task.state).must_equal 'new'
57
- _(task.execution_plan_id).must_equal @action.execution_plan_id
58
- _(task.operation).must_equal 'support'
59
- _(task.remote_task_id).must_be :nil?
56
+ assert_equal 'new', task.state
57
+ assert_equal @action.execution_plan_id, task.execution_plan_id
58
+ assert_equal 'support', task.operation
59
+ assert_nil task.remote_task_id
60
60
  end
61
61
  end
62
62
  end
@@ -65,22 +65,22 @@ module ForemanTasks
65
65
  it "doesn't trigger the corresponding action again on the proxy" do
66
66
  action = run_action(@action)
67
67
 
68
- _(action.state).must_equal :suspended
68
+ assert_equal :suspended, action.state
69
69
 
70
- _(Support::DummyProxyAction.proxy.log[:trigger_task].size).must_equal 1
70
+ assert_equal 1, Support::DummyProxyAction.proxy.log[:trigger_task].size
71
71
  end
72
72
  end
73
73
 
74
74
  it 'supports skipping' do
75
75
  action = run_action(@action, ::Dynflow::Action::Skip)
76
- _(action.state).must_equal :success
76
+ assert_equal :success, action.state
77
77
  end
78
78
 
79
79
  describe 'cancel' do
80
80
  it 'sends the cancel event to the proxy when the cancel event is sent for the first time' do
81
81
  action = run_action(@action, ::Dynflow::Action::Cancellable::Cancel)
82
- _(Support::DummyProxyAction.proxy.log[:cancel_task].first).must_equal [action.execution_plan_id]
83
- _(action.state).must_equal :suspended
82
+ assert_equal [action.execution_plan_id], Support::DummyProxyAction.proxy.log[:cancel_task].first
83
+ assert_equal :suspended, action.state
84
84
  end
85
85
 
86
86
  it 'cancels the action immediatelly when cancel event is sent for the second time' do
@@ -91,14 +91,14 @@ module ForemanTasks
91
91
  e
92
92
  end
93
93
 
94
- _(Support::DummyProxyAction.proxy.log[:cancel_task].size).must_equal 1
95
- _(error.message).must_match 'Cancel enforced'
94
+ assert_equal 1, Support::DummyProxyAction.proxy.log[:cancel_task].size
95
+ assert_match 'Cancel enforced', error.message
96
96
  end
97
97
  end
98
98
 
99
99
  it 'saves the data comming from the proxy to the output and finishes' do
100
100
  action = run_action(@action, ::Actions::ProxyAction::CallbackData.new('result' => 'success'))
101
- _(action.output[:proxy_output]).must_equal('result' => 'success')
101
+ assert_equal({ 'result' => 'success' }, action.output[:proxy_output])
102
102
  end
103
103
 
104
104
  it 'handles connection errors' do
@@ -112,12 +112,12 @@ module ForemanTasks
112
112
  end
113
113
  end
114
114
  action = run_stubbed_action.call action
115
- _(action.state).must_equal :suspended
116
- _(action.world.clock.pending_pings.length).must_equal 1
117
- _(action.output[:metadata][:failed_proxy_tasks].length).must_equal 1
115
+ assert_equal :suspended, action.state
116
+ assert_equal 1, action.world.clock.pending_pings.length
117
+ assert_equal 1, action.output[:metadata][:failed_proxy_tasks].length
118
118
  2.times { action.output[:metadata][:failed_proxy_tasks] << {} }
119
- _(proc { action = run_stubbed_action.call action }).must_raise(Errno::ECONNREFUSED)
120
- _(action.state).must_equal :error
119
+ assert_raises(Errno::ECONNREFUSED) { run_stubbed_action.call action }
120
+ assert_equal :error, action.state
121
121
  end
122
122
 
123
123
  it 'hides secrets' do
@@ -127,12 +127,12 @@ module ForemanTasks
127
127
  'foo' => 'bar',
128
128
  'secrets' => secrets)
129
129
  task = ForemanTasks::Task.where(:external_id => triggered.id).first
130
- _(task.input[:secrets]).must_equal 'Secrets hidden'
130
+ assert_equal 'Secrets hidden', task.input[:secrets]
131
131
  triggered.future.wait # Wait for the task to get triggered before leaving the test
132
132
  end
133
133
 
134
134
  it 'wipes secrets' do
135
- _(@action.input[:secrets]).must_equal secrets
135
+ assert_equal secrets, @action.input[:secrets]
136
136
  action = run_action(@action, ::Actions::ProxyAction::CallbackData.new('result' => 'success'))
137
137
 
138
138
  # #wipe_secrets! gets called as a hook, hooks are not triggered when using action testing helpers
@@ -50,45 +50,45 @@ module ForemanTasks
50
50
  end
51
51
 
52
52
  specify 'it triggers the repeat when task is cancelled' do
53
- _(recurring_task).must_be :delayed?
54
- _(recurring_logic.tasks.count).must_equal 1
53
+ assert_predicate recurring_task, :delayed?
54
+ assert_equal 1, recurring_logic.tasks.count
55
55
  cancelled_events = recurring_task.execution_plan.cancel
56
56
  cancelled_events.each(&:wait!)
57
57
  recurring_logic.reload
58
- _(recurring_logic.tasks.count).must_equal 2
58
+ assert_equal 2, recurring_logic.tasks.count
59
59
  new_task = recurring_logic.tasks.find { |task| task.id != recurring_task.id }
60
- _(new_task.execution_plan.delay_record.args).must_equal args
61
- _(new_task.start_at).must_equal(recurring_task.start_at + 1.year)
60
+ assert_equal args, new_task.execution_plan.delay_record.args
61
+ assert_equal recurring_task.start_at + 1.year, new_task.start_at
62
62
  end
63
63
 
64
64
  specify 'it triggers the repeat when the task goes into planned state' do
65
65
  delay_options = recurring_logic.generate_delay_options
66
66
  task = ForemanTasks.delay HookedAction, delay_options, *args
67
- _(recurring_logic.tasks.count).must_equal 1
67
+ assert_equal 1, recurring_logic.tasks.count
68
68
 
69
69
  # Perform planning of the delayed plan
70
70
  task.execution_plan.delay_record.plan
71
71
 
72
72
  # Check a repetition was planned
73
- _(recurring_logic.tasks.count).must_equal 2
73
+ assert_equal 2, recurring_logic.tasks.count
74
74
  end
75
75
 
76
76
  specify 'it does not trigger repeat when failing in run' do
77
77
  delay_options = recurring_logic.generate_delay_options
78
78
  task = ForemanTasks.delay HookedAction, delay_options, true, args.last
79
- _(recurring_logic.tasks.count).must_equal 1
79
+ assert_equal 1, recurring_logic.tasks.count
80
80
 
81
81
  # Perform the planning (trigger repeat)
82
82
  task.execution_plan.delay_record.plan
83
- _(recurring_logic.tasks.count).must_equal 2
83
+ assert_equal 2, recurring_logic.tasks.count
84
84
 
85
85
  # Let it fail
86
86
  task.execution_plan.delay_record.execute.finished.wait
87
87
  task.reload
88
- _(task.result).must_equal 'error'
88
+ assert_equal 'error', task.result
89
89
 
90
90
  # Check no new repetitions were planned
91
- _(recurring_logic.tasks.count).must_equal 2
91
+ assert_equal 2, recurring_logic.tasks.count
92
92
  end
93
93
 
94
94
  specify 'it resets the request id on repetition' do
@@ -99,13 +99,13 @@ module ForemanTasks
99
99
 
100
100
  delay_options = recurring_logic.generate_delay_options
101
101
  task = ForemanTasks.delay HookedAction, delay_options, true, args.last
102
- _(task.input[:current_request_id]).must_equal expected_id
102
+ assert_equal expected_id, task.input[:current_request_id]
103
103
 
104
104
  SecureRandom.stubs(:uuid).returns(new_id)
105
105
  # Perform the planning (trigger repeat)
106
106
  task.execution_plan.delay_record.plan
107
107
  repetition = recurring_logic.tasks.find { |t| t.id != task.id }
108
- _(repetition.input[:current_request_id]).must_equal new_id
108
+ assert_equal new_id, repetition.input[:current_request_id]
109
109
  ensure
110
110
  ::Logging.mdc['request'] = old_id
111
111
  end
@@ -114,11 +114,11 @@ module ForemanTasks
114
114
  delay_options = past_recurring_logic.generate_delay_options
115
115
  delay_options[:start_at] = Time.zone.now - 1.week
116
116
  task = ForemanTasks.delay HookedAction, delay_options, *args
117
- _(past_recurring_logic.tasks.count).must_equal 1
117
+ assert_equal 1, past_recurring_logic.tasks.count
118
118
 
119
119
  task.execution_plan.delay_record.plan
120
120
  # Post planning, a new task should be scheduled
121
- _(past_recurring_logic.tasks.count).must_equal 2
121
+ assert_equal 2, past_recurring_logic.tasks.count
122
122
  # The scheduled task should have the start date according to cron in future.
123
123
  assert_equal (Time.zone.now + 1.minute).change(:sec => 0), past_recurring_logic.tasks.where(:state => "scheduled").first.start_at
124
124
  end
@@ -13,8 +13,8 @@ module ForemanTasks
13
13
  describe 'triggering' do
14
14
  it 'doesnt run anything on trigger' do
15
15
  Actions::TriggerProxyBatch.any_instance.expects(:trigger_remote_tasks_batch).never
16
- _(triggered.state).must_equal :suspended
17
- _(triggered.output[:planned_count]).must_equal 0
16
+ assert_equal :suspended, triggered.state
17
+ assert_equal 0, triggered.output[:planned_count]
18
18
  end
19
19
 
20
20
  it 'triggers remote tasks on TriggerNextBatch' do
@@ -37,7 +37,7 @@ module ForemanTasks
37
37
  Actions::TriggerProxyBatch.any_instance.expects(:trigger_remote_tasks_batch).once
38
38
  triggered.output[:planned_count] = 0
39
39
  action = run_action(triggered, Actions::TriggerProxyBatch::TriggerLastBatch)
40
- _(action.state).must_equal :success
40
+ assert_equal :success, action.state
41
41
  end
42
42
  end
43
43
 
@@ -57,7 +57,7 @@ module ForemanTasks
57
57
  ForemanTasks::RemoteTask.expects(:batch_trigger).with(proxy_operation_name, grouped_remote_batch)
58
58
 
59
59
  triggered.trigger_remote_tasks_batch
60
- _(triggered.output[:planned_count]).must_equal(batch_size)
60
+ assert_equal batch_size, triggered.output[:planned_count]
61
61
  end
62
62
  end
63
63
  end