|
| 1 | +suite: global values fallback tests |
| 2 | +templates: |
| 3 | + - agent.yaml |
| 4 | + - controller.yaml |
| 5 | + - secret.yaml |
| 6 | +values: |
| 7 | + - values.yaml |
| 8 | +tests: |
| 9 | + - it: should use global.castai.apiURL when local castai.apiURL is not set |
| 10 | + set: |
| 11 | + global: |
| 12 | + castai: |
| 13 | + apiURL: "https://global.cast.ai/" |
| 14 | + asserts: |
| 15 | + - contains: |
| 16 | + path: spec.template.spec.containers[0].env |
| 17 | + content: |
| 18 | + name: CASTAI_API_URL |
| 19 | + value: "https://global.cast.ai/" |
| 20 | + template: controller.yaml |
| 21 | + documentIndex: 0 |
| 22 | + - contains: |
| 23 | + path: spec.template.spec.containers[0].env |
| 24 | + content: |
| 25 | + name: CASTAI_API_URL |
| 26 | + value: "https://global.cast.ai/" |
| 27 | + template: agent.yaml |
| 28 | + documentIndex: 0 |
| 29 | + |
| 30 | + - it: should use global.castai.grpcURL over local default grpcAddr |
| 31 | + set: |
| 32 | + global: |
| 33 | + castai: |
| 34 | + grpcURL: "grpc.global.cast.ai:443" |
| 35 | + asserts: |
| 36 | + - contains: |
| 37 | + path: spec.template.spec.containers[0].env |
| 38 | + content: |
| 39 | + name: CASTAI_API_GRPC_ADDR |
| 40 | + value: "grpc.global.cast.ai:443" |
| 41 | + template: controller.yaml |
| 42 | + documentIndex: 0 |
| 43 | + - contains: |
| 44 | + path: spec.template.spec.containers[0].env |
| 45 | + content: |
| 46 | + name: CASTAI_API_GRPC_ADDR |
| 47 | + value: "grpc.global.cast.ai:443" |
| 48 | + template: agent.yaml |
| 49 | + documentIndex: 0 |
| 50 | + |
| 51 | + - it: should prefer global.castai.apiURL over local castai.apiURL |
| 52 | + set: |
| 53 | + castai.apiURL: "https://local.cast.ai/" |
| 54 | + global: |
| 55 | + castai: |
| 56 | + apiURL: "https://global.cast.ai/" |
| 57 | + asserts: |
| 58 | + - contains: |
| 59 | + path: spec.template.spec.containers[0].env |
| 60 | + content: |
| 61 | + name: CASTAI_API_URL |
| 62 | + value: "https://global.cast.ai/" |
| 63 | + template: controller.yaml |
| 64 | + documentIndex: 0 |
| 65 | + - contains: |
| 66 | + path: spec.template.spec.containers[0].env |
| 67 | + content: |
| 68 | + name: CASTAI_API_URL |
| 69 | + value: "https://global.cast.ai/" |
| 70 | + template: agent.yaml |
| 71 | + documentIndex: 0 |
| 72 | + |
| 73 | + - it: should prefer global.castai.grpcURL over local castai.grpcAddr |
| 74 | + set: |
| 75 | + castai.grpcAddr: "grpc.local.cast.ai:443" |
| 76 | + global: |
| 77 | + castai: |
| 78 | + grpcURL: "grpc.global.cast.ai:443" |
| 79 | + asserts: |
| 80 | + - contains: |
| 81 | + path: spec.template.spec.containers[0].env |
| 82 | + content: |
| 83 | + name: CASTAI_API_GRPC_ADDR |
| 84 | + value: "grpc.global.cast.ai:443" |
| 85 | + template: controller.yaml |
| 86 | + documentIndex: 0 |
| 87 | + - contains: |
| 88 | + path: spec.template.spec.containers[0].env |
| 89 | + content: |
| 90 | + name: CASTAI_API_GRPC_ADDR |
| 91 | + value: "grpc.global.cast.ai:443" |
| 92 | + template: agent.yaml |
| 93 | + documentIndex: 0 |
| 94 | + |
| 95 | + - it: should use default grpcAddr when neither local nor global is set |
| 96 | + asserts: |
| 97 | + - contains: |
| 98 | + path: spec.template.spec.containers[0].env |
| 99 | + content: |
| 100 | + name: CASTAI_API_GRPC_ADDR |
| 101 | + value: "kvisor.prod-master.cast.ai:443" |
| 102 | + template: controller.yaml |
| 103 | + documentIndex: 0 |
| 104 | + - contains: |
| 105 | + path: spec.template.spec.containers[0].env |
| 106 | + content: |
| 107 | + name: CASTAI_API_GRPC_ADDR |
| 108 | + value: "kvisor.prod-master.cast.ai:443" |
| 109 | + template: agent.yaml |
| 110 | + documentIndex: 0 |
| 111 | + |
| 112 | + - it: should use local castai.apiURL when global is not set |
| 113 | + set: |
| 114 | + castai.apiURL: "https://local.cast.ai/" |
| 115 | + asserts: |
| 116 | + - contains: |
| 117 | + path: spec.template.spec.containers[0].env |
| 118 | + content: |
| 119 | + name: CASTAI_API_URL |
| 120 | + value: "https://local.cast.ai/" |
| 121 | + template: controller.yaml |
| 122 | + documentIndex: 0 |
| 123 | + - contains: |
| 124 | + path: spec.template.spec.containers[0].env |
| 125 | + content: |
| 126 | + name: CASTAI_API_URL |
| 127 | + value: "https://local.cast.ai/" |
| 128 | + template: agent.yaml |
| 129 | + documentIndex: 0 |
| 130 | + |
| 131 | + - it: should fall back to defaults when global is empty map |
| 132 | + set: |
| 133 | + global: {} |
| 134 | + asserts: |
| 135 | + - contains: |
| 136 | + path: spec.template.spec.containers[0].env |
| 137 | + content: |
| 138 | + name: CASTAI_API_GRPC_ADDR |
| 139 | + value: "kvisor.prod-master.cast.ai:443" |
| 140 | + template: controller.yaml |
| 141 | + documentIndex: 0 |
| 142 | + - contains: |
| 143 | + path: spec.template.spec.containers[0].env |
| 144 | + content: |
| 145 | + name: CASTAI_API_GRPC_ADDR |
| 146 | + value: "kvisor.prod-master.cast.ai:443" |
| 147 | + template: agent.yaml |
| 148 | + documentIndex: 0 |
| 149 | + |
| 150 | + - it: should fall back to defaults when global.castai is empty map |
| 151 | + set: |
| 152 | + global: |
| 153 | + castai: {} |
| 154 | + asserts: |
| 155 | + - contains: |
| 156 | + path: spec.template.spec.containers[0].env |
| 157 | + content: |
| 158 | + name: CASTAI_API_GRPC_ADDR |
| 159 | + value: "kvisor.prod-master.cast.ai:443" |
| 160 | + template: controller.yaml |
| 161 | + documentIndex: 0 |
| 162 | + - contains: |
| 163 | + path: spec.template.spec.containers[0].env |
| 164 | + content: |
| 165 | + name: CASTAI_API_GRPC_ADDR |
| 166 | + value: "kvisor.prod-master.cast.ai:443" |
| 167 | + template: agent.yaml |
| 168 | + documentIndex: 0 |
| 169 | + |
| 170 | + - it: should use local values when global is empty map |
| 171 | + set: |
| 172 | + global: {} |
| 173 | + castai.apiURL: "https://local.cast.ai/" |
| 174 | + castai.grpcAddr: "grpc.local.cast.ai:443" |
| 175 | + asserts: |
| 176 | + - contains: |
| 177 | + path: spec.template.spec.containers[0].env |
| 178 | + content: |
| 179 | + name: CASTAI_API_URL |
| 180 | + value: "https://local.cast.ai/" |
| 181 | + template: controller.yaml |
| 182 | + documentIndex: 0 |
| 183 | + - contains: |
| 184 | + path: spec.template.spec.containers[0].env |
| 185 | + content: |
| 186 | + name: CASTAI_API_GRPC_ADDR |
| 187 | + value: "grpc.local.cast.ai:443" |
| 188 | + template: controller.yaml |
| 189 | + documentIndex: 0 |
| 190 | + - contains: |
| 191 | + path: spec.template.spec.containers[0].env |
| 192 | + content: |
| 193 | + name: CASTAI_API_URL |
| 194 | + value: "https://local.cast.ai/" |
| 195 | + template: agent.yaml |
| 196 | + documentIndex: 0 |
| 197 | + - contains: |
| 198 | + path: spec.template.spec.containers[0].env |
| 199 | + content: |
| 200 | + name: CASTAI_API_GRPC_ADDR |
| 201 | + value: "grpc.local.cast.ai:443" |
| 202 | + template: agent.yaml |
| 203 | + documentIndex: 0 |
| 204 | + |
| 205 | + - it: should use global.castai.clusterID over local castai.clusterID |
| 206 | + set: |
| 207 | + global: |
| 208 | + castai: |
| 209 | + clusterID: "global-cluster-id" |
| 210 | + asserts: |
| 211 | + - contains: |
| 212 | + path: spec.template.spec.containers[0].env |
| 213 | + content: |
| 214 | + name: CLUSTER_ID |
| 215 | + value: "global-cluster-id" |
| 216 | + valueFrom: null |
| 217 | + template: controller.yaml |
| 218 | + documentIndex: 0 |
| 219 | + - contains: |
| 220 | + path: spec.template.spec.containers[0].env |
| 221 | + content: |
| 222 | + name: CLUSTER_ID |
| 223 | + value: "global-cluster-id" |
| 224 | + valueFrom: null |
| 225 | + template: agent.yaml |
| 226 | + documentIndex: 0 |
| 227 | + |
| 228 | + - it: should prefer global.castai.clusterID over local castai.clusterID |
| 229 | + set: |
| 230 | + castai.clusterID: "local-cluster-id" |
| 231 | + global: |
| 232 | + castai: |
| 233 | + clusterID: "global-cluster-id" |
| 234 | + asserts: |
| 235 | + - contains: |
| 236 | + path: spec.template.spec.containers[0].env |
| 237 | + content: |
| 238 | + name: CLUSTER_ID |
| 239 | + value: "global-cluster-id" |
| 240 | + valueFrom: null |
| 241 | + template: controller.yaml |
| 242 | + documentIndex: 0 |
| 243 | + - contains: |
| 244 | + path: spec.template.spec.containers[0].env |
| 245 | + content: |
| 246 | + name: CLUSTER_ID |
| 247 | + value: "global-cluster-id" |
| 248 | + valueFrom: null |
| 249 | + template: agent.yaml |
| 250 | + documentIndex: 0 |
| 251 | + |
| 252 | + - it: should fail when global.castai.clusterID and clusterIdSecretKeyRef are both set |
| 253 | + set: |
| 254 | + castai.clusterID: "" |
| 255 | + castai.clusterIdSecretKeyRef: |
| 256 | + name: "cluster-secret" |
| 257 | + key: "CLUSTER_ID" |
| 258 | + global: |
| 259 | + castai: |
| 260 | + clusterID: "global-cluster-id" |
| 261 | + asserts: |
| 262 | + - failedTemplate: |
| 263 | + errorMessage: "clusterID cannot be used together with clusterIdConfigMapKeyRef or clusterIdSecretKeyRef" |
| 264 | + template: controller.yaml |
| 265 | + |
| 266 | + - it: should use local castai.clusterID when global is empty map |
| 267 | + set: |
| 268 | + global: {} |
| 269 | + asserts: |
| 270 | + - contains: |
| 271 | + path: spec.template.spec.containers[0].env |
| 272 | + content: |
| 273 | + name: CLUSTER_ID |
| 274 | + value: "test-cluster-id" |
| 275 | + valueFrom: null |
| 276 | + template: controller.yaml |
| 277 | + documentIndex: 0 |
| 278 | + - contains: |
| 279 | + path: spec.template.spec.containers[0].env |
| 280 | + content: |
| 281 | + name: CLUSTER_ID |
| 282 | + value: "test-cluster-id" |
| 283 | + valueFrom: null |
| 284 | + template: agent.yaml |
| 285 | + documentIndex: 0 |
0 commit comments