foreman-tasks 2.0.0 → 3.0.2
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/.github/workflows/js_tests.yml +31 -0
- data/.github/workflows/ruby_tests.yml +74 -0
- data/.rubocop.yml +12 -4
- data/.rubocop_todo.yml +32 -25
- data/Gemfile +5 -0
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +36 -60
- data/app/controllers/foreman_tasks/concerns/parameters/triggering.rb +1 -1
- data/app/controllers/foreman_tasks/recurring_logics_controller.rb +7 -0
- data/app/controllers/foreman_tasks/tasks_controller.rb +6 -3
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +3 -3
- data/app/lib/actions/proxy_action.rb +1 -1
- data/app/models/foreman_tasks/recurring_logic.rb +1 -1
- data/app/models/foreman_tasks/task.rb +11 -0
- data/app/models/foreman_tasks/task/dynflow_task.rb +29 -33
- data/app/models/foreman_tasks/task/status_explicator.rb +1 -1
- data/app/models/foreman_tasks/triggering.rb +1 -1
- data/app/models/setting/foreman_tasks.rb +9 -9
- data/app/services/foreman_tasks/dashboard_table_filter.rb +5 -1
- data/app/views/foreman_tasks/api/tasks/index.json.rabl +2 -0
- data/app/views/foreman_tasks/api/tasks/show.json.rabl +2 -0
- data/app/views/foreman_tasks/layouts/react.html.erb +1 -2
- data/app/views/foreman_tasks/recurring_logics/index.html.erb +3 -1
- data/app/views/foreman_tasks/tasks/show.html.erb +1 -6
- data/config/routes.rb +2 -1
- data/db/migrate/20200517215015_rename_bookmarks_controller.rb +2 -2
- data/db/migrate/20200611090846_add_task_lock_index_on_resource_type_and_task_id.rb +9 -0
- data/db/seeds.d/30-notification_blueprints.rb +7 -7
- data/db/seeds.d/61-foreman_tasks_bookmarks.rb +1 -1
- data/foreman-tasks.gemspec +1 -0
- data/lib/foreman_tasks/cleaner.rb +4 -6
- data/lib/foreman_tasks/dynflow/configuration.rb +1 -1
- data/lib/foreman_tasks/dynflow/persistence.rb +4 -6
- data/lib/foreman_tasks/engine.rb +2 -7
- data/lib/foreman_tasks/tasks/cleanup.rake +2 -2
- data/lib/foreman_tasks/tasks/dynflow.rake +6 -0
- data/lib/foreman_tasks/tasks/export_tasks.rake +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/en/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/en/foreman_tasks.po +50 -20
- data/locale/foreman_tasks.pot +173 -126
- data/locale/fr/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/fr/foreman_tasks.po +817 -0
- data/locale/ja/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/ja/foreman_tasks.po +817 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/zh_CN/foreman_tasks.po +816 -0
- data/package.json +1 -1
- data/script/npm_link_foreman_js.sh +26 -0
- data/test/controllers/api/recurring_logics_controller_test.rb +1 -1
- data/test/controllers/api/tasks_controller_test.rb +17 -7
- data/test/controllers/tasks_controller_test.rb +6 -6
- data/test/core/unit/runner_test.rb +20 -20
- data/test/core/unit/task_launcher_test.rb +8 -8
- data/test/helpers/foreman_tasks/foreman_tasks_helper_test.rb +7 -7
- data/test/helpers/foreman_tasks/tasks_helper_test.rb +3 -3
- data/test/lib/actions/middleware/keep_current_request_id_test.rb +3 -3
- data/test/support/history_tasks_builder.rb +1 -1
- data/test/tasks/generate_task_actions_test.rb +1 -1
- data/test/unit/actions/action_with_sub_plans_test.rb +2 -2
- data/test/unit/actions/bulk_action_test.rb +6 -6
- data/test/unit/actions/proxy_action_test.rb +20 -20
- data/test/unit/actions/recurring_action_test.rb +30 -32
- data/test/unit/cleaner_test.rb +24 -24
- data/test/unit/dashboard_table_filter_test.rb +5 -5
- data/test/unit/otp_manager_test.rb +2 -2
- data/test/unit/proxy_selector_test.rb +9 -9
- data/test/unit/recurring_logic_test.rb +32 -32
- data/test/unit/remote_task_test.rb +2 -2
- data/test/unit/task_groups_test.rb +4 -4
- data/test/unit/task_test.rb +18 -18
- data/test/unit/triggering_test.rb +8 -8
- data/test/unit/troubleshooting_help_generator_test.rb +6 -6
- data/test/unit/ui_notifications_test.rb +11 -11
- data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +2 -2
- data/webpack/ForemanTasks/Components/TaskActions/index.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/RunningSteps.js +17 -3
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +8 -153
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskButtons.js +168 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +6 -7
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskSkeleton.js +48 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +8 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +13 -70
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +95 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/RunningSteps.test.js.snap +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +78 -208
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskButtons.test.js.snap +212 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +8 -4
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js +100 -53
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss +13 -14
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +57 -95
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +3 -12
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +57 -28
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.fixtures.js +8 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +8 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +6 -6
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +84 -12
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +25 -21
- data/webpack/ForemanTasks/Components/TaskDetails/index.js +8 -3
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.scss +4 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.js +53 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.test.js +14 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.js +27 -19
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.scss +14 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -34
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/{StoppedTasksCardHelper.js → StoppedTasksCardTable.js} +28 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.test.js +54 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/OtherInfo.test.js.snap +48 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCard.test.js.snap +60 -1367
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCardTable.test.js.snap +960 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/__snapshots__/TasksCardsGrid.test.js.snap +14 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardActions.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +2 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js +17 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +2 -2
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +26 -14
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboard.test.js.snap +14 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardSelectors.test.js.snap +38 -22
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +2 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +25 -8
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +3 -3
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +6 -3
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.scss +0 -10
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +15 -2
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +2 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +48 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +39 -7
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionCellFormatter.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionCellFormatter.test.js.snap +2 -0
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/actionCellFormatter.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionCellFormatter.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/formatters/actionCellFormatter.js +10 -7
- data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionCellFormatter.js +7 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +39 -31
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +17 -8
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +8 -0
- data/webpack/ForemanTasks/Components/common/urlHelpers.js +7 -0
- data/webpack/ForemanTasks/ForemanTasksReducers.js +0 -2
- data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
- data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/API/index.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +5 -0
- metadata +35 -17
- data/.travis.yml +0 -5
- data/app/assets/stylesheets/foreman_tasks/tasks.scss +0 -9
- data/script/travis_run_js_tests.sh +0 -7
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -38
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +0 -33
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsReducer.test.js.snap +0 -26
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/integration.test.js.snap +0 -122
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +0 -67
- data/webpack/__mocks__/foremanReact/API.js +0 -7
data/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"description": "Foreman Tasks =============",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"foreman-js:link": "./script/npm_link_foreman_js.sh",
|
|
7
8
|
"lint": "tfm-lint --plugin -d /webpack",
|
|
8
9
|
"test": "tfm-test --plugin",
|
|
9
10
|
"test:watch": "tfm-test --plugin --watchAll",
|
|
@@ -27,7 +28,6 @@
|
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"c3": "^0.4.11",
|
|
29
30
|
"humanize-duration": "^3.20.1",
|
|
30
|
-
"react-html-parser": "^2.0.2",
|
|
31
31
|
"react-intl": "^2.8.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# This script replace the npm installation of `foreman-js`
|
|
4
|
+
# with your local version. Usefull when developing `foreman-js`
|
|
5
|
+
# Read more about foreman-js: https://github.com/theforeman/foreman-js
|
|
6
|
+
#
|
|
7
|
+
# This script designed to run using `npm run foreman-js:link` in foreman root
|
|
8
|
+
|
|
9
|
+
set -e
|
|
10
|
+
|
|
11
|
+
if [[ -z "${FOREMAN_JS_LOCATION}" ]]; then # FOREMAN_JS_LOCATION is empty
|
|
12
|
+
FOREMAN_JS_LOCATION="../foreman-js"
|
|
13
|
+
echo "FOREMAN_JS_LOCATION is not defined, using \"${FOREMAN_JS_LOCATION}\" instead"
|
|
14
|
+
elif [ ! -d "${FOREMAN_JS_LOCATION}" ]; then
|
|
15
|
+
echo "Can't find folder ${FOREMAN_JS_LOCATION}"
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
FOREMAN_JS_LOCATION="../${FOREMAN_JS_LOCATION}"
|
|
20
|
+
FOREMAN_JS_PACKAGES_LOCATION="${FOREMAN_JS_LOCATION}/packages"
|
|
21
|
+
FOREMAN_JS_INSTALL_LOCATION="./node_modules/@theforeman"
|
|
22
|
+
|
|
23
|
+
set -x
|
|
24
|
+
|
|
25
|
+
rm -rf $FOREMAN_JS_INSTALL_LOCATION
|
|
26
|
+
ln -s $FOREMAN_JS_PACKAGES_LOCATION $FOREMAN_JS_INSTALL_LOCATION
|
|
@@ -44,7 +44,7 @@ module ForemanRecurringLogic
|
|
|
44
44
|
post :cancel, params: { :id => @recurring_logic.id }
|
|
45
45
|
assert_response :success
|
|
46
46
|
@recurring_logic.reload
|
|
47
|
-
|
|
47
|
+
assert_equal @recurring_logic.state, 'cancelled'
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
@@ -45,6 +45,16 @@ module ForemanTasks
|
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
+
describe 'POST /api/tasks/bulk_search' do
|
|
49
|
+
it 'searching for a task' do
|
|
50
|
+
task = FactoryBot.create(:dynflow_task, :user_create_task)
|
|
51
|
+
post :bulk_search, params: { :searches => [{ :type => "task", :task_id => task.id, :search_id => "1" }] }
|
|
52
|
+
assert_response :success
|
|
53
|
+
data = JSON.parse(response.body)
|
|
54
|
+
_(data[0]['results'][0]['id']).must_equal task.id
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
48
58
|
describe 'GET /api/tasks/show' do
|
|
49
59
|
it 'searches for task' do
|
|
50
60
|
task = FactoryBot.create(:dynflow_task, :user_create_task)
|
|
@@ -115,7 +125,7 @@ module ForemanTasks
|
|
|
115
125
|
assert_response :success
|
|
116
126
|
response = JSON.parse(@response.body)
|
|
117
127
|
assert_kind_of Array, response
|
|
118
|
-
|
|
128
|
+
assert_empty response
|
|
119
129
|
end
|
|
120
130
|
end
|
|
121
131
|
end
|
|
@@ -135,18 +145,18 @@ module ForemanTasks
|
|
|
135
145
|
wait_for { ForemanTasks::Task.find_by(external_id: triggered.id).state == 'running' }
|
|
136
146
|
|
|
137
147
|
task = ForemanTasks::Task.where(:external_id => triggered.id).first
|
|
138
|
-
task.state.must_equal 'running'
|
|
139
|
-
task.result.must_equal 'pending'
|
|
148
|
+
_(task.state).must_equal 'running'
|
|
149
|
+
_(task.result).must_equal 'pending'
|
|
140
150
|
|
|
141
151
|
callback = Support::DummyProxyAction.proxy.log[:trigger_task].first[1][:callback]
|
|
142
152
|
post :callback, params: { 'callback' => callback, 'data' => { 'result' => 'success' } }
|
|
143
153
|
triggered.finished.wait(5)
|
|
144
154
|
|
|
145
155
|
task.reload
|
|
146
|
-
task.state.must_equal 'stopped'
|
|
147
|
-
task.result.must_equal 'success'
|
|
148
|
-
task.main_action.output['proxy_task_id'].must_equal Support::DummyProxyAction.proxy.uuid
|
|
149
|
-
task.main_action.output['proxy_output'].must_equal('result' => 'success')
|
|
156
|
+
_(task.state).must_equal 'stopped'
|
|
157
|
+
_(task.result).must_equal 'success'
|
|
158
|
+
_(task.main_action.output['proxy_task_id']).must_equal Support::DummyProxyAction.proxy.uuid
|
|
159
|
+
_(task.main_action.output['proxy_output']).must_equal('result' => 'success')
|
|
150
160
|
end
|
|
151
161
|
end
|
|
152
162
|
end
|
|
@@ -120,30 +120,30 @@ module ForemanTasks
|
|
|
120
120
|
@controller.stubs(:params).returns(:search => "id = #{task.id}")
|
|
121
121
|
in_taxonomy_scope(organizations.first) do |_o, _l|
|
|
122
122
|
results = @controller.send(:filter, ForemanTasks::Task)
|
|
123
|
-
results.map(&:id).sort.must_equal [task.id]
|
|
123
|
+
_(results.map(&:id).sort).must_equal [task.id]
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
it 'does not scope by taxonomy if unset' do
|
|
128
128
|
organizations
|
|
129
129
|
tasks
|
|
130
|
-
@controller.send(:current_taxonomy_search).must_equal ''
|
|
130
|
+
_(@controller.send(:current_taxonomy_search)).must_equal ''
|
|
131
131
|
results = @controller.send(:filter, ForemanTasks::Task)
|
|
132
|
-
results.map(&:id).sort.must_equal tasks.map(&:id).sort
|
|
132
|
+
_(results.map(&:id).sort).must_equal tasks.map(&:id).sort
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
it 'scopes by organization if set' do
|
|
136
136
|
scoped, _, unscoped = tasks
|
|
137
137
|
in_taxonomy_scope(organizations.first) do |o, _l|
|
|
138
|
-
@controller.send(:current_taxonomy_search).must_equal "(organization_id = #{o.id})"
|
|
138
|
+
_(@controller.send(:current_taxonomy_search)).must_equal "(organization_id = #{o.id})"
|
|
139
139
|
results = @controller.send(:filter, ForemanTasks::Task)
|
|
140
|
-
results.map(&:id).sort.must_equal [scoped, unscoped].map(&:id).sort
|
|
140
|
+
_(results.map(&:id).sort).must_equal [scoped, unscoped].map(&:id).sort
|
|
141
141
|
end
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
it 'scopes by org and location if set' do
|
|
145
145
|
in_taxonomy_scope(organizations.first, FactoryBot.create(:location)) do |o, l|
|
|
146
|
-
@controller.send(:current_taxonomy_search).must_equal "(organization_id = #{o.id} AND location_id = #{l.id})"
|
|
146
|
+
_(@controller.send(:current_taxonomy_search)).must_equal "(organization_id = #{o.id} AND location_id = #{l.id})"
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
149
|
end
|
|
@@ -14,7 +14,7 @@ module ForemanTasksCore
|
|
|
14
14
|
|
|
15
15
|
describe '#generate_updates' do
|
|
16
16
|
it 'returns empty hash when there are no outputs' do
|
|
17
|
-
runner.generate_updates.must_be :empty?
|
|
17
|
+
_(runner.generate_updates).must_be :empty?
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it 'returns a hash with outputs' do
|
|
@@ -22,10 +22,10 @@ module ForemanTasksCore
|
|
|
22
22
|
type = 'stdout'
|
|
23
23
|
runner.publish_data(message, type)
|
|
24
24
|
updates = runner.generate_updates
|
|
25
|
-
updates.keys.must_equal [suspended_action]
|
|
25
|
+
_(updates.keys).must_equal [suspended_action]
|
|
26
26
|
update = updates.values.first
|
|
27
|
-
update.exit_status.must_be :nil?
|
|
28
|
-
update.continuous_output.raw_outputs.count.must_equal 1
|
|
27
|
+
_(update.exit_status).must_be :nil?
|
|
28
|
+
_(update.continuous_output.raw_outputs.count).must_equal 1
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it 'works in compatibility mode' do
|
|
@@ -34,10 +34,10 @@ module ForemanTasksCore
|
|
|
34
34
|
type = 'stdout'
|
|
35
35
|
runner.publish_data(message, type)
|
|
36
36
|
updates = runner.generate_updates
|
|
37
|
-
updates.keys.must_equal [nil]
|
|
37
|
+
_(updates.keys).must_equal [nil]
|
|
38
38
|
update = updates.values.first
|
|
39
|
-
update.exit_status.must_be :nil?
|
|
40
|
-
update.continuous_output.raw_outputs.count.must_equal 1
|
|
39
|
+
_(update.exit_status).must_be :nil?
|
|
40
|
+
_(update.continuous_output.raw_outputs.count).must_equal 1
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -53,38 +53,38 @@ 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
|
|
57
|
-
outputs.values.each { |output| output.must_be_instance_of ContinuousOutput }
|
|
56
|
+
_(outputs.keys.count).must_equal 3
|
|
57
|
+
outputs.values.each { |output| _(output).must_be_instance_of ContinuousOutput }
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
describe '#generate_updates' do
|
|
62
62
|
it 'returns only updates for hosts with pending outputs' do
|
|
63
|
-
runner.generate_updates.must_equal({})
|
|
63
|
+
_(runner.generate_updates).must_equal({})
|
|
64
64
|
runner.publish_data_for('foo', 'something', 'something')
|
|
65
65
|
updates = runner.generate_updates
|
|
66
|
-
updates.keys.count.must_equal 1
|
|
66
|
+
_(updates.keys.count).must_equal 1
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it 'works in compatibility mode' do
|
|
70
70
|
runner = Parent.new targets
|
|
71
|
-
runner.generate_updates.must_equal({})
|
|
71
|
+
_(runner.generate_updates).must_equal({})
|
|
72
72
|
runner.broadcast_data('something', 'stdout')
|
|
73
73
|
updates = runner.generate_updates
|
|
74
|
-
updates.keys.count.must_equal 3
|
|
74
|
+
_(updates.keys.count).must_equal 3
|
|
75
75
|
# One of the keys is nil in compatibility mode
|
|
76
|
-
updates.keys.compact.count.must_equal 2
|
|
76
|
+
_(updates.keys.compact.count).must_equal 2
|
|
77
77
|
updates.keys.compact.each do |key|
|
|
78
|
-
key.must_be_instance_of ::Dynflow::Action::Suspended
|
|
78
|
+
_(key).must_be_instance_of ::Dynflow::Action::Suspended
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
it 'works without compatibility mode' do
|
|
83
83
|
runner.broadcast_data('something', 'stdout')
|
|
84
84
|
updates = runner.generate_updates
|
|
85
|
-
updates.keys.count.must_equal 3
|
|
85
|
+
_(updates.keys.count).must_equal 3
|
|
86
86
|
updates.keys.each do |key|
|
|
87
|
-
key.must_be_instance_of ::Dynflow::Action::Suspended
|
|
87
|
+
_(key).must_be_instance_of ::Dynflow::Action::Suspended
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
end
|
|
@@ -92,14 +92,14 @@ module ForemanTasksCore
|
|
|
92
92
|
describe '#publish_data_for' do
|
|
93
93
|
it 'publishes data for a single host' do
|
|
94
94
|
runner.publish_data_for('foo', 'message', 'stdout')
|
|
95
|
-
runner.generate_updates.keys.count.must_equal 1
|
|
95
|
+
_(runner.generate_updates.keys.count).must_equal 1
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
describe '#broadcast_data' do
|
|
100
100
|
it 'publishes data for all hosts' do
|
|
101
101
|
runner.broadcast_data('message', 'stdout')
|
|
102
|
-
runner.generate_updates.keys.count.must_equal 3
|
|
102
|
+
_(runner.generate_updates.keys.count).must_equal 3
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
@@ -115,7 +115,7 @@ module ForemanTasksCore
|
|
|
115
115
|
it 'broadcasts the exception to all targets' do
|
|
116
116
|
runner.expects(:publish_exit_status).never
|
|
117
117
|
runner.publish_exception('general failure', exception, false)
|
|
118
|
-
runner.generate_updates.keys.count.must_equal 3
|
|
118
|
+
_(runner.generate_updates.keys.count).must_equal 3
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
it 'publishes exit status if fatal' do
|
|
@@ -17,15 +17,15 @@ module ForemanTasksCore
|
|
|
17
17
|
|
|
18
18
|
it 'triggers an action' do
|
|
19
19
|
Support::DummyDynflowAction.any_instance.expects(:plan).with do |arg|
|
|
20
|
-
arg.must_equal(expected_result)
|
|
20
|
+
_(arg).must_equal(expected_result)
|
|
21
21
|
end
|
|
22
22
|
launcher.launch!(launcher_input)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it 'provides results' do
|
|
26
26
|
plan = launcher.launch!(launcher_input).finished.value!
|
|
27
|
-
launcher.results[:result].must_equal 'success'
|
|
28
|
-
plan.result.must_equal :success
|
|
27
|
+
_(launcher.results[:result]).must_equal 'success'
|
|
28
|
+
_(plan.result).must_equal :success
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -36,17 +36,17 @@ module ForemanTasksCore
|
|
|
36
36
|
Support::DummyDynflowAction.any_instance.expects(:plan).with { |arg| arg == expected_result }.twice
|
|
37
37
|
parent = launcher.launch!('foo' => launcher_input, 'bar' => launcher_input)
|
|
38
38
|
plan = parent.finished.value!
|
|
39
|
-
plan.result.must_equal :success
|
|
40
|
-
plan.sub_plans.count.must_equal 2
|
|
39
|
+
_(plan.result).must_equal :success
|
|
40
|
+
_(plan.sub_plans.count).must_equal 2
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it 'provides results' do
|
|
44
44
|
launcher.launch!('foo' => launcher_input, 'bar' => launcher_input)
|
|
45
|
-
launcher.results.keys.must_equal %w[foo bar]
|
|
45
|
+
_(launcher.results.keys).must_equal %w[foo bar]
|
|
46
46
|
launcher.results.values.each do |result|
|
|
47
47
|
plan = ForemanTasks.dynflow.world.persistence.load_execution_plan(result[:task_id])
|
|
48
|
-
result[:result].must_equal 'success'
|
|
49
|
-
plan.result.must_equal :success
|
|
48
|
+
_(result[:result]).must_equal 'success'
|
|
49
|
+
_(plan.result).must_equal :success
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
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
|
+
_(items.count).must_equal 1
|
|
14
|
+
_(items.first[:caption]).must_equal 'Tasks'
|
|
15
|
+
_(items.first[:url]).must_be_nil
|
|
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
|
+
_(items.map { |i| i[:caption] }).must_equal ['Tasks', 'A task']
|
|
24
|
+
_(items.last[:url]).must_be_nil
|
|
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
|
+
_(items.map { |i| i[:caption] }).must_equal ['Tasks', 'A task', 'Sub tasks']
|
|
35
|
+
_(items.last[:url]).must_be_nil
|
|
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
|
+
_(format_task_input(@task)).must_equal("Create user 'Anonymous Admin'")
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it 'displays the dash if task is nil' do
|
|
19
|
-
format_task_input(nil).must_equal('-')
|
|
19
|
+
_(format_task_input(nil)).must_equal('-')
|
|
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
|
+
_(format_task_input(@task)).must_equal("Create #{response}")
|
|
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
|
+
_(action.input[:current_request_id]).must_equal expected_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
|
+
_(action.output[:run_result]).must_equal expected_id
|
|
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
|
+
_(action.output[:finalize_result]).must_equal expected_id
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
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
|
+
_(ForemanTasks::Task.where(:action => label).count).must_equal tasks.count
|
|
30
30
|
assert_match(%r{Processed #{tasks.count}/#{tasks.count} tasks}, stdout)
|
|
31
31
|
end
|
|
32
32
|
|
|
@@ -43,8 +43,8 @@ module ForemanTasks
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
specify 'the sub-plan stores the information about its parent' do
|
|
46
|
-
task.sub_tasks.size.must_equal 1
|
|
47
|
-
task.sub_tasks.first.label.must_equal ChildAction.name
|
|
46
|
+
_(task.sub_tasks.size).must_equal 1
|
|
47
|
+
_(task.sub_tasks.first.label).must_equal ChildAction.name
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
specify "the locks of the sub-plan don't colide with the locks of its parent" do
|
|
@@ -31,20 +31,20 @@ module ForemanTasks
|
|
|
31
31
|
Target.expects(:unscoped).returns(Target)
|
|
32
32
|
Target.expects(:where).with(:id => targets.map(&:id)).returns(targets)
|
|
33
33
|
|
|
34
|
-
task.sub_tasks.count.must_equal targets.count
|
|
34
|
+
_(task.sub_tasks.count).must_equal targets.count
|
|
35
35
|
success, failed = task.sub_tasks.partition { |sub_task| sub_task.result == 'success' }
|
|
36
|
-
failed.must_be :empty?
|
|
37
|
-
success.count.must_equal 5
|
|
36
|
+
_(failed).must_be :empty?
|
|
37
|
+
_(success.count).must_equal 5
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
specify 'it plans a task for each target even if target cannot be found' do
|
|
41
41
|
Target.expects(:unscoped).returns(Target)
|
|
42
42
|
Target.expects(:where).with(:id => targets.map(&:id)).returns(targets.take(4))
|
|
43
43
|
|
|
44
|
-
task.sub_tasks.count.must_equal targets.count
|
|
44
|
+
_(task.sub_tasks.count).must_equal targets.count
|
|
45
45
|
success, failed = task.sub_tasks.partition { |sub_task| sub_task.result == 'success' }
|
|
46
|
-
success.count.must_equal 4
|
|
47
|
-
failed.count.must_equal 1
|
|
46
|
+
_(success.count).must_equal 4
|
|
47
|
+
_(failed.count).must_equal 1
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
@@ -37,17 +37,17 @@ module ForemanTasks
|
|
|
37
37
|
'proxy_action_name' => 'Proxy::DummyAction',
|
|
38
38
|
"proxy_version" => { "major" => 1, "minor" => 21, "patch" => 0 },
|
|
39
39
|
'callback' => { 'task_id' => Support::DummyProxyAction.proxy.uuid, 'step_id' => @action.run_step_id } }]
|
|
40
|
-
proxy_call.must_equal(expected_call)
|
|
40
|
+
_(proxy_call).must_equal(expected_call)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
describe 'with batch triggering' do
|
|
44
44
|
let(:batch_triggering) { true }
|
|
45
45
|
it 'create remote tasks for batch triggering' do
|
|
46
46
|
task = RemoteTask.first
|
|
47
|
-
task.state.must_equal 'new'
|
|
48
|
-
task.execution_plan_id.must_equal @action.execution_plan_id
|
|
49
|
-
task.operation.must_equal 'support'
|
|
50
|
-
task.remote_task_id.must_be :nil?
|
|
47
|
+
_(task.state).must_equal 'new'
|
|
48
|
+
_(task.execution_plan_id).must_equal @action.execution_plan_id
|
|
49
|
+
_(task.operation).must_equal 'support'
|
|
50
|
+
_(task.remote_task_id).must_be :nil?
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
@@ -56,22 +56,22 @@ module ForemanTasks
|
|
|
56
56
|
it "doesn't trigger the corresponding action again on the proxy" do
|
|
57
57
|
action = run_action(@action)
|
|
58
58
|
|
|
59
|
-
action.state.must_equal :suspended
|
|
59
|
+
_(action.state).must_equal :suspended
|
|
60
60
|
|
|
61
|
-
Support::DummyProxyAction.proxy.log[:trigger_task].size.must_equal 1
|
|
61
|
+
_(Support::DummyProxyAction.proxy.log[:trigger_task].size).must_equal 1
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
it 'supports skipping' do
|
|
66
66
|
action = run_action(@action, ::Dynflow::Action::Skip)
|
|
67
|
-
action.state.must_equal :success
|
|
67
|
+
_(action.state).must_equal :success
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
describe 'cancel' do
|
|
71
71
|
it 'sends the cancel event to the proxy when the cancel event is sent for the first time' do
|
|
72
72
|
action = run_action(@action, ::Dynflow::Action::Cancellable::Cancel)
|
|
73
|
-
Support::DummyProxyAction.proxy.log[:cancel_task].first.must_equal [Support::DummyProxyAction.proxy.uuid]
|
|
74
|
-
action.state.must_equal :suspended
|
|
73
|
+
_(Support::DummyProxyAction.proxy.log[:cancel_task].first).must_equal [Support::DummyProxyAction.proxy.uuid]
|
|
74
|
+
_(action.state).must_equal :suspended
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
it 'cancels the action immediatelly when cancel event is sent for the second time' do
|
|
@@ -82,14 +82,14 @@ module ForemanTasks
|
|
|
82
82
|
e
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
Support::DummyProxyAction.proxy.log[:cancel_task].size.must_equal 1
|
|
86
|
-
error.message.must_match 'Cancel enforced'
|
|
85
|
+
_(Support::DummyProxyAction.proxy.log[:cancel_task].size).must_equal 1
|
|
86
|
+
_(error.message).must_match 'Cancel enforced'
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
it 'saves the data comming from the proxy to the output and finishes' do
|
|
91
91
|
action = run_action(@action, ::Actions::ProxyAction::CallbackData.new('result' => 'success'))
|
|
92
|
-
action.output[:proxy_output].must_equal('result' => 'success')
|
|
92
|
+
_(action.output[:proxy_output]).must_equal('result' => 'success')
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it 'handles connection errors' do
|
|
@@ -103,12 +103,12 @@ module ForemanTasks
|
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
action = run_stubbed_action.call action
|
|
106
|
-
action.state.must_equal :suspended
|
|
107
|
-
action.world.clock.pending_pings.length.must_equal 1
|
|
108
|
-
action.output[:metadata][:failed_proxy_tasks].length.must_equal 1
|
|
106
|
+
_(action.state).must_equal :suspended
|
|
107
|
+
_(action.world.clock.pending_pings.length).must_equal 1
|
|
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)
|
|
111
|
-
action.state.must_equal :error
|
|
110
|
+
_ { proc { action = run_stubbed_action.call action } }.must_raise(Errno::ECONNREFUSED)
|
|
111
|
+
_(action.state).must_equal :error
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
it 'hides secrets' do
|
|
@@ -118,12 +118,12 @@ module ForemanTasks
|
|
|
118
118
|
'foo' => 'bar',
|
|
119
119
|
'secrets' => secrets)
|
|
120
120
|
task = ForemanTasks::Task.where(:external_id => triggered.id).first
|
|
121
|
-
task.input[:secrets].must_equal 'Secrets hidden'
|
|
121
|
+
_(task.input[:secrets]).must_equal 'Secrets hidden'
|
|
122
122
|
triggered.future.wait # Wait for the task to get triggered before leaving the test
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
it 'wipes secrets' do
|
|
126
|
-
@action.input[:secrets].must_equal secrets
|
|
126
|
+
_(@action.input[:secrets]).must_equal secrets
|
|
127
127
|
action = run_action(@action, ::Actions::ProxyAction::CallbackData.new('result' => 'success'))
|
|
128
128
|
|
|
129
129
|
# #wipe_secrets! gets called as a hook, hooks are not triggered when using action testing helpers
|