From 510fa590025e55e86e49f0b642c0256034fec63d Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 10 Dec 2023 23:57:14 +0900 Subject: [PATCH] Fix unit tests broken since Debian version bump Now Bookworm is supported instead of Bullseye. The hard-coded name is replaced by a fact value so that we don't have to update the value every time when we update the supported version. Change-Id: Ide9e4a9531f7aab2746722dbf9bc76fdf26345c7 --- ...penstack_extras_repo_debian_debian_spec.rb | 79 +++++++++---------- ...penstack_extras_repo_debian_ubuntu_spec.rb | 75 +++++++++--------- 2 files changed, 78 insertions(+), 76 deletions(-) diff --git a/spec/classes/openstack_extras_repo_debian_debian_spec.rb b/spec/classes/openstack_extras_repo_debian_debian_spec.rb index 84a01bd..b299209 100644 --- a/spec/classes/openstack_extras_repo_debian_debian_spec.rb +++ b/spec/classes/openstack_extras_repo_debian_debian_spec.rb @@ -58,14 +58,14 @@ apt-get update end it { should contain_apt__source('debian-openstack-backports').with( - :location => 'http://bullseye-bobcat.debian.net/debian', - :release => 'bullseye-bobcat-backports', + :location => "http://#{facts[:os]['distro']['codename']}-bobcat.debian.net/debian", + :release => "#{facts[:os]['distro']['codename']}-bobcat-backports", :repos => 'main', )} it { should contain_apt__source('debian-openstack-backports-nochange').with( - :location => 'http://bullseye-bobcat.debian.net/debian', - :release => 'bullseye-bobcat-backports-nochange', + :location => "http://#{facts[:os]['distro']['codename']}-bobcat.debian.net/debian", + :release => "#{facts[:os]['distro']['codename']}-bobcat-backports-nochange", :repos => 'main' )} @@ -78,21 +78,21 @@ apt-get update end it { should contain_apt__source('debian-openstack-backports').with( - :location => 'http://bullseye-pike.debian.net/debian', - :release => 'bullseye-pike-backports', + :location => "http://#{facts[:os]['distro']['codename']}-pike.debian.net/debian", + :release => "#{facts[:os]['distro']['codename']}-pike-backports", :repos => 'main', )} it { should contain_apt__source('debian-openstack-backports-nochange').with( - :location => 'http://bullseye-pike.debian.net/debian', - :release => 'bullseye-pike-backports-nochange', + :location => "http://#{facts[:os]['distro']['codename']}-pike.debian.net/debian", + :release => "#{facts[:os]['distro']['codename']}-pike-backports-nochange", :repos => 'main' )} it { should contain_exec('installing openstack-backports-archive-keyring') } end - context 'when not managing bullseye repo' do + context 'when not managing openstack repo' do let :params do default_params.merge!({ :manage_deb => false }) end @@ -102,23 +102,22 @@ apt-get update context 'with overridden source hash' do let :params do - default_params.merge!({ :source_hash => { - 'debian_unstable' => { - 'location' => 'http://mymirror/debian/', - 'repos' => 'main', - 'release' => 'unstable' - }, - 'puppetlabs' => { - 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'release' => 'bullseye', - 'key' => { - 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' - } - } - } - }) - default_params.merge!({ :use_extrepo => false }) + default_params.merge!({ + :source_hash => { + 'debian_unstable' => { + 'location' => 'http://mymirror/debian/', + 'repos' => 'main', + 'release' => 'unstable' + }, + 'puppetlabs' => { + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'main', + 'release' => facts[:os]['distro']['codename'], + 'key' => { 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' } + } + }, + :use_extrepo => false + }) end it { should contain_apt__source('debian_unstable').with( @@ -130,7 +129,7 @@ apt-get update it { should contain_apt__source('puppetlabs').with( :location => 'http://apt.puppetlabs.com', :repos => 'main', - :release => 'bullseye', + :release => facts[:os]['distro']['codename'], :key => { 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' }, )} @@ -139,19 +138,19 @@ apt-get update context 'with overridden source default' do let :params do - default_params.merge!({ :source_hash => { - 'debian_unstable' => { - 'location' => 'http://mymirror/debian/', - 'repos' => 'main', - 'release' => 'unstable' - }, - } - }) - default_params.merge!({ :source_defaults => { - 'include' => { 'src' => true } - } - }) - default_params.merge!({ :use_extrepo => false }) + default_params.merge!({ + :source_hash => { + 'debian_unstable' => { + 'location' => 'http://mymirror/debian/', + 'repos' => 'main', + 'release' => 'unstable' + }, + }, + :source_defaults => { + 'include' => { 'src' => true } + }, + :use_extrepo => false + }) end it { should contain_apt__source('debian_unstable').with( diff --git a/spec/classes/openstack_extras_repo_debian_ubuntu_spec.rb b/spec/classes/openstack_extras_repo_debian_ubuntu_spec.rb index 2be7f59..36d4485 100644 --- a/spec/classes/openstack_extras_repo_debian_ubuntu_spec.rb +++ b/spec/classes/openstack_extras_repo_debian_ubuntu_spec.rb @@ -28,7 +28,7 @@ describe 'openstack_extras::repo::debian::ubuntu' do it { should contain_apt__source('ubuntu-cloud-archive').with( :location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - :release => 'jammy-updates/bobcat', + :release => "#{facts[:os]['distro']['codename']}-updates/bobcat", :repos => 'main', )} @@ -42,7 +42,7 @@ describe 'openstack_extras::repo::debian::ubuntu' do it { should contain_apt__source('ubuntu-cloud-archive').with( :location => 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - :release => 'jammy-updates/juno', + :release => "#{facts[:os]['distro']['codename']}-updates/juno", :repos => 'main', )} @@ -59,33 +59,34 @@ describe 'openstack_extras::repo::debian::ubuntu' do context 'with overridden source hash' do let :params do - default_params.merge!({ :source_hash => { - 'local_mirror' => { - 'location' => 'http://mymirror/ubuntu/', - 'repos' => 'main', - 'release' => 'jammy' - }, - 'puppetlabs' => { - 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'release' => 'jammy', - 'key' => { - 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' - } - } - } - }) + default_params.merge!({ + :source_hash => { + 'local_mirror' => { + 'location' => 'http://mymirror/ubuntu/', + 'repos' => 'main', + 'release' => facts[:os]['distro']['codename'], + }, + 'puppetlabs' => { + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'main', + 'release' => facts[:os]['distro']['codename'], + 'key' => { + 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' + } + } + } + }) end it { should contain_apt__source('local_mirror').with( :location => 'http://mymirror/ubuntu/', - :release => 'jammy', + :release => facts[:os]['distro']['codename'], :repos => 'main' )} it { should contain_apt__source('puppetlabs').with( :location => 'http://apt.puppetlabs.com', - :release => 'jammy', + :release => facts[:os]['distro']['codename'], :repos => 'main', :key => { 'id' => '4BD6EC30', 'server' => 'pgp.mit.edu' } )} @@ -95,24 +96,24 @@ describe 'openstack_extras::repo::debian::ubuntu' do context 'with overridden source default' do let :params do - default_params.merge!({ :source_hash => { - 'local_mirror' => { - 'location' => 'http://mymirror/ubuntu/', - 'repos' => 'main', - 'release' => 'jammy' - } - } - }) - default_params.merge!({ :source_defaults => { - 'include' => { 'src' => true } - } - }) + default_params.merge!({ + :source_hash => { + 'local_mirror' => { + 'location' => 'http://mymirror/ubuntu/', + 'repos' => 'main', + 'release' => facts[:os]['distro']['codename'] + } + }, + :source_defaults => { + 'include' => { 'src' => true } + } + }) end it { should contain_apt__source('local_mirror').with( :include => { 'src' => true }, :location => 'http://mymirror/ubuntu/', - :release => 'jammy', + :release => facts[:os]['distro']['codename'], :repos => 'main', )} @@ -121,13 +122,15 @@ describe 'openstack_extras::repo::debian::ubuntu' do context 'with overridden uca repo name' do let :params do - default_params.merge!({ :repo => 'proposed', - :uca_location => 'http://mirror.dfw.rax.openstack.org/ubuntu-cloud-archive' }) + default_params.merge!({ + :repo => 'proposed', + :uca_location => 'http://mirror.dfw.rax.openstack.org/ubuntu-cloud-archive' + }) end it { should contain_apt__source('ubuntu-cloud-archive').with( :location => 'http://mirror.dfw.rax.openstack.org/ubuntu-cloud-archive', - :release => 'jammy-proposed/bobcat', + :release => "#{facts[:os]['distro']['codename']}-proposed/bobcat", :repos => 'main', )} end