|
2 | 2 |
|
3 | 3 | require 'spec_helper'
|
4 | 4 | describe 'kubernetes::repos', type: :class do
|
| 5 | + context 'Debian with default params' do |
| 6 | + let(:facts) do |
| 7 | + { |
| 8 | + osfamily: 'Debian', # needed to run dependent tests from fixtures puppetlabs-apt |
| 9 | + kernel: 'Linux', |
| 10 | + os: { |
| 11 | + family: 'Debian', |
| 12 | + name: 'Ubuntu', |
| 13 | + release: { |
| 14 | + full: '16.04' |
| 15 | + }, |
| 16 | + distro: { |
| 17 | + codename: 'xenial' |
| 18 | + } |
| 19 | + } |
| 20 | + } |
| 21 | + end |
| 22 | + let(:params) do |
| 23 | + { |
| 24 | + 'container_runtime' => 'docker', |
| 25 | + 'kubernetes_version' => '1.28.1', |
| 26 | + 'kubernetes_apt_location' => '', |
| 27 | + 'kubernetes_apt_release' => '', |
| 28 | + 'kubernetes_apt_repos' => '', |
| 29 | + 'kubernetes_key_id' => '', |
| 30 | + 'kubernetes_key_source' => '', |
| 31 | + 'kubernetes_yum_baseurl' => 'https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64', |
| 32 | + 'kubernetes_yum_gpgkey' => 'https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg', |
| 33 | + 'docker_apt_location' => 'https://download.docker.com/linux/ubuntu', |
| 34 | + 'docker_apt_release' => 'xenial', |
| 35 | + 'docker_apt_repos' => 'main', |
| 36 | + 'docker_yum_baseurl' => 'https://download.docker.com/linux/centos/7/x86_64/stable', |
| 37 | + 'docker_yum_gpgkey' => 'https://download.docker.com/linux/centos/gpg', |
| 38 | + 'docker_key_id' => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88', |
| 39 | + 'docker_key_source' => 'https://download.docker.com/linux/ubuntu/gpg', |
| 40 | + 'containerd_install_method' => 'archive', |
| 41 | + 'create_repos' => true, |
| 42 | + 'manage_docker' => true |
| 43 | + } |
| 44 | + end |
| 45 | + |
| 46 | + it { |
| 47 | + expect(subject).to contain_apt__source('kubernetes').with( |
| 48 | + ensure: 'present', |
| 49 | + location: 'https://pkgs.k8s.io/core:/stable:/v1.28/deb', |
| 50 | + repos: '/', |
| 51 | + key: { 'id' => 'F46193FF99DBC56573C3B95949D205BA06FEF67C', 'source' => 'https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key' }, |
| 52 | + ) |
| 53 | + } |
| 54 | + |
| 55 | + it { |
| 56 | + expect(subject).to contain_apt__source('docker').with( |
| 57 | + ensure: 'present', |
| 58 | + location: 'https://download.docker.com/linux/ubuntu', |
| 59 | + repos: 'main', |
| 60 | + release: 'xenial', |
| 61 | + key: { 'id' => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88', 'source' => 'https://download.docker.com/linux/ubuntu/gpg' }, |
| 62 | + ) |
| 63 | + } |
| 64 | + end |
| 65 | + |
5 | 66 | context 'with osfamily => Ubuntu and manage_docker => true' do
|
6 | 67 | let(:facts) do
|
7 | 68 | {
|
|
22 | 83 | let(:params) do
|
23 | 84 | {
|
24 | 85 | 'container_runtime' => 'docker',
|
| 86 | + 'kubernetes_version' => '1.28.1', |
25 | 87 | 'kubernetes_apt_location' => 'http://apt.kubernetes.io',
|
26 | 88 | 'kubernetes_apt_release' => 'kubernetes-xenial',
|
27 | 89 | 'kubernetes_apt_repos' => 'main',
|
|
83 | 145 | let(:params) do
|
84 | 146 | {
|
85 | 147 | 'container_runtime' => 'cri_containerd',
|
| 148 | + 'kubernetes_version' => '1.28.1', |
86 | 149 | 'kubernetes_apt_location' => 'http://apt.kubernetes.io',
|
87 | 150 | 'kubernetes_apt_release' => 'kubernetes-xenial',
|
88 | 151 | 'kubernetes_apt_repos' => 'main',
|
|
124 | 187 | }
|
125 | 188 | end
|
126 | 189 |
|
| 190 | + context 'RedHat with default params' do |
| 191 | + let(:facts) do |
| 192 | + { |
| 193 | + operatingsystem: 'RedHat', |
| 194 | + osfamily: 'RedHat', |
| 195 | + operatingsystemrelease: '7.0', |
| 196 | + kernel: 'Linux', |
| 197 | + os: { |
| 198 | + family: 'RedHat', |
| 199 | + name: 'RedHat', |
| 200 | + release: { |
| 201 | + full: '7.0' |
| 202 | + } |
| 203 | + } |
| 204 | + } |
| 205 | + end |
| 206 | + |
| 207 | + let(:params) do |
| 208 | + { |
| 209 | + 'container_runtime' => 'docker', |
| 210 | + 'kubernetes_version' => '1.28.1', |
| 211 | + 'kubernetes_apt_location' => '', |
| 212 | + 'kubernetes_apt_release' => '', |
| 213 | + 'kubernetes_apt_repos' => '', |
| 214 | + 'kubernetes_key_id' => '', |
| 215 | + 'kubernetes_key_source' => '', |
| 216 | + 'kubernetes_yum_baseurl' => '', |
| 217 | + 'kubernetes_yum_gpgkey' => '', |
| 218 | + 'docker_apt_location' => 'https://download.docker.com/linux/ubuntu', |
| 219 | + 'docker_apt_release' => 'xenial', |
| 220 | + 'docker_apt_repos' => 'main', |
| 221 | + 'docker_yum_baseurl' => 'https://download.docker.com/linux/centos/7/x86_64/stable', |
| 222 | + 'docker_yum_gpgkey' => 'https://download.docker.com/linux/centos/gpg', |
| 223 | + 'docker_key_id' => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88', |
| 224 | + 'docker_key_source' => 'https://download.docker.com/linux/ubuntu/gpg', |
| 225 | + 'containerd_install_method' => 'archive', |
| 226 | + 'create_repos' => true, |
| 227 | + 'manage_docker' => false |
| 228 | + } |
| 229 | + end |
| 230 | + |
| 231 | + it { is_expected.not_to contain_yumrepo('docker') } |
| 232 | + |
| 233 | + it { |
| 234 | + expect(subject).to contain_yumrepo('kubernetes').with( |
| 235 | + 'enabled' => '1', |
| 236 | + 'baseurl' => 'https://pkgs.k8s.io/core:/stable:/v1.28/rpm/', |
| 237 | + 'gpgkey' => 'https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key', |
| 238 | + ) |
| 239 | + } |
| 240 | + end |
| 241 | + |
127 | 242 | context 'with osfamily => RedHat and manage_epel => true and manage_docker => false' do
|
128 | 243 | let(:facts) do
|
129 | 244 | {
|
|
144 | 259 | let(:params) do
|
145 | 260 | {
|
146 | 261 | 'container_runtime' => 'docker',
|
| 262 | + 'kubernetes_version' => '1.28.1', |
147 | 263 | 'kubernetes_apt_location' => 'http://apt.kubernetes.io',
|
148 | 264 | 'kubernetes_apt_release' => 'kubernetes-xenial',
|
149 | 265 | 'kubernetes_apt_repos' => 'main',
|
|
165 | 281 | end
|
166 | 282 |
|
167 | 283 | it { is_expected.not_to contain_yumrepo('docker') }
|
168 |
| - it { is_expected.to contain_yumrepo('kubernetes') } |
| 284 | + |
| 285 | + it { |
| 286 | + expect(subject).to contain_yumrepo('kubernetes').with( |
| 287 | + 'enabled' => '1', |
| 288 | + 'baseurl' => 'https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64', |
| 289 | + 'gpgkey' => 'https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg', |
| 290 | + ) |
| 291 | + } |
169 | 292 | end
|
170 | 293 |
|
171 | 294 | context 'with osfamily => RedHat and container_runtime => cri_containerd and containerd_install_method => package' do
|
|
187 | 310 |
|
188 | 311 | let(:params) do
|
189 | 312 | {
|
| 313 | + 'kubernetes_version' => '1.28.1', |
190 | 314 | 'container_runtime' => 'cri_containerd',
|
191 | 315 | 'kubernetes_apt_location' => 'http://apt.kubernetes.io',
|
192 | 316 | 'kubernetes_apt_release' => 'kubernetes-xenial',
|
|
209 | 333 | end
|
210 | 334 |
|
211 | 335 | it { is_expected.to contain_yumrepo('docker') }
|
212 |
| - it { is_expected.to contain_yumrepo('kubernetes') } |
| 336 | + |
| 337 | + it { |
| 338 | + expect(subject).to contain_yumrepo('kubernetes').with( |
| 339 | + 'enabled' => '1', |
| 340 | + 'baseurl' => 'https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64', |
| 341 | + 'gpgkey' => 'https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg', |
| 342 | + ) |
| 343 | + } |
213 | 344 | end
|
214 | 345 | end
|
0 commit comments