Merge pull request #473 from mhaskel/freq_cleanup

Remove `update['always'] = true` support
This commit is contained in:
Daniele Sluijters 2015-03-19 10:14:56 +01:00
commit 0cbd24a4e5
5 changed files with 84 additions and 128 deletions

View file

@ -14,9 +14,6 @@ class apt(
if $update['frequency'] {
validate_re($update['frequency'], $frequency_options)
}
if $update['always'] {
validate_bool($update['always'])
}
if $update['timeout'] {
unless is_integer($update['timeout']) {
fail('timeout value for update must be an integer')
@ -84,7 +81,7 @@ class apt(
true => absent,
}
if $_update['always'] {
if $_update['frequency'] == 'always' {
Exec <| title=='apt_update' |> {
refreshonly => false,
}

View file

@ -57,7 +57,6 @@ class apt::params {
}
$update_defaults = {
'always' => false,
'frequency' => 'reluctantly',
'timeout' => undef,
'tries' => undef,

View file

@ -4,9 +4,6 @@ class apt::update {
#on the first run, but if it's not run in awhile something is likely borked
#with apt and we'd want to know about it.
if $::apt::_update['always'] == false {
#if always_apt_update is true there's no point in parsing this logic.
case $::apt::_update['frequency'] {
'always': {
$_kick_apt = true
@ -47,9 +44,6 @@ class apt::update {
$_kick_apt = false
}
}
} else {
$_kick_apt = false
}
if $_kick_apt {
$_refresh = false

View file

@ -96,7 +96,7 @@ describe 'apt' do
context 'lots of non-defaults' do
let :params do
{
:update => { 'always' => true, 'timeout' => 1, 'tries' => 3 },
:update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
:purge => { 'sources.list' => false, 'sources.list.d' => false,
'preferences' => false, 'preferences.d' => false, },
}

View file

@ -2,44 +2,11 @@
require 'spec_helper'
describe 'apt::update', :type => :class do
context "when update['always']=true" do
#This should completely disable all of this logic. These tests are to guarantee that we don't somehow magically change the behavior.
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
let (:pre_condition) { "class{'::apt': update => {'always' => true},}" }
it 'should trigger an apt-get update run' do
#set the apt_update exec's refreshonly attribute to false
is_expected.to contain_exec('apt_update').with({'refreshonly' => false })
end
['always','daily','weekly','reluctantly'].each do |update_frequency|
context "when apt::update['frequency'] has the value of #{update_frequency}" do
{ 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
context "and $::apt_update_last_success indicates #{desc}" do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } }
let (:pre_condition) { "class{'::apt': update => {'always' => true, 'frequency' => '#{update_frequency}'}, }" }
it 'should trigger an apt-get update run' do
# set the apt_update exec's refreshonly attribute to false
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
end
end
context 'when $::apt_update_last_success is nil' do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
let (:pre_condition) { "class{'::apt': update => {'always' => true, 'frequency' => '#{update_frequency}'}, }" }
it 'should trigger an apt-get update run' do
#set the apt_update exec\'s refreshonly attribute to false
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
end
end
end
end
end
end
context "when apt::update['always']=false" do
context "and apt::update['frequency']='always'" do
{ 'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
context "and $::apt_update_last_success indicates #{desc}" do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } }
let (:pre_condition) { "class{'::apt': update => {'always' => false, 'frequency' => 'always' },}" }
let (:pre_condition) { "class{'::apt': update => {'frequency' => 'always' },}" }
it 'should trigger an apt-get update run' do
#set the apt_update exec's refreshonly attribute to false
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
@ -48,7 +15,7 @@ describe 'apt::update', :type => :class do
end
context 'when $::apt_update_last_success is nil' do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'always' },}" }
let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" }
it 'should trigger an apt-get update run' do
#set the apt_update exec\'s refreshonly attribute to false
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
@ -59,7 +26,7 @@ describe 'apt::update', :type => :class do
{'a recent run' => Time.now.to_i, 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
context "and $::apt_update_last_success indicates #{desc}" do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy'} }
let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'reluctantly' },}" }
let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
it 'should not trigger an apt-get update run' do
#don't change the apt_update exec's refreshonly attribute. (it should be true)
is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
@ -68,7 +35,7 @@ describe 'apt::update', :type => :class do
end
context 'when $::apt_update_last_success is nil' do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => 'reluctantly' },}" }
let (:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
it 'should not trigger an apt-get update run' do
#don't change the apt_update exec's refreshonly attribute. (it should be true)
is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
@ -80,7 +47,7 @@ describe 'apt::update', :type => :class do
{ 'we are due for a run' => 1406660561,'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval|
context "and $::apt_update_last_success indicates #{desc}" do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :apt_update_last_success => factval, :lsbdistcodename => 'wheezy' } }
let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" }
let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
it 'should trigger an apt-get update run' do
#set the apt_update exec\'s refreshonly attribute to false
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
@ -89,7 +56,7 @@ describe 'apt::update', :type => :class do
end
context 'when the $::apt_update_last_success fact has a recent value' do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => Time.now.to_i } }
let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" }
let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
it 'should not trigger an apt-get update run' do
#don't change the apt_update exec\'s refreshonly attribute. (it should be true)
is_expected.to contain_exec('apt_update').with({'refreshonly' => true})
@ -97,7 +64,7 @@ describe 'apt::update', :type => :class do
end
context 'when $::apt_update_last_success is nil' do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :apt_update_last_success => nil } }
let (:pre_condition) { "class{ '::apt': update => {'always' => false, 'frequency' => '#{update_frequency}',} }" }
let (:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
it 'should trigger an apt-get update run' do
#set the apt_update exec\'s refreshonly attribute to false
is_expected.to contain_exec('apt_update').with({'refreshonly' => false})
@ -106,4 +73,3 @@ describe 'apt::update', :type => :class do
end
end
end
end