|
| 1 | +suite: test global value inheritance |
| 2 | +templates: |
| 3 | + - templates/deployment.yaml |
| 4 | +release: |
| 5 | + name: my-release |
| 6 | + namespace: my-namespace |
| 7 | +tests: |
| 8 | + # ============================================================================ |
| 9 | + # global.cluster |
| 10 | + # ============================================================================ |
| 11 | + - it: should inherit global.cluster when local cluster not set |
| 12 | + set: |
| 13 | + global.cluster: global-test-cluster |
| 14 | + asserts: |
| 15 | + - equal: |
| 16 | + path: spec.template.spec.containers[0].env[?(@.name=="clusterName")].value |
| 17 | + value: global-test-cluster |
| 18 | + |
| 19 | + - it: should use local cluster over global.cluster |
| 20 | + set: |
| 21 | + cluster: local-cluster |
| 22 | + global.cluster: global-cluster |
| 23 | + asserts: |
| 24 | + - equal: |
| 25 | + path: spec.template.spec.containers[0].env[?(@.name=="clusterName")].value |
| 26 | + value: local-cluster |
| 27 | + |
| 28 | + # ============================================================================ |
| 29 | + # global.labels |
| 30 | + # ============================================================================ |
| 31 | + - it: should inherit global.labels when local labels not set |
| 32 | + set: |
| 33 | + cluster: test-cluster |
| 34 | + global.labels: |
| 35 | + globalLabel1: globalValue1 |
| 36 | + globalLabel2: globalValue2 |
| 37 | + asserts: |
| 38 | + - equal: |
| 39 | + path: metadata.labels.globalLabel1 |
| 40 | + value: globalValue1 |
| 41 | + - equal: |
| 42 | + path: metadata.labels.globalLabel2 |
| 43 | + value: globalValue2 |
| 44 | + |
| 45 | + - it: should merge local labels with global.labels (local takes precedence) |
| 46 | + set: |
| 47 | + cluster: test-cluster |
| 48 | + labels: |
| 49 | + localLabel: localValue |
| 50 | + sharedLabel: localValue |
| 51 | + global.labels: |
| 52 | + globalLabel: globalValue |
| 53 | + sharedLabel: globalValue |
| 54 | + asserts: |
| 55 | + - equal: |
| 56 | + path: metadata.labels.localLabel |
| 57 | + value: localValue |
| 58 | + - equal: |
| 59 | + path: metadata.labels.globalLabel |
| 60 | + value: globalValue |
| 61 | + - equal: |
| 62 | + path: metadata.labels.sharedLabel |
| 63 | + value: localValue |
| 64 | + |
| 65 | + # ============================================================================ |
| 66 | + # global.podLabels |
| 67 | + # ============================================================================ |
| 68 | + - it: should inherit global.podLabels when local podLabels not set |
| 69 | + set: |
| 70 | + cluster: test-cluster |
| 71 | + global.podLabels: |
| 72 | + globalPodLabel1: globalPodValue1 |
| 73 | + globalPodLabel2: globalPodValue2 |
| 74 | + asserts: |
| 75 | + - equal: |
| 76 | + path: spec.template.metadata.labels.globalPodLabel1 |
| 77 | + value: globalPodValue1 |
| 78 | + - equal: |
| 79 | + path: spec.template.metadata.labels.globalPodLabel2 |
| 80 | + value: globalPodValue2 |
| 81 | + |
| 82 | + - it: should merge local podLabels with global.podLabels (local takes precedence) |
| 83 | + set: |
| 84 | + cluster: test-cluster |
| 85 | + podLabels: |
| 86 | + localPodLabel: localPodValue |
| 87 | + sharedPodLabel: localPodValue |
| 88 | + global.podLabels: |
| 89 | + globalPodLabel: globalPodValue |
| 90 | + sharedPodLabel: globalPodValue |
| 91 | + asserts: |
| 92 | + - equal: |
| 93 | + path: spec.template.metadata.labels.localPodLabel |
| 94 | + value: localPodValue |
| 95 | + - equal: |
| 96 | + path: spec.template.metadata.labels.globalPodLabel |
| 97 | + value: globalPodValue |
| 98 | + - equal: |
| 99 | + path: spec.template.metadata.labels.sharedPodLabel |
| 100 | + value: localPodValue |
| 101 | + |
| 102 | + # ============================================================================ |
| 103 | + # global.images.registry |
| 104 | + # ============================================================================ |
| 105 | + - it: should inherit global.images.registry when local image.registry not set |
| 106 | + set: |
| 107 | + cluster: test-cluster |
| 108 | + global.images.registry: global-registry.io |
| 109 | + asserts: |
| 110 | + - matchRegex: |
| 111 | + path: spec.template.spec.containers[0].image |
| 112 | + pattern: ^global-registry\.io/ |
| 113 | + |
| 114 | + - it: should use local image.registry over global.images.registry |
| 115 | + set: |
| 116 | + cluster: test-cluster |
| 117 | + image.registry: local-registry.io |
| 118 | + global.images.registry: global-registry.io |
| 119 | + asserts: |
| 120 | + - matchRegex: |
| 121 | + path: spec.template.spec.containers[0].image |
| 122 | + pattern: ^local-registry\.io/ |
| 123 | + |
| 124 | + # ============================================================================ |
| 125 | + # global.images.pullSecrets |
| 126 | + # ============================================================================ |
| 127 | + - it: should inherit global.images.pullSecrets when local image.pullSecrets not set |
| 128 | + set: |
| 129 | + cluster: test-cluster |
| 130 | + global.images.pullSecrets: |
| 131 | + - name: global-pull-secret |
| 132 | + asserts: |
| 133 | + - contains: |
| 134 | + path: spec.template.spec.imagePullSecrets |
| 135 | + content: |
| 136 | + name: global-pull-secret |
| 137 | + |
| 138 | + - it: should merge local image.pullSecrets with global.images.pullSecrets |
| 139 | + set: |
| 140 | + cluster: test-cluster |
| 141 | + image.pullSecrets: |
| 142 | + - name: local-pull-secret |
| 143 | + global.images.pullSecrets: |
| 144 | + - name: global-pull-secret |
| 145 | + asserts: |
| 146 | + - contains: |
| 147 | + path: spec.template.spec.imagePullSecrets |
| 148 | + content: |
| 149 | + name: local-pull-secret |
| 150 | + - contains: |
| 151 | + path: spec.template.spec.imagePullSecrets |
| 152 | + content: |
| 153 | + name: global-pull-secret |
| 154 | + |
| 155 | + # ============================================================================ |
| 156 | + # global.priorityClassName |
| 157 | + # ============================================================================ |
| 158 | + - it: should inherit global.priorityClassName when local priorityClassName not set |
| 159 | + set: |
| 160 | + cluster: test-cluster |
| 161 | + global.priorityClassName: global-priority-class |
| 162 | + asserts: |
| 163 | + - equal: |
| 164 | + path: spec.template.spec.priorityClassName |
| 165 | + value: global-priority-class |
| 166 | + |
| 167 | + - it: should use local priorityClassName over global.priorityClassName |
| 168 | + set: |
| 169 | + cluster: test-cluster |
| 170 | + priorityClassName: local-priority-class |
| 171 | + global.priorityClassName: global-priority-class |
| 172 | + asserts: |
| 173 | + - equal: |
| 174 | + path: spec.template.spec.priorityClassName |
| 175 | + value: local-priority-class |
| 176 | + |
| 177 | + # ============================================================================ |
| 178 | + # global.hostNetwork |
| 179 | + # ============================================================================ |
| 180 | + - it: should inherit global.hostNetwork when local hostNetwork not set |
| 181 | + set: |
| 182 | + cluster: test-cluster |
| 183 | + global.hostNetwork: true |
| 184 | + asserts: |
| 185 | + - equal: |
| 186 | + path: spec.template.spec.hostNetwork |
| 187 | + value: true |
| 188 | + - equal: |
| 189 | + path: spec.template.spec.dnsPolicy |
| 190 | + value: ClusterFirstWithHostNet |
| 191 | + |
| 192 | + - it: should use local hostNetwork over global.hostNetwork |
| 193 | + set: |
| 194 | + cluster: test-cluster |
| 195 | + hostNetwork: false |
| 196 | + global.hostNetwork: true |
| 197 | + asserts: |
| 198 | + - equal: |
| 199 | + path: spec.template.spec.hostNetwork |
| 200 | + value: false |
| 201 | + - notExists: |
| 202 | + path: spec.template.spec.dnsPolicy |
| 203 | + |
| 204 | + # ============================================================================ |
| 205 | + # global.dnsConfig |
| 206 | + # ============================================================================ |
| 207 | + - it: should inherit global.dnsConfig when local dnsConfig not set |
| 208 | + set: |
| 209 | + cluster: test-cluster |
| 210 | + global.dnsConfig: |
| 211 | + nameservers: |
| 212 | + - 1.2.3.4 |
| 213 | + searches: |
| 214 | + - ns1.svc.cluster-domain.example |
| 215 | + asserts: |
| 216 | + - equal: |
| 217 | + path: spec.template.spec.dnsConfig.nameservers[0] |
| 218 | + value: 1.2.3.4 |
| 219 | + - equal: |
| 220 | + path: spec.template.spec.dnsConfig.searches[0] |
| 221 | + value: ns1.svc.cluster-domain.example |
| 222 | + |
| 223 | + - it: should use local dnsConfig over global.dnsConfig |
| 224 | + set: |
| 225 | + cluster: test-cluster |
| 226 | + dnsConfig: |
| 227 | + nameservers: |
| 228 | + - 5.6.7.8 |
| 229 | + global.dnsConfig: |
| 230 | + nameservers: |
| 231 | + - 1.2.3.4 |
| 232 | + asserts: |
| 233 | + - equal: |
| 234 | + path: spec.template.spec.dnsConfig.nameservers[0] |
| 235 | + value: 5.6.7.8 |
| 236 | + - notContains: |
| 237 | + path: spec.template.spec.dnsConfig.nameservers |
| 238 | + content: 1.2.3.4 |
| 239 | + |
| 240 | + # ============================================================================ |
| 241 | + # global.nodeSelector |
| 242 | + # ============================================================================ |
| 243 | + - it: should inherit global.nodeSelector when local nodeSelector not set |
| 244 | + set: |
| 245 | + cluster: test-cluster |
| 246 | + global.nodeSelector: |
| 247 | + globalNodeKey: globalNodeValue |
| 248 | + asserts: |
| 249 | + - equal: |
| 250 | + path: spec.template.spec.nodeSelector["globalNodeKey"] |
| 251 | + value: globalNodeValue |
| 252 | + - equal: |
| 253 | + path: spec.template.spec.nodeSelector["kubernetes.io/os"] |
| 254 | + value: linux |
| 255 | + |
| 256 | + - it: should use local nodeSelector over global.nodeSelector |
| 257 | + set: |
| 258 | + cluster: test-cluster |
| 259 | + nodeSelector: |
| 260 | + localNodeKey: localNodeValue |
| 261 | + global.nodeSelector: |
| 262 | + globalNodeKey: globalNodeValue |
| 263 | + asserts: |
| 264 | + - equal: |
| 265 | + path: spec.template.spec.nodeSelector.localNodeKey |
| 266 | + value: localNodeValue |
| 267 | + - equal: |
| 268 | + path: spec.template.spec.nodeSelector["kubernetes.io/os"] |
| 269 | + value: linux |
| 270 | + - notExists: |
| 271 | + path: spec.template.spec.nodeSelector.globalNodeKey |
| 272 | + |
| 273 | + # ============================================================================ |
| 274 | + # global.affinity |
| 275 | + # ============================================================================ |
| 276 | + - it: should inherit global.affinity when local affinity not set |
| 277 | + set: |
| 278 | + cluster: test-cluster |
| 279 | + global.affinity: |
| 280 | + nodeAffinity: |
| 281 | + requiredDuringSchedulingIgnoredDuringExecution: |
| 282 | + nodeSelectorTerms: |
| 283 | + - matchExpressions: |
| 284 | + - key: global-key |
| 285 | + operator: In |
| 286 | + values: |
| 287 | + - global-value |
| 288 | + asserts: |
| 289 | + - equal: |
| 290 | + path: spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key |
| 291 | + value: global-key |
| 292 | + |
| 293 | + - it: should use local affinity over global.affinity |
| 294 | + set: |
| 295 | + cluster: test-cluster |
| 296 | + affinity: |
| 297 | + nodeAffinity: |
| 298 | + requiredDuringSchedulingIgnoredDuringExecution: |
| 299 | + nodeSelectorTerms: |
| 300 | + - matchExpressions: |
| 301 | + - key: local-key |
| 302 | + operator: In |
| 303 | + values: |
| 304 | + - local-value |
| 305 | + global.affinity: |
| 306 | + nodeAffinity: |
| 307 | + requiredDuringSchedulingIgnoredDuringExecution: |
| 308 | + nodeSelectorTerms: |
| 309 | + - matchExpressions: |
| 310 | + - key: global-key |
| 311 | + operator: In |
| 312 | + values: |
| 313 | + - global-value |
| 314 | + asserts: |
| 315 | + - equal: |
| 316 | + path: spec.template.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key |
| 317 | + value: local-key |
0 commit comments