|
| 1 | +# The tenant addon HelmRelease that ships this chart remediates a failed |
| 2 | +# install by uninstalling the release, and an uninstall deletes whatever the |
| 3 | +# chart rendered. Deleting a CRD makes the API server garbage-collect every |
| 4 | +# custom resource of that kind, so an unannotated CRD here costs the cluster |
| 5 | +# every ServiceMonitor, PodMonitor, PrometheusRule and ScrapeConfig it holds. |
| 6 | +# |
| 7 | +# The CRDs come from a vendored subchart that `make update` re-pulls, so the |
| 8 | +# annotation is set through values rather than by editing the templates. The |
| 9 | +# first case scopes to no template at all, so it holds every document the |
| 10 | +# chart renders, including a CRD the subchart starts shipping later. The named |
| 11 | +# cases pin the document count and the CRD name, so an assertion cannot pass |
| 12 | +# against a document it was not meant to inspect. |
| 13 | +suite: Prometheus Operator CRDs survive a release uninstall |
| 14 | +tests: |
| 15 | + - it: annotates every CustomResourceDefinition the chart renders |
| 16 | + asserts: |
| 17 | + - equal: |
| 18 | + path: kind |
| 19 | + value: CustomResourceDefinition |
| 20 | + - equal: |
| 21 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 22 | + value: keep |
| 23 | + |
| 24 | + - it: keeps the alertmanagerconfigs CRD |
| 25 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-alertmanagerconfigs.yaml |
| 26 | + asserts: |
| 27 | + - hasDocuments: |
| 28 | + count: 1 |
| 29 | + - equal: |
| 30 | + path: metadata.name |
| 31 | + value: alertmanagerconfigs.monitoring.coreos.com |
| 32 | + - equal: |
| 33 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 34 | + value: keep |
| 35 | + |
| 36 | + - it: keeps the alertmanagers CRD |
| 37 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-alertmanagers.yaml |
| 38 | + asserts: |
| 39 | + - hasDocuments: |
| 40 | + count: 1 |
| 41 | + - equal: |
| 42 | + path: metadata.name |
| 43 | + value: alertmanagers.monitoring.coreos.com |
| 44 | + - equal: |
| 45 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 46 | + value: keep |
| 47 | + |
| 48 | + - it: keeps the podmonitors CRD |
| 49 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-podmonitors.yaml |
| 50 | + asserts: |
| 51 | + - hasDocuments: |
| 52 | + count: 1 |
| 53 | + - equal: |
| 54 | + path: metadata.name |
| 55 | + value: podmonitors.monitoring.coreos.com |
| 56 | + - equal: |
| 57 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 58 | + value: keep |
| 59 | + |
| 60 | + - it: keeps the probes CRD |
| 61 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-probes.yaml |
| 62 | + asserts: |
| 63 | + - hasDocuments: |
| 64 | + count: 1 |
| 65 | + - equal: |
| 66 | + path: metadata.name |
| 67 | + value: probes.monitoring.coreos.com |
| 68 | + - equal: |
| 69 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 70 | + value: keep |
| 71 | + |
| 72 | + - it: keeps the prometheusagents CRD |
| 73 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-prometheusagents.yaml |
| 74 | + asserts: |
| 75 | + - hasDocuments: |
| 76 | + count: 1 |
| 77 | + - equal: |
| 78 | + path: metadata.name |
| 79 | + value: prometheusagents.monitoring.coreos.com |
| 80 | + - equal: |
| 81 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 82 | + value: keep |
| 83 | + |
| 84 | + - it: keeps the prometheuses CRD |
| 85 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-prometheuses.yaml |
| 86 | + asserts: |
| 87 | + - hasDocuments: |
| 88 | + count: 1 |
| 89 | + - equal: |
| 90 | + path: metadata.name |
| 91 | + value: prometheuses.monitoring.coreos.com |
| 92 | + - equal: |
| 93 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 94 | + value: keep |
| 95 | + |
| 96 | + - it: keeps the prometheusrules CRD |
| 97 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-prometheusrules.yaml |
| 98 | + asserts: |
| 99 | + - hasDocuments: |
| 100 | + count: 1 |
| 101 | + - equal: |
| 102 | + path: metadata.name |
| 103 | + value: prometheusrules.monitoring.coreos.com |
| 104 | + - equal: |
| 105 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 106 | + value: keep |
| 107 | + |
| 108 | + - it: keeps the scrapeconfigs CRD |
| 109 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-scrapeconfigs.yaml |
| 110 | + asserts: |
| 111 | + - hasDocuments: |
| 112 | + count: 1 |
| 113 | + - equal: |
| 114 | + path: metadata.name |
| 115 | + value: scrapeconfigs.monitoring.coreos.com |
| 116 | + - equal: |
| 117 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 118 | + value: keep |
| 119 | + |
| 120 | + - it: keeps the servicemonitors CRD |
| 121 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-servicemonitors.yaml |
| 122 | + asserts: |
| 123 | + - hasDocuments: |
| 124 | + count: 1 |
| 125 | + - equal: |
| 126 | + path: metadata.name |
| 127 | + value: servicemonitors.monitoring.coreos.com |
| 128 | + - equal: |
| 129 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 130 | + value: keep |
| 131 | + |
| 132 | + - it: keeps the thanosrulers CRD |
| 133 | + template: charts/prometheus-operator-crds/charts/crds/templates/crd-thanosrulers.yaml |
| 134 | + asserts: |
| 135 | + - hasDocuments: |
| 136 | + count: 1 |
| 137 | + - equal: |
| 138 | + path: metadata.name |
| 139 | + value: thanosrulers.monitoring.coreos.com |
| 140 | + - equal: |
| 141 | + path: metadata.annotations["helm.sh/resource-policy"] |
| 142 | + value: keep |
0 commit comments