|
4 | 4 | let(:facts) do |
5 | 5 | { |
6 | 6 | :os => { |
7 | | - :family => "Debian", |
| 7 | + :family => 'Debian', |
8 | 8 | :name => 'Ubuntu', |
9 | 9 | :release => { |
10 | | - :full => '16.04', |
| 10 | + :full => '22.04', |
11 | 11 | }, |
12 | 12 | :distro => { |
13 | | - :codename => "xenial", |
| 13 | + :codename => 'jammy', |
14 | 14 | }, |
15 | 15 | }, |
16 | 16 | } |
17 | 17 | end |
18 | 18 | context 'with controller => true and schedule_on_controller => true' do |
19 | 19 | let(:params) do { |
20 | | - 'controller' => true, |
21 | | - 'cni_rbac_binding' => 'foo', |
22 | | - 'cni_network_provider' => 'https://foo.test', |
23 | | - 'install_dashboard' => false, |
24 | | - 'kubernetes_version' => '1.10.2', |
25 | | - 'schedule_on_controller' => true, |
26 | | - 'node_name' => 'foo', |
| 20 | + controller: true, |
| 21 | + cni_rbac_binding: 'foo', |
| 22 | + cni_network_provider: 'https://foo.test', |
| 23 | + install_dashboard: false, |
| 24 | + kubernetes_version: '1.25.4', |
| 25 | + schedule_on_controller: true, |
| 26 | + node_name: 'foo', |
27 | 27 | } |
28 | 28 | end |
29 | 29 |
|
30 | | - it { should contain_exec('Install calico rbac bindings')} |
31 | | - it { should contain_exec('Install cni network provider')} |
32 | | - it { should contain_exec('schedule on controller')} |
| 30 | + it { is_expected.to contain_exec('Install calico rbac bindings').with({ |
| 31 | + 'command': ['kubectl', 'apply', '-f', 'foo'], |
| 32 | + 'onlyif': ['kubectl get nodes'], |
| 33 | + }) |
| 34 | + } |
| 35 | + it { is_expected.to contain_exec('Install cni network provider').with({ |
| 36 | + 'command': ['kubectl', 'apply', '-f', 'https://foo.test'], |
| 37 | + 'onlyif': ['kubectl get nodes'], |
| 38 | + }) |
| 39 | + } |
| 40 | + it { is_expected.to contain_exec('schedule on controller')} |
33 | 41 |
|
34 | | - it { should_not contain_exec('Install cni network (preinstall)')} |
35 | | - it { should_not contain_file('/etc/kubernetes/calico-installation.yaml')} |
36 | | - it { should_not contain_file_line('Configure calico ipPools.cidr')} |
| 42 | + it { is_expected.not_to contain_exec('Install cni network (preinstall)')} |
| 43 | + it { is_expected.not_to contain_file('/etc/kubernetes/calico-installation.yaml')} |
| 44 | + it { is_expected.not_to contain_file_line('Configure calico ipPools.cidr')} |
37 | 45 | end |
38 | 46 |
|
39 | | - context 'with cni_provider => calico' do |
40 | | - let(:params) do { |
41 | | - 'controller' => true, |
42 | | - 'cni_network_provider' => 'https://foo.test', |
43 | | - 'cni_provider' => 'calico', |
44 | | - 'install_dashboard' => false, |
45 | | - 'kubernetes_version' => '1.10.2', |
46 | | - 'node_name' => 'foo', |
47 | | - } |
48 | | - end |
49 | 47 |
|
50 | | - it { should contain_exec('Install cni network provider')} |
| 48 | + context 'CNI network provider' do |
| 49 | + ['flannel', 'weave', 'calico', 'cilium', 'calico-tigera'].each do |provider| |
51 | 50 |
|
52 | | - it { should_not contain_exec('Install cni network (preinstall)')} |
53 | | - it { should_not contain_file('/etc/kubernetes/calico-installation.yaml')} |
54 | | - it { should_not contain_file_line('Configure calico ipPools.cidr')} |
55 | | - end |
| 51 | + context "with #{provider}" do |
| 52 | + let(:params) do { |
| 53 | + controller: true, |
| 54 | + cni_network_provider: "https://#{provider}.test", |
| 55 | + cni_network_preinstall: 'https://foo.test/tigera-operator', |
| 56 | + cni_provider: provider, |
| 57 | + install_dashboard: false, |
| 58 | + kubernetes_version: '1.25.4', |
| 59 | + node_name: 'foo', |
| 60 | + } |
| 61 | + end |
56 | 62 |
|
57 | | - context 'with cni_provider => calico-tigera' do |
58 | | - let(:params) do { |
59 | | - 'controller' => true, |
60 | | - 'cni_network_preinstall' => 'https://foo.test/tigera-operator', |
61 | | - 'cni_network_provider' => 'https://foo.test', |
62 | | - 'cni_provider' => 'calico-tigera', |
63 | | - 'install_dashboard' => false, |
64 | | - 'kubernetes_version' => '1.10.2', |
65 | | - 'node_name' => 'foo', |
66 | | - } |
67 | | - end |
| 63 | + case provider |
| 64 | + when 'calico-tigera' |
| 65 | + it { is_expected.to contain_exec('Install cni network (preinstall)').with({ |
| 66 | + 'command': ['kubectl', 'apply', '-f', 'https://foo.test/tigera-operator'], |
| 67 | + 'onlyif': ['kubectl get nodes'], |
| 68 | + }) |
| 69 | + } |
| 70 | + it { is_expected.to contain_file('/etc/kubernetes/calico-installation.yaml')} |
| 71 | + it { is_expected.to contain_file_line('Configure calico ipPools.cidr')} |
| 72 | + it { is_expected.to contain_exec('Install cni network provider')} |
| 73 | + else |
| 74 | + it { |
| 75 | + is_expected.to contain_exec('Install cni network provider').with({ |
| 76 | + 'onlyif': ['kubectl get nodes'], |
| 77 | + 'command': ['kubectl', 'apply', '-f', "https://#{provider}.test"], |
| 78 | + 'unless': ['kubectl -n kube-system get daemonset | egrep "(flannel|weave|calico-node|cilium)"'], |
| 79 | + }) |
| 80 | + } |
68 | 81 |
|
69 | | - it { should contain_exec('Install cni network (preinstall)')} |
70 | | - it { should contain_file('/etc/kubernetes/calico-installation.yaml')} |
71 | | - it { should contain_file_line('Configure calico ipPools.cidr')} |
72 | | - it { should contain_exec('Install cni network provider')} |
| 82 | + it { is_expected.not_to contain_exec('Install cni network (preinstall)').with({ |
| 83 | + 'onlyif': ['kubectl get nodes'], |
| 84 | + }) |
| 85 | + } |
| 86 | + end |
| 87 | + end |
| 88 | + end |
73 | 89 | end |
74 | 90 |
|
75 | 91 | context 'with install_dashboard => false' do |
76 | 92 | let(:params) do { |
77 | | - 'controller' => true, |
78 | | - 'cni_rbac_binding' => nil, |
79 | | - 'cni_network_provider' => 'https://foo.test', |
80 | | - 'install_dashboard' => false, |
81 | | - 'kubernetes_version' => '1.10.2', |
82 | | - 'schedule_on_controller' => false, |
83 | | - 'node_name' => 'foo', |
| 93 | + controller: true, |
| 94 | + cni_rbac_binding: nil, |
| 95 | + cni_network_provider: 'https://foo.test', |
| 96 | + install_dashboard: false, |
| 97 | + kubernetes_version: '1.25.4', |
| 98 | + schedule_on_controller: false, |
| 99 | + node_name: 'foo', |
84 | 100 | } |
85 | 101 | end |
86 | | - it { is_expected.to_not contain_exec('Install Kubernetes dashboard')} |
| 102 | + it { is_expected.not_to contain_exec('Install Kubernetes dashboard')} |
87 | 103 | end |
88 | 104 |
|
89 | 105 | context 'with install_dashboard => true' do |
90 | 106 | let(:params) do { |
91 | | - 'controller' => true, |
92 | | - 'cni_rbac_binding' => nil, |
93 | | - 'cni_network_provider' => 'https://foo.test', |
94 | | - 'install_dashboard' => true, |
95 | | - 'kubernetes_version' => '1.10.2', |
96 | | - 'dashboard_version' => '1.10.1', |
97 | | - 'schedule_on_controller' => false, |
98 | | - 'node_name' => 'foo', |
| 107 | + controller: true, |
| 108 | + cni_rbac_binding: nil, |
| 109 | + cni_network_provider: 'https://foo.test', |
| 110 | + install_dashboard: true, |
| 111 | + kubernetes_version: '1.25.4', |
| 112 | + dashboard_version: '1.10.1', |
| 113 | + schedule_on_controller: false, |
| 114 | + node_name: 'foo', |
99 | 115 | } |
100 | 116 | end |
101 | 117 | it { is_expected.to contain_exec('Install Kubernetes dashboard').with_command(%r{dashboard/v1.10.1/src}) } |
|
0 commit comments