|
| 1 | +suite: Test Dashboard Provisioner |
| 2 | +templates: |
| 3 | + - hyperdx/deployment.yaml |
| 4 | + - hyperdx/dashboard-configmap.yaml |
| 5 | + - hyperdx/dashboard-provisioner-rbac.yaml |
| 6 | + - hyperdx/serviceaccount.yaml |
| 7 | +tests: |
| 8 | + - it: should not render RBAC or ConfigMap when dashboards are disabled |
| 9 | + set: |
| 10 | + hyperdx: |
| 11 | + dashboards: |
| 12 | + enabled: false |
| 13 | + asserts: |
| 14 | + - hasDocuments: |
| 15 | + count: 0 |
| 16 | + template: hyperdx/dashboard-configmap.yaml |
| 17 | + - hasDocuments: |
| 18 | + count: 0 |
| 19 | + template: hyperdx/dashboard-provisioner-rbac.yaml |
| 20 | + |
| 21 | + - it: should not add sidecar when dashboards are disabled |
| 22 | + set: |
| 23 | + hyperdx: |
| 24 | + dashboards: |
| 25 | + enabled: false |
| 26 | + asserts: |
| 27 | + - lengthEqual: |
| 28 | + path: spec.template.spec.containers |
| 29 | + count: 1 |
| 30 | + template: hyperdx/deployment.yaml |
| 31 | + |
| 32 | + - it: should add dashboard-watcher sidecar when enabled |
| 33 | + set: |
| 34 | + hyperdx: |
| 35 | + dashboards: |
| 36 | + enabled: true |
| 37 | + asserts: |
| 38 | + - lengthEqual: |
| 39 | + path: spec.template.spec.containers |
| 40 | + count: 2 |
| 41 | + template: hyperdx/deployment.yaml |
| 42 | + - equal: |
| 43 | + path: spec.template.spec.containers[1].name |
| 44 | + value: dashboard-watcher |
| 45 | + template: hyperdx/deployment.yaml |
| 46 | + |
| 47 | + - it: should set DASHBOARD_PROVISIONER_DIR on the app container |
| 48 | + set: |
| 49 | + hyperdx: |
| 50 | + dashboards: |
| 51 | + enabled: true |
| 52 | + asserts: |
| 53 | + - contains: |
| 54 | + path: spec.template.spec.containers[0].env |
| 55 | + content: |
| 56 | + name: DASHBOARD_PROVISIONER_DIR |
| 57 | + value: "/dashboards" |
| 58 | + template: hyperdx/deployment.yaml |
| 59 | + |
| 60 | + - it: should use the k8s-sidecar image for watcher |
| 61 | + set: |
| 62 | + hyperdx: |
| 63 | + dashboards: |
| 64 | + enabled: true |
| 65 | + sidecarImage: "kiwigrid/k8s-sidecar:2.5.0" |
| 66 | + asserts: |
| 67 | + - equal: |
| 68 | + path: spec.template.spec.containers[1].image |
| 69 | + value: "kiwigrid/k8s-sidecar:2.5.0" |
| 70 | + template: hyperdx/deployment.yaml |
| 71 | + |
| 72 | + - it: should configure watcher to discover labeled ConfigMaps across all namespaces |
| 73 | + set: |
| 74 | + hyperdx: |
| 75 | + dashboards: |
| 76 | + enabled: true |
| 77 | + asserts: |
| 78 | + - contains: |
| 79 | + path: spec.template.spec.containers[1].env |
| 80 | + content: |
| 81 | + name: LABEL |
| 82 | + value: "hyperdx.io/dashboard" |
| 83 | + template: hyperdx/deployment.yaml |
| 84 | + - contains: |
| 85 | + path: spec.template.spec.containers[1].env |
| 86 | + content: |
| 87 | + name: NAMESPACE |
| 88 | + value: "ALL" |
| 89 | + template: hyperdx/deployment.yaml |
| 90 | + |
| 91 | + - it: should share dashboards volume between app and watcher |
| 92 | + set: |
| 93 | + hyperdx: |
| 94 | + dashboards: |
| 95 | + enabled: true |
| 96 | + asserts: |
| 97 | + - contains: |
| 98 | + path: spec.template.spec.volumes |
| 99 | + content: |
| 100 | + name: dashboards |
| 101 | + emptyDir: {} |
| 102 | + template: hyperdx/deployment.yaml |
| 103 | + - contains: |
| 104 | + path: spec.template.spec.containers[0].volumeMounts |
| 105 | + content: |
| 106 | + name: dashboards |
| 107 | + mountPath: /dashboards |
| 108 | + readOnly: true |
| 109 | + template: hyperdx/deployment.yaml |
| 110 | + - contains: |
| 111 | + path: spec.template.spec.containers[1].volumeMounts |
| 112 | + content: |
| 113 | + name: dashboards |
| 114 | + mountPath: /dashboards |
| 115 | + template: hyperdx/deployment.yaml |
| 116 | + |
| 117 | + - it: should auto-create SA when dashboards enabled and no user SA configured |
| 118 | + set: |
| 119 | + hyperdx: |
| 120 | + dashboards: |
| 121 | + enabled: true |
| 122 | + serviceAccount: |
| 123 | + create: false |
| 124 | + name: "" |
| 125 | + asserts: |
| 126 | + - equal: |
| 127 | + path: spec.template.spec.serviceAccountName |
| 128 | + value: RELEASE-NAME-clickstack-app |
| 129 | + template: hyperdx/deployment.yaml |
| 130 | + - hasDocuments: |
| 131 | + count: 1 |
| 132 | + template: hyperdx/serviceaccount.yaml |
| 133 | + |
| 134 | + - it: should use existing user SA and not create a new one |
| 135 | + set: |
| 136 | + hyperdx: |
| 137 | + dashboards: |
| 138 | + enabled: true |
| 139 | + serviceAccount: |
| 140 | + create: false |
| 141 | + name: "my-custom-sa" |
| 142 | + asserts: |
| 143 | + - equal: |
| 144 | + path: spec.template.spec.serviceAccountName |
| 145 | + value: my-custom-sa |
| 146 | + template: hyperdx/deployment.yaml |
| 147 | + - hasDocuments: |
| 148 | + count: 0 |
| 149 | + template: hyperdx/serviceaccount.yaml |
| 150 | + |
| 151 | + - it: should bind ClusterRole to the user SA when configured |
| 152 | + set: |
| 153 | + hyperdx: |
| 154 | + dashboards: |
| 155 | + enabled: true |
| 156 | + serviceAccount: |
| 157 | + name: "my-custom-sa" |
| 158 | + asserts: |
| 159 | + - equal: |
| 160 | + path: subjects[0].name |
| 161 | + value: my-custom-sa |
| 162 | + documentIndex: 1 |
| 163 | + template: hyperdx/dashboard-provisioner-rbac.yaml |
| 164 | + |
| 165 | + - it: should bind ClusterRole to the default SA when no user SA configured |
| 166 | + set: |
| 167 | + hyperdx: |
| 168 | + dashboards: |
| 169 | + enabled: true |
| 170 | + asserts: |
| 171 | + - equal: |
| 172 | + path: subjects[0].name |
| 173 | + value: RELEASE-NAME-clickstack-app |
| 174 | + documentIndex: 1 |
| 175 | + template: hyperdx/dashboard-provisioner-rbac.yaml |
| 176 | + |
| 177 | + - it: should grant cluster-wide configmap list, get, and watch permissions |
| 178 | + set: |
| 179 | + hyperdx: |
| 180 | + dashboards: |
| 181 | + enabled: true |
| 182 | + asserts: |
| 183 | + - equal: |
| 184 | + path: rules[0].verbs |
| 185 | + value: ["list", "get", "watch"] |
| 186 | + documentIndex: 0 |
| 187 | + template: hyperdx/dashboard-provisioner-rbac.yaml |
| 188 | + |
| 189 | + - it: should not render inline ConfigMap when configMaps is empty |
| 190 | + set: |
| 191 | + hyperdx: |
| 192 | + dashboards: |
| 193 | + enabled: true |
| 194 | + configMaps: {} |
| 195 | + asserts: |
| 196 | + - hasDocuments: |
| 197 | + count: 0 |
| 198 | + template: hyperdx/dashboard-configmap.yaml |
| 199 | + |
| 200 | + - it: should render inline ConfigMap with discovery label |
| 201 | + set: |
| 202 | + hyperdx: |
| 203 | + dashboards: |
| 204 | + enabled: true |
| 205 | + configMaps: |
| 206 | + test.json: | |
| 207 | + { "name": "Test", "tiles": [] } |
| 208 | + asserts: |
| 209 | + - equal: |
| 210 | + path: metadata.labels["hyperdx.io/dashboard"] |
| 211 | + value: "true" |
| 212 | + template: hyperdx/dashboard-configmap.yaml |
| 213 | + |
| 214 | + - it: should include multiple dashboard files in inline ConfigMap |
| 215 | + set: |
| 216 | + hyperdx: |
| 217 | + dashboards: |
| 218 | + enabled: true |
| 219 | + configMaps: |
| 220 | + k8s-overview.json: | |
| 221 | + { "name": "Kubernetes Overview", "tiles": [] } |
| 222 | + app-metrics.json: | |
| 223 | + { "name": "App Metrics", "tiles": [] } |
| 224 | + asserts: |
| 225 | + - isNotNull: |
| 226 | + path: data["k8s-overview.json"] |
| 227 | + template: hyperdx/dashboard-configmap.yaml |
| 228 | + - isNotNull: |
| 229 | + path: data["app-metrics.json"] |
| 230 | + template: hyperdx/dashboard-configmap.yaml |
0 commit comments