Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dist-upgrade & autoremove action #832

Merged
merged 2 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions spec/acceptance/init_task_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# run a test task
require 'spec_helper_acceptance'

describe 'apt tasks' do
describe 'update and upgrade', if: pe_install? && puppet_version =~ %r{(5\.\d\.\d)} && fact_on(master, 'osfamily') == 'Debian' do
it 'execute arbitary sql' do
describe 'apt tasks', if: pe_install? && puppet_version =~ %r{(5\.\d\.\d)} && fact_on(master, 'osfamily') == 'Debian' do
describe 'update' do
it 'updates package lists' do
result = run_task(task_name: 'apt', params: 'action=update')
expect_multiple_regexes(result: result, regexes: [%r{Reading package lists}, %r{Job completed. 1/1 nodes succeeded}])
end
end
describe 'upgrade' do
it 'upgrades packages' do
result = run_task(task_name: 'apt', params: 'action=upgrade')
expect_multiple_regexes(result: result, regexes: [%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}, %r{Job completed. 1/1 nodes succeeded}])
end
end
describe 'dist-upgrade' do
it 'dist-upgrades packages' do
result = run_task(task_name: 'apt', params: 'action=dist-upgrade')
expect_multiple_regexes(result: result, regexes: [%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}, %r{Job completed. 1/1 nodes succeeded}])
end
end
describe 'autoremove' do
it 'autoremoves obsolete packages' do
result = run_task(task_name: 'apt', params: 'action=autoremove')
expect_multiple_regexes(result: result, regexes: [%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}, %r{Job completed. 1/1 nodes succeeded}])
end
end
end
2 changes: 1 addition & 1 deletion tasks/init.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"parameters": {
"action": {
"description": "Action to perform ",
"type": "Enum[update, upgrade]"
"type": "Enum[update, upgrade, dist-upgrade, autoremove]"
}
}
}
2 changes: 1 addition & 1 deletion tasks/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def apt_get(action)
cmd = ['apt-get', action]
cmd << '-y' if action == 'upgrade'
cmd << '-y' if ['upgrade', 'dist-upgrade', 'autoremove'].include?(action)
stdout, stderr, status = Open3.capture3(*cmd)
raise Puppet::Error, stderr if status != 0 # rubocop:disable GetText/DecorateFunctionMessage
{ status: stdout.strip }
Expand Down