|
| 1 | +suite: Test Dashboard Provisioner |
| 2 | +templates: |
| 3 | + - jobs/dashboard-provisioner.yaml |
| 4 | + - configmaps/dashboard-configmap.yaml |
| 5 | +tests: |
| 6 | + - it: should not render when dashboards are disabled |
| 7 | + set: |
| 8 | + hyperdx: |
| 9 | + dashboards: |
| 10 | + enabled: false |
| 11 | + asserts: |
| 12 | + - hasDocuments: |
| 13 | + count: 0 |
| 14 | + template: jobs/dashboard-provisioner.yaml |
| 15 | + - hasDocuments: |
| 16 | + count: 0 |
| 17 | + template: configmaps/dashboard-configmap.yaml |
| 18 | + |
| 19 | + - it: should not render when enabled but configMaps is empty |
| 20 | + set: |
| 21 | + hyperdx: |
| 22 | + dashboards: |
| 23 | + enabled: true |
| 24 | + configMaps: {} |
| 25 | + asserts: |
| 26 | + - hasDocuments: |
| 27 | + count: 0 |
| 28 | + template: jobs/dashboard-provisioner.yaml |
| 29 | + - hasDocuments: |
| 30 | + count: 0 |
| 31 | + template: configmaps/dashboard-configmap.yaml |
| 32 | + |
| 33 | + - it: should render Job and ConfigMap when configured |
| 34 | + set: |
| 35 | + hyperdx: |
| 36 | + dashboards: |
| 37 | + enabled: true |
| 38 | + configMaps: |
| 39 | + test-dashboard.json: | |
| 40 | + { "name": "Test Dashboard", "tiles": [] } |
| 41 | + asserts: |
| 42 | + - hasDocuments: |
| 43 | + count: 1 |
| 44 | + template: jobs/dashboard-provisioner.yaml |
| 45 | + - isKind: |
| 46 | + of: Job |
| 47 | + template: jobs/dashboard-provisioner.yaml |
| 48 | + - hasDocuments: |
| 49 | + count: 1 |
| 50 | + template: configmaps/dashboard-configmap.yaml |
| 51 | + - isKind: |
| 52 | + of: ConfigMap |
| 53 | + template: configmaps/dashboard-configmap.yaml |
| 54 | + |
| 55 | + - it: should have correct Helm hook annotations on Job |
| 56 | + set: |
| 57 | + hyperdx: |
| 58 | + dashboards: |
| 59 | + enabled: true |
| 60 | + configMaps: |
| 61 | + test.json: | |
| 62 | + { "name": "Test", "tiles": [] } |
| 63 | + asserts: |
| 64 | + - equal: |
| 65 | + path: metadata.annotations["helm.sh/hook"] |
| 66 | + value: post-install,post-upgrade |
| 67 | + template: jobs/dashboard-provisioner.yaml |
| 68 | + - equal: |
| 69 | + path: metadata.annotations["helm.sh/hook-weight"] |
| 70 | + value: "5" |
| 71 | + template: jobs/dashboard-provisioner.yaml |
| 72 | + - equal: |
| 73 | + path: metadata.annotations["helm.sh/hook-delete-policy"] |
| 74 | + value: before-hook-creation,hook-succeeded |
| 75 | + template: jobs/dashboard-provisioner.yaml |
| 76 | + |
| 77 | + - it: should have correct Helm hook annotations on ConfigMap |
| 78 | + set: |
| 79 | + hyperdx: |
| 80 | + dashboards: |
| 81 | + enabled: true |
| 82 | + configMaps: |
| 83 | + test.json: | |
| 84 | + { "name": "Test", "tiles": [] } |
| 85 | + asserts: |
| 86 | + - equal: |
| 87 | + path: metadata.annotations["helm.sh/hook"] |
| 88 | + value: pre-install,pre-upgrade |
| 89 | + template: configmaps/dashboard-configmap.yaml |
| 90 | + - equal: |
| 91 | + path: metadata.annotations["helm.sh/hook-weight"] |
| 92 | + value: "-5" |
| 93 | + template: configmaps/dashboard-configmap.yaml |
| 94 | + - equal: |
| 95 | + path: metadata.annotations["helm.sh/hook-delete-policy"] |
| 96 | + value: before-hook-creation |
| 97 | + template: configmaps/dashboard-configmap.yaml |
| 98 | + |
| 99 | + - it: should use the mongodb image |
| 100 | + set: |
| 101 | + mongodb: |
| 102 | + image: "mongo:5.0.32-focal" |
| 103 | + hyperdx: |
| 104 | + dashboards: |
| 105 | + enabled: true |
| 106 | + configMaps: |
| 107 | + test.json: | |
| 108 | + { "name": "Test", "tiles": [] } |
| 109 | + asserts: |
| 110 | + - equal: |
| 111 | + path: spec.template.spec.containers[0].image |
| 112 | + value: "mongo:5.0.32-focal" |
| 113 | + template: jobs/dashboard-provisioner.yaml |
| 114 | + |
| 115 | + - it: should have MONGO_URI env var |
| 116 | + set: |
| 117 | + hyperdx: |
| 118 | + dashboards: |
| 119 | + enabled: true |
| 120 | + configMaps: |
| 121 | + test.json: | |
| 122 | + { "name": "Test", "tiles": [] } |
| 123 | + asserts: |
| 124 | + - contains: |
| 125 | + path: spec.template.spec.containers[0].env |
| 126 | + content: |
| 127 | + name: MONGO_URI |
| 128 | + any: true |
| 129 | + template: jobs/dashboard-provisioner.yaml |
| 130 | + |
| 131 | + - it: should mount ConfigMap as volume at /dashboards |
| 132 | + set: |
| 133 | + hyperdx: |
| 134 | + dashboards: |
| 135 | + enabled: true |
| 136 | + configMaps: |
| 137 | + test.json: | |
| 138 | + { "name": "Test", "tiles": [] } |
| 139 | + asserts: |
| 140 | + - contains: |
| 141 | + path: spec.template.spec.containers[0].volumeMounts |
| 142 | + content: |
| 143 | + name: dashboards |
| 144 | + mountPath: /dashboards |
| 145 | + readOnly: true |
| 146 | + template: jobs/dashboard-provisioner.yaml |
| 147 | + - contains: |
| 148 | + path: spec.template.spec.volumes |
| 149 | + content: |
| 150 | + name: dashboards |
| 151 | + configMap: |
| 152 | + name: RELEASE-NAME-clickstack-dashboards |
| 153 | + template: jobs/dashboard-provisioner.yaml |
| 154 | + |
| 155 | + - it: should include multiple dashboard files in ConfigMap |
| 156 | + set: |
| 157 | + hyperdx: |
| 158 | + dashboards: |
| 159 | + enabled: true |
| 160 | + configMaps: |
| 161 | + k8s-overview.json: | |
| 162 | + { "name": "Kubernetes Overview", "tiles": [] } |
| 163 | + app-metrics.json: | |
| 164 | + { "name": "App Metrics", "tiles": [] } |
| 165 | + asserts: |
| 166 | + - isNotNull: |
| 167 | + path: data["k8s-overview.json"] |
| 168 | + template: configmaps/dashboard-configmap.yaml |
| 169 | + - isNotNull: |
| 170 | + path: data["app-metrics.json"] |
| 171 | + template: configmaps/dashboard-configmap.yaml |
| 172 | + |
| 173 | + - it: should propagate imagePullSecrets |
| 174 | + set: |
| 175 | + hyperdx: |
| 176 | + dashboards: |
| 177 | + enabled: true |
| 178 | + configMaps: |
| 179 | + test.json: | |
| 180 | + { "name": "Test", "tiles": [] } |
| 181 | + global: |
| 182 | + imagePullSecrets: |
| 183 | + - name: regcred |
| 184 | + asserts: |
| 185 | + - equal: |
| 186 | + path: spec.template.spec.imagePullSecrets[0].name |
| 187 | + value: regcred |
| 188 | + template: jobs/dashboard-provisioner.yaml |
| 189 | + |
| 190 | + - it: should not include imagePullSecrets when not configured |
| 191 | + set: |
| 192 | + hyperdx: |
| 193 | + dashboards: |
| 194 | + enabled: true |
| 195 | + configMaps: |
| 196 | + test.json: | |
| 197 | + { "name": "Test", "tiles": [] } |
| 198 | + asserts: |
| 199 | + - isNull: |
| 200 | + path: spec.template.spec.imagePullSecrets |
| 201 | + template: jobs/dashboard-provisioner.yaml |
| 202 | + |
| 203 | + - it: should apply resource limits |
| 204 | + set: |
| 205 | + hyperdx: |
| 206 | + dashboards: |
| 207 | + enabled: true |
| 208 | + configMaps: |
| 209 | + test.json: | |
| 210 | + { "name": "Test", "tiles": [] } |
| 211 | + resources: |
| 212 | + limits: |
| 213 | + cpu: 200m |
| 214 | + memory: 256Mi |
| 215 | + requests: |
| 216 | + cpu: 100m |
| 217 | + memory: 128Mi |
| 218 | + asserts: |
| 219 | + - isSubset: |
| 220 | + path: spec.template.spec.containers[0].resources |
| 221 | + content: |
| 222 | + limits: |
| 223 | + cpu: 200m |
| 224 | + memory: 256Mi |
| 225 | + requests: |
| 226 | + cpu: 100m |
| 227 | + memory: 128Mi |
| 228 | + template: jobs/dashboard-provisioner.yaml |
| 229 | + |
| 230 | + - it: should set correct Job spec defaults |
| 231 | + set: |
| 232 | + hyperdx: |
| 233 | + dashboards: |
| 234 | + enabled: true |
| 235 | + configMaps: |
| 236 | + test.json: | |
| 237 | + { "name": "Test", "tiles": [] } |
| 238 | + asserts: |
| 239 | + - equal: |
| 240 | + path: spec.backoffLimit |
| 241 | + value: 3 |
| 242 | + template: jobs/dashboard-provisioner.yaml |
| 243 | + - equal: |
| 244 | + path: spec.activeDeadlineSeconds |
| 245 | + value: 600 |
| 246 | + template: jobs/dashboard-provisioner.yaml |
| 247 | + - equal: |
| 248 | + path: spec.template.spec.restartPolicy |
| 249 | + value: OnFailure |
| 250 | + template: jobs/dashboard-provisioner.yaml |
0 commit comments