Skip to content

Commit bfd518f

Browse files
authored
Convert test back to a job and break out functionality for the config analysis (#397)
Signed-off-by: Pete Wall <[email protected]>
1 parent df734dd commit bfd518f

File tree

30 files changed

+2576
-2193
lines changed

30 files changed

+2576
-2193
lines changed

.github/configs/mysql-config.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ data:
6060
prometheus.scrape "mysql" {
6161
targets = prometheus.exporter.mysql.mysql.targets
6262
job_name = "integrations/mysql"
63+
clustering {
64+
enabled = true
65+
}
6366
forward_to = [prometheus.relabel.mysql.receiver]
6467
}
6568

.github/workflows/helm-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,4 @@ jobs:
201201
if: steps.list-changed.outputs.changed == 'true'
202202
run: |
203203
latestRelease=$(git describe --abbrev=0 --tags)
204-
ct install --config "${CT_CONFIGFILE}" --since "${latestRelease}"
204+
ct install --config "${CT_CONFIGFILE}" --since "${latestRelease}" --helm-extra-args "--timeout 10m"

charts/k8s-monitoring/README.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ The Prometheus and Loki services may be hosted on the same cluster, or remotely
111111
| cluster.kubernetesAPIService | string | `"kubernetes.default.svc.cluster.local:443"` | The Kubernetes service. Change this if your cluster DNS is configured differently than the default. |
112112
| cluster.name | string | `""` | The name of this cluster, which will be set in all labels. Required. |
113113
| cluster.platform | string | `""` | The specific platform for this cluster. Will enable compatibility for some platforms. Supported options: (empty) or "openshift". |
114+
| configAnalysis.enabled | bool | `true` | Should `helm test` run the config analysis pod? |
115+
| configAnalysis.extraAnnotations | object | `{}` | Extra annotations to add to the config analysis pod. |
116+
| configAnalysis.extraLabels | object | `{}` | Extra labels to add to the config analysis pod. |
117+
| configAnalysis.image.image | string | `"grafana/k8s-monitoring-test"` | Config Analysis image repository. |
118+
| configAnalysis.image.pullSecrets | list | `[]` | Optional set of image pull secrets. |
119+
| configAnalysis.image.registry | string | `"ghcr.io"` | Config Analysis image registry. |
120+
| configAnalysis.image.tag | string | `""` | Config Analysis image tag. Default is the chart version. |
121+
| configAnalysis.nodeSelector | object | `{"kubernetes.io/os":"linux"}` | nodeSelector to apply to the config analysis pod. |
122+
| configAnalysis.tolerations | list | `[]` | Tolerations to apply to the config analysis pod. |
123+
| configValidator.enabled | bool | `true` | Should config validation be run? |
114124
| configValidator.extraAnnotations | object | `{}` | Extra annotations to add to the test config validator job. |
115125
| configValidator.extraLabels | object | `{}` | Extra labels to add to the test config validator job. |
116126
| configValidator.nodeSelector | object | `{"kubernetes.io/os":"linux"}` | nodeSelector to apply to the config validator job. |
@@ -354,10 +364,11 @@ The Prometheus and Loki services may be hosted on the same cluster, or remotely
354364
| receivers.zipkin.enabled | bool | `false` | Receive Zipkin traces |
355365
| receivers.zipkin.port | int | `9411` | Which port to use for the Zipkin receiver. This port needs to be opened in the grafana-agent section below. |
356366
| test.attempts | int | `10` | How many times to attempt the test job. |
367+
| test.enabled | bool | `true` | Should `helm test` run the test job? |
357368
| test.envOverrides | object | `{"LOKI_URL":"","PROMETHEUS_URL":"","TEMPO_URL":""}` | Overrides the URLs for various data sources |
358-
| test.extraAnnotations | object | `{}` | Extra annotations to add to the test jobs. |
359-
| test.extraLabels | object | `{}` | Extra labels to add to the test jobs. |
360-
| test.extraQueries | list | `[]` | Additional queries that will be run with `helm test`. NOTE that this uses the host, username, and password in the externalServices section. The user account must have the ability to run queries. Example: extraQueries: - query: prometheus_metric{cluster="my-cluster-name"} type: [promql|logql] |
369+
| test.extraAnnotations | object | `{}` | Extra annotations to add to the test job. |
370+
| test.extraLabels | object | `{}` | Extra labels to add to the test job. |
371+
| test.extraQueries | list | `[]` | Additional queries to run during the test. NOTE that this uses the host, username, and password in the externalServices section. The user account must have the ability to run queries. Example: extraQueries: - query: prometheus_metric{cluster="my-cluster-name"} type: promql Can optionally provide expectations: - query: "avg(count_over_time(scrape_samples_scraped{cluster=~\"ci-test-cluster-2|from-the-other-agent\"}[1m]))" type: promql expect: value: 1 operator: == |
361372
| test.image.image | string | `"grafana/k8s-monitoring-test"` | Test job image repository. |
362373
| test.image.pullSecrets | list | `[]` | Optional set of image pull secrets. |
363374
| test.image.registry | string | `"ghcr.io"` | Test job image registry. |

charts/k8s-monitoring/ci/ci-2-values.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,14 @@ test:
8080
operator: "<=" # There's gotta be at least one pod
8181

8282
# Check for cluster events
83-
- query: "{cluster=\"ci-test-cluster-2\", job=\"integrations/kubernetes/eventhandler\"}"
83+
- query: "count_over_time({cluster=\"ci-test-cluster-2\", job=\"integrations/kubernetes/eventhandler\"}[1h])"
8484
type: logql
85+
8586
# Check for pod logs (gathered via API)
86-
- query: "{cluster=\"ci-test-cluster-2\", job!=\"integrations/kubernetes/eventhandler\"}"
87+
- query: "count_over_time({cluster=\"ci-test-cluster-2\", job!=\"integrations/kubernetes/eventhandler\"}[1h])"
8788
type: logql
89+
90+
# Check for traces
8891
- query: "{.k8s.cluster.name=\"ci-test-cluster-2\"}"
8992
type: traceql
9093

charts/k8s-monitoring/ci/ci-integrations-values.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ test:
106106
type: promql
107107

108108
# Check for MySQL logs, discovered by the module loaded above in .logs.extraConfig
109-
- query: "{cluster=\"ci-integrations-cluster\", job=\"integrations/mysql\"}"
109+
- query: "count_over_time({cluster=\"ci-integrations-cluster\", job=\"integrations/mysql\"}[1h])"
110110
type: logql
111111

112112
# Cluster events still work, too
113-
- query: "{cluster=\"ci-integrations-cluster\", job=\"integrations/kubernetes/eventhandler\"}"
113+
- query: "count_over_time({cluster=\"ci-integrations-cluster\", job=\"integrations/kubernetes/eventhandler\"}[1h])"
114114
type: logql
115115

116116
# Regular pod logs still work, too (checking the Loki pod <namespace>/<pod_name>)
117-
- query: "{cluster=\"ci-integrations-cluster\", job=\"loki/loki\"}"
117+
- query: "count_over_time({cluster=\"ci-integrations-cluster\", job=\"loki/loki\"}[1h])"
118118
type: logql
119119

120120
# DPM check

charts/k8s-monitoring/ci/ci-values.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ test:
6363
expect:
6464
count: 0
6565
# Check for cluster events
66-
- query: "{cluster=\"ci-test-cluster\", job=\"integrations/kubernetes/eventhandler\"}"
66+
- query: "count_over_time({cluster=\"ci-test-cluster\", job=\"integrations/kubernetes/eventhandler\"}[1h])"
6767
type: logql
6868
# Check for pod logs
69-
- query: "{cluster=\"ci-test-cluster\", job!=\"integrations/kubernetes/eventhandler\"}"
69+
- query: "count_over_time({cluster=\"ci-test-cluster\", job!=\"integrations/kubernetes/eventhandler\"}[1h])"
7070
type: logql
7171

7272
# DPM check

charts/k8s-monitoring/templates/hooks/validate-configuration.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.configValidator.enabled }}
12
---
23
apiVersion: batch/v1
34
kind: Job
@@ -112,3 +113,4 @@ data:
112113
logs.river: |-
113114
{{- include "agentLogsConfig" . | trim | nindent 4 }}
114115
{{- end }}
116+
{{- end -}}

0 commit comments

Comments
 (0)