(MODULES-10763) Remove frequency collector
authorLTangaF <9220123+LTangaF@users.noreply.github.com>
Thu, 7 Oct 2021 16:56:16 +0000 (16:56 +0000)
committerLTangaF <9220123+LTangaF@users.noreply.github.com>
Thu, 7 Oct 2021 16:56:16 +0000 (16:56 +0000)
The case logic in apt::update adequately covers the 'always' case and
the collector causes issues in acceptance testing.

manifests/init.pp
spec/classes/apt_update_spec.rb

index 49f93093ce99396695fc64f922fb21a9772247e9..2f82b7d8fdb40f374552f1a15b57006f9f8cb49f 100644 (file)
@@ -267,12 +267,6 @@ class apt (
     default => file,
   }
 
-  if $_update['frequency'] == 'always' {
-    Exec <| title=='apt_update' |> {
-      refreshonly => false,
-    }
-  }
-
   apt::setting { 'conf-update-stamp':
     priority => 15,
     content  => "${confheadertmp}${updatestamptmp}",
index c6336a9151c943347f4029eff026dc7a881cedbc..89ba942aac702dd2dd9f5d5e970db97c7fd5e1e0 100644 (file)
@@ -61,6 +61,36 @@ describe 'apt::update', type: :class do
         is_expected.to contain_exec('apt_update').with('refreshonly' => false)
       end
     end
+    context 'and Exec[apt_update] refreshonly is overridden to true and has recent run' do
+      let(:facts) do
+        {
+          os: {
+            family: 'Debian',
+            name: 'Debian',
+            release: {
+              major: '8',
+              full: '8.0',
+            },
+            distro: {
+              codename: 'jessie',
+              id: 'Debian',
+            },
+          },
+          apt_update_last_success: Time.now.to_i,
+        }
+      end
+      let(:pre_condition) do
+        "
+        class{'::apt': update => {'frequency' => 'always' },}
+        Exec <| title=='apt_update' |> { refreshonly => true }
+        "
+      end
+
+      it 'skips 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' => true)
+      end
+    end
   end
   context "when apt::update['frequency']='reluctantly'" do
     {