|
| 1 | +--- |
| 2 | +suite: Environment Vars |
| 3 | +templates: |
| 4 | + # primary template files |
| 5 | + - deployments.yaml |
| 6 | + - jobs.yaml |
| 7 | + |
| 8 | + # included templates must also be listed |
| 9 | + - configmaps_packs.yaml |
| 10 | + - configmaps_rbac.yaml |
| 11 | + - configmaps_st2-conf.yaml |
| 12 | + - configmaps_st2-urls.yaml |
| 13 | + - configmaps_st2web.yaml |
| 14 | + - secrets_datastore_crypto_key.yaml |
| 15 | + - secrets_ssh.yaml |
| 16 | + - secrets_st2apikeys.yaml |
| 17 | + - secrets_st2auth.yaml |
| 18 | + - secrets_st2chatops.yaml |
| 19 | + |
| 20 | +tests: |
| 21 | + - it: Deployments default to no env (except st2client) |
| 22 | + template: deployments.yaml |
| 23 | + set: |
| 24 | + st2: { packs: { sensors: [] } } # ensure only 1 sensor |
| 25 | + st2chatops: |
| 26 | + enabled: true |
| 27 | + asserts: |
| 28 | + - hasDocuments: |
| 29 | + count: 14 |
| 30 | + - equal: |
| 31 | + path: spec.template.spec.containers[0].env |
| 32 | + value: |
| 33 | + - name: ST2CLIENT |
| 34 | + value: "1" |
| 35 | + documentIndex: 12 |
| 36 | + - isNull: &is_null_env |
| 37 | + path: spec.template.spec.containers[0].env |
| 38 | + documentIndex: 0 |
| 39 | + - isNull: *is_null_env |
| 40 | + documentIndex: 1 |
| 41 | + - isNull: *is_null_env |
| 42 | + documentIndex: 2 |
| 43 | + - isNull: *is_null_env |
| 44 | + documentIndex: 3 |
| 45 | + - isNull: *is_null_env |
| 46 | + documentIndex: 4 |
| 47 | + - isNull: *is_null_env |
| 48 | + documentIndex: 5 |
| 49 | + - isNull: *is_null_env |
| 50 | + documentIndex: 6 |
| 51 | + - isNull: *is_null_env |
| 52 | + documentIndex: 7 |
| 53 | + - isNull: *is_null_env |
| 54 | + documentIndex: 8 |
| 55 | + - isNull: *is_null_env |
| 56 | + documentIndex: 9 |
| 57 | + - isNull: *is_null_env |
| 58 | + documentIndex: 10 |
| 59 | + - isNull: *is_null_env |
| 60 | + documentIndex: 11 |
| 61 | + - isNull: *is_null_env |
| 62 | + documentIndex: 13 |
| 63 | + |
| 64 | + - it: Jobs default to no env |
| 65 | + template: jobs.yaml |
| 66 | + set: |
| 67 | + st2: |
| 68 | + rbac: { enabled: true } # enable rbac job |
| 69 | + asserts: |
| 70 | + - hasDocuments: |
| 71 | + count: 4 |
| 72 | + - isNull: *is_null_env |
| 73 | + |
| 74 | + - it: Deployments accept custom env |
| 75 | + template: deployments.yaml |
| 76 | + set: |
| 77 | + st2auth: |
| 78 | + env: &env |
| 79 | + FOO: bar |
| 80 | + st2api: |
| 81 | + env: *env |
| 82 | + st2stream: |
| 83 | + env: *env |
| 84 | + st2web: |
| 85 | + env: *env |
| 86 | + st2rulesengine: |
| 87 | + env: *env |
| 88 | + st2timersengine: |
| 89 | + env: *env |
| 90 | + st2workflowengine: |
| 91 | + env: *env |
| 92 | + st2scheduler: |
| 93 | + env: *env |
| 94 | + st2notifier: |
| 95 | + env: *env |
| 96 | + st2sensorcontainer: |
| 97 | + env: *env |
| 98 | + st2: { packs: { sensors: [] } } # ensure only 1 sensor |
| 99 | + st2actionrunner: |
| 100 | + env: *env |
| 101 | + st2garbagecollector: |
| 102 | + env: *env |
| 103 | + st2client: |
| 104 | + env: *env |
| 105 | + st2chatops: |
| 106 | + enabled: false |
| 107 | + asserts: |
| 108 | + - hasDocuments: |
| 109 | + count: 13 # st2chatops env handled as secrets |
| 110 | + |
| 111 | + - contains: &contains_env |
| 112 | + path: spec.template.spec.containers[0].env |
| 113 | + content: |
| 114 | + name: FOO |
| 115 | + value: bar |
| 116 | + |
| 117 | + - it: Jobs accept custom env |
| 118 | + template: jobs.yaml |
| 119 | + set: |
| 120 | + st2: |
| 121 | + rbac: { enabled: true } # enable rbac job |
| 122 | + jobs: |
| 123 | + env: *env |
| 124 | + asserts: |
| 125 | + - hasDocuments: |
| 126 | + count: 4 |
| 127 | + |
| 128 | + - contains: *contains_env |
| 129 | + |
| 130 | + - it: Deployments envFrom defaults include st2-urls configMap and st2chatops secretRef |
| 131 | + template: deployments.yaml |
| 132 | + set: |
| 133 | + st2: { packs: { sensors: [] } } # ensure only 1 sensor |
| 134 | + st2chatops: |
| 135 | + enabled: true |
| 136 | + release: |
| 137 | + name: st2ha |
| 138 | + asserts: |
| 139 | + - hasDocuments: |
| 140 | + count: 14 |
| 141 | + - contains: &contains_st2_urls |
| 142 | + path: spec.template.spec.containers[0].envFrom |
| 143 | + content: |
| 144 | + configMapRef: |
| 145 | + name: st2ha-st2-urls |
| 146 | + # this is how st2chatops.env loads vars |
| 147 | + - contains: |
| 148 | + path: spec.template.spec.containers[0].envFrom |
| 149 | + content: |
| 150 | + secretRef: # not a configMap |
| 151 | + name: st2ha-st2chatops |
| 152 | + documentIndex: 13 |
| 153 | + |
| 154 | + - it: Jobs envFrom defaults |
| 155 | + template: jobs.yaml |
| 156 | + set: |
| 157 | + st2: |
| 158 | + rbac: { enabled: true } # enable rbac job |
| 159 | + release: |
| 160 | + name: st2ha |
| 161 | + asserts: |
| 162 | + - hasDocuments: |
| 163 | + count: 4 |
| 164 | + |
| 165 | + - contains: *contains_st2_urls |
| 166 | + documentIndex: 1 |
| 167 | + - contains: *contains_st2_urls |
| 168 | + documentIndex: 2 |
| 169 | + |
| 170 | + - isNull: &is_null_envFrom |
| 171 | + path: spec.template.spec.containers[0].envFrom |
| 172 | + documentIndex: 0 |
| 173 | + - isNull: *is_null_envFrom |
| 174 | + documentIndex: 3 |
| 175 | + |
| 176 | + - it: Deployments support envFromSecrets (st2actionrunner, st2sensorcontainer, and st2client) |
| 177 | + template: deployments.yaml |
| 178 | + set: |
| 179 | + st2: { packs: { sensors: [] } } # ensure only 1 sensor |
| 180 | + st2actionrunner: |
| 181 | + envFromSecrets: &envFromSecrets |
| 182 | + - my-external-secret-1 |
| 183 | + - my-external-secret-2 |
| 184 | + st2sensorcontainer: |
| 185 | + envFromSecrets: *envFromSecrets |
| 186 | + st2client: |
| 187 | + envFromSecrets: *envFromSecrets |
| 188 | + asserts: |
| 189 | + - contains: &contains_external_secret1 |
| 190 | + path: spec.template.spec.containers[0].envFrom |
| 191 | + content: |
| 192 | + secretRef: |
| 193 | + name: my-external-secret-1 |
| 194 | + documentIndex: 9 |
| 195 | + - contains: *contains_external_secret1 |
| 196 | + documentIndex: 10 |
| 197 | + - contains: *contains_external_secret1 |
| 198 | + documentIndex: 12 |
| 199 | + |
| 200 | + - contains: &contains_external_secret2 |
| 201 | + path: spec.template.spec.containers[0].envFrom |
| 202 | + content: |
| 203 | + secretRef: |
| 204 | + name: my-external-secret-2 |
| 205 | + documentIndex: 9 |
| 206 | + - contains: *contains_external_secret2 |
| 207 | + documentIndex: 10 |
| 208 | + - contains: *contains_external_secret2 |
| 209 | + documentIndex: 12 |
| 210 | + |
| 211 | + - it: Jobs support envFromSecrets |
| 212 | + template: jobs.yaml |
| 213 | + set: |
| 214 | + st2: |
| 215 | + rbac: { enabled: true } # enable rbac job |
| 216 | + jobs: |
| 217 | + envFromSecrets: *envFromSecrets |
| 218 | + asserts: |
| 219 | + - contains: *contains_external_secret1 |
| 220 | + - contains: *contains_external_secret2 |
0 commit comments