Skip to content

Commit

Permalink
all: fix grafana datasources and tests for multi wc
Browse files Browse the repository at this point in the history
  • Loading branch information
Elias-elastisys committed Oct 16, 2024
1 parent 9bd5dc6 commit 76565cc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
13 changes: 6 additions & 7 deletions helmfile.d/values/grafana/grafana-user.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ datasources:
If only one workload cluster, don't bother naming the datasource and set to default.
Otherwise set the name of the clusters so users know what they are looking at.
*/}}
{{- if eq (len .Values.global.clustersMonitoring) 1 }}
- name: "Workload Cluster"
{{- with first .Values.global.clustersMonitoring }}
- name: "Workload Cluster {{ . }}"
access: proxy
basicAuth: false
editable: false
Expand All @@ -71,11 +71,11 @@ datasources:
url: http://grafana-label-enforcer:9090
version: 1
jsonData:
customQueryParameters: "tenant_id={{ first .Values.global.clustersMonitoring }}"
customQueryParameters: "tenant_id={{ . }}"
manageAlerts: false
{{- else }}
{{- range .Values.global.clustersMonitoring }}
- name: "{{ . }}"
{{- end }}
{{- range rest .Values.global.clustersMonitoring }}
- name: "Workload Cluster {{ . }}"
access: proxy
basicAuth: false
editable: false
Expand All @@ -89,7 +89,6 @@ datasources:
manageAlerts: false
{{- end }}
{{- end }}
{{- end }}

{{ $trailingDot := "" }}
{{- if .Values.grafana.user.trailingDots }}
Expand Down
2 changes: 1 addition & 1 deletion tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Container to run unit tests
FROM ubuntu:rolling AS unit
FROM ubuntu:24.04 AS unit
LABEL org.opencontainers.image.source=https://github.com/elastisys/compliantkubernetes-apps

ARG DEBIAN_FRONTEND="noninteractive"
Expand Down
23 changes: 16 additions & 7 deletions tests/end-to-end/grafana/datasources.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("grafana admin datasources", function() {

// Cypress does not like trailing dots
cy.yqDig("sc", ".grafana.ops.trailingDots")
.should("not.equal", "true")
.should((value) => assert(value !== "true", ".grafana.ops.trailingDots in sc config must not be 'true'"))
})

beforeEach(function() {
Expand Down Expand Up @@ -74,7 +74,7 @@ describe("grafana dev datasources", function() {

// Cypress does not like trailing dots
cy.yqDig("sc", ".grafana.user.trailingDots")
.should("not.equal", "true")
.should((value) => assert(value !== "true", ".grafana.ops.trailingDots in sc config must not be 'true'"))
})

beforeEach(function() {
Expand Down Expand Up @@ -109,10 +109,19 @@ describe("grafana dev datasources", function() {
})

it("has workload cluster", function() {
cy.contains("Workload Cluster")
.should("exist")
.siblings()
.contains("default")
.should("exist")
cy.yqDigParse("sc", ".global.clustersMonitoring")
.then(([first_cluster, ...rest_clusters]) => {
cy.contains(`Workload Cluster ${first_cluster}`)
.should("exist")
.parent()
.siblings()
.contains("default")
.should("exist")

for (const cluster of rest_clusters) {
cy.contains(`Workload Cluster ${cluster}`)
.should("exist")
}
})
})
})

0 comments on commit 76565cc

Please sign in to comment.