Skip to content

Commit 5d36af3

Browse files
committed
(CAT-2378) fix failing spec
1 parent daba452 commit 5d36af3

File tree

7 files changed

+61
-67
lines changed

7 files changed

+61
-67
lines changed

spec/classes/config/kubeadm_spec.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
require 'spec_helper'
44
describe 'kubernetes::config::kubeadm', type: :class do
5-
subject(:catalogue) { catalogue }
6-
75
let(:pre_condition) { 'include kubernetes' }
86
let(:facts) do
97
{
@@ -302,7 +300,7 @@
302300
end
303301

304302
it {
305-
expect(catalogue).to contain_file('/etc/kubernetes/config.yaml') \
303+
is_expected.to contain_file('/etc/kubernetes/config.yaml') \
306304
.with_content(%r{clusterName: my_own_name\n})
307305
}
308306
end
@@ -316,7 +314,7 @@
316314
end
317315

318316
it {
319-
expect(catalogue).to contain_file('/etc/kubernetes/config.yaml') \
317+
is_expected.to contain_file('/etc/kubernetes/config.yaml') \
320318
.with_content(%r{clusterName: my_own_name\n})
321319
}
322320
end
@@ -595,7 +593,7 @@
595593
let(:config_yaml) { YAML.load_stream(catalogue.resource('file', '/etc/kubernetes/config.yaml').send(:parameters)[:content]) }
596594

597595
it {
598-
expect(catalogue).to contain_file('/etc/kubernetes/config.yaml') \
596+
is_expected.to contain_file('/etc/kubernetes/config.yaml') \
599597
.with_content(%r{key: node-role.kubernetes.io/control-plane\n})
600598
}
601599
end

spec/classes/kube_addons_spec.rb

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
require 'spec_helper'
44
describe 'kubernetes::kube_addons', type: :class do
5-
subject(:catalogue) { catalogue }
6-
75
let(:pre_condition) { 'include kubernetes' }
86
let(:facts) do
97
{
@@ -34,17 +32,21 @@
3432
end
3533

3634
it {
37-
expect(catalogue).to contain_exec('Install calico rbac bindings').with({
38-
command: ['kubectl', 'apply', '-f', 'foo'],
39-
onlyif: ['kubectl get nodes']
40-
})
35+
is_expected.to contain_exec('Install calico rbac bindings').with(
36+
{
37+
command: ['kubectl', 'apply', '-f', 'foo'],
38+
onlyif: ['kubectl get nodes']
39+
},
40+
)
4141
}
4242

4343
it {
44-
expect(catalogue).to contain_exec('Install cni network provider').with({
45-
command: ['kubectl', 'apply', '-f', 'https://foo.test'],
46-
onlyif: ['kubectl get nodes']
47-
})
44+
is_expected.to contain_exec('Install cni network provider').with(
45+
{
46+
command: ['kubectl', 'apply', '-f', 'https://foo.test'],
47+
onlyif: ['kubectl get nodes']
48+
},
49+
)
4850
}
4951

5052
it { is_expected.to contain_exec('schedule on controller') }
@@ -74,7 +76,7 @@
7476
case provider
7577
when 'calico-tigera'
7678
it {
77-
expect(catalogue).to contain_exec('Install cni network (preinstall)').with(
79+
is_expected.to contain_exec('Install cni network (preinstall)').with(
7880
{
7981
command: ['kubectl', 'create', '-f', 'https://foo.test/tigera-operator'],
8082
onlyif: 'kubectl get nodes'
@@ -87,7 +89,7 @@
8789
it { is_expected.to contain_exec('Install cni network provider') }
8890
when 'flannel'
8991
it {
90-
expect(catalogue).to contain_exec('Install cni network provider').with(
92+
is_expected.to contain_exec('Install cni network provider').with(
9193
{
9294
onlyif: ['kubectl get nodes'],
9395
command: ['kubectl', 'create', '-f', "https://#{provider}.test"],
@@ -97,17 +99,21 @@
9799
}
98100
else
99101
it {
100-
expect(catalogue).to contain_exec('Install cni network provider').with({
101-
onlyif: ['kubectl get nodes'],
102-
command: ['kubectl', 'apply', '-f', "https://#{provider}.test"],
103-
unless: ['kubectl -n kube-system get daemonset | egrep "(flannel|weave|calico-node|cilium)"']
104-
})
102+
is_expected.to contain_exec('Install cni network provider').with(
103+
{
104+
onlyif: ['kubectl get nodes'],
105+
command: ['kubectl', 'apply', '-f', "https://#{provider}.test"],
106+
unless: ['kubectl -n kube-system get daemonset | egrep "(flannel|weave|calico-node|cilium)"']
107+
},
108+
)
105109
}
106110

107111
it {
108-
expect(catalogue).not_to contain_exec('Install cni network (preinstall)').with({
109-
onlyif: ['kubectl get nodes']
110-
})
112+
is_expected.not_to contain_exec('Install cni network (preinstall)').with(
113+
{
114+
onlyif: ['kubectl get nodes']
115+
},
116+
)
111117
}
112118
end
113119
end

spec/classes/packages_spec.rb

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
require 'spec_helper'
44
describe 'kubernetes::packages', type: :class do
5-
subject(:catalogue) { catalogue }
6-
75
let(:pre_condition) do
86
[
97
'include kubernetes',
@@ -332,105 +330,105 @@
332330
it { is_expected.to contain_file('/etc/containerd/config.toml').without_source }
333331

334332
it {
335-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
333+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
336334
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"\]\s*},
337335
)
338336
}
339337

340338
it {
341-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
339+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
342340
%r{\s*endpoint = \["https://registry-1.docker.io"\]\s*},
343341
)
344342
}
345343

346344
it {
347-
expect(catalogue).to contain_file('/etc/containerd/config.toml').without_content(
345+
is_expected.to contain_file('/etc/containerd/config.toml').without_content(
348346
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.private.example.com"\]\s*},
349347
)
350348
}
351349

352350
it {
353-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
351+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
354352
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.even-more-private.example.com"\]\s*},
355353
)
356354
}
357355

358356
it {
359-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
357+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
360358
%r{\s*endpoint = \["https://docker.even-more-private.example.com"\]\s*},
361359
)
362360
}
363361

364362
it {
365-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
363+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
366364
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.configs."docker.private.example.com".auth\]\s*},
367365
)
368366
}
369367

370368
it {
371-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
369+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
372370
%r{\s*auth = "1azhzLXVuaXQtdGVzdDpCQ0NwNWZUUXlyd3c1aUxoMXpEQXJnUT=="\s*},
373371
)
374372
}
375373

376374
it {
377-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
375+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
378376
%r{\s*username = "user2"\s*},
379377
)
380378
}
381379

382380
it {
383-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
381+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
384382
%r{\s*password = "secret2"\s*},
385383
)
386384
}
387385

388386
it {
389-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
387+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
390388
%r{\s*identitytoken = "azhzLXVuaXQtdGVzdDpCQ0NwNWZUUXlyd3c1aUxoMXpEQXJnUT"\s*},
391389
)
392390
}
393391

394392
it {
395-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
393+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
396394
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.configs."docker.private.example.com".tls\]\s*},
397395
)
398396
}
399397

400398
it {
401-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
399+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
402400
%r{\s*ca_file = "ca1.pem"\s*},
403401
)
404402
}
405403

406404
it {
407-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
405+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
408406
%r{\s*cert_file = "cert1.pem"\s*},
409407
)
410408
}
411409

412410
it {
413-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
411+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
414412
%r{\s*key_file = "key1.pem"\s*},
415413
)
416414
}
417415

418416
it {
419-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
417+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
420418
%r{\s*insecure_skip_verify = true\s*},
421419
)
422420
}
423421

424422
it {
425-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
423+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
426424
%r{\s*ca_file = "ca2.pem"\s*},
427425
)
428426
}
429427

430428
it { is_expected.not_to contain_file('/etc/apt/preferences.d/containerd') }
431429

432430
it {
433-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
431+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
434432
%r{\saddress = "/run/containerd/containerd.sock"},
435433
)
436434
}
@@ -983,13 +981,13 @@
983981
it { is_expected.to contain_file('/etc/containerd/config.toml') }
984982

985983
it {
986-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
984+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
987985
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"\]\s*},
988986
)
989987
}
990988

991989
it {
992-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
990+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
993991
%r{\s*endpoint = \["https://registry-1.docker.io"\]\s*},
994992
)
995993
}
@@ -1162,7 +1160,7 @@
11621160
it { is_expected.not_to contain_file('/etc/systemd/system/docker.service.d') }
11631161

11641162
it {
1165-
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
1163+
is_expected.to contain_file('/etc/containerd/config.toml').with_content(
11661164
%r{\saddress = "unix:///run/containerd/containerd.sock"},
11671165
)
11681166
}

spec/classes/repos_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
require 'spec_helper'
44
describe 'kubernetes::repos', type: :class do
5-
subject(:catalogue) { catalogue }
6-
75
context 'with osfamily => Ubuntu and manage_docker => true' do
86
let(:facts) do
97
{
@@ -45,7 +43,7 @@
4543
end
4644

4745
it {
48-
expect(catalogue).to contain_apt__source('kubernetes').with(
46+
is_expected.to contain_apt__source('kubernetes').with(
4947
ensure: 'present',
5048
location: 'https://pkgs.k8s.io/core:/stable:/v1.32/deb/',
5149
repos: ' ',
@@ -55,7 +53,7 @@
5553
}
5654

5755
it {
58-
expect(catalogue).to contain_apt__source('docker').with(
56+
is_expected.to contain_apt__source('docker').with(
5957
ensure: 'present',
6058
location: 'https://download.docker.com/linux/debian',
6159
repos: 'main',
@@ -106,7 +104,7 @@
106104
end
107105

108106
it {
109-
expect(catalogue).to contain_apt__source('kubernetes').with(
107+
is_expected.to contain_apt__source('kubernetes').with(
110108
ensure: 'present',
111109
location: 'https://pkgs.k8s.io/core:/stable:/v1.32/deb/',
112110
repos: ' ',
@@ -116,7 +114,7 @@
116114
}
117115

118116
it {
119-
expect(catalogue).to contain_apt__source('docker').with(
117+
is_expected.to contain_apt__source('docker').with(
120118
ensure: 'present',
121119
location: 'https://download.docker.com/linux/debian',
122120
repos: 'main',

spec/classes/service_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
require 'spec_helper'
44
describe 'kubernetes::service', type: :class do
5-
subject(:catalogue) { catalogue }
6-
75
let(:pre_condition) { 'include kubernetes; include kubernetes::config::kubeadm' }
86
let(:facts) do
97
{
@@ -107,12 +105,12 @@
107105
end
108106

109107
it {
110-
expect(catalogue).to contain_file('/etc/systemd/system/kubelet.service.d/20-cloud.conf') \
108+
is_expected.to contain_file('/etc/systemd/system/kubelet.service.d/20-cloud.conf') \
111109
.with_content(%r{--cloud-provider=aws})
112110
}
113111

114112
it {
115-
expect(catalogue).not_to contain_file('/etc/systemd/system/kubelet.service.d/20-cloud.conf') \
113+
is_expected.not_to contain_file('/etc/systemd/system/kubelet.service.d/20-cloud.conf') \
116114
.with_content(%r{--cloud-config=})
117115
}
118116
end
@@ -131,12 +129,12 @@
131129
end
132130

133131
it {
134-
expect(catalogue).to contain_file('/etc/systemd/system/kubelet.service.d/20-cloud.conf') \
132+
is_expected.to contain_file('/etc/systemd/system/kubelet.service.d/20-cloud.conf') \
135133
.with_content(%r{--cloud-provider=openstack})
136134
}
137135

138136
it {
139-
expect(catalogue).to contain_file('/etc/systemd/system/kubelet.service.d/20-cloud.conf') \
137+
is_expected.to contain_file('/etc/systemd/system/kubelet.service.d/20-cloud.conf') \
140138
.with_content(%r{--cloud-config=/etc/kubernetes/cloud.conf})
141139
}
142140
end

spec/defines/kubeadm_join_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
require 'spec_helper'
44

55
describe 'kubernetes::kubeadm_join', type: :define do
6-
subject(:catalogue) { catalogue }
7-
86
let(:pre_condition) { 'include kubernetes' }
97
let(:title) { 'kubeadm join' }
108
let(:facts) do
@@ -45,7 +43,7 @@
4543
it { is_expected.to compile.with_all_deps }
4644

4745
it {
48-
expect(catalogue).to contain_exec('kubeadm join')
46+
is_expected.to contain_exec('kubeadm join')
4947
.with_command("kubeadm join '10.0.0.1:6443' --discovery-token 'token' --discovery-token-ca-cert-hash 'sha256:hash' --node-name 'kube-node' --token 'token'")
5048
}
5149
end

0 commit comments

Comments
 (0)