-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathpuppet_agent_osfamily_aix_spec.rb
218 lines (190 loc) · 6.14 KB
/
puppet_agent_osfamily_aix_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
require 'spec_helper'
describe 'puppet_agent' do
let(:common_facts) do
{
clientcert: 'foo.example.vm',
is_pe: true,
os: {
architecture: 'PowerPC_POWER7',
family: 'AIX',
name: 'AIX',
},
platform_tag: 'aix-7.2-power',
servername: 'master.example.vm',
}
end
before(:each) do
allow(Puppet::FileSystem).to receive(:exist?).and_call_original
allow(Puppet::FileSystem).to receive(:read_preserve_line_endings).and_call_original
allow(Puppet::FileSystem).to receive(:exist?).with('/opt/puppetlabs/puppet/VERSION').and_return true
end
shared_examples 'aix' do |aixver, pkg_aixver, powerver|
let(:rpmname) { "puppet-agent-#{params[:package_version]}-1.aix#{pkg_aixver}.ppc.rpm" }
let(:tag) { "aix-#{pkg_aixver}-power" }
let(:source) { "puppet:///pe_packages/2000.0.0/#{tag}/#{rpmname}" }
let(:facts) do
common_facts.merge({
architecture: "PowerPC_POWER#{powerver}",
platform_tag: "aix-#{aixver}-power",
})
end
before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
end
it { is_expected.to contain_file('/opt/puppetlabs') }
it { is_expected.to contain_file('/opt/puppetlabs/packages') }
it {
is_expected.to contain_file("/opt/puppetlabs/packages/#{rpmname}").with({ 'source' => source })
}
it { is_expected.to contain_class('puppet_agent::osfamily::aix') }
it { is_expected.to contain_class('Puppet_agent::Install') }
it {
is_expected.to contain_package('puppet-agent')
.with({
'source' => "/opt/puppetlabs/packages/#{rpmname}",
'ensure' => params[:package_version],
'provider' => 'rpm',
})
}
end
context 'with a user specified source' do
let(:facts) do
common_facts.merge({
architecture: 'PowerPC_POWER8',
platform_tag: 'aix-7.1-power',
})
end
let(:params) do
{
package_version: '7.10.100.1',
collection: 'puppet7',
source: 'https://fake-pe-master.com',
}
end
before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
end
it {
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm').with_source('https://fake-pe-master.com/packages/2000.0.0/aix-7.1-power/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm')
}
end
context 'with a user defined PE version' do
let(:facts) do
common_facts.merge(
{
architecture: 'PowerPC_POWER8',
platform_tag: 'aix-7.1-power',
}
)
end
let(:params) do
{
package_version: '7.10.100.1',
collection: 'puppet7',
alternate_pe_version: '2222.2.2',
}
end
before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
end
it {
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm').with_source('puppet:///pe_packages/2222.2.2/aix-7.1-power/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm')
}
end
context 'with a puppet6 collection' do
context 'with versions up to 6.19.1' do
let(:params) do
{
package_version: '6.0.0',
collection: 'puppet6',
}
end
[['7.2', '6.1', '8'], ['7.1', '6.1', '8'], ['7.1', '6.1', '7'], ['6.1', '6.1', '7']].each do |aixver, pkg_aixver, powerver|
context "aix #{aixver}" do
include_examples 'aix', aixver, pkg_aixver, powerver
end
end
end
context 'with versions higher than 6.19.1' do
let(:params) do
{
package_version: '6.20.0',
collection: 'puppet6',
}
end
[['7.2', '7.1', '8'], ['7.1', '7.1', '8'], ['7.1', '7.1', '7'], ['6.1', '7.1', '7']].each do |aixver, pkg_aixver, powerver|
context "aix #{aixver}" do
include_examples 'aix', aixver, pkg_aixver, powerver
end
end
end
end
context 'with a puppet7 collection' do
context 'with versions higher than 7.0.0' do
let(:params) do
{
package_version: '7.0.1',
collection: 'puppet7',
}
end
[['7.2', '7.1', '8'], ['7.1', '7.1', '8'], ['7.1', '7.1', '7'], ['6.1', '7.1', '7']].each do |aixver, pkg_aixver, powerver|
context "aix #{aixver}" do
include_examples 'aix', aixver, pkg_aixver, powerver
end
end
end
end
context 'with a puppet8 collection' do
context 'with versions greater than or equal to 8.0.0' do
let(:params) do
{
package_version: '8.0.0',
collection: 'puppet8',
}
end
[['7.2', '7.2', '7']].each do |aixver, pkg_aixver, powerver|
context "aix #{aixver}" do
include_examples 'aix', aixver, pkg_aixver, powerver
end
end
end
end
context 'with package_version auto' do
let(:params) do
{
package_version: 'auto',
}
end
let(:facts) do
common_facts.merge({
serverversion: '7.10.200'
})
end
let(:rpmname) { 'puppet-agent-7.10.200-1.aix7.1.ppc.rpm' }
before(:each) do
allow(Puppet::FileSystem).to receive(:read_preserve_line_endings).with('/opt/puppetlabs/puppet/VERSION').and_return "7.10.200\n"
end
it {
is_expected.to contain_package('puppet-agent')
.with({
'source' => "/opt/puppetlabs/packages/#{rpmname}",
'ensure' => '7.10.200',
'provider' => 'rpm',
})
}
end
context 'unsupported environments' do
let(:params) do
{
package_version: '6.0.0',
collection: 'puppet6'
}
end
context 'not AIX' do
let(:facts) do
override_facts(common_facts, os: { name: 'not-AIX' })
end
it { expect { catalogue }.to raise_error(%r{not supported}) }
end
end
end