Skip to content

Commit 24a3836

Browse files
authored
Merge pull request #641 from mhashizume/MODULES-11365/main/puppet8-rspec
(MODULES-11365) Enable rspec tests on Ruby 3.2
2 parents 8c36ace + 476d9b8 commit 24a3836

9 files changed

+43
-215
lines changed

.github/workflows/unit_tests_with_nightly_puppet_gem.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ 'ubuntu-20.04', 'macos-latest', 'windows-2022' ]
16-
puppet_version: [ 6, 7 ]
16+
puppet_version: [ '7', '8' ]
1717
include:
18-
- puppet_version: 6
19-
ruby: 2.5
20-
- puppet_version: 7
21-
ruby: 2.7
18+
- puppet_version: '7'
19+
ruby: '2.7'
20+
- puppet_version: '8'
21+
ruby: '3.2'
2222

2323
- os: 'ubuntu-20.04'
2424
os_type: 'Linux'
@@ -31,7 +31,11 @@ jobs:
3131
- os: 'windows-2022'
3232
os_type: 'Windows'
3333
env_set_cmd: '$env:'
34-
gem_file: 'puppet-latest-x64-mingw32.gem'
34+
# setup-ruby uses ucrt for newer Rubies, but we only support mingw
35+
# in our Windows Puppet nightly gems. For now, we'll just install
36+
# the universal gem and manually install the ffi dependency
37+
gem_file: 'puppet-latest.gem'
38+
extra_steps: 'gem install ffi --version 1.15.5'
3539

3640
runs-on: ${{ matrix.os }}
3741
steps:
@@ -45,6 +49,7 @@ jobs:
4549

4650
- name: Install the latest nightly build of puppet${{ matrix.puppet_version }} gem
4751
run: |
52+
${{ matrix.extra_steps }}
4853
curl https://nightlies.puppet.com/downloads/gems/puppet${{ matrix.puppet_version }}-nightly/${{ matrix.gem_file }} --output puppet.gem --location
4954
gem install puppet.gem -N
5055

.sync.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Gemfile:
4343
version: '4.21.0' # due to https://github.com/octokit/octokit.rb/issues/1391
4444
- gem: async
4545
version: '~> 1.30' # otherwise async 2.0.0(needs ruby >=3.1.0) is wrongly selected by bundler on jenkins while running with ruby 2.7.1
46+
- gem: puppet_litmus
47+
version: '0.34.5'
4648
appveyor.yml:
4749
delete: true
4850
.travis.yml:

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ group :development do
5252
gem "async", '~> 1.30', require: false
5353
end
5454
group :system_tests do
55-
gem "puppet_litmus", '< 1.0.0', require: false, platforms: [:ruby, :x64_mingw]
55+
# Pin Litmus to the last version that doens't pin r10k
56+
# We need later versions of r10k for Ruby 3.2 compatibility
57+
gem "puppet_litmus", '= 0.34.5', require: false, platforms: [:ruby, :x64_mingw]
5658
gem "serverspec", '~> 2.41', require: false
5759
gem "voxpupuli-acceptance"
5860
end

spec/classes/puppet_agent_osfamily_aix_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
let(:common_facts) do
55
{
66
clientcert: 'foo.example.vm',
7-
is_pe: true,
7+
is_pe: true,
88
os: {
99
architecture: 'PowerPC_POWER7',
1010
family: 'AIX',
1111
name: 'AIX',
1212
},
13-
platform_tag: 'aix-7.2-power',
14-
servername: 'master.example.vm',
13+
platform_tag: 'aix-7.2-power',
14+
servername: 'master.example.vm',
1515
}
1616
end
1717

@@ -212,7 +212,7 @@
212212

213213
context 'not AIX' do
214214
let(:facts) do
215-
override_facts(common_facts, { os: { name: 'not-AIX', }, })
215+
override_facts(common_facts, os: { name: 'not-AIX' })
216216
end
217217

218218
it { expect { catalogue }.to raise_error(%r{not supported}) }

spec/classes/puppet_agent_osfamily_darwin_spec.rb

Lines changed: 8 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,13 @@
4141
describe 'supported environment' do
4242
let(:params) { { package_version: package_version } }
4343

44-
context 'when running a supported OSX' do
44+
context 'when running a supported macOS' do
4545
['osx-10.15-x86_64', 'osx-11-x86_64', 'osx-12-x86_64'].each do |tag|
4646
context "on #{tag} with no aio_version" do
4747
let(:osmajor) { tag.split('-')[1] }
4848

4949
let(:facts) do
50-
override_facts(facts,
51-
{
52-
aio_agent_version: '1.10.99',
53-
is_pe: true,
54-
os: {
55-
macosx: {
56-
version: {
57-
major: osmajor,
58-
},
59-
},
60-
},
61-
platform_tag: tag,
62-
})
50+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: osmajor, }, }, }, platform_tag: tag)
6351
end
6452

6553
it { is_expected.to compile.with_all_deps }
@@ -95,18 +83,7 @@
9583
}
9684
end
9785
let(:facts) do
98-
override_facts(facts, {
99-
aio_agent_version: '1.10.99',
100-
is_pe: true,
101-
os: {
102-
macosx: {
103-
version: {
104-
major: '10.13',
105-
},
106-
},
107-
},
108-
platform_tag: 'osx-10.13-x86_64',
109-
})
86+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: '10.13', }, }, }, platform_tag: 'osx-10.13-x86_64')
11087
end
11188

11289
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.100.1-1.osx10.13.dmg').with_source('https://fake-pe-master.com/packages/2000.0.0/osx-10.13-x86_64/puppet-agent-5.10.100.1-1.osx10.13.dmg') }
@@ -119,69 +96,33 @@
11996
}
12097
end
12198
let(:facts) do
122-
override_facts(facts, {
123-
aio_agent_version: '1.10.99',
124-
is_pe: true,
125-
os: {
126-
macosx: {
127-
version: {
128-
major: '10.13',
129-
},
130-
},
131-
},
132-
platform_tag: 'osx-10.13-x86_64',
133-
serverversion: '5.10.200',
134-
})
99+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: '10.13', }, }, }, platform_tag: 'osx-10.13-x86_64', serverversion: '5.10.200')
135100
end
136101

137102
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.200-1.osx10.13.dmg').with_source('puppet:///pe_packages/2000.0.0/osx-10.13-x86_64/puppet-agent-5.10.200-1.osx10.13.dmg') }
138103
end
139104

140-
describe 'when using package_version auto with MacOS 11(two numbers version productversion)' do
105+
describe 'when using package_version auto with macOS 11 (two numbers version productversion)' do
141106
let(:params) do
142107
{
143108
package_version: 'auto',
144109
}
145110
end
146111
let(:facts) do
147-
override_facts(facts, {
148-
aio_agent_version: '1.10.99',
149-
is_pe: true,
150-
os: {
151-
macosx: {
152-
version: {
153-
major: '11.2',
154-
},
155-
},
156-
},
157-
platform_tag: 'osx-11-x86_64',
158-
serverversion: '5.10.200'
159-
})
112+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: '11.2', }, }, }, platform_tag: 'osx-11-x86_64', serverversion: '5.10.200')
160113
end
161114

162115
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.200-1.osx11.dmg').with_source('puppet:///pe_packages/2000.0.0/osx-11-x86_64/puppet-agent-5.10.200-1.osx11.dmg') }
163116
end
164117

165-
describe 'when using package_version auto with MacOS 11(one number version productversion)' do
118+
describe 'when using package_version auto with macOS 11 (one number version productversion)' do
166119
let(:params) do
167120
{
168121
package_version: 'auto',
169122
}
170123
end
171124
let(:facts) do
172-
override_facts(facts, {
173-
aio_agent_version: '1.10.99',
174-
is_pe: true,
175-
os: {
176-
macosx: {
177-
version: {
178-
major: '11',
179-
},
180-
},
181-
},
182-
platform_tag: 'osx-11-x86_64',
183-
serverversion: '5.10.200',
184-
})
125+
override_facts(facts, aio_agent_version: '1.10.99', is_pe: true, os: { macosx: { version: { major: '11', }, }, }, platform_tag: 'osx-11-x86_64', serverversion: '5.10.200')
185126
end
186127

187128
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.200-1.osx11.dmg').with_source('puppet:///pe_packages/2000.0.0/osx-11-x86_64/puppet-agent-5.10.200-1.osx11.dmg') }

spec/classes/puppet_agent_osfamily_debian_spec.rb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@
4545
end
4646

4747
let(:facts) do
48-
override_facts(facts, {
49-
is_pe: true,
50-
platform_tag: 'debian-7-x86_64',
51-
})
48+
override_facts(facts, is_pe: true, platform_tag: 'debian-7-x86_64')
5249
end
5350

5451
context 'when managing PE debian apt repo' do
@@ -96,19 +93,7 @@
9693

9794
context 'focal' do
9895
let(:facts) do
99-
override_facts(facts, {
100-
is_pe: true,
101-
os: {
102-
distro: {
103-
codename: 'focal',
104-
},
105-
name: 'Ubuntu',
106-
release: {
107-
full: '20.04',
108-
},
109-
},
110-
platform_tag: 'ubuntu-2004-x86_64',
111-
})
96+
override_facts(facts, is_pe: true, os: { distro: { codename: 'focal', }, name: 'Ubuntu', release: { full: '20.04', }, }, platform_tag: 'ubuntu-2004-x86_64')
11297
end
11398

11499
context 'when managing debian focal apt repo' do

spec/classes/puppet_agent_osfamily_redhat_spec.rb

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@
2424
[['Rocky', 'el/8', 8], ['AlmaLinux', 'el/8', 8], ['Fedora', 'fedora/f36', 36], ['CentOS', 'el/7', 7], ['Amazon', 'el/6', 2017], ['Amazon', 'el/7', 2]].each do |os, urlbit, osmajor|
2525
context "with #{os} and #{urlbit}" do
2626
let(:facts) do
27-
override_facts(super(), {
28-
os: {
29-
name: os,
30-
release: {
31-
major: osmajor,
32-
},
33-
},
34-
})
27+
override_facts(super(), os: { name: os, release: { major: osmajor, }, })
3528
end
3629

3730
script = <<-SCRIPT
@@ -182,16 +175,7 @@
182175
end
183176

184177
let(:facts) do
185-
override_facts(super(), {
186-
is_pe: true,
187-
os: {
188-
name: os,
189-
release: {
190-
major: osmajor,
191-
},
192-
},
193-
platform_tag: tag,
194-
})
178+
override_facts(super(), is_pe: true, os: { name: os, release: { major: osmajor, }, }, platform_tag: tag)
195179
end
196180

197181
context 'when using a custom source' do

0 commit comments

Comments
 (0)